diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index e202ed7..e3320ab 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -17,9 +17,7 @@ #include #ifdef HW_RVL -extern "C" { #include -} #endif #include "vba.h" diff --git a/source/ngc/tbtime.c b/source/ngc/tbtime.c deleted file mode 100644 index d41eba0..0000000 --- a/source/ngc/tbtime.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "tbtime.h" - -unsigned long -tb_diff_msec (tb_t * end, tb_t * start) -{ - unsigned long upper, lower; - upper = end->u - start->u; - if (start->l > end->l) - upper--; - lower = end->l - start->l; - return ((upper * ((unsigned long) 0x80000000 / (TB_CLOCK / 2000))) + - (lower / (TB_CLOCK / 1000))); -} - - diff --git a/source/ngc/tbtime.h b/source/ngc/tbtime.h deleted file mode 100644 index 779702e..0000000 --- a/source/ngc/tbtime.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************** -* tmbinc msec timer -****************************************************************************/ -#ifndef __TMBINCTIMER__ -#define __TMBINCTIMER__ -#ifdef HW_RVL -#define TB_CLOCK 60750000 //WII -#else -#define TB_CLOCK 40500000 -#endif -#define mftb(rval) ({unsigned long u; do { \ - asm volatile ("mftbu %0" : "=r" (u)); \ - asm volatile ("mftb %0" : "=r" ((rval)->l)); \ - asm volatile ("mftbu %0" : "=r" ((rval)->u)); \ - } while(u != ((rval)->u)); }) - -typedef struct - { - unsigned long l, u; - } -tb_t; - -unsigned long tb_diff_msec (tb_t * end, tb_t * start); - -#endif - diff --git a/source/ngc/vba.cpp b/source/ngc/vba.cpp index efeca47..d47504e 100644 --- a/source/ngc/vba.cpp +++ b/source/ngc/vba.cpp @@ -17,9 +17,7 @@ #include #ifdef HW_RVL -extern "C" { #include -} #endif #include "FreeTypeGX.h" diff --git a/source/ngc/vbaconfig.cpp b/source/ngc/vbaconfig.cpp index a5c3502..6543a44 100644 --- a/source/ngc/vbaconfig.cpp +++ b/source/ngc/vbaconfig.cpp @@ -34,7 +34,7 @@ void FixInvalidSettings() GCSettings.MusicVolume = 40; if(!(GCSettings.SFXVolume >= 0 && GCSettings.SFXVolume <= 100)) GCSettings.SFXVolume = 40; - if(!(GCSettings.render >= 0 && GCSettings.render < 2)) + if(!(GCSettings.render >= 0 && GCSettings.render < 3)) GCSettings.render = 1; if(!(GCSettings.videomode >= 0 && GCSettings.videomode < 5)) GCSettings.videomode = 0; diff --git a/source/ngc/vbasupport.cpp b/source/ngc/vbasupport.cpp index 23480b4..43e3ef4 100644 --- a/source/ngc/vbasupport.cpp +++ b/source/ngc/vbasupport.cpp @@ -15,6 +15,11 @@ #include #include +extern "C" { +long long gettime(); +u32 diff_usec(long long start,long long end); +} + #include "pngu/pngu.h" #include "unzip.h" @@ -46,16 +51,7 @@ #include "gcunzip.h" #include "gamesettings.h" -extern "C" -{ -#include "tbtime.h" -long long gettime(); -u32 diff_usec(long long start,long long end); -} - -static tb_t start, now; - -u32 loadtimeradjust; +static u32 start; int cartridgeType = 0; u32 RomIdCode; int SunBars = 3; @@ -114,8 +110,8 @@ struct EmulatedSystem emulator = ****************************************************************************/ u32 systemGetClock( void ) { - mftb(&now); - return tb_diff_msec(&now, &start) - loadtimeradjust; + u32 now = gettime(); + return diff_usec(start, now) / 1000; } void systemFrame() {} @@ -784,7 +780,7 @@ static void gbApplyPerImagePreferences() else if (strcmp(title, "TMNT3") == 0) RomIdCode = TMNT3; } - // look for matching palettes if a monochrome gameboy game + // look for matching palettes if a monochrome gameboy game // (or if a Super Gameboy game, but the palette will be ignored later in that case) int snum = -1; if ((Colour != 0x80) && (Colour != 0xC0)) { @@ -1095,7 +1091,7 @@ bool LoadVBAROM(int method) lastTime = systemFrameSkip = 0; // Start system clock - mftb(&start); + start = gettime(); return true; } diff --git a/source/ngc/vbasupport.h b/source/ngc/vbasupport.h index de5bf6f..fd00773 100644 --- a/source/ngc/vbasupport.h +++ b/source/ngc/vbasupport.h @@ -14,7 +14,6 @@ #include "System.h" extern struct EmulatedSystem emulator; -extern u32 loadtimeradjust; extern int cartridgeType; extern int SunBars; extern u32 RomIdCode; diff --git a/source/ngc/vmmem.cpp b/source/ngc/vmmem.cpp index 69b1786..9f7f25a 100644 --- a/source/ngc/vmmem.cpp +++ b/source/ngc/vmmem.cpp @@ -27,10 +27,6 @@ #include "filebrowser.h" #include "gcunzip.h" -extern "C" { -#include "tbtime.h" -} - #define MEM_BAD 0xff #define MEM_VM 0x01 #define MEM_UN 0x80 @@ -40,7 +36,6 @@ unsigned int MEM2Storage = 0x91000000; int GBAROMSize = 0; #ifdef USE_VM -//extern u32 loadtimeradjust; /** Setup VM to use small 16kb windows **/ #define VMSHIFTBITS 14 @@ -362,11 +357,8 @@ int VMCPULoadROM(int method) static void VMNewPage( int pageid ) { int res; - //tb_t start,end; char msg[512]; - //mftb(&start); - res = fseek( romfile, pageid << VMSHIFTBITS, SEEK_SET ); if (res) // fseek returns non-zero on a failure { @@ -379,20 +371,6 @@ static void VMNewPage( int pageid ) VMAllocate( pageid ); res = fread( vmpage[pageid].pageptr, 1, 1 << VMSHIFTBITS, romfile ); - if ( res != ( 1 << VMSHIFTBITS ) ) - { - // Homebrew ROMS may not have the expected amount of data - // and then end up here - but they still work - so we won't throw an error - - /*sprintf(msg, "Error reading! %d bytes only\n", res); - InfoPrompt(msg); - VMClose(); - ExitApp();*/ - } - - //mftb(&end); - - //loadtimeradjust += tb_diff_msec(&end, &start); } /****************************************************************************