More than 5 years have passed since last update.
z88dkのzccでMSX PSGを鳴らす。
tone.c
/*
zcc +msx -lndos -create-app tone.c
bload"cas:",r
*/
# include <stdio.h>
# include <psg.h>
# define BOOL int
# define FALSE 0
# define TRUE 1
int snsmat(int line)
{
# asm
ld a, l
call $0141 ; SNSMAT
ld l, a
ld h, 0
# endasm
}
void main()
{
BOOL press = FALSE;
psg_init();
sound(7, 076); // ch.A tone enable
puts("Press A key.\n");
for (;;) {
int bits = snsmat(2);
if (bits & 0x40) {
if (press) {
sound(8, 0);
press = FALSE;
}
} else {
if (! press) {
sound(0, 0xfe);
sound(1, 0);
sound(8, 12);
press = TRUE;
}
}
}
}
WebMSXのCassetteにa.casをドロップする。
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
