From a193d47deb7c25874613601f684e95ec6ff5197c Mon Sep 17 00:00:00 2001 From: cyberwarriorx Date: Sun, 15 Oct 2006 22:08:43 +0000 Subject: [PATCH] -Moved over LoadFirmware function from gtk code to emulator core. Yet another function that should be portable --- desmume/src/NDSSystem.c | 25 +++++++++++++++++++++++++ desmume/src/NDSSystem.h | 1 + 2 files changed, 26 insertions(+) diff --git a/desmume/src/NDSSystem.c b/desmume/src/NDSSystem.c index 5fb7c6bdf..7a2c7ebf0 100644 --- a/desmume/src/NDSSystem.c +++ b/desmume/src/NDSSystem.c @@ -413,3 +413,28 @@ int NDS_WriteBMP(const char *filename) return 1; } + +int NDS_LoadFirmware(const char *filename) +{ + int i; + long size; + FILE *file; + + if ((file = fopen(filename, "rb")) == NULL) + return -1; + + fseek(file, 0, SEEK_END); + size = ftell(file); + fseek(file, 0, SEEK_SET); + + if(size > MMU.fw.size) + { + fclose(file); + return -1; + } + + i = fread(MMU.fw.data, size, 1, file); + fclose(file); + + return i; +} diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 431eb5e13..16568289b 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -194,6 +194,7 @@ void NDS_FreeROM(void); void NDS_Reset(void); int NDS_WriteBMP(const char *filename); +int NDS_LoadFirmware(const char *filename); static INLINE void NDS_ARM9HBlankInt(void) {