slot the VICMON cartridge into your VIC20
start VICMON by entering: SYS 24576
- start program at 1403 and load #$00 into the accumulator. This will be our flag to determine if we are moving right (#$00) or left (#$01). We begin moving to the right (#$00).
- store the value in the accumulator into the memory location $1400. We will use this memory location to store the direction flag to move right or left (#$00 or #$01 respectively).
- load the 0th row coordinate (#$00) into the X register
- load the column coordinate of the left-most screen border (#$00) into the Y register
- load the clear screen character ($93) into the accumulator
- run subroutine ($FFD2) to output the clear screen character ($93) from the accumulator
- load $#00 into the accumulator to ensure all bits are turned off (this will make 6 set position instead of get)
- call the set cursor location (Plot) subroutine at address $FFF0
- load the value for letter W (#$57) into the accumulator
- run subroutine ($FFD2) to output the W character (#$57) from the accumulator to screen
- load the value from location $1400 into the accumulator
- compare the value in the accumulator with #$01 (to check if we should go to the left)
- if the comparison was true, then jump to the instructions to move the cursor to the left (point 20)
- otherwise, compare the value in the Y register with the right-most column coordinate (#$15)
- if the comparison was true, then jump to set the program to move to the left (point 18)
- otherwise, increment the value in the Y register (INY)
- loop back to clear the screen (point 5)
- load #$01 into the accumulator
- store the value in the accumulator into the memory location $1400 to indicate we will now move from right to left
- compare the value in the Y register with the left-most column coordinate (#$00)
- if the comparison was true, then jump to reset and repeat loop (point 24)
- otherwise, decrement the value in the Y register (DEY)
- loop back to clear the screen (point 5)
- load the column coordinate of the left-most screen border (#$00) into the Y register
- load #$00 into the accumulator to indicate we want to move from left to right
- store the value in the accumulator into the memory location $1400
- jump to set the position on the screen and loop (point 8)
- terminate program. This actually won't ever happen as we will be held into an infinite loop
test the program from VICMON by entering: .G 1403
the result will be a character W moving from left to right and back in a pingpong loop.
congratulations!
As the program will run in a loop you will have to terminate it by pressing STOP + RESTORE on your VIC20 or ESC+PageUp if you are using the VIC20 VICE emulator.
This will quit the execution and return you to BASIC. To go back to VICMON and your program, just type SYS 24576 as usual.