battery and saves work now, many many other improvements

This commit is contained in:
dborth 2008-09-17 01:54:21 +00:00
parent 10ef70fcdd
commit eff1bf8705
14 changed files with 384 additions and 403 deletions

View File

@ -43,13 +43,12 @@ void MIXER_AddSamples( u8 *sampledata, int len )
do
{
/* Do simple linear interpolate */
// Do simple linear interpolate
dst[head++] = src[fixofs >> 16];
head &= MIXERMASK;
fixofs += fixinc;
}
while( --intlen );
}
/****************************************************************************

View File

@ -17,12 +17,10 @@
#include <string.h>
#ifdef WII_DVD
#ifdef __cplusplus
extern "C" {
#include <di/di.h>
}
#endif
#endif
#include "menudraw.h"
#include "gcunzip.h"

View File

@ -174,12 +174,12 @@ ParseFATdirectory(int method)
int
LoadFATFile (char *filename, int length)
{
char zipbuffer[2048];
/* char zipbuffer[2048];
char filepath[MAXPATHLEN];
FILE *handle;
unsigned char *rbuffer;
u32 size;
*/
/* Check filename length */
if ((strlen(currentdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
sprintf(filepath, "%s/%s",currentdir,filelist[selection].filename);

View File

@ -19,19 +19,16 @@
#include <sys/dir.h>
#ifdef WII_DVD
#ifdef __cplusplus
extern "C" {
#include <di/di.h>
}
#endif
#endif
#include "vba.h"
#include "vbasupport.h"
#include "vmmem.h"
#include "menudraw.h"
#include "video.h"
#include "filesel.h"
#include "fileop.h"
#include "memcardop.h"
#include "input.h"

View File

@ -28,6 +28,7 @@ typedef struct
#define MAXFILES 2000 // Restrict to 2000 files per dir
extern FILEENTRIES filelist[MAXFILES];
extern char ROMFilename[512];
void ClearSaveBuffer ();
int OpenROM (int method);

View File

@ -20,6 +20,8 @@
#include <unistd.h>
#include <wiiuse/wpad.h>
#include "vba.h"
#include "vbasupport.h"
#include "button_mapping.h"
#include "menu.h"
#include "video.h"
@ -44,7 +46,7 @@
// VBA controller buttons
// All other pads are mapped to this
unsigned int vbapadmap[] = {
VBA_BUTTON_A, VBA_BUTTON_B,
VBA_BUTTON_B, VBA_BUTTON_A,
VBA_BUTTON_SELECT, VBA_BUTTON_START,
VBA_UP, VBA_DOWN,
VBA_LEFT, VBA_RIGHT,
@ -53,7 +55,7 @@ unsigned int vbapadmap[] = {
/*** Gamecube controller Padmap ***/
unsigned int gcpadmap[] = {
PAD_BUTTON_A, PAD_BUTTON_B,
PAD_BUTTON_B, PAD_BUTTON_A,
PAD_TRIGGER_Z, PAD_BUTTON_START,
PAD_BUTTON_UP, PAD_BUTTON_DOWN,
PAD_BUTTON_LEFT, PAD_BUTTON_RIGHT,
@ -65,23 +67,23 @@ unsigned int wmpadmap[] = {
WPAD_BUTTON_MINUS, WPAD_BUTTON_PLUS,
WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT,
WPAD_BUTTON_UP, WPAD_BUTTON_DOWN,
0x0000, 0x0000
WPAD_BUTTON_B, WPAD_BUTTON_A
};
/*** Classic Controller Padmap ***/
unsigned int ccpadmap[] = {
WPAD_CLASSIC_BUTTON_A, WPAD_CLASSIC_BUTTON_B,
WPAD_CLASSIC_BUTTON_Y, WPAD_CLASSIC_BUTTON_B,
WPAD_CLASSIC_BUTTON_MINUS, WPAD_CLASSIC_BUTTON_PLUS,
WPAD_CLASSIC_BUTTON_UP, WPAD_CLASSIC_BUTTON_DOWN,
WPAD_CLASSIC_BUTTON_LEFT, WPAD_CLASSIC_BUTTON_RIGHT,
WPAD_CLASSIC_BUTTON_FULL_L, WPAD_CLASSIC_BUTTON_FULL_R
};
/*** Nunchuk + wiimote Padmap ***/
unsigned int ncpadmap[] = { WPAD_BUTTON_A, WPAD_BUTTON_B,
unsigned int ncpadmap[] = {
WPAD_NUNCHUK_BUTTON_C, WPAD_NUNCHUK_BUTTON_Z,
WPAD_BUTTON_MINUS, WPAD_BUTTON_PLUS,
WPAD_BUTTON_2, WPAD_BUTTON_1,
WPAD_BUTTON_UP, WPAD_BUTTON_DOWN,
WPAD_BUTTON_LEFT, WPAD_BUTTON_RIGHT
WPAD_BUTTON_LEFT, WPAD_BUTTON_RIGHT,
WPAD_BUTTON_2, WPAD_BUTTON_1
};
#ifdef HW_RVL
@ -302,12 +304,10 @@ u32 DecodeJoy(unsigned short pad)
}
u32 GetJoy()
{
short i;
int pad = 0;
u32 res = 0;
s8 gc_px = PAD_SubStickX (0);
u32 jp = PAD_ButtonsHeld (0); // gamecube controller button info
#ifdef HW_RVL
s8 wm_sx = WPAD_StickX (0,1);
@ -315,7 +315,7 @@ u32 GetJoy()
#endif
// request to go back to menu
if ((gc_px < -70) || (jp & PAD_BUTTON_START)
if ((gc_px < -70)
#ifdef HW_RVL
|| (wm_pb & WPAD_BUTTON_HOME)
|| (wm_pb & WPAD_CLASSIC_BUTTON_HOME)
@ -323,10 +323,9 @@ u32 GetJoy()
#endif
)
{
/*
if (GCSettings.AutoSave == 1)
{
SaveRAM(GCSettings.SaveMethod, SILENT);
SaveBattery(GCSettings.SaveMethod, SILENT);
}
else if (GCSettings.AutoSave == 2)
{
@ -334,11 +333,10 @@ u32 GetJoy()
}
else if(GCSettings.AutoSave == 3)
{
SaveRAM(GCSettings.SaveMethod, SILENT);
SaveBattery(GCSettings.SaveMethod, SILENT);
SaveState(GCSettings.SaveMethod, SILENT);
}
*/
mainmenu(3);
MainMenu(3);
return 0;
}
else

View File

@ -1,9 +1,7 @@
/****************************************************************************
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 May-June 2007
* Tantric August 2008
* Tantric September 2008
*
* menu.cpp
*
@ -80,17 +78,14 @@ LoadManager ()
int loadROM = OpenROM(GCSettings.LoadMethod);
/***
* check for autoloadsram / freeze
* check for autoload battery / state
***/
if ( loadROM == 1 ) // if ROM was loaded, load the SRAM & settings
if ( loadROM == 1 ) // if ROM was loaded, load the battery / state
{
//if ( GCSettings.AutoLoad == 1 )
// LoadSRAM(GCSettings.SaveMethod, SILENT);
//else if ( GCSettings.AutoLoad == 2 )
// NGCUnfreezeGame (GCSettings.SaveMethod, SILENT);
// setup cheats
//SetupCheats();
if (GCSettings.AutoLoad == 1)
LoadBattery(GCSettings.SaveMethod, SILENT);
else if (GCSettings.AutoLoad == 2)
LoadState(GCSettings.SaveMethod, SILENT);
}
return loadROM;
@ -125,7 +120,20 @@ PreferencesMenu ()
while (quit == 0)
{
// some load/save methods are not implemented - here's where we skip them
// they need to be skipped in the order they were enumerated in snes9xGX.h
// they need to be skipped in the order they were enumerated in vba.h
// skip
if(GCSettings.LoadMethod == METHOD_DVD)
GCSettings.LoadMethod++;
if(GCSettings.LoadMethod == METHOD_SMB)
GCSettings.LoadMethod++;
if(GCSettings.SaveMethod == METHOD_SMB)
GCSettings.SaveMethod++;
if(GCSettings.SaveMethod == METHOD_MC_SLOTA)
GCSettings.SaveMethod++;
if(GCSettings.SaveMethod == METHOD_MC_SLOTB)
GCSettings.SaveMethod++;
// no USB ports on GameCube
#ifndef HW_RVL
@ -200,7 +208,6 @@ PreferencesMenu ()
sprintf (prefmenu[6], "Verify MC Saves %s",
GCSettings.VerifySaves == true ? " ON" : "OFF");
ret = RunMenu (prefmenu, prefmenuCount, (char*)"Preferences", 16);
switch (ret)
@ -302,21 +309,20 @@ GameMenu ()
quit = retval = 1;
break;
case 2: // Load SRAM
//quit = retval = LoadSRAM(GCSettings.SaveMethod, NOTSILENT);
case 2: // Load Battery
quit = retval = LoadBattery(GCSettings.SaveMethod, NOTSILENT);
break;
case 3: // Save SRAM
//SaveSRAM(GCSettings.SaveMethod, NOTSILENT);
case 3: // Save Battery
SaveBattery(GCSettings.SaveMethod, NOTSILENT);
break;
case 4: // Load Freeze
//quit = retval = NGCUnfreezeGame (GCSettings.SaveMethod, NOTSILENT);
case 4: // Load State
quit = retval = LoadState(GCSettings.SaveMethod, NOTSILENT);
break;
case 5: // Save Freeze
//NGCFreezeGame (GCSettings.SaveMethod, NOTSILENT);
//emulator.emuWriteState(statename);
case 5: // Save State
SaveState(GCSettings.SaveMethod, NOTSILENT);
break;
case -1: // Button B
@ -334,10 +340,6 @@ GameMenu ()
/****************************************************************************
* Controller Configuration
*
* Snes9x 1.51 uses a cmd system to work out which button has been pressed.
* Here, I simply move the designated value to the gcpadmaps array, which
* saves on updating the cmd sequences.
***************************************************************************/
u32
GetInput (u16 ctrlr_type)
@ -365,13 +367,7 @@ GetInput (u16 ctrlr_type)
#ifdef HW_RVL
else
{
// if ( WPAD_Probe( 0, &exp_type) == 0) // check wiimote and expansion status (first if wiimote is connected & no errors)
// {
pressed = WPAD_ButtonsHeld (0);
// if (ctrlr_type != CTRLR_WIIMOTE && exp_type != ctrlr_type+1) // if we need input from an expansion, and its not connected...
// pressed = 0;
// }
}
#endif
/*** check for exit sequence (c-stick left OR home button) ***/
@ -429,27 +425,22 @@ GetButtonMap(u16 ctrlr_type, char* btn_name)
DrawMenu(&cfg_text[0], NULL, cfg_text_count, 1); // display text
// while (previous != pressed && pressed == 0); // get two consecutive button presses (which are the same)
// {
// previous = pressed;
// VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
pressed = GetInput(ctrlr_type);
// }
return pressed;
} // end getButtonMap()
int cfg_btns_count = 11;
char cfg_btns_menu[][50] = {
"A - ",
"B - ",
"L TRIG - ",
"R TRIG - ",
"A - ",
"SELECT - ",
"START - ",
"UP - ",
"DOWN - ",
"LEFT - ",
"RIGHT - ",
"L TRIG - ",
"R TRIG - ",
"Return to previous"
};
@ -531,8 +522,6 @@ ConfigureButtons (u16 ctrlr_type)
case 7:
case 8:
case 9:
case 10:
case 11:
/*** Change button map ***/
// wait for input
memset (temp, 0, sizeof(temp));
@ -544,7 +533,7 @@ ConfigureButtons (u16 ctrlr_type)
break;
case -1: /*** Button B ***/
case 12:
case 10:
/*** Return ***/
quit = 1;
break;
@ -634,7 +623,7 @@ char menuitems[][50] = {
};
void
mainmenu (int selectedMenu)
MainMenu (int selectedMenu)
{
tb_t start,end;
mftb(&start);

View File

@ -14,6 +14,6 @@
#define _NGCMENU_
void mainmenu (int selectedMenu);
void MainMenu (int selectedMenu);
#endif

View File

@ -48,12 +48,6 @@ extern int screenheight;
extern unsigned int *xfb[2];
extern int whichfb;
/*** Permanent backdrop ***/
#ifdef HW_RVL
u32 *backdrop;
#else
static u32 *backdrop;
#endif
unsigned int getcolour (u8 r1, u8 g1, u8 b1);
void DrawLineFast( int startx, int endx, int y, u8 r, u8 g, u8 b );
u32 getrgb( u32 ycbr, u32 low );
@ -235,33 +229,23 @@ Credits ()
else
ypos += 32;
setfontsize (18);
DrawText (-1, ypos += 30, (char*)"Technical");
DrawText (125, ypos += 22, (char*)"VBA GX GameCube/Wii Port");
DrawText (350, ypos, (char*)"Tantric");
DrawText (125, ypos += 18, (char*)"VBA GameCube Port Improvements");
DrawText (350, ypos, (char*)"emukidid");
DrawText (125, ypos += 18, (char*)"Original VBA GameCube Port");
DrawText (350, ypos, (char*)"SoftDev");
DrawText (125, ypos += 18, (char*)"Visual Boy Advance 1.7.2");
DrawText (350, ypos, (char*)"Forgotten");
DrawText (125, ypos += 18, (char*)"libogc");
DrawText (350, ypos, (char*)"Shagkur & wintermute");
DrawText (125, ypos += 18, (char*)"Testing");
DrawText (350, ypos, (char*)"tehskeen users");
setfontsize (14);
DrawText (-1, ypos += 22, (char*)"Snes9x v1.5.1 - Snes9x Team");
DrawText (-1, ypos += 18, (char*)"GameCube Port 2.0 WIP6 and earlier - SoftDev");
DrawText (-1, ypos += 18, (char*)"Additional improvements to 2.0 WIP6 - eke-eke");
DrawText (-1, ypos += 18, (char*)"GameCube 2.0.1bx enhancements - crunchy2");
DrawText (-1, ypos += 18, (char*)"v00x updates - michniewski & Tantric");
DrawText (-1, ypos += 18, (char*)"GX - http://www.gc-linux.org");
DrawText (-1, ypos += 18, (char*)"libogc - Shagkur & wintermute");
setfontsize (18);
DrawText (-1, ypos += 30, (char*)"Testing");
setfontsize (14);
DrawText (-1, ypos += 22, (char*)"crunchy2 / tehskeen users / others");
setfontsize (18);
DrawText (-1, ypos += 30, (char*)"Documentation");
setfontsize (14);
DrawText (-1, ypos += 22, (char*)"brakken, crunchy2, michniewski");
DrawText (-1, ypos += 36, (char*)"And many others who have contributed over the years!");
setfontsize (12);
DrawText (-1, ypos += 50, (char*)"Snes9x - Copyright (c) Snes9x Team 1996 - 2006");
DrawText (-1, ypos += 15, (char*)"This software is open source and may be copied, distributed, or modified");
DrawText (-1, ypos += 50, (char*)"This software is open source and may be copied, distributed, or modified");
DrawText (-1, ypos += 15, (char*)"under the terms of the GNU General Public License (GPL) Version 2.");
showscreen ();
@ -447,7 +431,7 @@ DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsiz
}
setfontsize (12);
DrawText (510, screenheight - 20, VERSIONSTR);
DrawText (510, screenheight - 20, (char *)VERSIONSTR);
// Draw menu items

View File

@ -31,7 +31,7 @@ extern unsigned int wmpadmap[];
extern unsigned int ccpadmap[];
extern unsigned int ncpadmap[];
#define PREFS_FILE_NAME "SNES9xGX.xml"
#define PREFS_FILE_NAME "VBAGX.xml"
char prefscomment[2][32];
@ -147,7 +147,7 @@ preparePrefsData (int method)
createXMLSetting("SaveMethod", "Save Method", toStr(GCSettings.SaveMethod));
createXMLSetting("LoadFolder", "Load Folder", GCSettings.LoadFolder);
createXMLSetting("SaveFolder", "Save Folder", GCSettings.SaveFolder);
createXMLSetting("CheatFolder", "Cheats Folder", GCSettings.CheatFolder);
//createXMLSetting("CheatFolder", "Cheats Folder", GCSettings.CheatFolder);
createXMLSetting("VerifySaves", "Verify Memory Card Saves", toStr(GCSettings.VerifySaves));
createXMLSection("Network", "Network Settings");
@ -157,7 +157,7 @@ preparePrefsData (int method)
createXMLSetting("smbuser", "Share Username", GCSettings.smbuser);
createXMLSetting("smbpwd", "Share Password", GCSettings.smbpwd);
createXMLSection("Emulation", "Emulation Settings");
//createXMLSection("Emulation", "Emulation Settings");
createXMLSection("Controller", "Controller Settings");

View File

@ -24,6 +24,7 @@ extern "C" {
#endif
#include "vbasupport.h"
#include "preferences.h"
#include "audio.h"
#include "dvd.h"
#include "smbop.h"
@ -48,15 +49,16 @@ int main()
DI_Init(); // first
#endif
int selectedMenu = -1;
PAD_Init (); /*** Initialise pads for input ***/
// Initialise controllers
#ifdef HW_RVL
WPAD_Init();
// read wiimote accelerometer and IR data
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
#endif
PAD_Init ();
int selectedMenu = -1;
InitialiseVideo();
@ -85,9 +87,16 @@ int main()
// Set defaults
DefaultSettings ();
// Load preferences
if(!LoadPrefs())
{
WaitPrompt((char*) "Preferences reset - check settings!");
selectedMenu = 2; // change to preferences menu
}
while (ROMSize == 0)
{
mainmenu (selectedMenu);
MainMenu (selectedMenu);
}
//Main loop

View File

@ -16,7 +16,7 @@
#include <gccore.h>
#define VERSIONNUM "1.0.0"
#define VERSIONSTR "VBA 1.0.0"
#define VERSIONSTR "VBA GX 1.0.0"
#define NOTSILENT 0
#define SILENT 1

View File

@ -1,11 +1,18 @@
/****************************************************************************
* Visual Boy Advance 1.7.2 Nintendo Wii/Gamecube Port
*
* Tantric September 2008
*
* vbasupport.cpp
*
* VBA support code
***************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "GBA.h"
#include "agbprint.h"
#include "Flash.h"
@ -18,7 +25,8 @@
#include "gb/GB.h"
#include "gb/gbGlobals.h"
#include "vba.h"
#include "fileop.h"
#include "audio.h"
#include "vmmem.h"
#include "pal60.h"
@ -32,9 +40,22 @@ extern "C"
#include "sdfileio.h"
}
/**
* Globals
*/
static tb_t start, now;
u32 loadtimeradjust;
int throttle = 100;
u32 throttleLastTime = 0;
static u32 autoFrameSkipLastTime = 0;
static int frameskipadjust = 0;
int vAspect = 0;
int hAspect = 0;
/****************************************************************************
* VBA Globals
***************************************************************************/
int RGB_LOW_BITS_MASK=0x821;
int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
@ -54,7 +75,6 @@ int destWidth = 0;
int destHeight = 0;
int srcPitch = 0;
int saveExists = 0;
int systemRedShift = 0;
int systemBlueShift = 0;
int systemGreenShift = 0;
@ -64,11 +84,6 @@ u16 systemColorMap16[0x10000];
//u32 systemColorMap32[0x10000];
u32 *systemColorMap32 = (u32 *)&systemColorMap16;
/*** 2D Video Globals ***/
extern u32 whichfb;
extern u32 *xfb[2];
extern GXRModeObj *vmode;
struct EmulatedSystem emulator =
{
NULL,
@ -87,28 +102,25 @@ struct EmulatedSystem emulator =
0
};
static tb_t start, now;
u32 loadtimeradjust;
int throttle = 100;
u32 throttleLastTime = 0;
int vAspect = 0;
int hAspect = 0;
//char filename[1024]; //rom file name
//char batfilename[1024]; //battery save file name
//char statename[1024]; //savestate file name
void debuggerOutput(char *, u32)
{}
void (*dbgOutput)(char *, u32) = debuggerOutput;
void systemMessage(int num, const char *msg, ...)
/****************************************************************************
* systemGetClock
*
* Returns number of milliseconds since program start
****************************************************************************/
u32 systemGetClock( void )
{
/*** For now ... do nothing ***/
mftb(&now);
return tb_diff_msec(&now, &start) - loadtimeradjust;
}
void systemFrame() {}
void systemScreenCapture(int a) {}
void systemShowSpeed(int speed) {}
void systemGbBorderOn() {}
bool systemPauseOnFrame()
{
return false;
}
void GC_Sleep(u32 dwMiliseconds)
@ -120,22 +132,6 @@ void GC_Sleep(u32 dwMiliseconds)
}
}
void systemFrame()
{}
void systemScreenCapture(int a)
{}
void systemShowSpeed(int speed)
{}
static u32 autoFrameSkipLastTime = 0;
static int frameskipadjust = 0;
void write_save()
{
//emulator.emuWriteBattery(batfilename);
}
void system10Frames(int rate)
{
if ( cartridgeType == 1 )
@ -177,81 +173,138 @@ void system10Frames(int rate)
}
}
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;
}
/****************************************************************************
* System
****************************************************************************/
void systemGbPrint(u8 *data,int pages,int feed,int palette, int contrast) {}
void debuggerOutput(char *, u32) {}
void (*dbgOutput)(char *, u32) = debuggerOutput;
void systemMessage(int num, const char *msg, ...) {}
void systemUpdateMotionSensor()
{}
/****************************************************************************
* Saves
****************************************************************************/
void systemGbBorderOn()
{}
bool LoadBattery(int method, bool silent)
{
char filepath[1024];
bool result = false;
ShowAction ((char*) "Loading...");
if(method == METHOD_AUTO)
method = autoSaveMethod(); // we use 'Save' because we need R/W
if(method == METHOD_SD || method == METHOD_USB)
{
ChangeFATInterface(method, NOTSILENT);
sprintf (filepath, "%s/%s/%s.sav", ROOTFATDIR, GCSettings.SaveFolder, ROMFilename);
result = emulator.emuReadBattery(filepath);
}
if(!result && !silent)
WaitPrompt ((char*) "Save file not found");
return result;
}
bool SaveBattery(int method, bool silent)
{
char filepath[1024];
bool result = false;
ShowAction ((char*) "Saving...");
if(method == METHOD_AUTO)
method = autoSaveMethod(); // we use 'Save' because we need R/W
if(method == METHOD_SD || method == METHOD_USB)
{
ChangeFATInterface(method, NOTSILENT);
sprintf (filepath, "%s/%s/%s.sav", ROOTFATDIR, GCSettings.SaveFolder, ROMFilename);
result = emulator.emuWriteBattery(filepath);
}
if(!result && !silent)
WaitPrompt ((char*) "Save failed");
return result;
}
bool LoadState(int method, bool silent)
{
char filepath[1024];
bool result = false;
ShowAction ((char*) "Loading...");
if(method == METHOD_AUTO)
method = autoSaveMethod(); // we use 'Save' because we need R/W
if(method == METHOD_SD || method == METHOD_USB)
{
ChangeFATInterface(method, NOTSILENT);
sprintf (filepath, "%s/%s/%s.sgm", ROOTFATDIR, GCSettings.SaveFolder, ROMFilename);
result = emulator.emuReadState(filepath);
}
if(!result && !silent)
WaitPrompt ((char*) "State file not found");
return result;
}
bool SaveState(int method, bool silent)
{
char filepath[1024];
bool result = false;
ShowAction ((char*) "Saving...");
if(method == METHOD_AUTO)
method = autoSaveMethod(); // we use 'Save' because we need R/W
if(method == METHOD_SD || method == METHOD_USB)
{
ChangeFATInterface(method, NOTSILENT);
sprintf (filepath, "%s/%s/%s.sgm", ROOTFATDIR, GCSettings.SaveFolder, ROMFilename);
result = emulator.emuWriteState(filepath);
}
if(!result && !silent)
WaitPrompt ((char*) "Save failed");
return result;
}
/****************************************************************************
* Sound
****************************************************************************/
void systemWriteDataToSoundBuffer()
{
MIXER_AddSamples((u8 *)soundFinalWave, (cartridgeType == 1));
}
void systemSoundPause()
{}
void systemSoundResume()
{}
void systemSoundReset()
{}
void systemGbPrint(u8 *data,int pages,int feed,int palette, int contrast)
{}
void systemSoundShutdown()
{}
bool systemSoundInit()
{
//memset(soundbuffer, 0, 3200);
return true;
}
bool systemPauseOnFrame()
{
return false;
}
int systemGetSensorX()
{
return sensorX;
}
int systemGetSensorY()
{
return sensorY;
}
bool systemCanChangeSoundQuality()
{
return true;
}
void systemSoundPause() {}
void systemSoundResume() {}
void systemSoundReset() {}
void systemSoundShutdown() {}
/****************************************************************************
* systemReadJoypads
****************************************************************************/
@ -265,23 +318,12 @@ u32 systemReadJoypad(int which)
return GetJoy();
}
/****************************************************************************
* systemGetClock
*
* Returns number of milliseconds since program start
****************************************************************************/
u32 systemGetClock( void )
{
mftb(&now);
return tb_diff_msec(&now, &start) - loadtimeradjust;
}
/****************************************************************************
* systemDrawScreen
****************************************************************************/
void systemDrawScreen()
{
/** GB / GBC Have oodles of time - so sync on VSync **/
// GB / GBC Have oodles of time - so sync on VSync
GX_Render( srcWidth, srcHeight, pix, srcPitch );
#ifdef HW_RVL
@ -294,67 +336,6 @@ void systemDrawScreen()
#endif
}
/*
Checks to see if a previous SRAM/Flash save exists
If it does, it prompts the user to load it or not
*/
void checkSave() {
/* FILE* f = gen_fopen(statename, "rb");
if (f != NULL) {
gen_fclose(f);
whichfb^=1;
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], COLOR_BLACK);
//MENU_DrawString( 140, 50,"Quick Save State Exists" , 1 );
//MENU_DrawString( 140, 80,"Do you wish to load it?" , 1 );
//MENU_DrawString( -1, 170,"(L) or (+) YES" , 1 );
//MENU_DrawString( -1, 200,"(R) or (-) NO" , 1 );
VIDEO_WaitVSync ();
VIDEO_SetNextFramebuffer(xfb[whichfb]);
VIDEO_Flush();
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 loadVBAROM(char filename[])
{
cartridgeType = 0;
@ -375,7 +356,7 @@ int loadVBAROM(char filename[])
srcWidth = 240;
srcHeight = 160;
VMCPULoadROM(filename);
/* Actual Visual Aspect is 1.57 */
// Actual Visual Aspect is 1.57
hAspect = 70;
vAspect = 46;
srcPitch = 484;
@ -391,7 +372,7 @@ int loadVBAROM(char filename[])
srcWidth = 160;
srcHeight = 144;
gbLoadRom(filename);
/* Actual physical aspect is 1.0 */
// Actual physical aspect is 1.0
hAspect = 60;
vAspect = 46;
srcPitch = 324;
@ -405,13 +386,14 @@ int loadVBAROM(char filename[])
break;
}
/** Set defaults **/
// Set defaults
flashSetSize(0x10000);
rtcEnable(true);
agbPrintEnable(false);
askSound();
soundOffFlag = false;
soundLowPass = true;
/** Setup GX **/
// Setup GX
GX_Render_Init( srcWidth, srcHeight, hAspect, vAspect );
if ( cartridgeType == 1 )
@ -426,32 +408,42 @@ int loadVBAROM(char filename[])
CPUReset();
}
// emulator.emuReadBattery(batfilename);
if (saveExists)
{
//emulator.emuReadState(statename);
saveExists = 0;
}
soundVolume = 0;
systemSoundOn = true;
soundInit();
//AudioPlayer();
emulating = 1;
/** Start system clock **/
// Start system clock
mftb(&start);
//emulator.emuReset();
return 1;
}
/****************************************************************************
* EEPROM
****************************************************************************/
int systemGetSensorX()
{
return sensorX;
}
int systemGetSensorY()
{
return sensorY;
}
void systemUpdateMotionSensor() {}
/****************************************************************************
* Palette
****************************************************************************/
void InitialisePalette()
{
int i;
/** Build GBPalette **/
// Build GBPalette
for( i = 0; i < 24; )
{
systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10);
@ -459,7 +451,7 @@ void InitialisePalette()
systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10);
systemGbPalette[i++] = 0;
}
/** Set palette etc - Fixed to RGB565 **/
// Set palette etc - Fixed to RGB565
systemColorDepth = 16;
systemRedShift = 11;
systemGreenShift = 6;

View File

@ -1,6 +1,20 @@
/****************************************************************************
* Visual Boy Advance 1.7.2 Nintendo Wii/Gamecube Port
*
* Tantric September 2008
*
* vbasupport.h
*
* VBA support code
***************************************************************************/
#include "System.h"
extern struct EmulatedSystem emulator;
extern u32 loadtimeradjust;
int loadVBAROM(char filename[]);
void InitialisePalette();
bool LoadBattery(int method, bool silent);
bool SaveBattery(int method, bool silent);
bool LoadState(int method, bool silent);
bool SaveState(int method, bool silent);