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) {