* RTC command 10

* audio: compatibility for RaymanDS
* powerman: notes about new version
This commit is contained in:
Arisotura 2023-06-17 10:59:17 +02:00
parent 58c275cf8c
commit 139ab069f5
2 changed files with 178 additions and 77 deletions

View File

@ -322,6 +322,11 @@ void OnIPCRequest_RTC(u32 data)
switch (cmd) switch (cmd)
{ {
case 0x10: // read date and time
RTC_Read(0x20, 0x027FFDE8, 7);
SendIPCReply(0x5, 0x9000);
break;
case 0x11: // read date case 0x11: // read date
RTC_Read(0x20, 0x027FFDE8, 4); RTC_Read(0x20, 0x027FFDE8, 4);
SendIPCReply(0x5, 0x9100); SendIPCReply(0x5, 0x9100);
@ -460,93 +465,170 @@ void OnIPCRequest_Powerman(u32 data)
u32 cmd = (PM_Data[0] >> 8) - 0x60; u32 cmd = (PM_Data[0] >> 8) - 0x60;
printf("PM CMD %04X %04X\n", PM_Data[0], PM_Data[1]); printf("PM CMD %04X %04X\n", PM_Data[0], PM_Data[1]);
switch (cmd) if (false)
{ {
case 3: // utility // newer SDK revision
// TODO figure out condition for enabling this
switch (cmd)
{ {
switch (PM_Data[1] & 0xFF) case 1: // utility
{ {
case 1: // power LED: steady switch (PM_Data[1] & 0xFF)
SPI_Powerman::Registers[0] &= ~0x10; {
break; case 1: // power LED: steady
case 2: // power LED: fast blink SPI_Powerman::Registers[0] &= ~0x10;
SPI_Powerman::Registers[0] |= 0x30; break;
break; case 2: // power LED: fast blink
case 3: // power LED: slow blink SPI_Powerman::Registers[0] |= 0x30;
SPI_Powerman::Registers[0] &= ~0x20; break;
SPI_Powerman::Registers[0] |= 0x10; case 3: // power LED: slow blink
break; SPI_Powerman::Registers[0] &= ~0x20;
case 4: // lower backlights on SPI_Powerman::Registers[0] |= 0x10;
SPI_Powerman::Registers[0] |= 0x04; break;
break; case 4: // lower backlights on
case 5: // lower backlights off SPI_Powerman::Registers[0] |= 0x04;
SPI_Powerman::Registers[0] &= ~0x04; break;
break; case 5: // lower backlights off
case 6: // upper backlights on SPI_Powerman::Registers[0] &= ~0x04;
SPI_Powerman::Registers[0] |= 0x08; break;
break; case 6: // upper backlights on
case 7: // upper backlights off SPI_Powerman::Registers[0] |= 0x08;
SPI_Powerman::Registers[0] &= ~0x08; break;
break; case 7: // upper backlights off
case 8: // backlights on SPI_Powerman::Registers[0] &= ~0x08;
SPI_Powerman::Registers[0] |= 0x0C; break;
break; case 8: // backlights on
case 9: // backlights off SPI_Powerman::Registers[0] |= 0x0C;
SPI_Powerman::Registers[0] &= ~0x0C; break;
break; case 9: // backlights off
case 10: // sound amp on SPI_Powerman::Registers[0] &= ~0x0C;
SPI_Powerman::Registers[0] |= 0x01; break;
break; case 10: // sound amp on
case 11: // sound amp off SPI_Powerman::Registers[0] |= 0x01;
SPI_Powerman::Registers[0] &= ~0x01; break;
break; case 11: // sound amp off
case 12: // sound mute on SPI_Powerman::Registers[0] &= ~0x01;
SPI_Powerman::Registers[0] |= 0x02; break;
break; case 12: // sound mute on
case 13: // sound mute off SPI_Powerman::Registers[0] |= 0x02;
SPI_Powerman::Registers[0] &= ~0x02; break;
break; case 13: // sound mute off
case 14: // shutdown SPI_Powerman::Registers[0] &= ~0x02;
SPI_Powerman::Registers[0] &= ~0x01; break;
SPI_Powerman::Registers[0] |= 0x40; case 14: // shutdown
NDS::Stop(); SPI_Powerman::Registers[0] &= ~0x01;
break; SPI_Powerman::Registers[0] |= 0x40;
case 15: // ???? NDS::Stop();
SPI_Powerman::Registers[0] &= ~0x40; break;
break; case 15: // read register 0 bits
printf("%04X %04X %04X %04X\n", PM_Data[0], PM_Data[1], PM_Data[2], PM_Data[3]);
break;
}
SendIPCReply(0x8, 0x0300E100);
} }
break;
SendIPCReply(0x8, 0x0300E300); default:
printf("IPC: unknown powerman command %02X %04X\n", cmd, PM_Data[0]);
break;
} }
break; }
else
case 4: // write register {
switch (cmd)
{ {
u8 addr = PM_Data[0] & 0xFF; case 3: // utility
u8 val = PM_Data[1] & 0xFF; {
SPI_Powerman::Write(addr & 0x7F, true); switch (PM_Data[1] & 0xFF)
SPI_Powerman::Write(val, false); {
SendIPCReply(0x8, 0x03008000 | (((PM_Data[1] + 0x70) & 0xFF) << 8)); case 1: // power LED: steady
} SPI_Powerman::Registers[0] &= ~0x10;
break; break;
case 2: // power LED: fast blink
SPI_Powerman::Registers[0] |= 0x30;
break;
case 3: // power LED: slow blink
SPI_Powerman::Registers[0] &= ~0x20;
SPI_Powerman::Registers[0] |= 0x10;
break;
case 4: // lower backlights on
SPI_Powerman::Registers[0] |= 0x04;
break;
case 5: // lower backlights off
SPI_Powerman::Registers[0] &= ~0x04;
break;
case 6: // upper backlights on
SPI_Powerman::Registers[0] |= 0x08;
break;
case 7: // upper backlights off
SPI_Powerman::Registers[0] &= ~0x08;
break;
case 8: // backlights on
SPI_Powerman::Registers[0] |= 0x0C;
break;
case 9: // backlights off
SPI_Powerman::Registers[0] &= ~0x0C;
break;
case 10: // sound amp on
SPI_Powerman::Registers[0] |= 0x01;
break;
case 11: // sound amp off
SPI_Powerman::Registers[0] &= ~0x01;
break;
case 12: // sound mute on
SPI_Powerman::Registers[0] |= 0x02;
break;
case 13: // sound mute off
SPI_Powerman::Registers[0] &= ~0x02;
break;
case 14: // shutdown
SPI_Powerman::Registers[0] &= ~0x01;
SPI_Powerman::Registers[0] |= 0x40;
NDS::Stop();
break;
case 15: // ????
SPI_Powerman::Registers[0] &= ~0x40;
break;
}
case 5: // read register SendIPCReply(0x8, 0x0300E300);
{ }
u8 addr = PM_Data[0] & 0xFF; break;
SPI_Powerman::Write((addr & 0x7F) | 0x80, true);
SPI_Powerman::Write(0, false);
u8 ret = SPI_Powerman::Read();
SendIPCReply(0x8, 0x03008000 | ret | (((PM_Data[1] + 0x70) & 0xFF) << 8));
}
break;
case 6: case 4: // write register
{ {
// TODO u8 addr = PM_Data[0] & 0xFF;
u8 val = PM_Data[1] & 0xFF;
SPI_Powerman::Write(addr & 0x7F, true);
SPI_Powerman::Write(val, false);
SendIPCReply(0x8, 0x03008000 | (((PM_Data[1] + 0x70) & 0xFF) << 8));
}
break;
SendIPCReply(0x8, 0x03008000 | (((PM_Data[1] + 0x70) & 0xFF) << 8)); case 5: // read register
{
u8 addr = PM_Data[0] & 0xFF;
SPI_Powerman::Write((addr & 0x7F) | 0x80, true);
SPI_Powerman::Write(0, false);
u8 ret = SPI_Powerman::Read();
SendIPCReply(0x8, 0x03008000 | ret | (((PM_Data[1] + 0x70) & 0xFF) << 8));
}
break;
case 6:
{
// TODO
SendIPCReply(0x8, 0x03008000 | (((PM_Data[1] + 0x70) & 0xFF) << 8));
}
break;
default:
printf("IPC: unknown powerman command %02X %04X\n", cmd, PM_Data[0]);
break;
} }
break;
} }
} }

View File

@ -390,8 +390,11 @@ void Reset()
if (NDSCart::CartROM) if (NDSCart::CartROM)
{ {
u32 gamecode = *(u32*)&NDSCart::CartROM[0xC]; u32 gamecode = *(u32*)&NDSCart::CartROM[0xC];
if ((gamecode & 0xFFFFFF) == 0x4D5341) // ASMx / Super Mario 64 DS gamecode &= 0xFFFFFF;
if (gamecode == 0x4D5341) // ASMx / Super Mario 64 DS
Version = 1; Version = 1;
else if (gamecode == 0x595241) // ARYx / Rayman DS
Version = 2;
} }
NDS::ScheduleEvent(NDS::Event_HLE_SoundCmd, true, 174592, Process, 1); NDS::ScheduleEvent(NDS::Event_HLE_SoundCmd, true, 174592, Process, 1);
@ -957,6 +960,11 @@ void ProcessCommands()
// COMMAND TRANSLATE for SM64DS (early sound engine version) // COMMAND TRANSLATE for SM64DS (early sound engine version)
cmd = cmd_trans_early[cmd]; cmd = cmd_trans_early[cmd];
} }
else if (Version == 2)
{
if (cmd >= 2)
cmd += 3;
}
switch (cmd) switch (cmd)
{ {
@ -1251,6 +1259,17 @@ void ProcessCommands()
} }
break; break;
case 0x15: // set channel pan
{
for (int i = 0; i < 16; i++)
{
if (!(args[0] & (1<<i))) continue;
SetChannelPan(i, args[1]);
}
}
break;
case 0x16: // set surround decay case 0x16: // set surround decay
{ {
SurroundDecay = args[0]; SurroundDecay = args[0];