Fix X button reset issue with 3in1 Plus ...

* 3 in 1 Plus remaining issue with x button option to boot to nor flash
game after having completed a norflash flash operation has now been
resolved. :D
* NorFlash menu appearing when hitting L after entering rumble selection
menu on Omega/Omega DE has been resolved. NorFlash menu now fully
disabled for Omega to avoid possible bricking of this cart.
* Screen init process for GBA Frame loader optimized.
This commit is contained in:
ApacheThunder 2024-07-11 22:54:46 -05:00
parent 7b62f440d2
commit ead3daa6b7
7 changed files with 72 additions and 43 deletions

View File

@ -315,7 +315,7 @@ void chip_reset() {
*((vu16*)0x08600000) = 0xF0;
return;
} else if(ID == 0x89168916) {
*((vu16*)(FlashBase+0)) = 0x50;
// *((vu16*)(FlashBase+0)) = 0x50;
*((vu16*)(FlashBase+0x1000*2)) = 0x50;
*((vu16*)(FlashBase+0)) = 0xFF;
*((vu16*)(FlashBase+0x1000*2)) = 0xFF;
@ -568,6 +568,7 @@ void WriteNorFlashINTEL(u32 address,u8 *buffer,u32 size) {
*((vu16*)(FlashBase+mapaddress+(loopwrite>>1)+0x2000)) = 0xFF;
*((vu16*)(FlashBase+mapaddress+(loopwrite>>1))) = 0xE8;
*((vu16*)(FlashBase+mapaddress+(loopwrite>>1)+0x2000)) = 0xE8;
// Disabling this fixes X button reset bug with 3in1 Plus.
// *((vu16*)(FlashBase+mapaddress+(loopwrite>>1))) = 0x70;
// *((vu16*)(FlashBase+mapaddress+(loopwrite>>1)+0x2000)) = 0x70;
v1=v2=0;
@ -593,6 +594,9 @@ void WriteNorFlashINTEL(u32 address,u8 *buffer,u32 size) {
break;
}
}
// Adding this fixes 3in1 Plus reset bug with X button.
*((vu16*)(FlashBase+mapaddress+(loopwrite>>1))) = 0xFF;
*((vu16*)(FlashBase+mapaddress+(loopwrite>>1)+0x2000)) = 0xFF;
}
}
if(b512) {

View File

@ -567,7 +567,7 @@ static const struct save_type sSaveTypes[SAVE_TYPE_COUNT] = {
};
const struct save_type* save_findTag() {
u32 curAddr = 0x080000C0;
u32 curAddr = 0x080000C0;
char saveTag[16];
while (curAddr < 0x08000000+romSize) {
u32 fst = *(u32*)curAddr;

View File

@ -537,12 +537,12 @@ int checkSRAM(char *name) {
if(ctrl.sign[i] != Rudolph[i])break;
}
if((carttype < 4) && !isSuperCard && !is3in1Plus && !isOmega)OpenNorWrite();
// if((carttype < 4) && !isSuperCard && !is3in1Plus && !isOmega)OpenNorWrite();
if(Rudolph[i] != 0) {
strcpy((char *)ctrl.sign, Rudolph);
ctrl_set();
if((carttype < 4) && !isSuperCard && !is3in1Plus && !isOmega)CloseNorWrite();
// if((carttype < 4) && !isSuperCard && !is3in1Plus && !isOmega)CloseNorWrite();
return false;
}
@ -562,11 +562,11 @@ int checkSRAM(char *name) {
savesize = 0x10000;
ctrl.save_siz[GBAmode] = savesize;
ctrl_set();
if((carttype < 4) && !isSuperCard && !is3in1Plus && !isOmega)CloseNorWrite();
// if((carttype < 4) && !isSuperCard && !is3in1Plus && !isOmega)CloseNorWrite();
return false;
}
if((carttype < 4) && !isSuperCard && !is3in1Plus && !isOmega)CloseNorWrite();
// if((carttype < 4) && !isSuperCard && !is3in1Plus && !isOmega)CloseNorWrite();
return true;
}
@ -719,7 +719,7 @@ void SRAMdump(int cmd) {
} else {
dsp_bar(5, -1);
dmp = fopen(name, "rb");
if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)OpenNorWrite();
// if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)OpenNorWrite();
if (isOmega)Omega_Bank_Switching(0);
@ -760,7 +760,7 @@ void SRAMdump(int cmd) {
}
}
}
if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)CloseNorWrite();
// if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)CloseNorWrite();
}
fclose(dmp);
_RamSave(0);
@ -771,7 +771,7 @@ void blankSRAM(char *savename) {
memset(rwbuf, 0xFF, USE_SRAM / 2);
if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)OpenNorWrite();
// if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)OpenNorWrite();
if (isOmega)Omega_Bank_Switching(0);
@ -792,7 +792,7 @@ void blankSRAM(char *savename) {
strcpy((char *)ctrl.sav_nam[GBAmode], savename);
ctrl_set();
if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)CloseNorWrite();
// if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)CloseNorWrite();
}
void writeSramToFile(char *savename) {
@ -827,11 +827,11 @@ void writeSramToFile(char *savename) {
ctrl.save_flg[GBAmode] = 0xFF;
if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)OpenNorWrite();
// if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)OpenNorWrite();
ctrl_set();
if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)CloseNorWrite();
// if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)CloseNorWrite();
}
void writeSramFromFile(char *savename) {
@ -849,7 +849,7 @@ void writeSramFromFile(char *savename) {
return;
}
if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)OpenNorWrite();
// if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)OpenNorWrite();
ctrl.save_siz[GBAmode] = savesize;
ctrl.save_flg[GBAmode] = 0x00;
@ -878,7 +878,7 @@ void writeSramFromFile(char *savename) {
}
// }
if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)CloseNorWrite();
// if((carttype < 4) && !isSuperCard && !isOmega && !is3in1Plus)CloseNorWrite();
fclose(saver);
}
@ -979,11 +979,10 @@ int writeFileToNor(int sel) {
dsp_bar(1, 100);
fclose(gbaFile);
// if (is3in1Plus)chip_reset();
CloseNorWrite();
dsp_bar(5, -1);
// getSaveFilename(sel, savName);
if(cmd >= 0) { writeSramFromFile(savName); } else { blankSRAM(savName); }
@ -992,8 +991,8 @@ int writeFileToNor(int sel) {
for (int i = 0; i < 30; i++)swiWaitForVBlank();
dsp_bar(-1, 100);
// SetRampage(USE_SRAM_NOR);
return(0);
// SetRampage(USE_SRAM_NOR);
return 0;
}

View File

@ -42,6 +42,7 @@
#include "ctrl_tbl.h"
#include "skin.h"
#include "message.h"
#include "tonccpy.h"
extern uint16* MainScreen;
extern uint16* SubScreen;
@ -109,32 +110,33 @@ void turn_off(bool softReset) {
void gba_frame() {
int ret;
int x=0, y=0;
u16 *pDstBuf1;
u16 *pDstBuf2;
int mode = 3; // old mode == 2
// int x = 0, y = 0;
// u16 *pDstBuf1;
// u16 *pDstBuf2;
if (access("/gbaframe.bmp", F_OK) == 0) {
ret = LoadSkin(2, "/gbaframe.bmp");
ret = LoadSkin(mode, "/gbaframe.bmp");
if(ret)return;
}
sprintf(tbuf, "%s/gbaframe.bmp", ini.sign_dir);
if (access(tbuf, F_OK) == 0) {
ret = LoadSkin(2, tbuf);
ret = LoadSkin(mode, tbuf);
if(ret)return;
}
if (access("/_system_/gbaframe.bmp", F_OK) == 0) {
ret = LoadSkin(2, "/_system_/gbaframe.bmp");
ret = LoadSkin(mode, "/_system_/gbaframe.bmp");
if(ret)return;
}
if (access("/ttmenu/gbaframe.bmp", F_OK) == 0) {
ret = LoadSkin(2, "/ttmenu/gbaframe.bmp");
ret = LoadSkin(mode, "/ttmenu/gbaframe.bmp");
if(ret)return;
}
pDstBuf1 = (u16*)0x06000000;
/*pDstBuf1 = (u16*)0x06000000;
pDstBuf2 = (u16*)0x06020000;
for(y = 0; y < 192; y++) {
for(x = 0; x < 256; x++) {
@ -143,7 +145,7 @@ void gba_frame() {
}
pDstBuf1 += 256;
pDstBuf2 += 256;
}
}*/
}
static void resetToSlot2() {
@ -168,10 +170,28 @@ void gbaMode() {
if(strncmp(GBA_HEADER.gamecode, "PASS", 4) == 0)resetToSlot2();
videoSetMode(0);
videoSetModeSub(0);
// videoSetMode(0);
// videoSetModeSub(0);
vramSetPrimaryBanks(VRAM_A_MAIN_BG, VRAM_B_MAIN_BG, VRAM_C_MAIN_BG, VRAM_D_MAIN_BG);
// vramSetPrimaryBanks(VRAM_A_MAIN_BG, VRAM_B_MAIN_BG, VRAM_C_MAIN_BG, VRAM_D_MAIN_BG);
videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
vramSetBankB(VRAM_B_MAIN_BG_0x06020000);
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
vramSetBankD(VRAM_D_LCD);
// for the main screen
REG_BG3CNT = BG_BMP16_256x256 | BG_BMP_BASE(0) | BG_WRAP_OFF;
REG_BG3PA = 1 << 8; //scale x
REG_BG3PB = 0; //rotation x
REG_BG3PC = 0; //rotation y
REG_BG3PD = 1 << 8; //scale y
REG_BG3X = 0; //translation x
REG_BG3Y = 0; //translation y*/
toncset((void*)BG_BMP_RAM(0),0,0x18000);
toncset((void*)BG_BMP_RAM(8),0,0x18000);
swiWaitForVBlank();
if(PersonalData->gbaScreen) { lcdMainOnBottom(); } else { lcdMainOnTop(); }
@ -180,6 +200,7 @@ void gbaMode() {
sysSetBusOwners(ARM7_OWNS_CARD, ARM7_OWNS_ROM);
fifoSendValue32(FIFO_USER_01, 1);
REG_IME = 0;
irqDisable(IRQ_VBLANK);
while(1)swiWaitForVBlank();
}
@ -847,7 +868,7 @@ int gba_sel() {
}
break;
} else if (isOmega && (GBAmode == 0)) {
SetRampage(0x8002);
SetRompage(0x8002);
gbaMode();
}
}

View File

@ -18,3 +18,4 @@ extern char *jstrncpy(char *s1, char *s2, size_t n);
#ifdef __cplusplus
}
#endif

View File

@ -283,7 +283,7 @@ static bool intLoadBM(const char *bmpfn,u16 *pbm,const u32 bmw,const u32 bmh) {
ALIGN(4) static u16 *pBuf;
bool LoadSkin(int mod, char *Name) {
bool LoadSkin(int mode, const char *Name) {
u16 *pDstBuf1;
u16 *pDstBuf2;
@ -291,7 +291,7 @@ bool LoadSkin(int mod, char *Name) {
pBuf = (u16*)malloc(256*192*2);
if(!intLoadBM(Name, pBuf, 256, 192)) { free(pBuf); return false; }
switch (mod) {
switch (mode) {
case 0: pDstBuf1 = (u16*)0x06020000; break;
case 1: pDstBuf1 = (u16*)0x06220000; break;
case 2:
@ -300,19 +300,22 @@ bool LoadSkin(int mod, char *Name) {
// pDstBuf1 = (u16*)0x06800000;
// pDstBuf2 = (u16*)0x06820000;
break;
case 3: {
pDstBuf1 = BG_BMP_RAM(0);
pDstBuf2 = BG_BMP_RAM(8);
} break;
default: pDstBuf1 = (u16*)0x06020000; break;
}
for(s32 y=0;y<192;y++) {
for(s32 x=0;x<256;x++) {
pDstBuf1[x]=pBuf[x];
if(mod == 2)pDstBuf2[x]=pBuf[x];
for (s32 y = 0; y < 192; y++) {
for (s32 x = 0; x < 256; x++) {
pDstBuf1[x] = pBuf[x];
if ((mode == 2) || (mode == 3))pDstBuf2[x] = pBuf[x];
}
pDstBuf1+=256;
if(mod == 2)pDstBuf2+=256;
pBuf+=256;
pDstBuf1 += 256;
if ((mode == 2) || (mode == 3))pDstBuf2 += 256;
pBuf += 256;
}
// free(pBuf);
return true;
}

View File

@ -2,8 +2,9 @@
extern "C" {
#endif
extern bool LoadSkin(int mod, char *Name);
extern bool LoadSkin(int mode, const char *Name);
#ifdef __cplusplus
}
#endif