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