Skip to content

Commit

Permalink
direct boot fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CasualPokePlayer committed Nov 1, 2024
1 parent dfe0e6c commit a09a408
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/DSi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,8 @@ void DSi::SetupDirectBoot()

SPI.GetFirmwareMem()->SetupDirectBoot();

I2S.WriteSndExCnt(0x8008, 0xFFFF);

ARM9.CP15Write(0x100, 0x00056078);
ARM9.CP15Write(0x200, 0x0000004A);
ARM9.CP15Write(0x201, 0x0000004A);
Expand Down Expand Up @@ -2725,10 +2727,10 @@ u8 DSi::ARM7IORead8(u32 addr)
case 0x4004601: if (!(SCFG_EXT[1] & (1 << 20))) return 0; return I2S.ReadMicCnt() >> 8;
case 0x4004602: return 0;
case 0x4004603: return 0;
case 0x4004604: if (!(SCFG_EXT[1] & (1 << 20))) return 0; Log(LogLevel::Debug, "Mic data 8 bit read???\n"); return I2S.ReadMicData() & 0xFF;
case 0x4004605: if (!(SCFG_EXT[1] & (1 << 20))) return 0; Log(LogLevel::Debug, "Mic data 8 bit read???\n"); return (I2S.ReadMicData() >> 8) & 0xFF;
case 0x4004606: if (!(SCFG_EXT[1] & (1 << 20))) return 0; Log(LogLevel::Debug, "Mic data 8 bit read???\n"); return (I2S.ReadMicData() >> 16) & 0xFF;
case 0x4004607: if (!(SCFG_EXT[1] & (1 << 20))) return 0; Log(LogLevel::Debug, "Mic data 8 bit read???\n"); return I2S.ReadMicData() >> 24;
case 0x4004604: if (!(SCFG_EXT[1] & (1 << 20))) return 0; return I2S.ReadMicData() & 0xFF;
case 0x4004605: if (!(SCFG_EXT[1] & (1 << 20))) return 0; return (I2S.ReadMicData() >> 8) & 0xFF;
case 0x4004606: if (!(SCFG_EXT[1] & (1 << 20))) return 0; return (I2S.ReadMicData() >> 16) & 0xFF;
case 0x4004607: if (!(SCFG_EXT[1] & (1 << 20))) return 0; return I2S.ReadMicData() >> 24;
case 0x4004700: if (!(SCFG_EXT[1] & (1 << 21))) return 0; return I2S.ReadSndExCnt() & 0xFF;
case 0x4004701: if (!(SCFG_EXT[1] & (1 << 21))) return 0; return I2S.ReadSndExCnt() >> 8;

Expand Down Expand Up @@ -2775,8 +2777,8 @@ u16 DSi::ARM7IORead16(u32 addr)

case 0x4004600: if (!(SCFG_EXT[1] & (1 << 20))) return 0; return I2S.ReadMicCnt();
case 0x4004602: return 0;
case 0x4004604: if (!(SCFG_EXT[1] & (1 << 20))) return 0; Log(LogLevel::Debug, "Mic data 16 bit read???\n"); return I2S.ReadMicData() >> 16;
case 0x4004606: if (!(SCFG_EXT[1] & (1 << 20))) return 0; Log(LogLevel::Debug, "Mic data 16 bit read???\n"); return I2S.ReadMicData() & 0xFFFF;
case 0x4004604: if (!(SCFG_EXT[1] & (1 << 20))) return 0; return I2S.ReadMicData() >> 16;
case 0x4004606: if (!(SCFG_EXT[1] & (1 << 20))) return 0; return I2S.ReadMicData() & 0xFFFF;
case 0x4004700: if (!(SCFG_EXT[1] & (1 << 21))) return 0; return I2S.ReadSndExCnt();

case 0x04004C00: return GPIO_Data | ((u16)GPIO_Dir << 8);
Expand Down Expand Up @@ -3030,13 +3032,11 @@ void DSi::ARM7IOWrite16(u32 addr, u16 val)
case 0x4004600:
if (!(SCFG_EXT[1] & (1 << 20)))
return;
Log(LogLevel::Debug, "MIC_CNT Write %04X\n", val);
I2S.WriteMicCnt(val, 0xFFFF);
return;
case 0x4004700:
if (!(SCFG_EXT[1] & (1 << 21)))
return;
Log(LogLevel::Debug, "SNDEXCNT Write %04X\n", val);
I2S.WriteSndExCnt(val, 0xFFFF);
return;

Expand Down
4 changes: 1 addition & 3 deletions src/DSi_I2S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ void DSi_I2S::WriteMicCnt(u16 val, u16 mask)

u32 DSi_I2S::ReadMicData()
{
Log(LogLevel::Debug, "MIC_DATA read, FIFO level = %d\n", MicFifo.Level());
// CHECKME: This is a complete guess on how mic data reads work
// gbatek states the FIFO is 16 words large, with 1 word having 2 samples
u32 ret = MicFifo.IsEmpty() ? 0 : (u16)MicFifo.Read();
Expand Down Expand Up @@ -193,13 +192,12 @@ void DSi_I2S::Clock(u32 freq)
// if bit 13 is set, an IRQ is generated when the mic FIFO is half full
if (MicCnt & (1 << 13))
{
Log(LogLevel::Debug, "Do half full mic IRQ\n");
Log(LogLevel::Debug, "Do half full mic IRQ, %d / %d\n", oldLevel, MicFifo.Level());
if (oldLevel < 16 && MicFifo.Level() >= 16) DSi.SetIRQ2(IRQ2_DSi_MicExt);
}
// if bit 13 is not set and bit 14 is set, an IRQ is generated when the mic FIFO is full
else if (MicCnt & (1 << 14))
{
Log(LogLevel::Debug, "Do full mic IRQ\n");
if (oldLevel < 32 && MicFifo.Level() >= 32) DSi.SetIRQ2(IRQ2_DSi_MicExt);
}
}
Expand Down

0 comments on commit a09a408

Please sign in to comment.