* 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)
{
case 0x10: // read date and time
RTC_Read(0x20, 0x027FFDE8, 7);
SendIPCReply(0x5, 0x9000);
break;
case 0x11: // read date
RTC_Read(0x20, 0x027FFDE8, 4);
SendIPCReply(0x5, 0x9100);
@ -460,93 +465,170 @@ void OnIPCRequest_Powerman(u32 data)
u32 cmd = (PM_Data[0] >> 8) - 0x60;
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
SPI_Powerman::Registers[0] &= ~0x10;
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;
switch (PM_Data[1] & 0xFF)
{
case 1: // power LED: steady
SPI_Powerman::Registers[0] &= ~0x10;
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: // 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;
case 4: // write register
}
else
{
switch (cmd)
{
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;
case 3: // utility
{
switch (PM_Data[1] & 0xFF)
{
case 1: // power LED: steady
SPI_Powerman::Registers[0] &= ~0x10;
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
{
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;
SendIPCReply(0x8, 0x0300E300);
}
break;
case 6:
{
// TODO
case 4: // write register
{
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)
{
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;
else if (gamecode == 0x595241) // ARYx / Rayman DS
Version = 2;
}
NDS::ScheduleEvent(NDS::Event_HLE_SoundCmd, true, 174592, Process, 1);
@ -957,6 +960,11 @@ void ProcessCommands()
// COMMAND TRANSLATE for SM64DS (early sound engine version)
cmd = cmd_trans_early[cmd];
}
else if (Version == 2)
{
if (cmd >= 2)
cmd += 3;
}
switch (cmd)
{
@ -1251,6 +1259,17 @@ void ProcessCommands()
}
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
{
SurroundDecay = args[0];