inkey1.asm
; z88dk / PC-88 mon
; z80asm -b -l inkey1.asm
tvram equ $f3c8
org $b000
start:
ld a, $0c ; cls
rst $18 ; OUTIO
.loop
; キー入力
ld a, (dir)
ld b, a
in a, ($0a) ; 左キー
and $04
jr nz, skip1
dec b
.skip1
in a, ($08) ; 右キー
and $04
jr nz, skip2
inc b
.skip2
ld a, b
and $3f ; 0~63
ld (dir), a
call WaitVBlank
; クリア
ld hl, tvram+120*5
ld b, 80
ld a, $20 ; ' '
.cls
ld (hl), a
inc hl
djnz cls
; 描画
ld hl, tvram+120*5
ld a, (dir)
ld b, a
ld a, $8e
.cont
dec b
jp m, break
ld (hl), a
inc hl
jr cont
.break
jr loop
WaitVBlank:
in a, ($40)
and $20
jr nz, WaitVBlank
.wait
in a, ($40)
and $20
jr z, wait
ret
dir: defb $20