Options 2 and 3 are best left for a completed game which is fully M/code but for the present I shall use option 1 as this is easier to set up.
The disadvantage is that the M/code has to be assembled each time as the area used varies as the assembler listing lengthens.
I have re-written the assembler listing for this method and included all the subroutines so far. These have been revised to make them clearer and include the variables as explained last time.
I have put the data for the character on page 94 of the manual for those who have not created one yet. Also I have put a basic main loop in so that the program will run and you can move the character around though, since M/code is very fast, you will not have much control yet.
This routine uses the OS subroutine OSBYTE. This is used for the M/code equivalent of the *FX calls.
Register A is loaded with the value of the FX call and registers X & Y the parameters needed. Thus:
LDA#15:LDX#0:LDY#0:JMPosbyte
is the equivalent of *FX15,0 used for clearing the buffers.
.lt LDA#129:LDX#&9E:LDY#&FF:JSRosbyte \ INKEY-98
BCCrt:JSRleft
For the present, the movement subroutines simply increase or decrease the co-ordinates for printing the character. They will need to be added to later.
.delay PHA:TXA:PHA:TYA:PHA: \ save register values on stack
LDXspeed:.xloop :LDY#255:.yloop DEY:BNEyloop:DEX:BNExloop:
PLA:TAY:PLA:TAX:PLA:RTS \ restore register values
The subroutine will need to be called in the main loop by:
320 JSRdelay
350 JSRdelay
It is entered twice so that the character flashes evenly.
LDA#129:LDX#&8F:LDY#&FF:JSRosbyte \ INKEY-113 ESCAPE
BCCcont:RTS \ Return to BASIC
.cont
This must be in the main loop since, if it were in a subroutine, it would simply end the routine and not return to BASIC.
Whether it is to select from a menu or simply to answer a yes or no question, we shall need to make our choice.
For this we use the OS routine OSRDCH (&FFE0).
This routine stops the program and waits for a key to be pressed. It will put the ASC value of the key into register A.
If ESCAPE is pressed, the Carry flag is set so a test of this flag can be used for breaking out of the program and returning to BASIC:
.rdch JSRosrdch
BCCcont
RTS \ Return to BASIC
.cont (rest of program)
For answering a question add:
CMP#ASC"Y":BEQ yes
CMP#ASC"N":BEQ no
JMPrdch
.yes JSR instructions \ (or whatever)
.no (rest of program)
This can be extended or altered to any keys.
.rdch JSRosrdch
CMP#ASC"1":BCCrdch \ back if <ASC"1"
CMP#ASC"4":BCSdrch \ back if >ASC"3"
CMP#ASC"1":BEQchoice1
CMP#ASC"2":BEQchoice2
CMP#ASC"3":BEQchoice3
.choice1 JSRoption1:JMPrep
JSRoption2:JMPrep
JSRoption3:JMPrep
.rep (rest of program)
The speed of the game can be selected by:
200 .spset JSRosrdch
CMP#ASC"1":BCCspset
CMP#ASC"4":BCSspset
SEC:SBC#48
ASL A:ASL A:ASL A:ASL A
STAspeed
Enter this in the program before the main loop.
Richard Dimond, EUG #21