From ea3822a65427b3486bcc522fc2314d01109351b7 Mon Sep 17 00:00:00 2001 From: cyberwarriorx Date: Sun, 15 Oct 2006 23:00:26 +0000 Subject: [PATCH] -gtk code now working again. --- desmume/src/gtk/desmume.c | 110 +------------------------------------- desmume/src/gtk/desmume.h | 4 -- desmume/src/gtk/main.c | 5 +- 3 files changed, 4 insertions(+), 115 deletions(-) diff --git a/desmume/src/gtk/desmume.c b/desmume/src/gtk/desmume.c index cefbf8246..bdff4bc3d 100644 --- a/desmume/src/gtk/desmume.c +++ b/desmume/src/gtk/desmume.c @@ -22,120 +22,14 @@ u32 desmume_last_cycle; void desmume_init() { - NDSInit(); + NDS_Init(); execute = FALSE; } void desmume_free() { execute = FALSE; - desmume_free_rom(); - NDSDeInit(); -} - -void desmume_mem_init() -{ - //ARM7 EXCEPTION VECTORS - MMU_writeWord(1, 0x00, 0xE25EF002); - MMU_writeWord(1, 0x04, 0xEAFFFFFE); - MMU_writeWord(1, 0x18, 0xEA000000); - MMU_writeWord(1, 0x20, 0xE92D500F); - MMU_writeWord(1, 0x24, 0xE3A00301); - MMU_writeWord(1, 0x28, 0xE28FE000); - MMU_writeWord(1, 0x2C, 0xE510F004); - MMU_writeWord(1, 0x30, 0xE8BD500F); - MMU_writeWord(1, 0x34, 0xE25EF004); - - //ARM9 EXCEPTION VECTORS - MMU_writeWord(0, 0xFFF0018, 0xEA000000); - MMU_writeWord(0, 0xFFF0020, 0xE92D500F); - MMU_writeWord(0, 0xFFF0024, 0xEE190F11); - MMU_writeWord(0, 0xFFF0028, 0xE1A00620); - MMU_writeWord(0, 0xFFF002C, 0xE1A00600); - MMU_writeWord(0, 0xFFF0030, 0xE2800C40); - MMU_writeWord(0, 0xFFF0034, 0xE28FE000); - MMU_writeWord(0, 0xFFF0038, 0xE510F004); - MMU_writeWord(0, 0xFFF003C, 0xE8BD500F); - MMU_writeWord(0, 0xFFF0040, 0xE25EF004); -} - -#define DSGBA_EXTENSTION ".ds.gba" -#define DSGBA_LOADER_SIZE 512 -enum -{ - ROM_NDS = 0, - ROM_DSGBA -}; -int desmume_load_rom(const char *filename) -{ - int i; - uint type; - const char *p = filename; - FILE *file; - u32 size, mask; - u8 *data; - - type = ROM_NDS; - - p += strlen(p); - p -= strlen(DSGBA_EXTENSTION); - if(memcmp(p, DSGBA_EXTENSTION, strlen(DSGBA_EXTENSTION)) == 0) - { - type = ROM_DSGBA; - } - - file = fopen(filename, "rb"); - if(!file) { return -1; } - - fseek(file, 0, SEEK_END); - size = ftell(file); - fseek(file, 0, SEEK_SET); - - if(type == ROM_DSGBA) - { - fseek(file, DSGBA_LOADER_SIZE, SEEK_SET); - size -= DSGBA_LOADER_SIZE; - } - - mask = size; - mask |= (mask >>1); - mask |= (mask >>2); - mask |= (mask >>4); - mask |= (mask >>8); - mask |= (mask >>16); - - data = (u8*)malloc(mask + 1); - if(!data) { fclose(file); return -1; } - - i = fread(data, 1, size, file); - - fclose(file); - - MMU_unsetRom(); - NDS_loadROM(data, mask); - desmume_rom_data = data; - - strcpy(szRomPath, dirname((char *) filename)); - cflash_close(); - cflash_init(); - - return i; -} - -void desmume_free_rom() -{ - if(desmume_rom_data) - { - free(desmume_rom_data); - desmume_rom_data = NULL; - } -} - -void desmume_reset() -{ - execute = FALSE; - desmume_mem_init(); - desmume_last_cycle = 0; + NDS_DeInit(); } void desmume_pause() diff --git a/desmume/src/gtk/desmume.h b/desmume/src/gtk/desmume.h index dd7717354..bc86a28e6 100644 --- a/desmume/src/gtk/desmume.h +++ b/desmume/src/gtk/desmume.h @@ -25,10 +25,6 @@ extern void desmume_init(); extern void desmume_free(); -extern int desmume_load_rom(const char *filename); -extern void desmume_free_rom(); -extern void desmume_reset(); - extern void desmume_pause(); extern void desmume_resume(); extern void desmume_toggle(); diff --git a/desmume/src/gtk/main.c b/desmume/src/gtk/main.c index d9d6633cd..9c962b246 100644 --- a/desmume/src/gtk/main.c +++ b/desmume/src/gtk/main.c @@ -188,8 +188,7 @@ Build date: " __DATE__ ", " __TIME__ "."); static int Open(const char *filename) { - int i = desmume_load_rom(filename); - desmume_reset(); + int i = NDS_LoadROM(filename); return i; } @@ -292,7 +291,7 @@ static void Close() static void Reset() { - desmume_reset(); + NDS_Reset(); desmume_resume(); pStatusBar_Change("Running ...");