fix(apu): some invalid i/o registers should read 0x0000

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-10-29 04:29:44 -03:00
parent 36832ba1fb
commit c75682dbd4
1 changed files with 18 additions and 16 deletions

View File

@ -48,25 +48,26 @@ pub fn read(comptime T: type, apu: *const Apu, addr: u32) ?T {
0x60 => apu.ch1.sound1CntL(), 0x60 => apu.ch1.sound1CntL(),
0x62 => apu.ch1.sound1CntH(), 0x62 => apu.ch1.sound1CntH(),
0x64 => apu.ch1.sound1CntX(), 0x64 => apu.ch1.sound1CntX(),
0x66 => null, 0x66 => 0x0000, // suite.gba expects 0x0000, not 0xDEAD
0x68 => apu.ch2.sound2CntL(), 0x68 => apu.ch2.sound2CntL(),
0x6A => null, 0x6A => 0x0000,
0x6C => apu.ch2.sound2CntH(), 0x6C => apu.ch2.sound2CntH(),
0x6E => null, 0x6E => 0x0000,
0x70 => apu.ch3.sound3CntL(), 0x70 => apu.ch3.sound3CntL(),
0x72 => apu.ch3.sound3CntH(), 0x72 => apu.ch3.sound3CntH(),
0x74 => apu.ch3.sound3CntX(), 0x74 => apu.ch3.sound3CntX(),
0x76 => null, 0x76 => 0x0000,
0x78 => apu.ch4.sound4CntL(), 0x78 => apu.ch4.sound4CntL(),
0x7A => null, 0x7A => 0x0000,
0x7C => apu.ch4.sound4CntH(), 0x7C => apu.ch4.sound4CntH(),
0x7E => null, 0x7E => 0x0000,
0x80 => apu.soundCntL(), 0x80 => apu.soundCntL(),
0x82 => apu.soundCntH(), 0x82 => apu.soundCntH(),
0x84 => apu.soundCntX(), 0x84 => apu.soundCntX(),
0x86 => null, 0x86 => 0x0000,
0x88 => apu.bias.raw, // SOUNDBIAS 0x88 => apu.bias.raw, // SOUNDBIAS
0x8A, 0x8C, 0x8E => null, 0x8A => 0x0000,
0x8C, 0x8E => null,
0x90, 0x92, 0x94, 0x96, 0x98, 0x9A, 0x9C, 0x9E => apu.ch3.wave_dev.read(T, apu.ch3.select, addr), 0x90, 0x92, 0x94, 0x96, 0x98, 0x9A, 0x9C, 0x9E => apu.ch3.wave_dev.read(T, apu.ch3.select, addr),
0xA0, 0xA2 => null, // FIFO_A 0xA0, 0xA2 => null, // FIFO_A
0xA4, 0xA6 => null, // FIFO_B 0xA4, 0xA6 => null, // FIFO_B
@ -76,25 +77,26 @@ pub fn read(comptime T: type, apu: *const Apu, addr: u32) ?T {
0x60, 0x61 => @truncate(T, @as(u16, apu.ch1.sound1CntL()) >> shift(byte)), 0x60, 0x61 => @truncate(T, @as(u16, apu.ch1.sound1CntL()) >> shift(byte)),
0x62, 0x63 => @truncate(T, apu.ch1.sound1CntH() >> shift(byte)), 0x62, 0x63 => @truncate(T, apu.ch1.sound1CntH() >> shift(byte)),
0x64, 0x65 => @truncate(T, apu.ch1.sound1CntX() >> shift(byte)), 0x64, 0x65 => @truncate(T, apu.ch1.sound1CntX() >> shift(byte)),
0x66, 0x67 => null, 0x66, 0x67 => 0x00, // assuming behaviour is identical to that of 16-bit reads
0x68, 0x69 => @truncate(T, apu.ch2.sound2CntL() >> shift(byte)), 0x68, 0x69 => @truncate(T, apu.ch2.sound2CntL() >> shift(byte)),
0x6A, 0x6B => null, 0x6A, 0x6B => 0x00,
0x6C, 0x6D => @truncate(T, apu.ch2.sound2CntH() >> shift(byte)), 0x6C, 0x6D => @truncate(T, apu.ch2.sound2CntH() >> shift(byte)),
0x6E, 0x6F => null, 0x6E, 0x6F => 0x00,
0x70, 0x71 => @truncate(T, @as(u16, apu.ch3.sound3CntL()) >> shift(byte)), // SOUND3CNT_L 0x70, 0x71 => @truncate(T, @as(u16, apu.ch3.sound3CntL()) >> shift(byte)), // SOUND3CNT_L
0x72, 0x73 => @truncate(T, apu.ch3.sound3CntH() >> shift(byte)), 0x72, 0x73 => @truncate(T, apu.ch3.sound3CntH() >> shift(byte)),
0x74, 0x75 => @truncate(T, apu.ch3.sound3CntX() >> shift(byte)), // SOUND3CNT_L 0x74, 0x75 => @truncate(T, apu.ch3.sound3CntX() >> shift(byte)), // SOUND3CNT_L
0x76, 0x77 => null, 0x76, 0x77 => 0x00,
0x78, 0x79 => @truncate(T, apu.ch4.sound4CntL() >> shift(byte)), 0x78, 0x79 => @truncate(T, apu.ch4.sound4CntL() >> shift(byte)),
0x7A, 0x7B => null, 0x7A, 0x7B => 0x00,
0x7C, 0x7D => @truncate(T, apu.ch4.sound4CntH() >> shift(byte)), 0x7C, 0x7D => @truncate(T, apu.ch4.sound4CntH() >> shift(byte)),
0x7E, 0x7F => null, 0x7E, 0x7F => 0x00,
0x80, 0x81 => @truncate(T, apu.soundCntL() >> shift(byte)), // SOUNDCNT_L 0x80, 0x81 => @truncate(T, apu.soundCntL() >> shift(byte)), // SOUNDCNT_L
0x82, 0x83 => @truncate(T, apu.soundCntH() >> shift(byte)), // SOUNDCNT_H 0x82, 0x83 => @truncate(T, apu.soundCntH() >> shift(byte)), // SOUNDCNT_H
0x84, 0x85 => @truncate(T, @as(u16, apu.soundCntX()) >> shift(byte)), 0x84, 0x85 => @truncate(T, @as(u16, apu.soundCntX()) >> shift(byte)),
0x86, 0x87 => null, 0x86, 0x87 => 0x00,
0x88, 0x89 => @truncate(T, apu.bias.raw >> shift(byte)), // SOUNDBIAS 0x88, 0x89 => @truncate(T, apu.bias.raw >> shift(byte)), // SOUNDBIAS
0x8A...0x8F => null, 0x8A, 0x8B => 0x00,
0x8C...0x8F => null,
0x90...0x9F => apu.ch3.wave_dev.read(T, apu.ch3.select, addr), 0x90...0x9F => apu.ch3.wave_dev.read(T, apu.ch3.select, addr),
0xA0, 0xA1, 0xA2, 0xA3 => null, // FIFO_A 0xA0, 0xA1, 0xA2, 0xA3 => null, // FIFO_A
0xA4, 0xA5, 0xA6, 0xA7 => null, // FIFO_B 0xA4, 0xA5, 0xA6, 0xA7 => null, // FIFO_B