From 9d4c7b0ddbcaf82c809d6fa7377a53fcf58531ac Mon Sep 17 00:00:00 2001 From: RocketRobz Date: Wed, 28 Aug 2024 23:18:38 -0600 Subject: [PATCH] Optimize touch screen mode switch code (outside of NO$GBA) ALSO: Fix sound/mic frequency writing --- booter/arm7/source/main.c | 3 +- booter_fc/arm7/source/main.c | 3 +- slot1launch/bootloader/source/main.arm7.c | 278 ++++++++++--------- slot1launch/bootloaderAlt/source/main.arm7.c | 276 +++++++++--------- title/bootloader/source/boot.c | 269 +++++++++--------- universal/bootloader_menu/source/boot.c | 269 +++++++++--------- 6 files changed, 567 insertions(+), 531 deletions(-) diff --git a/booter/arm7/source/main.c b/booter/arm7/source/main.c index 4b3a7a69e2..64fd57b02a 100644 --- a/booter/arm7/source/main.c +++ b/booter/arm7/source/main.c @@ -80,7 +80,8 @@ int main() { } } - *(vu16*)(0x04004700) |= BIT(13); // Set 48khz sound/mic frequency + *(vu16*)0x04004700 &= ~BIT(15); // Runs before sound frequency change + *(vu16*)0x04004700 |= BIT(13); // Set 48khz sound/mic frequency // clear sound registers dmaFillWords(0, (void*)0x04000400, 0x100); diff --git a/booter_fc/arm7/source/main.c b/booter_fc/arm7/source/main.c index 3bbc1eff85..d9913e23ea 100644 --- a/booter_fc/arm7/source/main.c +++ b/booter_fc/arm7/source/main.c @@ -74,7 +74,8 @@ int main() { *(vu16*)(0x04004014) = 0x264C; *(vu16*)(0x04004C02) = 0x4000; // enable powerbutton irq (Fix for Unlaunch 1.3) - *(vu16*)(0x04004700) |= BIT(13); // Set 48khz sound/mic frequency (DSi/3DS only) + *(vu16*)0x04004700 &= ~BIT(15); // Runs before sound frequency change + *(vu16*)0x04004700 |= BIT(13); // Set 48khz sound/mic frequency (DSi/3DS only) // clear sound registers dmaFillWords(0, (void*)0x04000400, 0x100); diff --git a/slot1launch/bootloader/source/main.arm7.c b/slot1launch/bootloader/source/main.arm7.c index c89872af1b..68fd451bfb 100644 --- a/slot1launch/bootloader/source/main.arm7.c +++ b/slot1launch/bootloader/source/main.arm7.c @@ -499,146 +499,151 @@ static void NDSTouchscreenMode(void) { volLevel = 0xA7; } + const bool noSgba = (strncmp((const char*)0x04FFFA00, "no$gba", 6) == 0); + // Touchscreen - cdcReadReg (0x63, 0x00); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); - cdcReadReg (CDC_CONTROL, 0x51); - cdcReadReg (CDC_TOUCHCNT, 0x02); - cdcReadReg (CDC_CONTROL, 0x3F); - cdcReadReg (CDC_SOUND, 0x28); - cdcReadReg (CDC_SOUND, 0x2A); - cdcReadReg (CDC_SOUND, 0x2E); - cdcWriteReg(CDC_CONTROL, 0x52, 0x80); - cdcWriteReg(CDC_CONTROL, 0x40, 0x0C); - cdcWriteReg(CDC_SOUND, 0x24, 0xFF); - cdcWriteReg(CDC_SOUND, 0x25, 0xFF); - cdcWriteReg(CDC_SOUND, 0x26, 0x7F); - cdcWriteReg(CDC_SOUND, 0x27, 0x7F); - cdcWriteReg(CDC_SOUND, 0x28, 0x4A); - cdcWriteReg(CDC_SOUND, 0x29, 0x4A); - cdcWriteReg(CDC_SOUND, 0x2A, 0x10); - cdcWriteReg(CDC_SOUND, 0x2B, 0x10); - cdcWriteReg(CDC_CONTROL, 0x51, 0x00); - cdcReadReg (CDC_TOUCHCNT, 0x02); - cdcWriteReg(CDC_TOUCHCNT, 0x02, 0x98); - cdcWriteReg(CDC_SOUND, 0x23, 0x00); - cdcWriteReg(CDC_SOUND, 0x1F, 0x14); - cdcWriteReg(CDC_SOUND, 0x20, 0x14); - cdcWriteReg(CDC_CONTROL, 0x3F, 0x00); - cdcReadReg (CDC_CONTROL, 0x0B); - cdcWriteReg(CDC_CONTROL, 0x05, 0x00); - cdcWriteReg(CDC_CONTROL, 0x0B, 0x01); - cdcWriteReg(CDC_CONTROL, 0x0C, 0x02); - cdcWriteReg(CDC_CONTROL, 0x12, 0x01); - cdcWriteReg(CDC_CONTROL, 0x13, 0x02); - cdcWriteReg(CDC_SOUND, 0x2E, 0x00); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); - cdcWriteReg(CDC_CONTROL, 0x01, 0x01); - cdcWriteReg(CDC_CONTROL, 0x39, 0x66); - cdcReadReg (CDC_SOUND, 0x20); - cdcWriteReg(CDC_SOUND, 0x20, 0x10); - cdcWriteReg(CDC_CONTROL, 0x04, 0x00); - cdcWriteReg(CDC_CONTROL, 0x12, 0x81); - cdcWriteReg(CDC_CONTROL, 0x13, 0x82); - cdcWriteReg(CDC_CONTROL, 0x51, 0x82); - cdcWriteReg(CDC_CONTROL, 0x51, 0x00); - cdcWriteReg(CDC_CONTROL, 0x04, 0x03); - cdcWriteReg(CDC_CONTROL, 0x05, 0xA1); - cdcWriteReg(CDC_CONTROL, 0x06, 0x15); - cdcWriteReg(CDC_CONTROL, 0x0B, 0x87); - cdcWriteReg(CDC_CONTROL, 0x0C, 0x83); - cdcWriteReg(CDC_CONTROL, 0x12, 0x87); - cdcWriteReg(CDC_CONTROL, 0x13, 0x83); - cdcReadReg (CDC_TOUCHCNT, 0x10); - cdcWriteReg(CDC_TOUCHCNT, 0x10, 0x08); - cdcWriteReg(0x04, 0x08, 0x7F); - cdcWriteReg(0x04, 0x09, 0xE1); - cdcWriteReg(0x04, 0x0A, 0x80); - cdcWriteReg(0x04, 0x0B, 0x1F); - cdcWriteReg(0x04, 0x0C, 0x7F); - cdcWriteReg(0x04, 0x0D, 0xC1); - cdcWriteReg(CDC_CONTROL, 0x41, 0x08); - cdcWriteReg(CDC_CONTROL, 0x42, 0x08); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); - cdcWriteReg(0x04, 0x08, 0x7F); - cdcWriteReg(0x04, 0x09, 0xE1); - cdcWriteReg(0x04, 0x0A, 0x80); - cdcWriteReg(0x04, 0x0B, 0x1F); - cdcWriteReg(0x04, 0x0C, 0x7F); - cdcWriteReg(0x04, 0x0D, 0xC1); - cdcWriteReg(CDC_SOUND, 0x2F, 0x2B); - cdcWriteReg(CDC_SOUND, 0x30, 0x40); - cdcWriteReg(CDC_SOUND, 0x31, 0x40); - cdcWriteReg(CDC_SOUND, 0x32, 0x60); - cdcReadReg (CDC_CONTROL, 0x74); - cdcWriteReg(CDC_CONTROL, 0x74, 0x02); - cdcReadReg (CDC_CONTROL, 0x74); - cdcWriteReg(CDC_CONTROL, 0x74, 0x10); - cdcReadReg (CDC_CONTROL, 0x74); - cdcWriteReg(CDC_CONTROL, 0x74, 0x40); - cdcWriteReg(CDC_SOUND, 0x21, 0x20); - cdcWriteReg(CDC_SOUND, 0x22, 0xF0); - cdcReadReg (CDC_CONTROL, 0x51); - cdcReadReg (CDC_CONTROL, 0x3F); - cdcWriteReg(CDC_CONTROL, 0x3F, 0xD4); - cdcWriteReg(CDC_SOUND, 0x23, 0x44); - cdcWriteReg(CDC_SOUND, 0x1F, 0xD4); - cdcWriteReg(CDC_SOUND, 0x28, 0x4E); - cdcWriteReg(CDC_SOUND, 0x29, 0x4E); - cdcWriteReg(CDC_SOUND, 0x24, 0x9E); - cdcWriteReg(CDC_SOUND, 0x25, 0x9E); - cdcWriteReg(CDC_SOUND, 0x20, 0xD4); - cdcWriteReg(CDC_SOUND, 0x2A, 0x14); - cdcWriteReg(CDC_SOUND, 0x2B, 0x14); - cdcWriteReg(CDC_SOUND, 0x26, 0xA7); - cdcWriteReg(CDC_SOUND, 0x27, 0xA7); - cdcWriteReg(CDC_CONTROL, 0x40, 0x00); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); + if (noSgba) { + cdcReadReg (0x63, 0x00); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); + cdcReadReg (CDC_CONTROL, 0x51); + cdcReadReg (CDC_TOUCHCNT, 0x02); + cdcReadReg (CDC_CONTROL, 0x3F); + cdcReadReg (CDC_SOUND, 0x28); + cdcReadReg (CDC_SOUND, 0x2A); + cdcReadReg (CDC_SOUND, 0x2E); + cdcWriteReg(CDC_CONTROL, 0x52, 0x80); + cdcWriteReg(CDC_CONTROL, 0x40, 0x0C); + cdcWriteReg(CDC_SOUND, 0x24, 0xFF); + cdcWriteReg(CDC_SOUND, 0x25, 0xFF); + cdcWriteReg(CDC_SOUND, 0x26, 0x7F); + cdcWriteReg(CDC_SOUND, 0x27, 0x7F); + cdcWriteReg(CDC_SOUND, 0x28, 0x4A); + cdcWriteReg(CDC_SOUND, 0x29, 0x4A); + cdcWriteReg(CDC_SOUND, 0x2A, 0x10); + cdcWriteReg(CDC_SOUND, 0x2B, 0x10); + cdcWriteReg(CDC_CONTROL, 0x51, 0x00); + cdcReadReg (CDC_TOUCHCNT, 0x02); + cdcWriteReg(CDC_TOUCHCNT, 0x02, 0x98); + cdcWriteReg(CDC_SOUND, 0x23, 0x00); + cdcWriteReg(CDC_SOUND, 0x1F, 0x14); + cdcWriteReg(CDC_SOUND, 0x20, 0x14); + cdcWriteReg(CDC_CONTROL, 0x3F, 0x00); + cdcReadReg (CDC_CONTROL, 0x0B); + cdcWriteReg(CDC_CONTROL, 0x05, 0x00); + cdcWriteReg(CDC_CONTROL, 0x0B, 0x01); + cdcWriteReg(CDC_CONTROL, 0x0C, 0x02); + cdcWriteReg(CDC_CONTROL, 0x12, 0x01); + cdcWriteReg(CDC_CONTROL, 0x13, 0x02); + cdcWriteReg(CDC_SOUND, 0x2E, 0x00); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); + cdcWriteReg(CDC_CONTROL, 0x01, 0x01); + cdcWriteReg(CDC_CONTROL, 0x39, 0x66); + cdcReadReg (CDC_SOUND, 0x20); + cdcWriteReg(CDC_SOUND, 0x20, 0x10); + cdcWriteReg(CDC_CONTROL, 0x04, 0x00); + cdcWriteReg(CDC_CONTROL, 0x12, 0x81); + cdcWriteReg(CDC_CONTROL, 0x13, 0x82); + cdcWriteReg(CDC_CONTROL, 0x51, 0x82); + cdcWriteReg(CDC_CONTROL, 0x51, 0x00); + cdcWriteReg(CDC_CONTROL, 0x04, 0x03); + cdcWriteReg(CDC_CONTROL, 0x05, 0xA1); + cdcWriteReg(CDC_CONTROL, 0x06, 0x15); + cdcWriteReg(CDC_CONTROL, 0x0B, 0x87); + cdcWriteReg(CDC_CONTROL, 0x0C, 0x83); + cdcWriteReg(CDC_CONTROL, 0x12, 0x87); + cdcWriteReg(CDC_CONTROL, 0x13, 0x83); + cdcReadReg (CDC_TOUCHCNT, 0x10); + cdcWriteReg(CDC_TOUCHCNT, 0x10, 0x08); + cdcWriteReg(0x04, 0x08, 0x7F); + cdcWriteReg(0x04, 0x09, 0xE1); + cdcWriteReg(0x04, 0x0A, 0x80); + cdcWriteReg(0x04, 0x0B, 0x1F); + cdcWriteReg(0x04, 0x0C, 0x7F); + cdcWriteReg(0x04, 0x0D, 0xC1); + cdcWriteReg(CDC_CONTROL, 0x41, 0x08); + cdcWriteReg(CDC_CONTROL, 0x42, 0x08); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); + cdcWriteReg(0x04, 0x08, 0x7F); + cdcWriteReg(0x04, 0x09, 0xE1); + cdcWriteReg(0x04, 0x0A, 0x80); + cdcWriteReg(0x04, 0x0B, 0x1F); + cdcWriteReg(0x04, 0x0C, 0x7F); + cdcWriteReg(0x04, 0x0D, 0xC1); + cdcWriteReg(CDC_SOUND, 0x2F, 0x2B); + cdcWriteReg(CDC_SOUND, 0x30, 0x40); + cdcWriteReg(CDC_SOUND, 0x31, 0x40); + cdcWriteReg(CDC_SOUND, 0x32, 0x60); + cdcReadReg (CDC_CONTROL, 0x74); + cdcWriteReg(CDC_CONTROL, 0x74, 0x02); + cdcReadReg (CDC_CONTROL, 0x74); + cdcWriteReg(CDC_CONTROL, 0x74, 0x10); + cdcReadReg (CDC_CONTROL, 0x74); + cdcWriteReg(CDC_CONTROL, 0x74, 0x40); + cdcWriteReg(CDC_SOUND, 0x21, 0x20); + cdcWriteReg(CDC_SOUND, 0x22, 0xF0); + cdcReadReg (CDC_CONTROL, 0x51); + cdcReadReg (CDC_CONTROL, 0x3F); + cdcWriteReg(CDC_CONTROL, 0x3F, 0xD4); + cdcWriteReg(CDC_SOUND, 0x23, 0x44); + cdcWriteReg(CDC_SOUND, 0x1F, 0xD4); + cdcWriteReg(CDC_SOUND, 0x28, 0x4E); + cdcWriteReg(CDC_SOUND, 0x29, 0x4E); + cdcWriteReg(CDC_SOUND, 0x24, 0x9E); + cdcWriteReg(CDC_SOUND, 0x25, 0x9E); + cdcWriteReg(CDC_SOUND, 0x20, 0xD4); + cdcWriteReg(CDC_SOUND, 0x2A, 0x14); + cdcWriteReg(CDC_SOUND, 0x2B, 0x14); + cdcWriteReg(CDC_SOUND, 0x26, 0xA7); + cdcWriteReg(CDC_SOUND, 0x27, 0xA7); + cdcWriteReg(CDC_CONTROL, 0x40, 0x00); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); + } cdcWriteReg(CDC_SOUND, 0x26, volLevel); cdcWriteReg(CDC_SOUND, 0x27, volLevel); cdcWriteReg(CDC_SOUND, 0x2E, 0x03); cdcWriteReg(CDC_TOUCHCNT, 0x03, 0x00); cdcWriteReg(CDC_SOUND, 0x21, 0x20); cdcWriteReg(CDC_SOUND, 0x22, 0xF0); - cdcReadReg (CDC_SOUND, 0x22); - cdcWriteReg(CDC_SOUND, 0x22, 0x00); + cdcWriteReg(CDC_SOUND, 0x22, 0x70); cdcWriteReg(CDC_CONTROL, 0x52, 0x80); cdcWriteReg(CDC_CONTROL, 0x51, 0x00); - - // Set remaining values - cdcWriteReg(CDC_CONTROL, 0x03, 0x44); - cdcWriteReg(CDC_CONTROL, 0x0D, 0x00); - cdcWriteReg(CDC_CONTROL, 0x0E, 0x80); - cdcWriteReg(CDC_CONTROL, 0x0F, 0x80); - cdcWriteReg(CDC_CONTROL, 0x10, 0x08); - cdcWriteReg(CDC_CONTROL, 0x14, 0x80); - cdcWriteReg(CDC_CONTROL, 0x15, 0x80); - cdcWriteReg(CDC_CONTROL, 0x16, 0x04); - cdcWriteReg(CDC_CONTROL, 0x1A, 0x01); - cdcWriteReg(CDC_CONTROL, 0x1E, 0x01); - cdcWriteReg(CDC_CONTROL, 0x24, 0x80); - cdcWriteReg(CDC_CONTROL, 0x33, 0x34); - cdcWriteReg(CDC_CONTROL, 0x34, 0x32); - cdcWriteReg(CDC_CONTROL, 0x35, 0x12); - cdcWriteReg(CDC_CONTROL, 0x36, 0x03); - cdcWriteReg(CDC_CONTROL, 0x37, 0x02); - cdcWriteReg(CDC_CONTROL, 0x38, 0x03); - cdcWriteReg(CDC_CONTROL, 0x3C, 0x19); - cdcWriteReg(CDC_CONTROL, 0x3D, 0x05); - cdcWriteReg(CDC_CONTROL, 0x44, 0x0F); - cdcWriteReg(CDC_CONTROL, 0x45, 0x38); - cdcWriteReg(CDC_CONTROL, 0x49, 0x00); - cdcWriteReg(CDC_CONTROL, 0x4A, 0x00); - cdcWriteReg(CDC_CONTROL, 0x4B, 0xEE); - cdcWriteReg(CDC_CONTROL, 0x4C, 0x10); - cdcWriteReg(CDC_CONTROL, 0x4D, 0xD8); - cdcWriteReg(CDC_CONTROL, 0x4E, 0x7E); - cdcWriteReg(CDC_CONTROL, 0x4F, 0xE3); - cdcWriteReg(CDC_CONTROL, 0x58, 0x7F); - cdcWriteReg(CDC_CONTROL, 0x74, 0xD2); - cdcWriteReg(CDC_CONTROL, 0x75, 0x2C); - cdcWriteReg(CDC_SOUND, 0x22, 0x70); - cdcWriteReg(CDC_SOUND, 0x2C, 0x20); + + if (noSgba) { + // Set remaining values + cdcWriteReg(CDC_CONTROL, 0x03, 0x44); + cdcWriteReg(CDC_CONTROL, 0x0D, 0x00); + cdcWriteReg(CDC_CONTROL, 0x0E, 0x80); + cdcWriteReg(CDC_CONTROL, 0x0F, 0x80); + cdcWriteReg(CDC_CONTROL, 0x10, 0x08); + cdcWriteReg(CDC_CONTROL, 0x14, 0x80); + cdcWriteReg(CDC_CONTROL, 0x15, 0x80); + cdcWriteReg(CDC_CONTROL, 0x16, 0x04); + cdcWriteReg(CDC_CONTROL, 0x1A, 0x01); + cdcWriteReg(CDC_CONTROL, 0x1E, 0x01); + cdcWriteReg(CDC_CONTROL, 0x24, 0x80); + cdcWriteReg(CDC_CONTROL, 0x33, 0x34); + cdcWriteReg(CDC_CONTROL, 0x34, 0x32); + cdcWriteReg(CDC_CONTROL, 0x35, 0x12); + cdcWriteReg(CDC_CONTROL, 0x36, 0x03); + cdcWriteReg(CDC_CONTROL, 0x37, 0x02); + cdcWriteReg(CDC_CONTROL, 0x38, 0x03); + cdcWriteReg(CDC_CONTROL, 0x3C, 0x19); + cdcWriteReg(CDC_CONTROL, 0x3D, 0x05); + cdcWriteReg(CDC_CONTROL, 0x44, 0x0F); + cdcWriteReg(CDC_CONTROL, 0x45, 0x38); + cdcWriteReg(CDC_CONTROL, 0x49, 0x00); + cdcWriteReg(CDC_CONTROL, 0x4A, 0x00); + cdcWriteReg(CDC_CONTROL, 0x4B, 0xEE); + cdcWriteReg(CDC_CONTROL, 0x4C, 0x10); + cdcWriteReg(CDC_CONTROL, 0x4D, 0xD8); + cdcWriteReg(CDC_CONTROL, 0x4E, 0x7E); + cdcWriteReg(CDC_CONTROL, 0x4F, 0xE3); + cdcWriteReg(CDC_CONTROL, 0x58, 0x7F); + cdcWriteReg(CDC_CONTROL, 0x74, 0xD2); + cdcWriteReg(CDC_CONTROL, 0x75, 0x2C); + cdcWriteReg(CDC_SOUND, 0x22, 0x70); + cdcWriteReg(CDC_SOUND, 0x2C, 0x20); + } // Finish up! cdcReadReg (CDC_TOUCHCNT, 0x02); @@ -651,6 +656,10 @@ static void NDSTouchscreenMode(void) { } static void DSiTouchscreenMode(void) { + if (strncmp((const char*)0x04FFFA00, "no$gba", 6) != 0) { + return; + } + // Touchscreen cdcWriteReg(0, 0x01, 0x01); cdcWriteReg(0, 0x39, 0x66); @@ -1007,18 +1016,21 @@ void arm7_main (void) { my_readUserSettings(ndsHeader); // Header has to be loaded first if (my_isDSiMode()) { + *(vu16*)0x4004700 &= ~BIT(15); // Runs before sound frequency change + *(vu16*)0x4004700 = (soundFreq ? 0xC00F : 0x800F); + if (dsiModeConfirmed) { *(u32*)0x3FFFFC8 = 0x7884; // Fix sound pitch table for DSi mode (works with SDK5 binaries) if (ndsHeader->unitCode == 0 || (ndsHeader->unitCode > 0 && !(*(u8*)0x02FFE1BF & BIT(0)))) { twlTouch ? DSiTouchscreenMode() : NDSTouchscreenMode(); - *(u16*)0x4000500 = 0x807F; + *(vu16*)0x4000500 = 0x807F; } } else { REG_SCFG_ROM = 0x703; twlTouch ? DSiTouchscreenMode() : NDSTouchscreenMode(); - *(u16*)0x4000500 = 0x807F; + *(vu16*)0x4000500 = 0x807F; REG_GPIO_WIFI |= BIT(8); // Old NDS-Wifi mode diff --git a/slot1launch/bootloaderAlt/source/main.arm7.c b/slot1launch/bootloaderAlt/source/main.arm7.c index 2ef9aed208..60945cc042 100644 --- a/slot1launch/bootloaderAlt/source/main.arm7.c +++ b/slot1launch/bootloaderAlt/source/main.arm7.c @@ -321,146 +321,151 @@ static void NDSTouchscreenMode(void) { volLevel = 0xA7; //} + const bool noSgba = (strncmp((const char*)0x04FFFA00, "no$gba", 6) == 0); + // Touchscreen - cdcReadReg (0x63, 0x00); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); - cdcReadReg (CDC_CONTROL, 0x51); - cdcReadReg (CDC_TOUCHCNT, 0x02); - cdcReadReg (CDC_CONTROL, 0x3F); - cdcReadReg (CDC_SOUND, 0x28); - cdcReadReg (CDC_SOUND, 0x2A); - cdcReadReg (CDC_SOUND, 0x2E); - cdcWriteReg(CDC_CONTROL, 0x52, 0x80); - cdcWriteReg(CDC_CONTROL, 0x40, 0x0C); - cdcWriteReg(CDC_SOUND, 0x24, 0xFF); - cdcWriteReg(CDC_SOUND, 0x25, 0xFF); - cdcWriteReg(CDC_SOUND, 0x26, 0x7F); - cdcWriteReg(CDC_SOUND, 0x27, 0x7F); - cdcWriteReg(CDC_SOUND, 0x28, 0x4A); - cdcWriteReg(CDC_SOUND, 0x29, 0x4A); - cdcWriteReg(CDC_SOUND, 0x2A, 0x10); - cdcWriteReg(CDC_SOUND, 0x2B, 0x10); - cdcWriteReg(CDC_CONTROL, 0x51, 0x00); - cdcReadReg (CDC_TOUCHCNT, 0x02); - cdcWriteReg(CDC_TOUCHCNT, 0x02, 0x98); - cdcWriteReg(CDC_SOUND, 0x23, 0x00); - cdcWriteReg(CDC_SOUND, 0x1F, 0x14); - cdcWriteReg(CDC_SOUND, 0x20, 0x14); - cdcWriteReg(CDC_CONTROL, 0x3F, 0x00); - cdcReadReg (CDC_CONTROL, 0x0B); - cdcWriteReg(CDC_CONTROL, 0x05, 0x00); - cdcWriteReg(CDC_CONTROL, 0x0B, 0x01); - cdcWriteReg(CDC_CONTROL, 0x0C, 0x02); - cdcWriteReg(CDC_CONTROL, 0x12, 0x01); - cdcWriteReg(CDC_CONTROL, 0x13, 0x02); - cdcWriteReg(CDC_SOUND, 0x2E, 0x00); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); - cdcWriteReg(CDC_CONTROL, 0x01, 0x01); - cdcWriteReg(CDC_CONTROL, 0x39, 0x66); - cdcReadReg (CDC_SOUND, 0x20); - cdcWriteReg(CDC_SOUND, 0x20, 0x10); - cdcWriteReg(CDC_CONTROL, 0x04, 0x00); - cdcWriteReg(CDC_CONTROL, 0x12, 0x81); - cdcWriteReg(CDC_CONTROL, 0x13, 0x82); - cdcWriteReg(CDC_CONTROL, 0x51, 0x82); - cdcWriteReg(CDC_CONTROL, 0x51, 0x00); - cdcWriteReg(CDC_CONTROL, 0x04, 0x03); - cdcWriteReg(CDC_CONTROL, 0x05, 0xA1); - cdcWriteReg(CDC_CONTROL, 0x06, 0x15); - cdcWriteReg(CDC_CONTROL, 0x0B, 0x87); - cdcWriteReg(CDC_CONTROL, 0x0C, 0x83); - cdcWriteReg(CDC_CONTROL, 0x12, 0x87); - cdcWriteReg(CDC_CONTROL, 0x13, 0x83); - cdcReadReg (CDC_TOUCHCNT, 0x10); - cdcWriteReg(CDC_TOUCHCNT, 0x10, 0x08); - cdcWriteReg(0x04, 0x08, 0x7F); - cdcWriteReg(0x04, 0x09, 0xE1); - cdcWriteReg(0x04, 0x0A, 0x80); - cdcWriteReg(0x04, 0x0B, 0x1F); - cdcWriteReg(0x04, 0x0C, 0x7F); - cdcWriteReg(0x04, 0x0D, 0xC1); - cdcWriteReg(CDC_CONTROL, 0x41, 0x08); - cdcWriteReg(CDC_CONTROL, 0x42, 0x08); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); - cdcWriteReg(0x04, 0x08, 0x7F); - cdcWriteReg(0x04, 0x09, 0xE1); - cdcWriteReg(0x04, 0x0A, 0x80); - cdcWriteReg(0x04, 0x0B, 0x1F); - cdcWriteReg(0x04, 0x0C, 0x7F); - cdcWriteReg(0x04, 0x0D, 0xC1); - cdcWriteReg(CDC_SOUND, 0x2F, 0x2B); - cdcWriteReg(CDC_SOUND, 0x30, 0x40); - cdcWriteReg(CDC_SOUND, 0x31, 0x40); - cdcWriteReg(CDC_SOUND, 0x32, 0x60); - cdcReadReg (CDC_CONTROL, 0x74); - cdcWriteReg(CDC_CONTROL, 0x74, 0x02); - cdcReadReg (CDC_CONTROL, 0x74); - cdcWriteReg(CDC_CONTROL, 0x74, 0x10); - cdcReadReg (CDC_CONTROL, 0x74); - cdcWriteReg(CDC_CONTROL, 0x74, 0x40); - cdcWriteReg(CDC_SOUND, 0x21, 0x20); - cdcWriteReg(CDC_SOUND, 0x22, 0xF0); - cdcReadReg (CDC_CONTROL, 0x51); - cdcReadReg (CDC_CONTROL, 0x3F); - cdcWriteReg(CDC_CONTROL, 0x3F, 0xD4); - cdcWriteReg(CDC_SOUND, 0x23, 0x44); - cdcWriteReg(CDC_SOUND, 0x1F, 0xD4); - cdcWriteReg(CDC_SOUND, 0x28, 0x4E); - cdcWriteReg(CDC_SOUND, 0x29, 0x4E); - cdcWriteReg(CDC_SOUND, 0x24, 0x9E); - cdcWriteReg(CDC_SOUND, 0x25, 0x9E); - cdcWriteReg(CDC_SOUND, 0x20, 0xD4); - cdcWriteReg(CDC_SOUND, 0x2A, 0x14); - cdcWriteReg(CDC_SOUND, 0x2B, 0x14); - cdcWriteReg(CDC_SOUND, 0x26, 0xA7); - cdcWriteReg(CDC_SOUND, 0x27, 0xA7); - cdcWriteReg(CDC_CONTROL, 0x40, 0x00); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); + if (noSgba) { + cdcReadReg (0x63, 0x00); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); + cdcReadReg (CDC_CONTROL, 0x51); + cdcReadReg (CDC_TOUCHCNT, 0x02); + cdcReadReg (CDC_CONTROL, 0x3F); + cdcReadReg (CDC_SOUND, 0x28); + cdcReadReg (CDC_SOUND, 0x2A); + cdcReadReg (CDC_SOUND, 0x2E); + cdcWriteReg(CDC_CONTROL, 0x52, 0x80); + cdcWriteReg(CDC_CONTROL, 0x40, 0x0C); + cdcWriteReg(CDC_SOUND, 0x24, 0xFF); + cdcWriteReg(CDC_SOUND, 0x25, 0xFF); + cdcWriteReg(CDC_SOUND, 0x26, 0x7F); + cdcWriteReg(CDC_SOUND, 0x27, 0x7F); + cdcWriteReg(CDC_SOUND, 0x28, 0x4A); + cdcWriteReg(CDC_SOUND, 0x29, 0x4A); + cdcWriteReg(CDC_SOUND, 0x2A, 0x10); + cdcWriteReg(CDC_SOUND, 0x2B, 0x10); + cdcWriteReg(CDC_CONTROL, 0x51, 0x00); + cdcReadReg (CDC_TOUCHCNT, 0x02); + cdcWriteReg(CDC_TOUCHCNT, 0x02, 0x98); + cdcWriteReg(CDC_SOUND, 0x23, 0x00); + cdcWriteReg(CDC_SOUND, 0x1F, 0x14); + cdcWriteReg(CDC_SOUND, 0x20, 0x14); + cdcWriteReg(CDC_CONTROL, 0x3F, 0x00); + cdcReadReg (CDC_CONTROL, 0x0B); + cdcWriteReg(CDC_CONTROL, 0x05, 0x00); + cdcWriteReg(CDC_CONTROL, 0x0B, 0x01); + cdcWriteReg(CDC_CONTROL, 0x0C, 0x02); + cdcWriteReg(CDC_CONTROL, 0x12, 0x01); + cdcWriteReg(CDC_CONTROL, 0x13, 0x02); + cdcWriteReg(CDC_SOUND, 0x2E, 0x00); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); + cdcWriteReg(CDC_CONTROL, 0x01, 0x01); + cdcWriteReg(CDC_CONTROL, 0x39, 0x66); + cdcReadReg (CDC_SOUND, 0x20); + cdcWriteReg(CDC_SOUND, 0x20, 0x10); + cdcWriteReg(CDC_CONTROL, 0x04, 0x00); + cdcWriteReg(CDC_CONTROL, 0x12, 0x81); + cdcWriteReg(CDC_CONTROL, 0x13, 0x82); + cdcWriteReg(CDC_CONTROL, 0x51, 0x82); + cdcWriteReg(CDC_CONTROL, 0x51, 0x00); + cdcWriteReg(CDC_CONTROL, 0x04, 0x03); + cdcWriteReg(CDC_CONTROL, 0x05, 0xA1); + cdcWriteReg(CDC_CONTROL, 0x06, 0x15); + cdcWriteReg(CDC_CONTROL, 0x0B, 0x87); + cdcWriteReg(CDC_CONTROL, 0x0C, 0x83); + cdcWriteReg(CDC_CONTROL, 0x12, 0x87); + cdcWriteReg(CDC_CONTROL, 0x13, 0x83); + cdcReadReg (CDC_TOUCHCNT, 0x10); + cdcWriteReg(CDC_TOUCHCNT, 0x10, 0x08); + cdcWriteReg(0x04, 0x08, 0x7F); + cdcWriteReg(0x04, 0x09, 0xE1); + cdcWriteReg(0x04, 0x0A, 0x80); + cdcWriteReg(0x04, 0x0B, 0x1F); + cdcWriteReg(0x04, 0x0C, 0x7F); + cdcWriteReg(0x04, 0x0D, 0xC1); + cdcWriteReg(CDC_CONTROL, 0x41, 0x08); + cdcWriteReg(CDC_CONTROL, 0x42, 0x08); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); + cdcWriteReg(0x04, 0x08, 0x7F); + cdcWriteReg(0x04, 0x09, 0xE1); + cdcWriteReg(0x04, 0x0A, 0x80); + cdcWriteReg(0x04, 0x0B, 0x1F); + cdcWriteReg(0x04, 0x0C, 0x7F); + cdcWriteReg(0x04, 0x0D, 0xC1); + cdcWriteReg(CDC_SOUND, 0x2F, 0x2B); + cdcWriteReg(CDC_SOUND, 0x30, 0x40); + cdcWriteReg(CDC_SOUND, 0x31, 0x40); + cdcWriteReg(CDC_SOUND, 0x32, 0x60); + cdcReadReg (CDC_CONTROL, 0x74); + cdcWriteReg(CDC_CONTROL, 0x74, 0x02); + cdcReadReg (CDC_CONTROL, 0x74); + cdcWriteReg(CDC_CONTROL, 0x74, 0x10); + cdcReadReg (CDC_CONTROL, 0x74); + cdcWriteReg(CDC_CONTROL, 0x74, 0x40); + cdcWriteReg(CDC_SOUND, 0x21, 0x20); + cdcWriteReg(CDC_SOUND, 0x22, 0xF0); + cdcReadReg (CDC_CONTROL, 0x51); + cdcReadReg (CDC_CONTROL, 0x3F); + cdcWriteReg(CDC_CONTROL, 0x3F, 0xD4); + cdcWriteReg(CDC_SOUND, 0x23, 0x44); + cdcWriteReg(CDC_SOUND, 0x1F, 0xD4); + cdcWriteReg(CDC_SOUND, 0x28, 0x4E); + cdcWriteReg(CDC_SOUND, 0x29, 0x4E); + cdcWriteReg(CDC_SOUND, 0x24, 0x9E); + cdcWriteReg(CDC_SOUND, 0x25, 0x9E); + cdcWriteReg(CDC_SOUND, 0x20, 0xD4); + cdcWriteReg(CDC_SOUND, 0x2A, 0x14); + cdcWriteReg(CDC_SOUND, 0x2B, 0x14); + cdcWriteReg(CDC_SOUND, 0x26, 0xA7); + cdcWriteReg(CDC_SOUND, 0x27, 0xA7); + cdcWriteReg(CDC_CONTROL, 0x40, 0x00); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); + } cdcWriteReg(CDC_SOUND, 0x26, volLevel); cdcWriteReg(CDC_SOUND, 0x27, volLevel); cdcWriteReg(CDC_SOUND, 0x2E, 0x03); cdcWriteReg(CDC_TOUCHCNT, 0x03, 0x00); cdcWriteReg(CDC_SOUND, 0x21, 0x20); cdcWriteReg(CDC_SOUND, 0x22, 0xF0); - cdcReadReg (CDC_SOUND, 0x22); - cdcWriteReg(CDC_SOUND, 0x22, 0x00); + cdcWriteReg(CDC_SOUND, 0x22, 0x70); cdcWriteReg(CDC_CONTROL, 0x52, 0x80); cdcWriteReg(CDC_CONTROL, 0x51, 0x00); - - // Set remaining values - cdcWriteReg(CDC_CONTROL, 0x03, 0x44); - cdcWriteReg(CDC_CONTROL, 0x0D, 0x00); - cdcWriteReg(CDC_CONTROL, 0x0E, 0x80); - cdcWriteReg(CDC_CONTROL, 0x0F, 0x80); - cdcWriteReg(CDC_CONTROL, 0x10, 0x08); - cdcWriteReg(CDC_CONTROL, 0x14, 0x80); - cdcWriteReg(CDC_CONTROL, 0x15, 0x80); - cdcWriteReg(CDC_CONTROL, 0x16, 0x04); - cdcWriteReg(CDC_CONTROL, 0x1A, 0x01); - cdcWriteReg(CDC_CONTROL, 0x1E, 0x01); - cdcWriteReg(CDC_CONTROL, 0x24, 0x80); - cdcWriteReg(CDC_CONTROL, 0x33, 0x34); - cdcWriteReg(CDC_CONTROL, 0x34, 0x32); - cdcWriteReg(CDC_CONTROL, 0x35, 0x12); - cdcWriteReg(CDC_CONTROL, 0x36, 0x03); - cdcWriteReg(CDC_CONTROL, 0x37, 0x02); - cdcWriteReg(CDC_CONTROL, 0x38, 0x03); - cdcWriteReg(CDC_CONTROL, 0x3C, 0x19); - cdcWriteReg(CDC_CONTROL, 0x3D, 0x05); - cdcWriteReg(CDC_CONTROL, 0x44, 0x0F); - cdcWriteReg(CDC_CONTROL, 0x45, 0x38); - cdcWriteReg(CDC_CONTROL, 0x49, 0x00); - cdcWriteReg(CDC_CONTROL, 0x4A, 0x00); - cdcWriteReg(CDC_CONTROL, 0x4B, 0xEE); - cdcWriteReg(CDC_CONTROL, 0x4C, 0x10); - cdcWriteReg(CDC_CONTROL, 0x4D, 0xD8); - cdcWriteReg(CDC_CONTROL, 0x4E, 0x7E); - cdcWriteReg(CDC_CONTROL, 0x4F, 0xE3); - cdcWriteReg(CDC_CONTROL, 0x58, 0x7F); - cdcWriteReg(CDC_CONTROL, 0x74, 0xD2); - cdcWriteReg(CDC_CONTROL, 0x75, 0x2C); - cdcWriteReg(CDC_SOUND, 0x22, 0x70); - cdcWriteReg(CDC_SOUND, 0x2C, 0x20); + + if (noSgba) { + // Set remaining values + cdcWriteReg(CDC_CONTROL, 0x03, 0x44); + cdcWriteReg(CDC_CONTROL, 0x0D, 0x00); + cdcWriteReg(CDC_CONTROL, 0x0E, 0x80); + cdcWriteReg(CDC_CONTROL, 0x0F, 0x80); + cdcWriteReg(CDC_CONTROL, 0x10, 0x08); + cdcWriteReg(CDC_CONTROL, 0x14, 0x80); + cdcWriteReg(CDC_CONTROL, 0x15, 0x80); + cdcWriteReg(CDC_CONTROL, 0x16, 0x04); + cdcWriteReg(CDC_CONTROL, 0x1A, 0x01); + cdcWriteReg(CDC_CONTROL, 0x1E, 0x01); + cdcWriteReg(CDC_CONTROL, 0x24, 0x80); + cdcWriteReg(CDC_CONTROL, 0x33, 0x34); + cdcWriteReg(CDC_CONTROL, 0x34, 0x32); + cdcWriteReg(CDC_CONTROL, 0x35, 0x12); + cdcWriteReg(CDC_CONTROL, 0x36, 0x03); + cdcWriteReg(CDC_CONTROL, 0x37, 0x02); + cdcWriteReg(CDC_CONTROL, 0x38, 0x03); + cdcWriteReg(CDC_CONTROL, 0x3C, 0x19); + cdcWriteReg(CDC_CONTROL, 0x3D, 0x05); + cdcWriteReg(CDC_CONTROL, 0x44, 0x0F); + cdcWriteReg(CDC_CONTROL, 0x45, 0x38); + cdcWriteReg(CDC_CONTROL, 0x49, 0x00); + cdcWriteReg(CDC_CONTROL, 0x4A, 0x00); + cdcWriteReg(CDC_CONTROL, 0x4B, 0xEE); + cdcWriteReg(CDC_CONTROL, 0x4C, 0x10); + cdcWriteReg(CDC_CONTROL, 0x4D, 0xD8); + cdcWriteReg(CDC_CONTROL, 0x4E, 0x7E); + cdcWriteReg(CDC_CONTROL, 0x4F, 0xE3); + cdcWriteReg(CDC_CONTROL, 0x58, 0x7F); + cdcWriteReg(CDC_CONTROL, 0x74, 0xD2); + cdcWriteReg(CDC_CONTROL, 0x75, 0x2C); + cdcWriteReg(CDC_SOUND, 0x22, 0x70); + cdcWriteReg(CDC_SOUND, 0x2C, 0x20); + } // Finish up! cdcReadReg (CDC_TOUCHCNT, 0x02); @@ -473,6 +478,10 @@ static void NDSTouchscreenMode(void) { } static void DSiTouchscreenMode(void) { + if (strncmp((const char*)0x04FFFA00, "no$gba", 6) != 0) { + return; + } + // Touchscreen cdcWriteReg(0, 0x01, 0x01); cdcWriteReg(0, 0x39, 0x66); @@ -714,8 +723,11 @@ void arm7_main (void) { } if (my_isDSiMode()) { + *(vu16*)0x4004700 &= ~BIT(15); // Runs before sound frequency change + *(vu16*)0x4004700 = (soundFreq ? 0xC00F : 0x800F); + twlTouch ? DSiTouchscreenMode() : NDSTouchscreenMode(); - *(u16*)0x4000500 = 0x807F; + *(vu16*)0x4000500 = 0x807F; REG_GPIO_WIFI |= BIT(8); // Old NDS-Wifi mode } diff --git a/title/bootloader/source/boot.c b/title/bootloader/source/boot.c index bf1c071f4d..147b5cc87c 100644 --- a/title/bootloader/source/boot.c +++ b/title/bootloader/source/boot.c @@ -395,146 +395,151 @@ static void NDSTouchscreenMode(void) { volLevel = 0xA7; //} + const bool noSgba = (strncmp((const char*)0x04FFFA00, "no$gba", 6) == 0); + // Touchscreen - cdcReadReg (0x63, 0x00); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); - cdcReadReg (CDC_CONTROL, 0x51); - cdcReadReg (CDC_TOUCHCNT, 0x02); - cdcReadReg (CDC_CONTROL, 0x3F); - cdcReadReg (CDC_SOUND, 0x28); - cdcReadReg (CDC_SOUND, 0x2A); - cdcReadReg (CDC_SOUND, 0x2E); - cdcWriteReg(CDC_CONTROL, 0x52, 0x80); - cdcWriteReg(CDC_CONTROL, 0x40, 0x0C); - cdcWriteReg(CDC_SOUND, 0x24, 0xFF); - cdcWriteReg(CDC_SOUND, 0x25, 0xFF); - cdcWriteReg(CDC_SOUND, 0x26, 0x7F); - cdcWriteReg(CDC_SOUND, 0x27, 0x7F); - cdcWriteReg(CDC_SOUND, 0x28, 0x4A); - cdcWriteReg(CDC_SOUND, 0x29, 0x4A); - cdcWriteReg(CDC_SOUND, 0x2A, 0x10); - cdcWriteReg(CDC_SOUND, 0x2B, 0x10); - cdcWriteReg(CDC_CONTROL, 0x51, 0x00); - cdcReadReg (CDC_TOUCHCNT, 0x02); - cdcWriteReg(CDC_TOUCHCNT, 0x02, 0x98); - cdcWriteReg(CDC_SOUND, 0x23, 0x00); - cdcWriteReg(CDC_SOUND, 0x1F, 0x14); - cdcWriteReg(CDC_SOUND, 0x20, 0x14); - cdcWriteReg(CDC_CONTROL, 0x3F, 0x00); - cdcReadReg (CDC_CONTROL, 0x0B); - cdcWriteReg(CDC_CONTROL, 0x05, 0x00); - cdcWriteReg(CDC_CONTROL, 0x0B, 0x01); - cdcWriteReg(CDC_CONTROL, 0x0C, 0x02); - cdcWriteReg(CDC_CONTROL, 0x12, 0x01); - cdcWriteReg(CDC_CONTROL, 0x13, 0x02); - cdcWriteReg(CDC_SOUND, 0x2E, 0x00); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); - cdcWriteReg(CDC_CONTROL, 0x01, 0x01); - cdcWriteReg(CDC_CONTROL, 0x39, 0x66); - cdcReadReg (CDC_SOUND, 0x20); - cdcWriteReg(CDC_SOUND, 0x20, 0x10); - cdcWriteReg(CDC_CONTROL, 0x04, 0x00); - cdcWriteReg(CDC_CONTROL, 0x12, 0x81); - cdcWriteReg(CDC_CONTROL, 0x13, 0x82); - cdcWriteReg(CDC_CONTROL, 0x51, 0x82); - cdcWriteReg(CDC_CONTROL, 0x51, 0x00); - cdcWriteReg(CDC_CONTROL, 0x04, 0x03); - cdcWriteReg(CDC_CONTROL, 0x05, 0xA1); - cdcWriteReg(CDC_CONTROL, 0x06, 0x15); - cdcWriteReg(CDC_CONTROL, 0x0B, 0x87); - cdcWriteReg(CDC_CONTROL, 0x0C, 0x83); - cdcWriteReg(CDC_CONTROL, 0x12, 0x87); - cdcWriteReg(CDC_CONTROL, 0x13, 0x83); - cdcReadReg (CDC_TOUCHCNT, 0x10); - cdcWriteReg(CDC_TOUCHCNT, 0x10, 0x08); - cdcWriteReg(0x04, 0x08, 0x7F); - cdcWriteReg(0x04, 0x09, 0xE1); - cdcWriteReg(0x04, 0x0A, 0x80); - cdcWriteReg(0x04, 0x0B, 0x1F); - cdcWriteReg(0x04, 0x0C, 0x7F); - cdcWriteReg(0x04, 0x0D, 0xC1); - cdcWriteReg(CDC_CONTROL, 0x41, 0x08); - cdcWriteReg(CDC_CONTROL, 0x42, 0x08); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); - cdcWriteReg(0x04, 0x08, 0x7F); - cdcWriteReg(0x04, 0x09, 0xE1); - cdcWriteReg(0x04, 0x0A, 0x80); - cdcWriteReg(0x04, 0x0B, 0x1F); - cdcWriteReg(0x04, 0x0C, 0x7F); - cdcWriteReg(0x04, 0x0D, 0xC1); - cdcWriteReg(CDC_SOUND, 0x2F, 0x2B); - cdcWriteReg(CDC_SOUND, 0x30, 0x40); - cdcWriteReg(CDC_SOUND, 0x31, 0x40); - cdcWriteReg(CDC_SOUND, 0x32, 0x60); - cdcReadReg (CDC_CONTROL, 0x74); - cdcWriteReg(CDC_CONTROL, 0x74, 0x02); - cdcReadReg (CDC_CONTROL, 0x74); - cdcWriteReg(CDC_CONTROL, 0x74, 0x10); - cdcReadReg (CDC_CONTROL, 0x74); - cdcWriteReg(CDC_CONTROL, 0x74, 0x40); - cdcWriteReg(CDC_SOUND, 0x21, 0x20); - cdcWriteReg(CDC_SOUND, 0x22, 0xF0); - cdcReadReg (CDC_CONTROL, 0x51); - cdcReadReg (CDC_CONTROL, 0x3F); - cdcWriteReg(CDC_CONTROL, 0x3F, 0xD4); - cdcWriteReg(CDC_SOUND, 0x23, 0x44); - cdcWriteReg(CDC_SOUND, 0x1F, 0xD4); - cdcWriteReg(CDC_SOUND, 0x28, 0x4E); - cdcWriteReg(CDC_SOUND, 0x29, 0x4E); - cdcWriteReg(CDC_SOUND, 0x24, 0x9E); - cdcWriteReg(CDC_SOUND, 0x25, 0x9E); - cdcWriteReg(CDC_SOUND, 0x20, 0xD4); - cdcWriteReg(CDC_SOUND, 0x2A, 0x14); - cdcWriteReg(CDC_SOUND, 0x2B, 0x14); - cdcWriteReg(CDC_SOUND, 0x26, 0xA7); - cdcWriteReg(CDC_SOUND, 0x27, 0xA7); - cdcWriteReg(CDC_CONTROL, 0x40, 0x00); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); + if (noSgba) { + cdcReadReg (0x63, 0x00); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); + cdcReadReg (CDC_CONTROL, 0x51); + cdcReadReg (CDC_TOUCHCNT, 0x02); + cdcReadReg (CDC_CONTROL, 0x3F); + cdcReadReg (CDC_SOUND, 0x28); + cdcReadReg (CDC_SOUND, 0x2A); + cdcReadReg (CDC_SOUND, 0x2E); + cdcWriteReg(CDC_CONTROL, 0x52, 0x80); + cdcWriteReg(CDC_CONTROL, 0x40, 0x0C); + cdcWriteReg(CDC_SOUND, 0x24, 0xFF); + cdcWriteReg(CDC_SOUND, 0x25, 0xFF); + cdcWriteReg(CDC_SOUND, 0x26, 0x7F); + cdcWriteReg(CDC_SOUND, 0x27, 0x7F); + cdcWriteReg(CDC_SOUND, 0x28, 0x4A); + cdcWriteReg(CDC_SOUND, 0x29, 0x4A); + cdcWriteReg(CDC_SOUND, 0x2A, 0x10); + cdcWriteReg(CDC_SOUND, 0x2B, 0x10); + cdcWriteReg(CDC_CONTROL, 0x51, 0x00); + cdcReadReg (CDC_TOUCHCNT, 0x02); + cdcWriteReg(CDC_TOUCHCNT, 0x02, 0x98); + cdcWriteReg(CDC_SOUND, 0x23, 0x00); + cdcWriteReg(CDC_SOUND, 0x1F, 0x14); + cdcWriteReg(CDC_SOUND, 0x20, 0x14); + cdcWriteReg(CDC_CONTROL, 0x3F, 0x00); + cdcReadReg (CDC_CONTROL, 0x0B); + cdcWriteReg(CDC_CONTROL, 0x05, 0x00); + cdcWriteReg(CDC_CONTROL, 0x0B, 0x01); + cdcWriteReg(CDC_CONTROL, 0x0C, 0x02); + cdcWriteReg(CDC_CONTROL, 0x12, 0x01); + cdcWriteReg(CDC_CONTROL, 0x13, 0x02); + cdcWriteReg(CDC_SOUND, 0x2E, 0x00); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); + cdcWriteReg(CDC_CONTROL, 0x01, 0x01); + cdcWriteReg(CDC_CONTROL, 0x39, 0x66); + cdcReadReg (CDC_SOUND, 0x20); + cdcWriteReg(CDC_SOUND, 0x20, 0x10); + cdcWriteReg(CDC_CONTROL, 0x04, 0x00); + cdcWriteReg(CDC_CONTROL, 0x12, 0x81); + cdcWriteReg(CDC_CONTROL, 0x13, 0x82); + cdcWriteReg(CDC_CONTROL, 0x51, 0x82); + cdcWriteReg(CDC_CONTROL, 0x51, 0x00); + cdcWriteReg(CDC_CONTROL, 0x04, 0x03); + cdcWriteReg(CDC_CONTROL, 0x05, 0xA1); + cdcWriteReg(CDC_CONTROL, 0x06, 0x15); + cdcWriteReg(CDC_CONTROL, 0x0B, 0x87); + cdcWriteReg(CDC_CONTROL, 0x0C, 0x83); + cdcWriteReg(CDC_CONTROL, 0x12, 0x87); + cdcWriteReg(CDC_CONTROL, 0x13, 0x83); + cdcReadReg (CDC_TOUCHCNT, 0x10); + cdcWriteReg(CDC_TOUCHCNT, 0x10, 0x08); + cdcWriteReg(0x04, 0x08, 0x7F); + cdcWriteReg(0x04, 0x09, 0xE1); + cdcWriteReg(0x04, 0x0A, 0x80); + cdcWriteReg(0x04, 0x0B, 0x1F); + cdcWriteReg(0x04, 0x0C, 0x7F); + cdcWriteReg(0x04, 0x0D, 0xC1); + cdcWriteReg(CDC_CONTROL, 0x41, 0x08); + cdcWriteReg(CDC_CONTROL, 0x42, 0x08); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); + cdcWriteReg(0x04, 0x08, 0x7F); + cdcWriteReg(0x04, 0x09, 0xE1); + cdcWriteReg(0x04, 0x0A, 0x80); + cdcWriteReg(0x04, 0x0B, 0x1F); + cdcWriteReg(0x04, 0x0C, 0x7F); + cdcWriteReg(0x04, 0x0D, 0xC1); + cdcWriteReg(CDC_SOUND, 0x2F, 0x2B); + cdcWriteReg(CDC_SOUND, 0x30, 0x40); + cdcWriteReg(CDC_SOUND, 0x31, 0x40); + cdcWriteReg(CDC_SOUND, 0x32, 0x60); + cdcReadReg (CDC_CONTROL, 0x74); + cdcWriteReg(CDC_CONTROL, 0x74, 0x02); + cdcReadReg (CDC_CONTROL, 0x74); + cdcWriteReg(CDC_CONTROL, 0x74, 0x10); + cdcReadReg (CDC_CONTROL, 0x74); + cdcWriteReg(CDC_CONTROL, 0x74, 0x40); + cdcWriteReg(CDC_SOUND, 0x21, 0x20); + cdcWriteReg(CDC_SOUND, 0x22, 0xF0); + cdcReadReg (CDC_CONTROL, 0x51); + cdcReadReg (CDC_CONTROL, 0x3F); + cdcWriteReg(CDC_CONTROL, 0x3F, 0xD4); + cdcWriteReg(CDC_SOUND, 0x23, 0x44); + cdcWriteReg(CDC_SOUND, 0x1F, 0xD4); + cdcWriteReg(CDC_SOUND, 0x28, 0x4E); + cdcWriteReg(CDC_SOUND, 0x29, 0x4E); + cdcWriteReg(CDC_SOUND, 0x24, 0x9E); + cdcWriteReg(CDC_SOUND, 0x25, 0x9E); + cdcWriteReg(CDC_SOUND, 0x20, 0xD4); + cdcWriteReg(CDC_SOUND, 0x2A, 0x14); + cdcWriteReg(CDC_SOUND, 0x2B, 0x14); + cdcWriteReg(CDC_SOUND, 0x26, 0xA7); + cdcWriteReg(CDC_SOUND, 0x27, 0xA7); + cdcWriteReg(CDC_CONTROL, 0x40, 0x00); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); + } cdcWriteReg(CDC_SOUND, 0x26, volLevel); cdcWriteReg(CDC_SOUND, 0x27, volLevel); cdcWriteReg(CDC_SOUND, 0x2E, 0x03); cdcWriteReg(CDC_TOUCHCNT, 0x03, 0x00); cdcWriteReg(CDC_SOUND, 0x21, 0x20); cdcWriteReg(CDC_SOUND, 0x22, 0xF0); - cdcReadReg (CDC_SOUND, 0x22); - cdcWriteReg(CDC_SOUND, 0x22, 0x00); + cdcWriteReg(CDC_SOUND, 0x22, 0x70); cdcWriteReg(CDC_CONTROL, 0x52, 0x80); cdcWriteReg(CDC_CONTROL, 0x51, 0x00); - - // Set remaining values - cdcWriteReg(CDC_CONTROL, 0x03, 0x44); - cdcWriteReg(CDC_CONTROL, 0x0D, 0x00); - cdcWriteReg(CDC_CONTROL, 0x0E, 0x80); - cdcWriteReg(CDC_CONTROL, 0x0F, 0x80); - cdcWriteReg(CDC_CONTROL, 0x10, 0x08); - cdcWriteReg(CDC_CONTROL, 0x14, 0x80); - cdcWriteReg(CDC_CONTROL, 0x15, 0x80); - cdcWriteReg(CDC_CONTROL, 0x16, 0x04); - cdcWriteReg(CDC_CONTROL, 0x1A, 0x01); - cdcWriteReg(CDC_CONTROL, 0x1E, 0x01); - cdcWriteReg(CDC_CONTROL, 0x24, 0x80); - cdcWriteReg(CDC_CONTROL, 0x33, 0x34); - cdcWriteReg(CDC_CONTROL, 0x34, 0x32); - cdcWriteReg(CDC_CONTROL, 0x35, 0x12); - cdcWriteReg(CDC_CONTROL, 0x36, 0x03); - cdcWriteReg(CDC_CONTROL, 0x37, 0x02); - cdcWriteReg(CDC_CONTROL, 0x38, 0x03); - cdcWriteReg(CDC_CONTROL, 0x3C, 0x19); - cdcWriteReg(CDC_CONTROL, 0x3D, 0x05); - cdcWriteReg(CDC_CONTROL, 0x44, 0x0F); - cdcWriteReg(CDC_CONTROL, 0x45, 0x38); - cdcWriteReg(CDC_CONTROL, 0x49, 0x00); - cdcWriteReg(CDC_CONTROL, 0x4A, 0x00); - cdcWriteReg(CDC_CONTROL, 0x4B, 0xEE); - cdcWriteReg(CDC_CONTROL, 0x4C, 0x10); - cdcWriteReg(CDC_CONTROL, 0x4D, 0xD8); - cdcWriteReg(CDC_CONTROL, 0x4E, 0x7E); - cdcWriteReg(CDC_CONTROL, 0x4F, 0xE3); - cdcWriteReg(CDC_CONTROL, 0x58, 0x7F); - cdcWriteReg(CDC_CONTROL, 0x74, 0xD2); - cdcWriteReg(CDC_CONTROL, 0x75, 0x2C); - cdcWriteReg(CDC_SOUND, 0x22, 0x70); - cdcWriteReg(CDC_SOUND, 0x2C, 0x20); + + if (noSgba) { + // Set remaining values + cdcWriteReg(CDC_CONTROL, 0x03, 0x44); + cdcWriteReg(CDC_CONTROL, 0x0D, 0x00); + cdcWriteReg(CDC_CONTROL, 0x0E, 0x80); + cdcWriteReg(CDC_CONTROL, 0x0F, 0x80); + cdcWriteReg(CDC_CONTROL, 0x10, 0x08); + cdcWriteReg(CDC_CONTROL, 0x14, 0x80); + cdcWriteReg(CDC_CONTROL, 0x15, 0x80); + cdcWriteReg(CDC_CONTROL, 0x16, 0x04); + cdcWriteReg(CDC_CONTROL, 0x1A, 0x01); + cdcWriteReg(CDC_CONTROL, 0x1E, 0x01); + cdcWriteReg(CDC_CONTROL, 0x24, 0x80); + cdcWriteReg(CDC_CONTROL, 0x33, 0x34); + cdcWriteReg(CDC_CONTROL, 0x34, 0x32); + cdcWriteReg(CDC_CONTROL, 0x35, 0x12); + cdcWriteReg(CDC_CONTROL, 0x36, 0x03); + cdcWriteReg(CDC_CONTROL, 0x37, 0x02); + cdcWriteReg(CDC_CONTROL, 0x38, 0x03); + cdcWriteReg(CDC_CONTROL, 0x3C, 0x19); + cdcWriteReg(CDC_CONTROL, 0x3D, 0x05); + cdcWriteReg(CDC_CONTROL, 0x44, 0x0F); + cdcWriteReg(CDC_CONTROL, 0x45, 0x38); + cdcWriteReg(CDC_CONTROL, 0x49, 0x00); + cdcWriteReg(CDC_CONTROL, 0x4A, 0x00); + cdcWriteReg(CDC_CONTROL, 0x4B, 0xEE); + cdcWriteReg(CDC_CONTROL, 0x4C, 0x10); + cdcWriteReg(CDC_CONTROL, 0x4D, 0xD8); + cdcWriteReg(CDC_CONTROL, 0x4E, 0x7E); + cdcWriteReg(CDC_CONTROL, 0x4F, 0xE3); + cdcWriteReg(CDC_CONTROL, 0x58, 0x7F); + cdcWriteReg(CDC_CONTROL, 0x74, 0xD2); + cdcWriteReg(CDC_CONTROL, 0x75, 0x2C); + cdcWriteReg(CDC_SOUND, 0x22, 0x70); + cdcWriteReg(CDC_SOUND, 0x2C, 0x20); + } // Finish up! cdcReadReg (CDC_TOUCHCNT, 0x02); @@ -709,7 +714,7 @@ int main (void) { if ((dsiMode && ((ARM9_SRC==0x4000 && !(dsiFlags & BIT(0))) || dsMode || tscTgds)) || (!dsiMode && REG_SCFG_EXT != 0 && memcmp(ndsHeaderTitle, "TWLMENUPP", 9) != 0 && memcmp(ndsHeaderTitle, "NDSBOOTSTRAP", 12) != 0)) { NDSTouchscreenMode(); - *(u16*)0x4000500 = 0x807F; + *(vu16*)0x4000500 = 0x807F; if (dsMode) REG_GPIO_WIFI |= BIT(8); // Old NDS-Wifi mode i2cWriteRegister(I2C_PM, I2CREGPM_MMCPWR, 0); // Press power button for auto-reset i2cWriteRegister(I2C_PM, I2CREGPM_RESETFLAG, 1); // Bootflag = Warmboot/SkipHealthSafety diff --git a/universal/bootloader_menu/source/boot.c b/universal/bootloader_menu/source/boot.c index 29d887f0a4..427a15f6f5 100644 --- a/universal/bootloader_menu/source/boot.c +++ b/universal/bootloader_menu/source/boot.c @@ -396,146 +396,151 @@ static void NDSTouchscreenMode(void) { volLevel = 0xA7; //} + const bool noSgba = (strncmp((const char*)0x04FFFA00, "no$gba", 6) == 0); + // Touchscreen - cdcReadReg (0x63, 0x00); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); - cdcReadReg (CDC_CONTROL, 0x51); - cdcReadReg (CDC_TOUCHCNT, 0x02); - cdcReadReg (CDC_CONTROL, 0x3F); - cdcReadReg (CDC_SOUND, 0x28); - cdcReadReg (CDC_SOUND, 0x2A); - cdcReadReg (CDC_SOUND, 0x2E); - cdcWriteReg(CDC_CONTROL, 0x52, 0x80); - cdcWriteReg(CDC_CONTROL, 0x40, 0x0C); - cdcWriteReg(CDC_SOUND, 0x24, 0xFF); - cdcWriteReg(CDC_SOUND, 0x25, 0xFF); - cdcWriteReg(CDC_SOUND, 0x26, 0x7F); - cdcWriteReg(CDC_SOUND, 0x27, 0x7F); - cdcWriteReg(CDC_SOUND, 0x28, 0x4A); - cdcWriteReg(CDC_SOUND, 0x29, 0x4A); - cdcWriteReg(CDC_SOUND, 0x2A, 0x10); - cdcWriteReg(CDC_SOUND, 0x2B, 0x10); - cdcWriteReg(CDC_CONTROL, 0x51, 0x00); - cdcReadReg (CDC_TOUCHCNT, 0x02); - cdcWriteReg(CDC_TOUCHCNT, 0x02, 0x98); - cdcWriteReg(CDC_SOUND, 0x23, 0x00); - cdcWriteReg(CDC_SOUND, 0x1F, 0x14); - cdcWriteReg(CDC_SOUND, 0x20, 0x14); - cdcWriteReg(CDC_CONTROL, 0x3F, 0x00); - cdcReadReg (CDC_CONTROL, 0x0B); - cdcWriteReg(CDC_CONTROL, 0x05, 0x00); - cdcWriteReg(CDC_CONTROL, 0x0B, 0x01); - cdcWriteReg(CDC_CONTROL, 0x0C, 0x02); - cdcWriteReg(CDC_CONTROL, 0x12, 0x01); - cdcWriteReg(CDC_CONTROL, 0x13, 0x02); - cdcWriteReg(CDC_SOUND, 0x2E, 0x00); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); - cdcWriteReg(CDC_CONTROL, 0x01, 0x01); - cdcWriteReg(CDC_CONTROL, 0x39, 0x66); - cdcReadReg (CDC_SOUND, 0x20); - cdcWriteReg(CDC_SOUND, 0x20, 0x10); - cdcWriteReg(CDC_CONTROL, 0x04, 0x00); - cdcWriteReg(CDC_CONTROL, 0x12, 0x81); - cdcWriteReg(CDC_CONTROL, 0x13, 0x82); - cdcWriteReg(CDC_CONTROL, 0x51, 0x82); - cdcWriteReg(CDC_CONTROL, 0x51, 0x00); - cdcWriteReg(CDC_CONTROL, 0x04, 0x03); - cdcWriteReg(CDC_CONTROL, 0x05, 0xA1); - cdcWriteReg(CDC_CONTROL, 0x06, 0x15); - cdcWriteReg(CDC_CONTROL, 0x0B, 0x87); - cdcWriteReg(CDC_CONTROL, 0x0C, 0x83); - cdcWriteReg(CDC_CONTROL, 0x12, 0x87); - cdcWriteReg(CDC_CONTROL, 0x13, 0x83); - cdcReadReg (CDC_TOUCHCNT, 0x10); - cdcWriteReg(CDC_TOUCHCNT, 0x10, 0x08); - cdcWriteReg(0x04, 0x08, 0x7F); - cdcWriteReg(0x04, 0x09, 0xE1); - cdcWriteReg(0x04, 0x0A, 0x80); - cdcWriteReg(0x04, 0x0B, 0x1F); - cdcWriteReg(0x04, 0x0C, 0x7F); - cdcWriteReg(0x04, 0x0D, 0xC1); - cdcWriteReg(CDC_CONTROL, 0x41, 0x08); - cdcWriteReg(CDC_CONTROL, 0x42, 0x08); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); - cdcWriteReg(0x04, 0x08, 0x7F); - cdcWriteReg(0x04, 0x09, 0xE1); - cdcWriteReg(0x04, 0x0A, 0x80); - cdcWriteReg(0x04, 0x0B, 0x1F); - cdcWriteReg(0x04, 0x0C, 0x7F); - cdcWriteReg(0x04, 0x0D, 0xC1); - cdcWriteReg(CDC_SOUND, 0x2F, 0x2B); - cdcWriteReg(CDC_SOUND, 0x30, 0x40); - cdcWriteReg(CDC_SOUND, 0x31, 0x40); - cdcWriteReg(CDC_SOUND, 0x32, 0x60); - cdcReadReg (CDC_CONTROL, 0x74); - cdcWriteReg(CDC_CONTROL, 0x74, 0x02); - cdcReadReg (CDC_CONTROL, 0x74); - cdcWriteReg(CDC_CONTROL, 0x74, 0x10); - cdcReadReg (CDC_CONTROL, 0x74); - cdcWriteReg(CDC_CONTROL, 0x74, 0x40); - cdcWriteReg(CDC_SOUND, 0x21, 0x20); - cdcWriteReg(CDC_SOUND, 0x22, 0xF0); - cdcReadReg (CDC_CONTROL, 0x51); - cdcReadReg (CDC_CONTROL, 0x3F); - cdcWriteReg(CDC_CONTROL, 0x3F, 0xD4); - cdcWriteReg(CDC_SOUND, 0x23, 0x44); - cdcWriteReg(CDC_SOUND, 0x1F, 0xD4); - cdcWriteReg(CDC_SOUND, 0x28, 0x4E); - cdcWriteReg(CDC_SOUND, 0x29, 0x4E); - cdcWriteReg(CDC_SOUND, 0x24, 0x9E); - cdcWriteReg(CDC_SOUND, 0x25, 0x9E); - cdcWriteReg(CDC_SOUND, 0x20, 0xD4); - cdcWriteReg(CDC_SOUND, 0x2A, 0x14); - cdcWriteReg(CDC_SOUND, 0x2B, 0x14); - cdcWriteReg(CDC_SOUND, 0x26, 0xA7); - cdcWriteReg(CDC_SOUND, 0x27, 0xA7); - cdcWriteReg(CDC_CONTROL, 0x40, 0x00); - cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); + if (noSgba) { + cdcReadReg (0x63, 0x00); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); + cdcReadReg (CDC_CONTROL, 0x51); + cdcReadReg (CDC_TOUCHCNT, 0x02); + cdcReadReg (CDC_CONTROL, 0x3F); + cdcReadReg (CDC_SOUND, 0x28); + cdcReadReg (CDC_SOUND, 0x2A); + cdcReadReg (CDC_SOUND, 0x2E); + cdcWriteReg(CDC_CONTROL, 0x52, 0x80); + cdcWriteReg(CDC_CONTROL, 0x40, 0x0C); + cdcWriteReg(CDC_SOUND, 0x24, 0xFF); + cdcWriteReg(CDC_SOUND, 0x25, 0xFF); + cdcWriteReg(CDC_SOUND, 0x26, 0x7F); + cdcWriteReg(CDC_SOUND, 0x27, 0x7F); + cdcWriteReg(CDC_SOUND, 0x28, 0x4A); + cdcWriteReg(CDC_SOUND, 0x29, 0x4A); + cdcWriteReg(CDC_SOUND, 0x2A, 0x10); + cdcWriteReg(CDC_SOUND, 0x2B, 0x10); + cdcWriteReg(CDC_CONTROL, 0x51, 0x00); + cdcReadReg (CDC_TOUCHCNT, 0x02); + cdcWriteReg(CDC_TOUCHCNT, 0x02, 0x98); + cdcWriteReg(CDC_SOUND, 0x23, 0x00); + cdcWriteReg(CDC_SOUND, 0x1F, 0x14); + cdcWriteReg(CDC_SOUND, 0x20, 0x14); + cdcWriteReg(CDC_CONTROL, 0x3F, 0x00); + cdcReadReg (CDC_CONTROL, 0x0B); + cdcWriteReg(CDC_CONTROL, 0x05, 0x00); + cdcWriteReg(CDC_CONTROL, 0x0B, 0x01); + cdcWriteReg(CDC_CONTROL, 0x0C, 0x02); + cdcWriteReg(CDC_CONTROL, 0x12, 0x01); + cdcWriteReg(CDC_CONTROL, 0x13, 0x02); + cdcWriteReg(CDC_SOUND, 0x2E, 0x00); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); + cdcWriteReg(CDC_CONTROL, 0x01, 0x01); + cdcWriteReg(CDC_CONTROL, 0x39, 0x66); + cdcReadReg (CDC_SOUND, 0x20); + cdcWriteReg(CDC_SOUND, 0x20, 0x10); + cdcWriteReg(CDC_CONTROL, 0x04, 0x00); + cdcWriteReg(CDC_CONTROL, 0x12, 0x81); + cdcWriteReg(CDC_CONTROL, 0x13, 0x82); + cdcWriteReg(CDC_CONTROL, 0x51, 0x82); + cdcWriteReg(CDC_CONTROL, 0x51, 0x00); + cdcWriteReg(CDC_CONTROL, 0x04, 0x03); + cdcWriteReg(CDC_CONTROL, 0x05, 0xA1); + cdcWriteReg(CDC_CONTROL, 0x06, 0x15); + cdcWriteReg(CDC_CONTROL, 0x0B, 0x87); + cdcWriteReg(CDC_CONTROL, 0x0C, 0x83); + cdcWriteReg(CDC_CONTROL, 0x12, 0x87); + cdcWriteReg(CDC_CONTROL, 0x13, 0x83); + cdcReadReg (CDC_TOUCHCNT, 0x10); + cdcWriteReg(CDC_TOUCHCNT, 0x10, 0x08); + cdcWriteReg(0x04, 0x08, 0x7F); + cdcWriteReg(0x04, 0x09, 0xE1); + cdcWriteReg(0x04, 0x0A, 0x80); + cdcWriteReg(0x04, 0x0B, 0x1F); + cdcWriteReg(0x04, 0x0C, 0x7F); + cdcWriteReg(0x04, 0x0D, 0xC1); + cdcWriteReg(CDC_CONTROL, 0x41, 0x08); + cdcWriteReg(CDC_CONTROL, 0x42, 0x08); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x00); + cdcWriteReg(0x04, 0x08, 0x7F); + cdcWriteReg(0x04, 0x09, 0xE1); + cdcWriteReg(0x04, 0x0A, 0x80); + cdcWriteReg(0x04, 0x0B, 0x1F); + cdcWriteReg(0x04, 0x0C, 0x7F); + cdcWriteReg(0x04, 0x0D, 0xC1); + cdcWriteReg(CDC_SOUND, 0x2F, 0x2B); + cdcWriteReg(CDC_SOUND, 0x30, 0x40); + cdcWriteReg(CDC_SOUND, 0x31, 0x40); + cdcWriteReg(CDC_SOUND, 0x32, 0x60); + cdcReadReg (CDC_CONTROL, 0x74); + cdcWriteReg(CDC_CONTROL, 0x74, 0x02); + cdcReadReg (CDC_CONTROL, 0x74); + cdcWriteReg(CDC_CONTROL, 0x74, 0x10); + cdcReadReg (CDC_CONTROL, 0x74); + cdcWriteReg(CDC_CONTROL, 0x74, 0x40); + cdcWriteReg(CDC_SOUND, 0x21, 0x20); + cdcWriteReg(CDC_SOUND, 0x22, 0xF0); + cdcReadReg (CDC_CONTROL, 0x51); + cdcReadReg (CDC_CONTROL, 0x3F); + cdcWriteReg(CDC_CONTROL, 0x3F, 0xD4); + cdcWriteReg(CDC_SOUND, 0x23, 0x44); + cdcWriteReg(CDC_SOUND, 0x1F, 0xD4); + cdcWriteReg(CDC_SOUND, 0x28, 0x4E); + cdcWriteReg(CDC_SOUND, 0x29, 0x4E); + cdcWriteReg(CDC_SOUND, 0x24, 0x9E); + cdcWriteReg(CDC_SOUND, 0x25, 0x9E); + cdcWriteReg(CDC_SOUND, 0x20, 0xD4); + cdcWriteReg(CDC_SOUND, 0x2A, 0x14); + cdcWriteReg(CDC_SOUND, 0x2B, 0x14); + cdcWriteReg(CDC_SOUND, 0x26, 0xA7); + cdcWriteReg(CDC_SOUND, 0x27, 0xA7); + cdcWriteReg(CDC_CONTROL, 0x40, 0x00); + cdcWriteReg(CDC_CONTROL, 0x3A, 0x60); + } cdcWriteReg(CDC_SOUND, 0x26, volLevel); cdcWriteReg(CDC_SOUND, 0x27, volLevel); cdcWriteReg(CDC_SOUND, 0x2E, 0x03); cdcWriteReg(CDC_TOUCHCNT, 0x03, 0x00); cdcWriteReg(CDC_SOUND, 0x21, 0x20); cdcWriteReg(CDC_SOUND, 0x22, 0xF0); - cdcReadReg (CDC_SOUND, 0x22); - cdcWriteReg(CDC_SOUND, 0x22, 0x00); + cdcWriteReg(CDC_SOUND, 0x22, 0x70); cdcWriteReg(CDC_CONTROL, 0x52, 0x80); cdcWriteReg(CDC_CONTROL, 0x51, 0x00); - - // Set remaining values - cdcWriteReg(CDC_CONTROL, 0x03, 0x44); - cdcWriteReg(CDC_CONTROL, 0x0D, 0x00); - cdcWriteReg(CDC_CONTROL, 0x0E, 0x80); - cdcWriteReg(CDC_CONTROL, 0x0F, 0x80); - cdcWriteReg(CDC_CONTROL, 0x10, 0x08); - cdcWriteReg(CDC_CONTROL, 0x14, 0x80); - cdcWriteReg(CDC_CONTROL, 0x15, 0x80); - cdcWriteReg(CDC_CONTROL, 0x16, 0x04); - cdcWriteReg(CDC_CONTROL, 0x1A, 0x01); - cdcWriteReg(CDC_CONTROL, 0x1E, 0x01); - cdcWriteReg(CDC_CONTROL, 0x24, 0x80); - cdcWriteReg(CDC_CONTROL, 0x33, 0x34); - cdcWriteReg(CDC_CONTROL, 0x34, 0x32); - cdcWriteReg(CDC_CONTROL, 0x35, 0x12); - cdcWriteReg(CDC_CONTROL, 0x36, 0x03); - cdcWriteReg(CDC_CONTROL, 0x37, 0x02); - cdcWriteReg(CDC_CONTROL, 0x38, 0x03); - cdcWriteReg(CDC_CONTROL, 0x3C, 0x19); - cdcWriteReg(CDC_CONTROL, 0x3D, 0x05); - cdcWriteReg(CDC_CONTROL, 0x44, 0x0F); - cdcWriteReg(CDC_CONTROL, 0x45, 0x38); - cdcWriteReg(CDC_CONTROL, 0x49, 0x00); - cdcWriteReg(CDC_CONTROL, 0x4A, 0x00); - cdcWriteReg(CDC_CONTROL, 0x4B, 0xEE); - cdcWriteReg(CDC_CONTROL, 0x4C, 0x10); - cdcWriteReg(CDC_CONTROL, 0x4D, 0xD8); - cdcWriteReg(CDC_CONTROL, 0x4E, 0x7E); - cdcWriteReg(CDC_CONTROL, 0x4F, 0xE3); - cdcWriteReg(CDC_CONTROL, 0x58, 0x7F); - cdcWriteReg(CDC_CONTROL, 0x74, 0xD2); - cdcWriteReg(CDC_CONTROL, 0x75, 0x2C); - cdcWriteReg(CDC_SOUND, 0x22, 0x70); - cdcWriteReg(CDC_SOUND, 0x2C, 0x20); + + if (noSgba) { + // Set remaining values + cdcWriteReg(CDC_CONTROL, 0x03, 0x44); + cdcWriteReg(CDC_CONTROL, 0x0D, 0x00); + cdcWriteReg(CDC_CONTROL, 0x0E, 0x80); + cdcWriteReg(CDC_CONTROL, 0x0F, 0x80); + cdcWriteReg(CDC_CONTROL, 0x10, 0x08); + cdcWriteReg(CDC_CONTROL, 0x14, 0x80); + cdcWriteReg(CDC_CONTROL, 0x15, 0x80); + cdcWriteReg(CDC_CONTROL, 0x16, 0x04); + cdcWriteReg(CDC_CONTROL, 0x1A, 0x01); + cdcWriteReg(CDC_CONTROL, 0x1E, 0x01); + cdcWriteReg(CDC_CONTROL, 0x24, 0x80); + cdcWriteReg(CDC_CONTROL, 0x33, 0x34); + cdcWriteReg(CDC_CONTROL, 0x34, 0x32); + cdcWriteReg(CDC_CONTROL, 0x35, 0x12); + cdcWriteReg(CDC_CONTROL, 0x36, 0x03); + cdcWriteReg(CDC_CONTROL, 0x37, 0x02); + cdcWriteReg(CDC_CONTROL, 0x38, 0x03); + cdcWriteReg(CDC_CONTROL, 0x3C, 0x19); + cdcWriteReg(CDC_CONTROL, 0x3D, 0x05); + cdcWriteReg(CDC_CONTROL, 0x44, 0x0F); + cdcWriteReg(CDC_CONTROL, 0x45, 0x38); + cdcWriteReg(CDC_CONTROL, 0x49, 0x00); + cdcWriteReg(CDC_CONTROL, 0x4A, 0x00); + cdcWriteReg(CDC_CONTROL, 0x4B, 0xEE); + cdcWriteReg(CDC_CONTROL, 0x4C, 0x10); + cdcWriteReg(CDC_CONTROL, 0x4D, 0xD8); + cdcWriteReg(CDC_CONTROL, 0x4E, 0x7E); + cdcWriteReg(CDC_CONTROL, 0x4F, 0xE3); + cdcWriteReg(CDC_CONTROL, 0x58, 0x7F); + cdcWriteReg(CDC_CONTROL, 0x74, 0xD2); + cdcWriteReg(CDC_CONTROL, 0x75, 0x2C); + cdcWriteReg(CDC_SOUND, 0x22, 0x70); + cdcWriteReg(CDC_SOUND, 0x2C, 0x20); + } // Finish up! cdcReadReg (CDC_TOUCHCNT, 0x02); @@ -641,7 +646,7 @@ int main (void) { if ((dsiMode && ((ARM9_SRC==0x4000 && !(dsiFlags & BIT(0))) || dsMode || tscTgds)) || (!dsiMode && REG_SCFG_EXT != 0 && memcmp(ndsHeaderTitle, "TWLMENUPP", 9) != 0 && memcmp(ndsHeaderTitle, "NDSBOOTSTRAP", 12) != 0)) { NDSTouchscreenMode(); - *(u16*)0x4000500 = 0x807F; + *(vu16*)0x4000500 = 0x807F; if (dsMode) REG_GPIO_WIFI |= BIT(8); // Old NDS-Wifi mode i2cWriteRegister(I2C_PM, I2CREGPM_MMCPWR, 0); // Press power button for auto-reset i2cWriteRegister(I2C_PM, I2CREGPM_RESETFLAG, 1); // Bootflag = Warmboot/SkipHealthSafety