A sample programming session in VICMON
Posted: Wed Dec 26, 2018 6:10 am
Hi, y'all!
Let's just pretend we got a VICMON cartridge for Christmas. How about translating the well known "Coloured Birds" example of the VIC User's Manual (see p. 41) to machine language?
Here we go:

At first, we need to take care of the two strings present in the program: unfortunately, VICMON and it's brethren do not feature an easy method to directly enter PETSCII strings into memory - unlike the ":"-command in the output of "M" or the ","-command in the output of "D", the "´"-output of the "I"nterpret command is not reversible.
It's really a nuisance to look up all the PETSCII codes, but the H-command comes to the rescue! There, the single quote (´) allows to search for a given plain text string, and we just let H search in $0000 to $03FF where it keeps that string to compare it with memory. As evident, VICMON stores that string from $0031 onwards, and for the string with the control characters, we leave out the double quote ("). Note: other monitors most probably use a different position for that buffer!
So two T commands transfer the 8 byte long control character string from $0032..$0039 to $1800..$1807 and the 6 byte long 'birds' string from $0031..$0036 to $1808..$180D. The program is now supposed to start at $180E.
We now need a random number between 0 and 7 (both inclusive) to index into the control characters. For our application, we take the lowest 3 bits of the VIA #2 timer 1 low byte in $9124. In principle, that's a bad (pseudo) random number generator, but it's good enough for our purpose.
The instructions from $180E..$1817 output the random colour code, and the loop in $181A..$1825 outputs the "birds" string, with the KERNAL CHROUT routine at $FFD2:

Before we jump back to the start of the program, we check for the STOP key with JSR $FFE1. When it is not pressed, BNE $180E loops. Otherwise, the program is halted with the BRK instruction and returns to the monitor:

Not to forget: save the program before you start it! Tape users will of course use "01" instead of "08".
Now, go for "G 180E" to let the birds fly! And wee, it's noticably faster than its BASIC counterpart!

Finally, the STOP key halts the program, as was intended. If you get a white prompt, just press Ctrl-6 to return to a blue cursor. With R, you can re-display the register contents in that case.

A Happy Boxing Day!
Michael
Let's just pretend we got a VICMON cartridge for Christmas. How about translating the well known "Coloured Birds" example of the VIC User's Manual (see p. 41) to machine language?

Code: Select all
1 A$="{BLK,WHT,RED,CYN,PUR,GRN,BLU,YEL}"
2 N=INT(RND(1)*8)+1
3 B$=MID$(A$,N,1)
4 PRINTB$"{SHIFT-U,SHIFT-Q,SHIFT-I,SHIFT-J,SHIFT-Q,SHIFT-K}";
5 GOTO2

At first, we need to take care of the two strings present in the program: unfortunately, VICMON and it's brethren do not feature an easy method to directly enter PETSCII strings into memory - unlike the ":"-command in the output of "M" or the ","-command in the output of "D", the "´"-output of the "I"nterpret command is not reversible.
It's really a nuisance to look up all the PETSCII codes, but the H-command comes to the rescue! There, the single quote (´) allows to search for a given plain text string, and we just let H search in $0000 to $03FF where it keeps that string to compare it with memory. As evident, VICMON stores that string from $0031 onwards, and for the string with the control characters, we leave out the double quote ("). Note: other monitors most probably use a different position for that buffer!
So two T commands transfer the 8 byte long control character string from $0032..$0039 to $1800..$1807 and the 6 byte long 'birds' string from $0031..$0036 to $1808..$180D. The program is now supposed to start at $180E.
We now need a random number between 0 and 7 (both inclusive) to index into the control characters. For our application, we take the lowest 3 bits of the VIA #2 timer 1 low byte in $9124. In principle, that's a bad (pseudo) random number generator, but it's good enough for our purpose.

The instructions from $180E..$1817 output the random colour code, and the loop in $181A..$1825 outputs the "birds" string, with the KERNAL CHROUT routine at $FFD2:

Before we jump back to the start of the program, we check for the STOP key with JSR $FFE1. When it is not pressed, BNE $180E loops. Otherwise, the program is halted with the BRK instruction and returns to the monitor:

Not to forget: save the program before you start it! Tape users will of course use "01" instead of "08".

Now, go for "G 180E" to let the birds fly! And wee, it's noticably faster than its BASIC counterpart!

Finally, the STOP key halts the program, as was intended. If you get a white prompt, just press Ctrl-6 to return to a blue cursor. With R, you can re-display the register contents in that case.

A Happy Boxing Day!

Michael