More than 5 years have passed since last update.
z88dkのz80asm/zccでMSX用のキーマトリクス表示を作る。
参考:
MSX Datapack - キーボード・インターフェイス
MSXキーマトリクス表
- z80asm
snsmat.asm
CHPUT equ $00a2
CLS equ $00c3
SNSMAT equ $0141
org $d000
xor a
call CLS
start:
ld e, 0 ; E = キーマトリクスの行(0~10)
ld hl, text+3
push hl ; 出力先 push
.line
ld a, e
call SNSMAT
ld d, a ; D = キーマトリクスの行の状態
pop hl
ld bc, 12 ; 次の行
add hl, bc
push hl
ld b, 8
.bits
xor a
sla d
adc a, $30
ld (hl), a
inc hl
djnz bits
inc e
ld a, 11
cp e
jr nz, line
pop hl ; 出力先 pop
ld hl, text
call puts
jr start
puts:
ld a, (hl)
or a
ret z
call CHPUT
inc hl
jr puts
text: defm 11
defm " 76543210\r\n"
defm "0 \r\n"
defm "1 \r\n"
defm "2 \r\n"
defm "3 \r\n"
defm "4 \r\n"
defm "5 \r\n"
defm "6 \r\n"
defm "7 \r\n"
defm "8 \r\n"
defm "9 \r\n"
defm "A \r\n"
defm 0
アセンブル
z80asm -b snsmat
snsmat.binファイルが作られる。
appmake +msx -b snsmat.bin --org 0xd000
snsmat.msxファイルが作られる。
WebMSXを起動する。
snsmat.msxファイルを[Drive A]の[+ FILES]にドロップする(Altキーを併用してもいい)
bload"snsmat.msx",r
と入力する。
左Altキーを押した所
👁 WMSX Screen.png
- zcc
snsmat.c
/*
zcc +msx -lndos -create-app snsmat.c
bload"cas:",r
*/
# include <stdio.h>
# include <stdlib.h>
int snsmat(int line)
{
# asm
ld a, l
call $0141 ; SNSMAT
ld l, a
ld h, 0
# endasm
}
void main()
{
char buf[20];
printf("\x0c");
for (;;) {
printf("\x0b 76543210\n");
for (int i = 0; i <= 10; i++) {
int bits = snsmat(i);
itoa(0x100 | bits, buf, 2);
printf("%X %s\n", i, buf+1);
}
}
}
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
