SMB/DVD/ZIP now mostly functional

This commit is contained in:
dborth 2008-09-26 08:10:36 +00:00
parent 9edc1f9b4b
commit 2522d87963
7 changed files with 87 additions and 62 deletions

View File

@ -23,6 +23,7 @@
#include "menudraw.h" #include "menudraw.h"
#include "filesel.h" #include "filesel.h"
#include "preferences.h" #include "preferences.h"
#include "sdfileio.h"
// temporary // temporary
#include "vmmem.h" #include "vmmem.h"

View File

@ -321,7 +321,7 @@ int FileSelector (int method)
dvddirlength = filelist[selection].length; dvddirlength = filelist[selection].length;
} }
ROMSize = loadVBAROM(method); ROMSize = LoadVBAROM(method);
if (ROMSize > 0) if (ROMSize > 0)
{ {

View File

@ -65,7 +65,6 @@ int main()
int selectedMenu = -1; int selectedMenu = -1;
InitialiseVideo(); InitialiseVideo();
GX_Start();
// Initialise freetype font system // Initialise freetype font system
if (FT_Init ()) if (FT_Init ())
@ -78,7 +77,7 @@ int main()
fatInitDefault(); fatInitDefault();
// Initialize DVD subsystem (GameCube only) // Initialize DVD subsystem (GameCube only)
#ifndef HW_RVL #ifdef HW_DOL
DVD_Init (); DVD_Init ();
#endif #endif

View File

@ -342,7 +342,34 @@ void systemDrawScreen()
#endif #endif
} }
int loadVBAROM(int method) extern bool gbUpdateSizes();
bool LoadGBROM()
{
char filepath[1024];
sprintf(filepath, "%s/%s",currentdir,filelist[selection].filename);
int size = 0;
if(gbRom != NULL)
{
gbCleanUp();
}
systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
gbRom = utilLoad(filepath,
utilIsGBImage,
NULL,
size);
if(!gbRom)
return false;
gbRomSize = size;
return gbUpdateSizes();
}
int LoadVBAROM(int method)
{ {
int type = 2; int type = 2;
@ -383,7 +410,7 @@ int loadVBAROM(int method)
emulator = GBSystem; emulator = GBSystem;
srcWidth = 160; srcWidth = 160;
srcHeight = 144; srcHeight = 144;
//gbLoadRom(filepath); LoadGBROM();
// Actual physical aspect is 1.0 // Actual physical aspect is 1.0
hAspect = 60; hAspect = 60;
vAspect = 46; vAspect = 46;

View File

@ -12,7 +12,7 @@
extern struct EmulatedSystem emulator; extern struct EmulatedSystem emulator;
extern u32 loadtimeradjust; extern u32 loadtimeradjust;
int loadVBAROM(int method); int LoadVBAROM(int method);
void InitialisePalette(); void InitialisePalette();
bool LoadBattery(int method, bool silent); bool LoadBattery(int method, bool silent);
bool SaveBattery(int method, bool silent); bool SaveBattery(int method, bool silent);

View File

@ -19,6 +19,8 @@
#include "images/bg.h" #include "images/bg.h"
#include "pal60.h" #include "pal60.h"
extern unsigned int SMBTimer; // timer to reset SMB connection
/*** External 2D Video ***/ /*** External 2D Video ***/
/*** 2D Video Globals ***/ /*** 2D Video Globals ***/
GXRModeObj *vmode = NULL; // Graphics Mode Object GXRModeObj *vmode = NULL; // Graphics Mode Object
@ -29,7 +31,7 @@ int screenheight;
/*** 3D GX ***/ /*** 3D GX ***/
#define DEFAULT_FIFO_SIZE ( 256 * 1024 ) #define DEFAULT_FIFO_SIZE ( 256 * 1024 )
static u8 *gp_fifo; static u8 gp_fifo[DEFAULT_FIFO_SIZE] ATTRIBUTE_ALIGN(32);
/*** Texture memory ***/ /*** Texture memory ***/
static u8 *texturemem = NULL; static u8 *texturemem = NULL;
@ -71,43 +73,6 @@ static camera cam = { {0.0F, 0.0F, 0.0F},
{0.0F, 0.0F, -0.5F} {0.0F, 0.0F, -0.5F}
}; };
/****************************************************************************
* Initialise Video
*
* Before doing anything in libogc, it's recommended to configure a video
* output.
****************************************************************************/
void InitialiseVideo ()
{
// Start VIDEO Subsystem
VIDEO_Init();
vmode = VIDEO_GetPreferredMode(NULL);
VIDEO_Configure(vmode);
screenheight = vmode->xfbHeight;
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
VIDEO_SetNextFramebuffer(xfb[0]);
VIDEO_SetBlack(FALSE);
// set timings in VI to PAL60
/*u32 *vreg = (u32 *)0xCC002000;
for (int i = 0; i < 64; i++ )
vreg[i] = vpal60[i];*/
VIDEO_Flush();
VIDEO_WaitVSync();
if(vmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync();
VIDEO_SetPostRetraceCallback((VIRetraceCallback)UpdatePadsCB);
VIDEO_SetNextFramebuffer(xfb[0]);
}
/**************************************************************************** /****************************************************************************
* StartGX * StartGX
****************************************************************************/ ****************************************************************************/
@ -121,7 +86,7 @@ void GX_Start()
memset(&gp_fifo, 0, DEFAULT_FIFO_SIZE); memset(&gp_fifo, 0, DEFAULT_FIFO_SIZE);
/*** Initialise GX ***/ /*** Initialise GX ***/
GX_Init(gp_fifo, DEFAULT_FIFO_SIZE); GX_Init(&gp_fifo, DEFAULT_FIFO_SIZE);
GX_SetCopyClear(gxbackground, 0x00ffffff); GX_SetCopyClear(gxbackground, 0x00ffffff);
GX_SetViewport(0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1); GX_SetViewport(0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1);
@ -156,6 +121,44 @@ UpdatePadsCB ()
PAD_ScanPads(); PAD_ScanPads();
} }
/****************************************************************************
* Initialise Video
*
* Before doing anything in libogc, it's recommended to configure a video
* output.
****************************************************************************/
void InitialiseVideo ()
{
/*** Start VIDEO Subsystem ***/
VIDEO_Init();
vmode = VIDEO_GetPreferredMode(NULL);
VIDEO_Configure(vmode);
screenheight = vmode->xfbHeight;
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
VIDEO_SetNextFramebuffer(xfb[0]);
VIDEO_SetBlack(FALSE);
// set timings in VI to PAL60
/*u32 *vreg = (u32 *)0xCC002000;
for (int i = 0; i < 64; i++ )
vreg[i] = vpal60[i];*/
VIDEO_Flush();
VIDEO_WaitVSync();
if(vmode->viTVMode&VI_NON_INTERLACE)
VIDEO_WaitVSync();
VIDEO_SetPostRetraceCallback((VIRetraceCallback)UpdatePadsCB);
VIDEO_SetNextFramebuffer(xfb[0]);
GX_Start();
}
/**************************************************************************** /****************************************************************************
* Scaler Support Functions * Scaler Support Functions
****************************************************************************/ ****************************************************************************/
@ -216,11 +219,12 @@ void GX_Render_Init(int width, int height, int haspect, int vaspect)
/*** Allocate 32byte aligned texture memory ***/ /*** Allocate 32byte aligned texture memory ***/
texturesize = (width * height) * 2; texturesize = (width * height) * 2;
if (texturemem) if (texturemem)
free(texturemem); free(texturemem);
texturemem = (u8 *) memalign(32, texturesize); texturemem = (u8 *) memalign(32, texturesize);
memset(texturemem, 0, texturesize); memset(texturemem, 0, texturesize);
/*** Setup for first call to scaler ***/ /*** Setup for first call to scaler ***/
@ -308,6 +312,8 @@ void GX_Render(int width, int height, u8 * buffer, int pitch)
VIDEO_SetNextFramebuffer(xfb[whichfb]); VIDEO_SetNextFramebuffer(xfb[whichfb]);
VIDEO_Flush(); VIDEO_Flush();
SMBTimer++;
} }
@ -327,8 +333,8 @@ clearscreen (int c)
void void
showscreen () showscreen ()
{ {
copynow = GX_FALSE;
VIDEO_SetNextFramebuffer (xfb[whichfb]); VIDEO_SetNextFramebuffer (xfb[whichfb]);
VIDEO_Flush (); VIDEO_Flush ();
VIDEO_WaitVSync (); VIDEO_WaitVSync ();
} }

View File

@ -27,6 +27,7 @@
#include "fileop.h" #include "fileop.h"
#include "dvd.h" #include "dvd.h"
#include "menudraw.h" #include "menudraw.h"
#include "filesel.h"
extern "C" { extern "C" {
#include "tbtime.h" #include "tbtime.h"
@ -39,9 +40,7 @@ extern "C" {
unsigned int MEM2Storage = 0x91000000; unsigned int MEM2Storage = 0x91000000;
static char *gbabase = NULL; static char *gbabase = NULL;
static FILE *romfile = NULL;
static u32 GBAROMSize = 0; static u32 GBAROMSize = 0;
//static char romfilename[1024];
/** /**
* GBA Memory * GBA Memory
@ -92,12 +91,7 @@ static void VMClose( void )
if ( gbabase != NULL ) if ( gbabase != NULL )
free(gbabase); free(gbabase);
if ( romfile != NULL )
gen_fclose(romfile);
gbabase = NULL; gbabase = NULL;
romfile = NULL;
} }
/**************************************************************************** /****************************************************************************
@ -108,10 +102,8 @@ static void VMClose( void )
int VMCPULoadROM(int method) int VMCPULoadROM(int method)
{ {
int res=0;
VMClose(); VMClose();
VMAllocGBA(); VMAllocGBA();
GBAROMSize = 0; GBAROMSize = 0;
rom = (u8 *)MEM2Storage; rom = (u8 *)MEM2Storage;
@ -122,24 +114,24 @@ int VMCPULoadROM(int method)
{ {
case METHOD_SD: case METHOD_SD:
case METHOD_USB: case METHOD_USB:
res = LoadFATFile ((char *)rom); GBAROMSize = LoadFATFile ((char *)rom);
break; break;
case METHOD_DVD: case METHOD_DVD:
res = LoadDVDFile ((unsigned char *)rom); GBAROMSize = LoadDVDFile ((unsigned char *)rom);
break; break;
case METHOD_SMB: case METHOD_SMB:
res = LoadSMBFile ((char *)rom); GBAROMSize = LoadSMBFile ((char *)rom);
break; break;
} }
if(res) if(GBAROMSize)
CPUUpdateRenderBuffers( true ); CPUUpdateRenderBuffers( true );
else else
VMClose(); VMClose();
return res; return GBAROMSize;
} }