VOOZH about

URL: https://qiita.com/fuzzball/items/246dd6bcc2b20613dd68

⇱ [PC-6001] キー入力 & ジョイスティック入力 #Z80 - Qiita


👁 Image
3

Go to list of users who liked

1

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

@fuzzball

[PC-6001] キー入力 & ジョイスティック入力

3
Last updated at Posted at 2013-04-30

#キー入力
##BIOSを使う

call $1061 ;Aregに状態が返ってくる
bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
SPACE reserved STOP SHIFT
  • 0:OFF, 1:ON
  • BASICのSTICK(0),STRIG(0)に相当

#ジョイスティック入力
##BIOSを使う

ld a,no ;ジョイスティック番号(#1:$01,#2:$02)
call $1CA6 ;Aregに状態が返ってくる
bit7-6 bit5 bit4 bit3 bit2 bit1 bit0
reserved TRIGGER1 TRIGGER2
  • 0:OFF, 1:ON
  • BASICのSTICK(n),STRIG(n)に相当(n=1~2)

ただし、BIOSの前半部分にバグがありPSGにノイズが乗ってしまうことがあるので、下記のようにして回避します。

entry:
 rrca
 rrca
 or %10000000
 push bc
 ld b,a
 ld a,$07 ;PSG/R7
 di
 out ($A0),a
 in a,($A2)
 ld c,a
 ;ここまではBIOSからの抜粋

 ;BIOSでは ld a,%10000000 になっていて下位6bitをクリアしてしまっている
 ;下位6bitはそのままでI/O設定のみ変更する
 and %00111111 ;上位2bitのみクリア
 or %10000000 ;bit7:IOB=出力, bit6:IOA=入力
 
 jp $1CB6 ;BIOSの途中に飛ぶ
3

Go to list of users who liked

1
0

Go to list of comments

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
3

Go to list of users who liked

1