Skip to content

Commit

Permalink
Reverted the GG_IO optimization, fixed TV noise graphics after Power …
Browse files Browse the repository at this point in the history
…off, fixed arcade file loading, fixed glitch if opening rom loading directly.
  • Loading branch information
FluBBaOfWard committed Oct 13, 2021
1 parent 4e8b800 commit 77d4e59
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 51 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ build
*.elf
*.nds
*.zip
include/ac
include/col
include/mt
include/PV-2000
include/sc
include/saves
*.sav
1 change: 1 addition & 0 deletions source/Cart.s
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ rawRom:
// .incbin "sms/Ace of Aces (UE) [!].sms"
// .incbin "sms/Action Fighter (TW).sms"
// .incbin "sms/After Burner (UE).sms"
// .incbin "sms/Aladdin (UE) [!].sms"
// .incbin "sms/Alex Kidd in Miracle World [v1].sms"
// .incbin "sms/Back to the Future 2 (UE) [!].sms"
// .incbin "sms/Back to the Future 3 (E) [!].sms"
Expand Down
16 changes: 10 additions & 6 deletions source/FileHandling.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void loadState() {
if ( (file = fopen(stateName, "r")) ) {
if ( (statePtr = malloc(STATESIZE)) ) {
cls(0);
drawText(" Loading state...", 12, 0);
drawText(" Loading state...", 11, 0);
fread(statePtr, 1, STATESIZE, file);
loadCart(g_emuFlags);
unpackState(statePtr);
Expand All @@ -184,7 +184,7 @@ void saveState() {
if ( (file = fopen(stateName, "w")) ) {
if ( (statePtr = malloc(STATESIZE)) ) {
cls(0);
drawText(" Saving state...", 12, 0);
drawText(" Saving state...", 11, 0);
packState(statePtr);
fwrite(statePtr, 1, STATESIZE, file);
free(statePtr);
Expand All @@ -198,11 +198,11 @@ void saveState() {
}
}

void loadGame(const char *gameName) {
bool loadGame(const char *gameName) {
char fileExt[8];
if ( gameName ) {
cls(0);
drawText(" Please wait, loading.", 12, 0);
drawText(" Please wait, loading.", 11, 0);
g_emuFlags &= ~(MD_MODE|GG_MODE|SG_MODE|SC_MODE|COL_MODE|MSX_MODE|SORDM5_MODE|SGAC_MODE|SYSE_MODE|MT_MODE);
g_ROM_Size = loadROM(ROM_Space, gameName, 0x100000);
if ( !g_ROM_Size ) {
Expand Down Expand Up @@ -240,15 +240,19 @@ void loadGame(const char *gameName) {
gameInserted = true;
powerButton = true;
closeMenu();
return false;
}
}
return true;
}

void selectGame() {
pauseEmulation = true;
setSelectedMenu(10);
const char *gameName = browseForFileType(FILEEXTENSIONS".zip");
cls(0);
loadGame(gameName);
if ( loadGame(gameName) ) {
backOutOfMenu();
}
}

static bool selectBios(const char *fileTypes, char *dest) {
Expand Down
2 changes: 1 addition & 1 deletion source/FileHandling.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern "C" {

int loadSettings(void);
void saveSettings(void);
void loadGame(const char *gameName);
bool loadGame(const char *gameName);
void loadState(void);
void saveState(void);
int loadNVRAM(void);
Expand Down
62 changes: 33 additions & 29 deletions source/Gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,33 +139,34 @@ static void uiDipSwitchesTetris(void);
static void uiDipSwitchesMegaTech(void);

static void ui9(void);
static void ui10(void);
static void ui11(void);


const fptr fnMain[] = {nullUI,subUI,subUI,subUI,subUI,subUI,subUI,subUI,subUI,subUI,subUI,subUI,subUI,subUI,subUI,subUI,subUI,subUI,subUI};

static const fptr fnList0[] = {uiDummy};
static const fptr fnList1[] = {selectGame, loadState, saveState, saveSRAM, saveSettings, ejectGame, powerOnOff, resetGame, ui10};
static const fptr fnList2[] = {ui4, ui5, ui6, ui7, ui9};
static const fptr fnList1[] = {selectGame, loadState, saveState, saveSRAM, saveSettings, ejectGame, powerOnOff, resetGame, ui9};
static const fptr fnList2[] = {ui4, ui5, ui6, ui7, ui11};
static const fptr fnList3[] = {uiDummy};
static const fptr fnList4[] = {autoBSet, autoASet, controllerSet, swapABSet, joypadSet, selectSet, rffSet};
static const fptr fnList5[] = {scalingSet, flickSet, brightSet, colorSet, borderSet, spriteSet, glassesSet, bgrLayerSet, sprLayerSet};
static const fptr fnList6[] = {countrySet, machineSet, ui8, ym2413Set};
static const fptr fnList7[] = {speedSet, autoStateSet, autoSettingsSet, autoNVRAMSet, autoPauseGameSet, powerSaveSet, screenSwapSet, debugTextSet, sleepSet};
static const fptr fnList8[] = {biosSet, selectUSBios, selectJPBios, selectGGBios, selectCOLECOBios, selectMSXBios, selectSORDM5Bios};
static const fptr fnList9[] = {uiDummy};
static const fptr fnList10[] = {exitEmulator, backOutOfMenu};
static const fptr fnList11[] = {dip0Set4_2,dip0Set6_1,dip0Set7_1};
static const fptr fnList12[] = {dip0Set0_4,dip0Set4_4,dip1Set0_1,dip1Set1_2,dip1Set3_2};
static const fptr fnList13[] = {dip0Set0_4,dip0Set4_4,dip1Set0_1,dip1Set1_1,dip1Set2_2,dip1Set4_2,dip1Set6_2};
static const fptr fnList14[] = {dip0Set0_4,dip0Set4_4,dip1Set0_2,dip1Set3_1,dip1Set5_2};
static const fptr fnList15[] = {dip0Set0_4,dip0Set4_4,dip1Set1_1,dip1Set2_2,dip1Set4_2,dip1Set6_2};
static const fptr fnList9[] = {exitEmulator, backOutOfMenu};
static const fptr fnList10[] = {uiDummy};
static const fptr fnList11[] = {uiDummy};
static const fptr fnList12[] = {dip0Set4_2,dip0Set6_1,dip0Set7_1};
static const fptr fnList13[] = {dip0Set0_4,dip0Set4_4,dip1Set0_1,dip1Set1_2,dip1Set3_2};
static const fptr fnList14[] = {dip0Set0_4,dip0Set4_4,dip1Set0_1,dip1Set1_1,dip1Set2_2,dip1Set4_2,dip1Set6_2};
static const fptr fnList15[] = {dip0Set0_4,dip0Set4_4,dip1Set0_2,dip1Set3_1,dip1Set5_2};
static const fptr fnList16[] = {dip0Set0_4,dip0Set4_4,dip1Set1_1,dip1Set2_2,dip1Set4_2,dip1Set6_2};
static const fptr fnList17[] = {dip0Set0_4,dip0Set4_4,dip1Set1_1,dip1Set4_2};
static const fptr fnList18[] = {dip1Sub0_4,dip0Sub5_3,dip0Set1_1,dip0Set0_1,dip0Set2_3,dip1Set4_4};
static const fptr fnList17[] = {dip0Set0_4,dip0Set4_4,dip1Set1_1,dip1Set2_2,dip1Set4_2,dip1Set6_2};
static const fptr fnList18[] = {dip0Set0_4,dip0Set4_4,dip1Set1_1,dip1Set4_2};
static const fptr fnList19[] = {dip1Sub0_4,dip0Sub5_3,dip0Set1_1,dip0Set0_1,dip0Set2_3,dip1Set4_4};
const fptr *const fnListX[] = {fnList0,fnList1,fnList2,fnList3,fnList4,fnList5,fnList6,fnList7,fnList8,fnList9,fnList10,fnList11,fnList12,fnList13,fnList14,fnList15,fnList16,fnList17,fnList18};
u8 menuXitems[] = {ARRSIZE(fnList0),ARRSIZE(fnList1),ARRSIZE(fnList2),ARRSIZE(fnList3),ARRSIZE(fnList4),ARRSIZE(fnList5),ARRSIZE(fnList6),ARRSIZE(fnList7),ARRSIZE(fnList8),ARRSIZE(fnList9),ARRSIZE(fnList10),ARRSIZE(fnList11),ARRSIZE(fnList12),ARRSIZE(fnList13),ARRSIZE(fnList14),ARRSIZE(fnList15),ARRSIZE(fnList16),ARRSIZE(fnList17),ARRSIZE(fnList18)};
const fptr drawuiX[] = {uiNullNormal,uiFile,uiOptions,uiAbout,uiController,uiDisplay,uiMachine,uiSettings,uiBios,uiDipSwitches,uiYesNo,uiDipSwitchesSGAC,uiDipSwitchesHangOnJr,uiDipSwitchesTransformer,uiDipSwitchesPythagoras,uiDipSwitchesOpaOpa,uiDipSwitchesFantasyZone2,uiDipSwitchesTetris,uiDipSwitchesMegaTech};
u8 menuXitems[] = {ARRSIZE(fnList0),ARRSIZE(fnList1),ARRSIZE(fnList2),ARRSIZE(fnList3),ARRSIZE(fnList4),ARRSIZE(fnList5),ARRSIZE(fnList6),ARRSIZE(fnList7),ARRSIZE(fnList8),ARRSIZE(fnList9),ARRSIZE(fnList10),ARRSIZE(fnList11),ARRSIZE(fnList12),ARRSIZE(fnList13),ARRSIZE(fnList14),ARRSIZE(fnList15),ARRSIZE(fnList16),ARRSIZE(fnList17),ARRSIZE(fnList18),ARRSIZE(fnList19)};
const fptr drawuiX[] = {uiNullNormal,uiFile,uiOptions,uiAbout,uiController,uiDisplay,uiMachine,uiSettings,uiBios,uiYesNo,uiDummy,uiDipSwitches,uiDipSwitchesSGAC,uiDipSwitchesHangOnJr,uiDipSwitchesTransformer,uiDipSwitchesPythagoras,uiDipSwitchesOpaOpa,uiDipSwitchesFantasyZone2,uiDipSwitchesTetris,uiDipSwitchesMegaTech};
const u8 menuXback[] = {0,0,0,0,2,2,2,2,6,2,1,2,2,2,2,2,2,2,2};

static int sdscPtr = 0;
Expand Down Expand Up @@ -501,30 +502,30 @@ static void uiDipSwitchesMegaTech() {
drawSubItem("Time per credit: ", mtTimerTxt[(dipSwitch1>>4) & 0xF]);
}

void ui9() {
int ds = 9;
void ui11() {
int ds = 11;
if (gArcadeGameSet == AC_CHAMPION_BOXING || gArcadeGameSet == AC_CHAMPION_WRESTLING || gArcadeGameSet == AC_DOKI_DOKI_PENGUIN) {
ds = 11;
} else if (gArcadeGameSet == AC_HANG_ON_JR) {
ds = 12;
} else if (gArcadeGameSet == AC_TRANSFORMER || gArcadeGameSet == AC_ASTRO_FLASH) {
} else if (gArcadeGameSet == AC_HANG_ON_JR) {
ds = 13;
} else if (gArcadeGameSet == AC_RIDDLE_OF_PYTHAGORAS) {
} else if (gArcadeGameSet == AC_TRANSFORMER || gArcadeGameSet == AC_ASTRO_FLASH) {
ds = 14;
} else if (gArcadeGameSet == AC_OPA_OPA) {
} else if (gArcadeGameSet == AC_RIDDLE_OF_PYTHAGORAS) {
ds = 15;
} else if (gArcadeGameSet == AC_FANTASY_ZONE_2) {
} else if (gArcadeGameSet == AC_OPA_OPA) {
ds = 16;
} else if (gArcadeGameSet == AC_TETRIS) {
} else if (gArcadeGameSet == AC_FANTASY_ZONE_2) {
ds = 17;
} else if (g_emuFlags & MT_MODE || g_machine == HW_MEGATECH) {
} else if (gArcadeGameSet == AC_TETRIS) {
ds = 18;
} else if (g_emuFlags & MT_MODE || g_machine == HW_MEGATECH) {
ds = 19;
}

setSelectedMenu(ds);
}
void ui10() {
setSelectedMenu(10);
void ui9() {
setSelectedMenu(9);
}

void nullUINormal(int keyHit) {
Expand Down Expand Up @@ -1407,10 +1408,13 @@ void setupSordM5Background(void) {
//---------------------------------------------------------------------------------

void powerOnOff() {
if ( (powerButton = !powerButton) ) {
loadCart(g_emuFlags);
}
powerButton = !powerButton;
loadCart(g_emuFlags); // This resets the graphics.
setMuteSoundGUI();
if (!isMenuOpen()) {
cls(0);
uiNullNormal();
}
}

void ejectGame() {
Expand Down
22 changes: 11 additions & 11 deletions source/RomLoading.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int loadArcadeROM(void *dest, const char *fName) {
if (loadFileInZip(dest, fName, megatechGames[i], megatechSizes[i]) == 0) {
size = cenHead.ucSize;
strlcpy(currentFilename, megatechNames[i], sizeof(currentFilename));
g_emuFlags |=MT_MODE;
g_emuFlags |= MT_MODE;
return size;
}
}
Expand All @@ -65,7 +65,7 @@ int loadArcadeROM(void *dest, const char *fName) {
if (loadFileInZip(dest+0x8000, fName, "cb6107.bin", 0x2000) == 0) {
size = 0x10000;
strlcpy(currentFilename, "Champion Boxing SG-AC", sizeof(currentFilename));
g_emuFlags |=SGAC_MODE;
g_emuFlags |= SGAC_MODE;
gArcadeGameSet = AC_CHAMPION_BOXING;
dipSwitch0 = 0x40;
}
Expand All @@ -77,7 +77,7 @@ int loadArcadeROM(void *dest, const char *fName) {
if (loadFileInZip(dest+0x8000, fName, "5734", 0x4000) == 0) {
size = 0x10000;
strlcpy(currentFilename, "Champion Wrestling SG-AC", sizeof(currentFilename));
g_emuFlags |=SGAC_MODE;
g_emuFlags |= SGAC_MODE;
gArcadeGameSet = AC_CHAMPION_WRESTLING;
dipSwitch0 = 0xC0;
}
Expand All @@ -89,7 +89,7 @@ int loadArcadeROM(void *dest, const char *fName) {
if (loadFileInZip(dest+0x8000, fName, "epr-7358.ic3", 0x4000) == 0) {
size = 0x10000;
strlcpy(currentFilename, "Doki Doki Penguin SG-AC", sizeof(currentFilename));
g_emuFlags |=SGAC_MODE;
g_emuFlags |= SGAC_MODE;
gArcadeGameSet = AC_DOKI_DOKI_PENGUIN;
dipSwitch0 = 0xC0;
}
Expand All @@ -103,7 +103,7 @@ int loadArcadeROM(void *dest, const char *fName) {
if (loadFileInZip(dest+0x20000, fName, "rom1.ic2", 0x8000) == 0) {
size = 0x40000;
strlcpy(currentFilename, "Hang On Jr System-E", sizeof(currentFilename));
g_emuFlags |=SYSE_MODE;
g_emuFlags |= SYSE_MODE;
gArcadeGameSet = AC_HANG_ON_JR;
}
}
Expand All @@ -118,7 +118,7 @@ int loadArcadeROM(void *dest, const char *fName) {
if (loadFileInZip(dest+0x20000, fName, "epr10422.bin", 0x8000) == 0) {
size = 0x40000;
strlcpy(currentFilename, "Riddle Of Pythagoras System-E", sizeof(currentFilename));
g_emuFlags |=SYSE_MODE;
g_emuFlags |= SYSE_MODE;
gArcadeGameSet = AC_RIDDLE_OF_PYTHAGORAS;
}
}
Expand All @@ -131,7 +131,7 @@ int loadArcadeROM(void *dest, const char *fName) {
if (loadFileInZip(dest+0x10000, fName, "epr12211.4", 0x8000) == 0) {
size = 0x20000;
strlcpy(currentFilename, "Tetris System-E", sizeof(currentFilename));
g_emuFlags |=SYSE_MODE;
g_emuFlags |= SYSE_MODE;
gArcadeGameSet = AC_TETRIS;
}
}
Expand All @@ -144,7 +144,7 @@ int loadArcadeROM(void *dest, const char *fName) {
if (loadFileInZip(dest+0x20000, fName, "epr-7350.ic2", 0x8000) == 0) {
size = 0x40000;
strlcpy(currentFilename, "Transformer System-E", sizeof(currentFilename));
g_emuFlags |=SYSE_MODE;
g_emuFlags |= SYSE_MODE;
gArcadeGameSet = AC_TRANSFORMER;
}
}
Expand All @@ -159,7 +159,7 @@ int loadArcadeROM(void *dest, const char *fName) {
if (loadFileInZip(dest+0x20000, fName, "epr-7350.ic2", 0x8000) == 0) {
size = 0x40000;
strlcpy(currentFilename, "Astro Flash System-E", sizeof(currentFilename));
g_emuFlags |=SYSE_MODE;
g_emuFlags |= SYSE_MODE;
gArcadeGameSet = AC_ASTRO_FLASH;
}
}
Expand All @@ -174,7 +174,7 @@ int loadArcadeROM(void *dest, const char *fName) {
if (loadFileInZip(dest+0x38000, fName, "epr-11412.ic2", 0x10000) == 0) {
size = 0x80000;
strlcpy(currentFilename, "Fantasy Zone 2 System-E", sizeof(currentFilename));
g_emuFlags |=SYSE_MODE;
g_emuFlags |= SYSE_MODE;
gArcadeGameSet = AC_FANTASY_ZONE_2;
}
}
Expand All @@ -189,7 +189,7 @@ int loadArcadeROM(void *dest, const char *fName) {
if (loadFileInZip(dest+0x20000, fName, "epr11220.ic2", 0x8000) == 0) {
size = 0x40000;
strlcpy(currentFilename, "Opa Opa System-E", sizeof(currentFilename));
g_emuFlags |=SYSE_MODE;
g_emuFlags |= SYSE_MODE;
gArcadeGameSet = AC_OPA_OPA;
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/Shared
Submodule Shared updated 3 files
+4 −0 EmuMenu.c
+1 −0 EmuMenu.h
+1 −1 Unzip
7 changes: 4 additions & 3 deletions source/io.s
Original file line number Diff line number Diff line change
Expand Up @@ -919,12 +919,13 @@ StereoCtrl_GG_W: ;@ GG stereo control, 0x06
;@------------------------------------------------------------------------------
IOCtrl_GG_W: ;@ GG com port stuff, 0x00-0x07
;@------------------------------------------------------------------------------
strb r0,[pc,addy]
adr r1,GGIO
strb r0,[r1,addy]
bx lr
GGIO:
.byte 0xC0,0x7F,0xFF,0x00,0xFF,0x00,0xFF,0xFF
GGIO_Default:
.byte 0xC0,0x7F,0xFF,0x00,0xFF,0x00,0xFF,0xFF
GGIO:
.byte 0xC0,0x7F,0xFF,0x00,0xFF,0x00,0xFF,0xFF
;@------------------------------------------------------------------------------
IOCtrl_SMS_W:
;@------------------------------------------------------------------------------
Expand Down

0 comments on commit 77d4e59

Please sign in to comment.