An entry for the Vintage Computing Christmas Challenge 2021
Author: (private) System: Commodore Plus/4 Language: 6502 (DASM Assembler) Source code length: 2414 bytes Executable length: 51 bytes Actual code length: 37+2 bytes (*) How to run: Install VICE, start the 'xplus4' emulator and drag and drop the prg file into it.
(*) The code depends on two of the bytes in the BASIC stub.
HOW THE CODE WORKS
The code uses a KERNAL routine to scroll the screen upwards and then writes asterisk characters directly into the bottom row of screen RAM. This is done 14 times.
Character counts are stored as negative values, so that the starting column may be easily calculated by adding a constant and then dividing by two.
The line number in the BASIC stub is used to store the address of the character counts, adjusted for the value the Y register will have after calling SCROLLUP. The current BASIC line number automatically becomes available at zero page location $39, which is used by the code as a pointer to the char counts.
The undocumented 'lax' opcode is used to load a char count into both A and X registers at the same time.
An infinite loop is entered when the code reads the positive value of the 'jsr' opcode ($20) right after the table of char counts.
See also the source code with comments (source.asm), which may be assembled using DASM (https://dasm-assembler.github.io/). |