1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PC-88 z80asmでキー入力

Posted at
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

inkey1.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?