July 24, 2008 update by theinternetftw

This commit is contained in:
dborth 2008-09-14 20:59:03 +00:00
parent 5a65f55992
commit 9644c251ef
5 changed files with 841 additions and 585 deletions

View File

@ -38,13 +38,13 @@ bool speedup = false;
bool synchronize = true; bool synchronize = true;
bool cpuDisableSfx = false; bool cpuDisableSfx = false;
bool cpuIsMultiBoot = false; bool cpuIsMultiBoot = false;
bool parseDebug = true; bool parseDebug = false;
int layerSettings = 0xff00; int layerSettings = 0xff00;
int layerEnable = 0xff00; int layerEnable = 0xff00;
bool speedHack = false; bool speedHack = false;
int cpuSaveType = 0; int cpuSaveType = 0;
bool cpuEnhancedDetection = true; bool cpuEnhancedDetection = true;
bool cheatsEnabled = true; bool cheatsEnabled = false;
u8 *bios = NULL; u8 *bios = NULL;
u8 *rom = NULL; u8 *rom = NULL;

View File

@ -103,7 +103,6 @@ NGCPad()
{ {
float mag,ang; float mag,ang;
int b = wpad->exp.classic.btns; int b = wpad->exp.classic.btns;
/* Stolen Shamelessly out of Falco's unofficial SNES9x update */
ang = wpad->exp.classic.ljs.ang; ang = wpad->exp.classic.ljs.ang;
mag = wpad->exp.classic.ljs.mag; mag = wpad->exp.classic.ljs.mag;
@ -116,7 +115,7 @@ NGCPad()
res |= VBA_DOWN; res |= VBA_DOWN;
if (ang > 203.5 & ang <= 337.5) if (ang > 203.5 & ang <= 337.5)
res |= VBA_LEFT; res |= VBA_LEFT;
} }
int x_s = 0; //getStickValue(&wpad.exp.classic.ljs, STICK_X, 127); int x_s = 0; //getStickValue(&wpad.exp.classic.ljs, STICK_X, 127);
int y_s = 0; //getStickValue(&wpad.exp.classic.ljs, STICK_Y, 127); int y_s = 0; //getStickValue(&wpad.exp.classic.ljs, STICK_Y, 127);
@ -155,14 +154,13 @@ NGCPad()
} }
//user needs a GC remote //user needs a GC remote
else PAD_ScanPads();
{ p = PAD_ButtonsHeld(0);
p = PAD_ButtonsHeld(0);
x = PAD_StickX(0); x = PAD_StickX(0);
y = PAD_StickY(0); y = PAD_StickY(0);
if (x * x + y * y > padcal * padcal) if (x * x + y * y > padcal * padcal)
{ {
if (x > 0 && y == 0) if (x > 0 && y == 0)
res |= VBA_RIGHT; res |= VBA_RIGHT;
if (x < 0 && y == 0) if (x < 0 && y == 0)
res |= VBA_LEFT; res |= VBA_LEFT;
@ -223,7 +221,7 @@ NGCPad()
if((p & PAD_BUTTON_X) && (p & PAD_BUTTON_Y)) if((p & PAD_BUTTON_X) && (p & PAD_BUTTON_Y))
menuCalled = 1; menuCalled = 1;
}
#endif #endif
#ifdef GC_BUILD #ifdef GC_BUILD

View File

@ -44,7 +44,7 @@ static Mtx view;
static int vwidth, vheight, oldvwidth, oldvheight; static int vwidth, vheight, oldvwidth, oldvheight;
#define HASPECT 80 #define HASPECT 80
#define VASPECT 60 #define VASPECT 45
/* New texture based scaler */ /* New texture based scaler */
typedef struct tagcamera typedef struct tagcamera
@ -132,11 +132,11 @@ void GX_Start(int width, int height, int haspect, int vaspect)
{ {
Mtx p; Mtx p;
/*** Set new aspect ***/ /*** Set new aspect (now with crap AR hack!) ***/
square[0] = square[9] = -haspect; square[0] = square[9] = (-haspect - 7);
square[3] = square[6] = haspect; square[3] = square[6] = (haspect + 7);
square[1] = square[4] = vaspect; square[1] = square[4] = (vaspect + 7);
square[7] = square[10] = -vaspect; square[7] = square[10] = (-vaspect - 7);
/*** Allocate 32byte aligned texture memory ***/ /*** Allocate 32byte aligned texture memory ***/
texturesize = (width * height) * 2; texturesize = (width * height) * 2;

View File

@ -24,8 +24,8 @@ extern int isWiimoteAvailable;
void setup_controllers() void setup_controllers()
{ /* Doesn't work, either always returns { /* Doesn't work, either always returns
WiimoteAvailable or switches REALLY fast WiimoteAvailable only or apparently switches
between the two. WTF. REALLY fast between the two. WTF.
WPAD_ScanPads(); WPAD_ScanPads();
WPADData pad; WPADData pad;
@ -69,6 +69,7 @@ extern "C"
{ {
#include "gx_supp.h" #include "gx_supp.h"
#include "tbtime.h" #include "tbtime.h"
#include "sdfileio.h"
} }
/** VBA **/ /** VBA **/
@ -110,10 +111,13 @@ int srcHeight = 0;
int destWidth = 0; int destWidth = 0;
int destHeight = 0; int destHeight = 0;
int srcPitch = 0; int srcPitch = 0;
int saveExists = 0;
extern int menuCalled; extern int menuCalled;
#define WITHGX 1 #define WITHGX 1
#define DEBUGON 0 #define DEBUGON 0
#if DEBUGON #if DEBUGON
const char *dbg_local_ip = "192.168.1.32"; const char *dbg_local_ip = "192.168.1.32";
const char *dbg_netmask = "255.255.255.0"; const char *dbg_netmask = "255.255.255.0";
@ -133,12 +137,7 @@ void (*dbgOutput)(char *, u32) = debuggerOutput;
/** /**
* Locals * Locals
*/ */
extern "C"
{
void SDInit( void );
int gen_getdir( char *whichdir );
};
extern char *direntries[1000];
extern char *MENU_GetLoadFile( char *whichdir ); extern char *MENU_GetLoadFile( char *whichdir );
extern void MENU_DrawString( int x, int y, char *msg, int style ); extern void MENU_DrawString( int x, int y, char *msg, int style );
@ -170,6 +169,13 @@ void doScan(u32 blah)
PAD_ScanPads(); PAD_ScanPads();
} }
int throttle = 100;
u32 throttleLastTime = 0;
char filename[1024]; //rom file name
char batfilename[1024]; //battery save file name
char statename[1024]; //savestate file name
/**************************************************************************** /****************************************************************************
* Initialise Video * Initialise Video
* *
@ -192,6 +198,7 @@ Initialise (void)
#ifdef WII_BUILD #ifdef WII_BUILD
CONF_Init(); CONF_Init();
WPAD_Init(); WPAD_Init();
setup_controllers();
#endif #endif
vmode = VIDEO_GetPreferredMode(NULL); vmode = VIDEO_GetPreferredMode(NULL);
@ -223,11 +230,11 @@ Initialise (void)
/*** Get the PAD status updated by libogc ***/ /*** Get the PAD status updated by libogc ***/
VIDEO_SetPreRetraceCallback (doScan); VIDEO_SetPreRetraceCallback (doScan);
VIDEO_SetBlack (0); VIDEO_SetBlack (0);
/*
int i; int i;
u32 *vreg = (u32 *)0xCC002000; u32 *vreg = (u32 *)0xCC002000;
for ( i = 0; i < 64; i++ ) for ( i = 0; i < 64; i++ )
vreg[i] = vpal60[i]; vreg[i] = vpal60[i]; */
/*** Update the video for next vblank ***/ /*** Update the video for next vblank ***/
VIDEO_Flush (); VIDEO_Flush ();
@ -240,8 +247,18 @@ Initialise (void)
void systemMessage(int num, const char *msg, ...) void systemMessage(int num, const char *msg, ...)
{ {
/*** For now ... do nothing ***/ /*** For now ... do nothing ***/
} }
void GC_Sleep(u32 dwMiliseconds)
{
int nVBlanks = (dwMiliseconds / 16);
while (nVBlanks-- > 0)
{
VIDEO_WaitVSync();
}
}
void systemFrame() void systemFrame()
{} {}
@ -252,48 +269,10 @@ void systemShowSpeed(int speed)
{} {}
static u32 autoFrameSkipLastTime = 0; static u32 autoFrameSkipLastTime = 0;
static int frameskipadjust = 0; static int frameskipadjust = 0;
void system1Frame(int rate)
void write_save()
{ {
/* if ( cartridgeType == 1 ) emulator.emuWriteBattery(batfilename);
return;
u32 time = systemGetClock();
u32 diff = time - autoFrameSkipLastTime;
int speed = 100;
if(diff)
speed = (1000000/rate)/diff;
char temp[512];
sprintf(temp,"Speed: %i",speed);
MENU_DrawString( -1, 450,temp , 1 );
if(speed >= 98)
{
frameskipadjust++;
if(frameskipadjust >= 3)
{
frameskipadjust=0;
if(systemFrameSkip > 0)
systemFrameSkip--;
}
}
else
{
if(speed < 80)
frameskipadjust -= (90 - speed)/5;
else if(systemFrameSkip < 9)
frameskipadjust--;
if(frameskipadjust <= -2)
{
frameskipadjust += 2;
if(systemFrameSkip < 9)
systemFrameSkip++;
}
}
autoFrameSkipLastTime = time;
*/
} }
void system10Frames(int rate) void system10Frames(int rate)
@ -307,10 +286,10 @@ void system10Frames(int rate)
if(diff) if(diff)
speed = (1000000/rate)/diff; speed = (1000000/rate)/diff;
/* char temp[512]; /* char temp[512];
sprintf(temp,"Speed: %i",speed); sprintf(temp,"Speed: %i",speed);
MENU_DrawString( -1, 450,temp , 1 ); MENU_DrawString( -1, 450,temp , 1 ); */
*/
if(speed >= 98) if(speed >= 98)
{ {
frameskipadjust++; frameskipadjust++;
@ -336,10 +315,30 @@ void system10Frames(int rate)
systemFrameSkip++; systemFrameSkip++;
} }
} }
autoFrameSkipLastTime = time;
if ( cartridgeType == 1 )
return;
/*
if(systemSaveUpdateCounter) {
char temp[512];
sprintf(temp,"Writing Save To Disk");
MENU_DrawString( -1, 450,temp , 1 );
} */
if(systemSaveUpdateCounter) {
if(--systemSaveUpdateCounter <= SYSTEM_SAVE_NOT_UPDATED) {
write_save();
systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
}
}
autoFrameSkipLastTime = time;
} }
void systemUpdateMotionSensor() void systemUpdateMotionSensor()
{} {}
@ -445,7 +444,9 @@ void systemDrawScreen()
GX_Render( srcWidth, srcHeight, pix, srcPitch ); GX_Render( srcWidth, srcHeight, pix, srcPitch );
#endif #endif
#ifdef WII_BUILD #ifdef WII_BUILD
VIDEO_WaitVSync (); VIDEO_WaitVSync ();
#endif #endif
#ifdef GC_BUILD #ifdef GC_BUILD
if ( cartridgeType == 1 ) if ( cartridgeType == 1 )
@ -470,10 +471,6 @@ int ShowDir( char *whichdir )
while(1); while(1);
} }
char filename[1024]; //rom file name
char batfilename[1024]; //battery save file name
/* /*
Asks user to select a ROM Asks user to select a ROM
*/ */
@ -490,11 +487,10 @@ void chooseRom() {
strncat(batfilename,fname,strlen(fname)-4); strncat(batfilename,fname,strlen(fname)-4);
strcat(batfilename,".SAV"); strcat(batfilename,".SAV");
} // construct savestate name
strcpy(statename, "/VBA/SAVES/");
void askSound() { strncat(statename,fname,strlen(fname)-4);
soundOffFlag = false; strcat(statename,".SGM");
soundLowPass = true;
} }
/* /*
@ -502,33 +498,63 @@ void askSound() {
If it does, it prompts the user to load it or not If it does, it prompts the user to load it or not
*/ */
void checkSave() { void checkSave() {
FILE* f = gen_fopen(statename, "rb");
} if (f != NULL) {
void GC_Sleep(u32 dwMiliseconds) gen_fclose(f);
{
int nVBlanks = (dwMiliseconds / 16);
while (nVBlanks-- > 0)
{
VIDEO_WaitVSync();
}
}
void write_save()
{
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], COLOR_BLACK);
MENU_DrawString( -1, 250,"Attempting to Save data ..." , 1 );
whichfb^=1; whichfb^=1;
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], COLOR_BLACK); VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], COLOR_BLACK);
if(emulator.emuWriteBattery(batfilename) == true) MENU_DrawString( 140, 50,"Quick Save State Exists" , 1 );
MENU_DrawString( -1, 250,"Save OK!" , 1 ); MENU_DrawString( 140, 80,"Do you wish to load it?" , 1 );
else MENU_DrawString( -1, 170,"(L) or (+) YES" , 1 );
MENU_DrawString( -1, 250,"Either no data to save yet or error!" , 1 ); MENU_DrawString( -1, 200,"(R) or (-) NO" , 1 );
VIDEO_WaitVSync (); VIDEO_WaitVSync ();
VIDEO_SetNextFramebuffer(xfb[whichfb]); VIDEO_SetNextFramebuffer(xfb[whichfb]);
VIDEO_Flush(); VIDEO_Flush();
GC_Sleep(2000); VIDEO_WaitVSync();
while(1) {
WPADData *wpad;
WPAD_ScanPads();
wpad = WPAD_Data(0);
if (isWiimoteAvailable) {
unsigned short b = wpad->btns_h;
if(b & WPAD_BUTTON_PLUS) {
saveExists = 1;
break;
}
if(b & WPAD_BUTTON_MINUS) break;
}
if (isClassicAvailable) {
unsigned short b = wpad->exp.classic.btns;
if(b & CLASSIC_CTRL_BUTTON_PLUS) {
saveExists = 1;
break;
}
if(b & CLASSIC_CTRL_BUTTON_MINUS) break;
}
u16 buttons = PAD_ButtonsHeld(0);
if(buttons & PAD_TRIGGER_R){
break;
}
if(buttons & PAD_TRIGGER_L){
saveExists = 1;
break;
}
}
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], COLOR_BLACK);
VIDEO_WaitVSync ();
VIDEO_SetNextFramebuffer(xfb[whichfb]);
VIDEO_Flush();
VIDEO_WaitVSync();
}
} }
void askSound() {
soundOffFlag = false;
soundLowPass = true;
}
int ingameMenu() { int ingameMenu() {
tb_t start,end; tb_t start,end;
mftb(&start); mftb(&start);
@ -542,16 +568,16 @@ int ingameMenu() {
#ifdef GC_BUILD #ifdef GC_BUILD
MENU_DrawString( 140, 80,"Nintendo Gamecube Port" , 1 ); MENU_DrawString( 140, 80,"Nintendo Gamecube Port" , 1 );
MENU_DrawString( -1, 170,"(B) - Resume play" , 1 ); MENU_DrawString( -1, 170,"(B) - Resume play" , 1 );
MENU_DrawString( -1, 200,"(L) - Write save" , 1 ); MENU_DrawString( -1, 200,"(L) - Write Quicksave" , 1 );
MENU_DrawString( -1, 230,"(R) - Reset game" , 1 ); MENU_DrawString( -1, 230,"(R) - Reset game" , 1 );
MENU_DrawString( -1, 320,"(Z) - Return to loader" , 1 ); MENU_DrawString( -1, 320,"(Z) - Return to loader" , 1 );
#endif #endif
#ifdef WII_BUILD #ifdef WII_BUILD
MENU_DrawString( 140, 80,"Nintendo Wii Port" , 1 ); MENU_DrawString( 140, 80,"Nintendo Wii Port" , 1 );
MENU_DrawString( -1, 170,"(B) or (Home) - Resume play" , 1 ); MENU_DrawString( -1, 170,"(B) or (Home) - Resume play" , 1 );
MENU_DrawString( -1, 200,"(L) or (+) - Write save" , 1 ); MENU_DrawString( -1, 200,"(L) or (+) - Write Quicksave" , 1 );
MENU_DrawString( -1, 230,"(R) or (-) - Reset game" , 1 ); MENU_DrawString( -1, 230,"(R) or (-) - Reset game" , 1 );
MENU_DrawString( -1, 320,"(Z) or (A+B) - Return to loader" , 1 ); MENU_DrawString( -1, 320,"(Z) or (A+B) - Return to loader" , 1 );
#endif #endif
sprintf(temp,"Frameskip: Auto (Currently %i)",systemFrameSkip); sprintf(temp,"Frameskip: Auto (Currently %i)",systemFrameSkip);
@ -559,95 +585,103 @@ int ingameMenu() {
VIDEO_WaitVSync (); VIDEO_WaitVSync ();
VIDEO_SetNextFramebuffer(xfb[whichfb]); VIDEO_SetNextFramebuffer(xfb[whichfb]);
VIDEO_Flush(); VIDEO_Flush();
VIDEO_WaitVSync(); VIDEO_WaitVSync();
//wait for user to let go of menu calling button //wait for user to let go of menu calling button
do{buttons = PAD_ButtonsHeld(0);}while((buttons & PAD_BUTTON_A)||(buttons & PAD_BUTTON_B)); do{buttons = PAD_ButtonsHeld(0);}
while((buttons & PAD_BUTTON_A)||(buttons & PAD_BUTTON_B));
//wait for user to let go of home button //wait for user to let go of home button
#ifdef WII_BUILD #ifdef WII_BUILD
WPADData *wpad; WPADData *wpad;
int btn; int btn;
if(isWiimoteAvailable) if(isWiimoteAvailable)
do{WPAD_ScanPads(); wpad = WPAD_Data(0); btn = wpad->btns_h;}while(btn & WPAD_BUTTON_HOME); do{WPAD_ScanPads(); wpad = WPAD_Data(0); btn = wpad->btns_h;}
while(btn & WPAD_BUTTON_HOME);
if(isClassicAvailable) if(isClassicAvailable)
do{WPAD_ScanPads(); wpad = WPAD_Data(0); btn = wpad->exp.classic.btns;}while(btn & CLASSIC_CTRL_BUTTON_HOME); do{WPAD_ScanPads(); wpad = WPAD_Data(0); btn = wpad->exp.classic.btns;}
while(btn & CLASSIC_CTRL_BUTTON_HOME);
#endif #endif
while(1){ while(1){
#ifdef WII_BUILD #ifdef WII_BUILD
WPADData *wpad; WPADData *wpad;
WPAD_ScanPads(); WPAD_ScanPads();
wpad = WPAD_Data(0); wpad = WPAD_Data(0);
if (isWiimoteAvailable) if (isWiimoteAvailable)
{ {
unsigned short b = wpad->btns_h; unsigned short b = wpad->btns_h;
if(b & WPAD_BUTTON_MINUS){ //Reset game if(b & WPAD_BUTTON_MINUS){ //Reset game
emulator.emuReset(); emulator.emuReset();
break; break;
} }
if(b & WPAD_BUTTON_PLUS) { //Write save if(b & WPAD_BUTTON_PLUS) { //Write save
write_save(); emulator.emuWriteState(statename);
break; GC_Sleep(1500);
} break;
}
if((b & WPAD_BUTTON_A) && (b & WPAD_BUTTON_B)) { //Return to loader if((b & WPAD_BUTTON_A) && (b & WPAD_BUTTON_B)) { //Return to loader
void (*reload)() = (void(*)())0x80001800; void (*reload)() = (void(*)())0x80001800;
reload(); reload();
} }
if(b & WPAD_BUTTON_HOME) { //Resume play if(b & WPAD_BUTTON_HOME) { //Resume play
do{WPAD_ScanPads(); wpad = WPAD_Data(0); b = wpad->btns_h;}while(b & WPAD_BUTTON_HOME); //wait for home do{WPAD_ScanPads(); wpad = WPAD_Data(0); b = wpad->btns_h;}
break; while(b & WPAD_BUTTON_HOME); //wait for home
} break;
} }
if (isClassicAvailable) /* if(b & WPAD_BUTTON_2) { //back to menu
{ INSERT BACK-TO-MENU HERE
int b = wpad->exp.classic.btns; } */
if(b & CLASSIC_CTRL_BUTTON_MINUS){ //Reset game }
emulator.emuReset(); if (isClassicAvailable)
break; {
} int b = wpad->exp.classic.btns;
if(b & CLASSIC_CTRL_BUTTON_PLUS) { //Write save if(b & CLASSIC_CTRL_BUTTON_MINUS){ //Reset game
write_save(); emulator.emuReset();
break; break;
} }
if(b & CLASSIC_CTRL_BUTTON_PLUS) { //Write save
emulator.emuWriteState(statename);
break;
}
if((b & CLASSIC_CTRL_BUTTON_A) && (b & CLASSIC_CTRL_BUTTON_B)) { //Return to loader if((b & CLASSIC_CTRL_BUTTON_A) && (b & CLASSIC_CTRL_BUTTON_B)) { //Return to loader
void (*reload)() = (void(*)())0x80001800; void (*reload)() = (void(*)())0x80001800;
reload(); reload();
} }
if(b & CLASSIC_CTRL_BUTTON_HOME) { //Resume play if(b & CLASSIC_CTRL_BUTTON_HOME) { //Resume play
do{WPAD_ScanPads(); wpad = WPAD_Data(0); b = wpad->exp.classic.btns;} do{WPAD_ScanPads(); wpad = WPAD_Data(0); b = wpad->exp.classic.btns;}
while(b & CLASSIC_CTRL_BUTTON_HOME); //wait for home button while(b & CLASSIC_CTRL_BUTTON_HOME); //wait for home button
break; break;
} }
} }
#endif #endif
u16 buttons = PAD_ButtonsHeld(0); //grab pad buttons u16 buttons = PAD_ButtonsHeld(0); //grab pad buttons
if(buttons & PAD_TRIGGER_R){ //Reset game if(buttons & PAD_TRIGGER_R){ //Reset game
emulator.emuReset(); emulator.emuReset();
break; break;
} }
if(buttons & PAD_TRIGGER_L) { //Write save if(buttons & PAD_TRIGGER_L) { //Write save
write_save(); emulator.emuWriteState(statename);
break; break;
} }
if(buttons & PAD_TRIGGER_Z) { //Return to loader if(buttons & PAD_TRIGGER_Z) { //Return to loader
void (*reload)() = (void(*)())0x80001800; void (*reload)() = (void(*)())0x80001800;
reload(); reload();
} }
if(buttons & PAD_BUTTON_B) { //Resume play if(buttons & PAD_BUTTON_B) { //Resume play
break; break;
} }
} }
AudioPlayer(); AudioPlayer();
mftb(&end); mftb(&end);
loadtimeradjust += tb_diff_msec(&end, &start); loadtimeradjust += tb_diff_msec(&end, &start);
return 0; return 0;
} }
/**************************************************************************** /****************************************************************************
* main * main
* *
@ -668,6 +702,7 @@ int main()
/** Kick off SD Lib **/ /** Kick off SD Lib **/
SDInit(); SDInit();
/** Build GBPalette **/ /** Build GBPalette **/
for( i = 0; i < 24; ) for( i = 0; i < 24; )
{ {
@ -688,9 +723,6 @@ int main()
(((i & 0x7c00) >> 10) << systemBlueShift); (((i & 0x7c00) >> 10) << systemBlueShift);
} }
#ifdef WII_BUILD
setup_controllers();
#endif
//Main loop //Main loop
while(1) { while(1) {
cartridgeType = 0; cartridgeType = 0;
@ -701,14 +733,14 @@ int main()
srcPitch = 0; srcPitch = 0;
chooseRom(); chooseRom();
//checkSave(); checkSave();
IMAGE_TYPE type = utilFindType(filename); IMAGE_TYPE type = utilFindType(filename);
switch( type ) switch( type )
{ {
case IMAGE_GBA: case IMAGE_GBA:
// printf("GameBoy Advance Image\n"); printf("GameBoy Advance Image\n");
cartridgeType = 2; cartridgeType = 2;
emulator = GBASystem; emulator = GBASystem;
srcWidth = 240; srcWidth = 240;
@ -724,7 +756,7 @@ int main()
break; break;
case IMAGE_GB: case IMAGE_GB:
// printf("GameBoy Image\n"); printf("GameBoy Image\n");
cartridgeType = 1; cartridgeType = 1;
emulator = GBSystem; emulator = GBSystem;
srcWidth = 160; srcWidth = 160;
@ -739,7 +771,7 @@ int main()
break; break;
default: default:
// printf("Unknown Image\n"); printf("Unknown Image\n");
while(1); while(1);
break; break;
@ -756,6 +788,8 @@ int main()
GX_Start( srcWidth, srcHeight, hAspect, vAspect ); GX_Start( srcWidth, srcHeight, hAspect, vAspect );
#endif #endif
if ( cartridgeType == 1 ) if ( cartridgeType == 1 )
{ {
gbSoundReset(); gbSoundReset();
@ -768,6 +802,12 @@ int main()
CPUReset(); CPUReset();
} }
emulator.emuReadBattery(batfilename);
if (saveExists){
emulator.emuReadState(statename);
saveExists = 0;
}
soundVolume = 0; soundVolume = 0;
systemSoundOn = true; systemSoundOn = true;
@ -778,17 +818,15 @@ int main()
/** Start system clock **/ /** Start system clock **/
mftb(&start); mftb(&start);
emulator.emuReadBattery(batfilename);
while ( emulating ) while ( emulating )
{ {
emulator.emuMain(emulator.emuCount); emulator.emuMain(emulator.emuCount);
if(menuCalled) { if(menuCalled) {
if(ingameMenu()) if(ingameMenu())
break; break;
menuCalled = 0; menuCalled = 0;
} }
} }
} }
/** Never **/ /** Never **/

220
src/zutil.h Normal file
View File

@ -0,0 +1,220 @@
/* zutil.h -- internal interface and configuration of the compression library
* Copyright (C) 1995-1998 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
/* @(#) $Id: zutil.h,v 1.2 2004/01/17 23:07:32 kxu Exp $ */
#ifndef _Z_UTIL_H
#define _Z_UTIL_H
#include <zlib.h>
#ifdef STDC
# include <stddef.h>
# include <string.h>
# include <stdlib.h>
#endif
#ifdef NO_ERRNO_H
extern int errno;
#else
# include <errno.h>
#endif
#ifndef local
# define local static
#endif
/* compile with -Dlocal if your debugger can't find static symbols */
typedef unsigned char uch;
typedef uch FAR uchf;
typedef unsigned short ush;
typedef ush FAR ushf;
typedef unsigned long ulg;
extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
#define ERR_RETURN(strm,err) \
return (strm->msg = (char*)ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
/* common constants */
#ifndef DEF_WBITS
# define DEF_WBITS MAX_WBITS
#endif
/* default windowBits for decompression. MAX_WBITS is for compression only */
#if MAX_MEM_LEVEL >= 8
# define DEF_MEM_LEVEL 8
#else
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
#endif
/* default memLevel */
#define STORED_BLOCK 0
#define STATIC_TREES 1
#define DYN_TREES 2
/* The three kinds of block type */
#define MIN_MATCH 3
#define MAX_MATCH 258
/* The minimum and maximum match lengths */
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
/* target dependencies */
#ifdef MSDOS
# define OS_CODE 0x00
# if defined(__TURBOC__) || defined(__BORLANDC__)
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block );
void *_Cdecl farmalloc( unsigned long nbytes );
# else
# include <alloc.h>
# endif
# else /* MSC or DJGPP */
# include <malloc.h>
# endif
#endif
#ifdef OS2
# define OS_CODE 0x06
#endif
#ifdef WIN32 /* Window 95 & Windows NT */
# define OS_CODE 0x0b
#endif
#if defined(VAXC) || defined(VMS)
# define OS_CODE 0x02
# define F_OPEN(name, mode) \
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
#endif
#ifdef AMIGA
# define OS_CODE 0x01
#endif
#if defined(ATARI) || defined(atarist)
# define OS_CODE 0x05
#endif
#if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 0x07
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fdopen */
# else
# ifndef fdopen
# define fdopen(fd,mode) NULL /* No fdopen() */
# endif
# endif
#endif
#ifdef __50SERIES /* Prime/PRIMOS */
# define OS_CODE 0x0F
#endif
#ifdef TOPS20
# define OS_CODE 0x0a
#endif
#if defined(_BEOS_) || defined(RISCOS)
# define fdopen(fd,mode) NULL /* No fdopen() */
#endif
#if (defined(_MSC_VER) && (_MSC_VER > 600))
# define fdopen(fd,type) _fdopen(fd,type)
#endif
/* Common defaults */
#ifndef OS_CODE
# define OS_CODE 0x03 /* assume Unix */
#endif
#ifndef F_OPEN
# define F_OPEN(name, mode) fopen((name), (mode))
#endif
/* functions */
#ifdef HAVE_STRERROR
extern char *strerror OF((int));
# define zstrerror(errnum) strerror(errnum)
#else
# define zstrerror(errnum) ""
#endif
#if defined(pyr)
# define NO_MEMCPY
#endif
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
/* Use our own functions for small and medium model with MSC <= 5.0.
* You may have to use the same strategy for Borland C (untested).
* The __SC__ check is for Symantec.
*/
# define NO_MEMCPY
#endif
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
# define HAVE_MEMCPY
#endif
#ifdef HAVE_MEMCPY
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
# define zmemcpy _fmemcpy
# define zmemcmp _fmemcmp
# define zmemzero(dest, len) _fmemset(dest, 0, len)
# else
# define zmemcpy memcpy
# define zmemcmp memcmp
# define zmemzero(dest, len) memset(dest, 0, len)
# endif
#else
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
extern void zmemzero OF((Bytef* dest, uInt len));
#endif
/* Diagnostic functions */
#ifdef DEBUG
# include <stdio.h>
extern int z_verbose;
extern void z_error OF((char *m));
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
#else
# define Assert(cond,msg)
# define Trace(x)
# define Tracev(x)
# define Tracevv(x)
# define Tracec(c,x)
# define Tracecv(c,x)
#endif
typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf,
uInt len));
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
void zcfree OF((voidpf opaque, voidpf ptr));
#define ZALLOC(strm, items, size) \
(*((strm)->zalloc))((strm)->opaque, (items), (size))
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
#endif /* _Z_UTIL_H */