0
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?

z88dk MSX ポート出力 __outp 音再生

Posted at

指定ポートに値を出力するには、__outp()を使用する
以下のコードは、音の周波数を指定して音を再生するサンプル

main.c
void setToneA(unsigned int freq)
{
    unsigned int n = 1789000 / (32 * freq);
    __outp(0xA0, 0);               // レジスタ0選択(Tone A low)
    __outp(0xA1, n & 0xFF);        // 下位8bit
    __outp(0xA0, 1);               // レジスタ1選択(Tone A high)
    __outp(0xA1, (n >> 8) & 0x0F); // 上位4bit
}

void setVolumeA(unsigned char vol)
{
    __outp(0xA0, 8);          // レジスタ8選択(Volume A)
    __outp(0xA1, vol & 0x0F); // 0〜15
}

void main()
{
    setToneA(440); // A音
    setVolumeA(7); // 音量
}
0
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
0
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?