; Init the start position of the player PLAYER_INIT: ; start at (16, 16) ld a, 40 ld (xcoord), a ld (oldxcoord), a ld a, 45 ld (ycoord), a ld (oldycoord), a ; print the player call PLAYER_PRINT ret ;; Scan key using direct input MOVE_SCAN_KEY: ld a,$FF ; Before any action, reset the keyport out (1),a ; ...by sending to the port 1 the value 255 (FF ld a,$FE ; select the keyboard group to scan (here the arrow keys) out (1),a ; ...by sending to the keyboard port (1) the value FE. in a,(1) ; Get the port value, which says wich keys was pressed cp 253 ;| Look for the key which was pressed and jump to the correct label. jp z,left ;| cp 251 ;| jp z,right ;| jp finloop right: ld a,(xcoord) add a,1 ld (xcoord),a jp print left: ld a,(xcoord) sub 1 ld (xcoord),a jp print ; Passe ici seulement si key press print: ld a,(xcoord) ld e,(ycoord) call PROTECT_ARENA call PLAYER_PRINT ;call WAITKEY finloop: ret ; On affiche le curseur PLAYER_PRINT: ; effacer la tout le sprite (on l'affichera un pixel plus loin apres) ld a,(oldxcoord) ld de,(oldycoord) ld d,0 ld hl, player call CLRSPR ; afficher nouveau sprite ld hl,(xcoord) ld de,(ycoord) ld (oldxcoord),hl ld (oldycoord),de ld a,l ld hl, player call DRWSPR call FASTCOPY ret player: .db 00000000b .db 00000000b .db 00011000b .db 00111100b .db 00111100b .db 00011000b .db 00000000b .db 00000000b