2
1

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.

MSX PSG

Posted at

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をドロップする。

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?