mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-01 00:15:14 +01:00
cleanup ARAM ROM injection code
This commit is contained in:
parent
74eecc747c
commit
eba96bba07
@ -259,7 +259,13 @@ and changed the setting, reset the game for the settings to take effect.
|
||||
These controllers can be controlled by either the Gamecube controller analog
|
||||
sticks,the Classic controller analog sticks, or by aiming at the screen
|
||||
with the wiimote.
|
||||
(these configurations cannot be changed, yet)
|
||||
|
||||
Aim Offscreen - Wiimote Minus, GameCube Z button
|
||||
Fire - B button
|
||||
Cursor - A button
|
||||
Turbo Toggle - Wiimote D-Pad Down, GameCube Y button
|
||||
|
||||
These configurations cannot be changed.
|
||||
|
||||
×—–—–—–—– –—–—–—–—–—–—–—–—–—–— —–—–—–—–—–—–—–—-—–-–•¬
|
||||
|0O×øo· ZIP SUPPORT ·oø×O0|
|
||||
|
@ -45,14 +45,12 @@ int selection;
|
||||
char currentdir[MAXPATHLEN];
|
||||
int maxfiles;
|
||||
extern int screenheight;
|
||||
extern unsigned long ARAM_ROMSIZE;
|
||||
unsigned long ROMSize = 0;
|
||||
|
||||
int havedir = -1;
|
||||
extern u64 dvddir;
|
||||
extern int dvddirlength;
|
||||
|
||||
int hasloaded = 0;
|
||||
|
||||
// Global file entry table
|
||||
FILEENTRIES filelist[MAXFILES];
|
||||
|
||||
@ -389,23 +387,22 @@ int FileSelector (int method)
|
||||
{
|
||||
case METHOD_SD:
|
||||
case METHOD_USB:
|
||||
ARAM_ROMSIZE = LoadFATFile ((char *)Memory.ROM, 0);
|
||||
ROMSize = LoadFATFile ((char *)Memory.ROM, 0);
|
||||
break;
|
||||
|
||||
case METHOD_DVD:
|
||||
dvddir = filelist[selection].offset;
|
||||
dvddirlength = filelist[selection].length;
|
||||
ARAM_ROMSIZE = LoadDVDFile (Memory.ROM, 0);
|
||||
ROMSize = LoadDVDFile (Memory.ROM, 0);
|
||||
break;
|
||||
|
||||
case METHOD_SMB:
|
||||
ARAM_ROMSIZE = LoadSMBFile ((char *)Memory.ROM, 0);
|
||||
ROMSize = LoadSMBFile ((char *)Memory.ROM, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ARAM_ROMSIZE > 0)
|
||||
if (ROMSize > 0)
|
||||
{
|
||||
hasloaded = 1; // indicator for memmap.cpp
|
||||
Memory.LoadROM ("BLANK.SMC");
|
||||
Memory.LoadSRAM ("BLANK");
|
||||
haverom = 1;
|
||||
|
@ -36,6 +36,7 @@ extern int offset;
|
||||
extern int selection;
|
||||
extern char currentdir[MAXPATHLEN];
|
||||
extern int maxfiles;
|
||||
extern unsigned long ROMSize;
|
||||
|
||||
void AllocSaveBuffer();
|
||||
void FreeSaveBuffer();
|
||||
|
@ -39,7 +39,6 @@ extern "C" {
|
||||
#include "cheats.h"
|
||||
|
||||
#include "snes9xGX.h"
|
||||
#include "aram.h"
|
||||
#include "video.h"
|
||||
#include "filesel.h"
|
||||
#include "unzip.h"
|
||||
@ -61,7 +60,6 @@ extern void DrawMenu (char items[][50], char *title, int maxitems, int selected,
|
||||
extern SCheatData Cheat;
|
||||
|
||||
extern int menu;
|
||||
extern unsigned long ARAM_ROMSIZE;
|
||||
|
||||
#define SOFTRESET_ADR ((volatile u32*)0xCC003024)
|
||||
|
||||
@ -1053,7 +1051,7 @@ MainMenu (int selectedMenu)
|
||||
int ret;
|
||||
|
||||
// disable game-specific menu items if a ROM isn't loaded
|
||||
if ( ARAM_ROMSIZE == 0 )
|
||||
if (ROMSize == 0)
|
||||
menuitems[2][0] = '\0';
|
||||
else
|
||||
sprintf (menuitems[2], "Game Menu");
|
||||
|
@ -61,7 +61,6 @@ extern "C" {
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
unsigned long ARAM_ROMSIZE = 0;
|
||||
int ConfigRequested = 0;
|
||||
FILE* debughandle;
|
||||
|
||||
@ -197,12 +196,6 @@ emulate ()
|
||||
* 7. Initialise Snes9x/GC Sound System
|
||||
* 8. Initialise Snes9x Graphics subsystem
|
||||
* 9. Let's Party!
|
||||
*
|
||||
* The SNES ROM is delivered from ARAM. (AR_SNESROM)
|
||||
* Any method of loading a ROM - RAM, DVD, SMB, SDCard, etc
|
||||
* MUST place the unpacked ROM at this location.
|
||||
* This provides a single consistent interface in memmap.cpp.
|
||||
* Refer to that file if you need to change it.
|
||||
***************************************************************************/
|
||||
int
|
||||
main ()
|
||||
@ -233,15 +226,28 @@ main ()
|
||||
// GC Audio RAM (for ROM and backdrop storage)
|
||||
AR_Init (NULL, 0);
|
||||
|
||||
// GameCube only - Injected ROM
|
||||
// Before going any further, let's copy any injected ROM image
|
||||
// We'll put it in ARAM for safe storage
|
||||
|
||||
#ifdef HW_DOL
|
||||
int *romptr = (int *) 0x81000000; // location of injected rom
|
||||
|
||||
if (memcmp ((char *) romptr, "SNESROM0", 8) == 0)
|
||||
{
|
||||
ARAM_ROMSIZE = romptr[2];
|
||||
romptr = (int *) 0x81000020;
|
||||
ARAMPut ((char *) romptr, (char *) AR_SNESROM, ARAM_ROMSIZE);
|
||||
ROMSize = romptr[2];
|
||||
|
||||
if(ROMSize > (1024*128) && ROMSize < (1024*1024*8))
|
||||
{
|
||||
romptr = (int *) 0x81000020;
|
||||
ARAMPut ((char *) romptr, (char *) AR_SNESROM, ROMSize);
|
||||
}
|
||||
else // not a valid ROM size
|
||||
{
|
||||
ROMSize = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Initialise freetype font system
|
||||
if (FT_Init ())
|
||||
@ -300,23 +306,29 @@ main ()
|
||||
selectedMenu = 1; // change to preferences menu
|
||||
}
|
||||
|
||||
// No appended ROM, so get the user to load one
|
||||
if (ARAM_ROMSIZE == 0)
|
||||
// GameCube only - Injected ROM
|
||||
// Everything's been initialized, we can copy our ROM back
|
||||
// from ARAM into main memory
|
||||
|
||||
#ifdef HW_DOL
|
||||
if(ROMSize > 0)
|
||||
{
|
||||
while (ARAM_ROMSIZE == 0)
|
||||
{
|
||||
MainMenu (selectedMenu);
|
||||
}
|
||||
ARAMFetchSlow( (char *)Memory.ROM, (char *)AR_SNESROM, ROMSize);
|
||||
Memory.LoadROM ("BLANK.SMC");
|
||||
Memory.LoadSRAM ("BLANK");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
// Get the user to load a ROM
|
||||
while (ROMSize <= 0)
|
||||
{
|
||||
// Load ROM
|
||||
save_flags = CPU.Flags;
|
||||
if (!Memory.LoadROM ("VIRTUAL.ROM"))
|
||||
while (1);
|
||||
CPU.Flags = save_flags;
|
||||
MainMenu (selectedMenu);
|
||||
}
|
||||
|
||||
// Load ROM
|
||||
save_flags = CPU.Flags;
|
||||
CPU.Flags = save_flags;
|
||||
|
||||
// Emulate
|
||||
emulate ();
|
||||
|
||||
|
@ -27,8 +27,6 @@
|
||||
/*** Snes9x GFX Buffer ***/
|
||||
static unsigned char snes9xgfx[1024 * 512 * 2];
|
||||
|
||||
/*** Memory ROM Loading ***/
|
||||
extern unsigned long ARAM_ROMSIZE;
|
||||
extern unsigned int SMBTimer;
|
||||
|
||||
/*** 2D Video ***/
|
||||
|
@ -196,11 +196,8 @@
|
||||
#include "cheats.h"
|
||||
#else
|
||||
#include <gccore.h>
|
||||
#include "aram.h" /*** Nintendo GameCube ARAM loader.
|
||||
FileLoader requires that the ROM is preloaded in ARAM first
|
||||
***/
|
||||
extern unsigned long ARAM_ROMSIZE;
|
||||
extern int hasloaded;
|
||||
|
||||
extern unsigned long ROMSize;
|
||||
#endif
|
||||
|
||||
#include "controls.h"
|
||||
@ -1139,30 +1136,17 @@ uint32 CMemory::FileLoader (uint8 *buffer, const char *filename, int32 maxsize)
|
||||
}
|
||||
|
||||
#else
|
||||
//#include "ftfont.h"
|
||||
/*** Nintendo Gamecube ARAM ROM File Loader
|
||||
This is simply a modified version of FILE_DEFAULT, which uses
|
||||
the ARAM as temporary ROM storage.
|
||||
|
||||
NB: Make sure ARAM_ROMSIZE is correct! All hell ensues if you don't
|
||||
/*** Nintendo Wii/Gamecube ROM File Loader
|
||||
By now we've already loaded the ROM into main memory
|
||||
This is simply a modified version of FILE_DEFAULT
|
||||
***/
|
||||
HeaderCount = 0;
|
||||
uint8 *ptr = buffer;
|
||||
|
||||
long unsigned int size = 0;
|
||||
uint32 ARAM_max = maxsize + 0x200 - (ptr - buffer);
|
||||
size = ARAM_ROMSIZE;
|
||||
|
||||
if ( size > ARAM_max )
|
||||
size = ARAM_max;
|
||||
|
||||
if ( hasloaded == 0 )
|
||||
ARAMFetchSlow( (char *)ptr, (char *)AR_SNESROM, size );
|
||||
uint32 size = ROMSize;
|
||||
|
||||
size = HeaderRemove(size, HeaderCount, ptr);
|
||||
ptr += size;
|
||||
totalSize += size;
|
||||
|
||||
#endif
|
||||
if (HeaderCount == 0)
|
||||
S9xMessage(S9X_INFO, S9X_HEADERS_INFO, "No ROM file header found.");
|
||||
|
Loading…
Reference in New Issue
Block a user