.include "skirmish.inc" .export INPUT_READ .importzp input_flags .importzp last_input_flags .importzp temp0 .importzp temp1 .segment "CODE" INPUT_READ: lda #0 sta temp0 lda $DC00 sta temp1 lda temp1 and #$01 bne :+ lda temp0 ora #INPUT_UP sta temp0 : lda temp1 and #$02 bne :+ lda temp0 ora #INPUT_DOWN sta temp0 : lda temp1 and #$04 bne :+ lda temp0 ora #INPUT_LEFT sta temp0 : lda temp1 and #$08 bne :+ lda temp0 ora #INPUT_RIGHT sta temp0 : lda temp1 and #$10 bne :+ lda temp0 ora #INPUT_FIRE sta temp0 : jsr $FFE4 beq keyboard_done cmp #'W' bne :+ lda temp0 ora #INPUT_UP sta temp0 : cmp #'S' bne :+ lda temp0 ora #INPUT_DOWN sta temp0 : cmp #'A' bne :+ lda temp0 ora #INPUT_LEFT sta temp0 : cmp #'D' bne :+ lda temp0 ora #INPUT_RIGHT sta temp0 : cmp #'Q' bne :+ lda temp0 ora #INPUT_NEXT sta temp0 : cmp #' ' bne :+ lda temp0 ora #INPUT_WAIT sta temp0 : cmp #'E' bne :+ lda temp0 ora #INPUT_WAIT sta temp0 : cmp #'R' bne keyboard_done lda temp0 ora #INPUT_RESTART sta temp0 keyboard_done: lda last_input_flags eor #$FF and temp0 sta input_flags lda temp0 sta last_input_flags rts