Wednesday 11 October 2017

More general routines

The plan is to write most of the general routines which can be reused up front, then do the actual games.

Some of it now works. If you run the latest version, of the Javascript version (link on right) or the C version you can now move your "player" LED with the arrow keys and shoot a "missile" LED with fire (Control key).

A Cop444 has a JSRP instruction which does a subroutine jump into page 2; what I'm doing is creating a whole pile of extra one byte instructions that do far more complex things.

So, in this bit of code there's the following which does this.

Update updates the screen display, timers and scans the keypad.

MoveHPlayer/MoveVPlayer move the player in that axis. They both skip if you move off the screen hence the NOPs. (I might change this as none of the games need this). CheckFire fires a new missile if possible and the fire key is down. MovePlayerMissile moves the P/M if it is in flight and return-skips if it is still in flight (e.g. you might check it collides with something). In this demo it increments the counter when the missile is in flight. (BumpCounter .... increments the counter)

All of these instructions are one byte JSRP commands.
game_code:

    jsrp     Update
    jsrp     MoveHPlayer
    nop
    jsrp     MoveVPlayer
    nop

    jsrp     CheckFire
    jsrp     MovePlayerMissile
    jp        game_code

    jsrp     BumpCounter
    jp       game_code

No comments:

Post a Comment