diff --git a/Makefile b/Makefile index 43cd320..f73d8b9 100644 --- a/Makefile +++ b/Makefile @@ -68,5 +68,3 @@ clean: copy: bin/GWRAM.po cp bin/GWRAM.po /Volumes/FLOPPYEMU/GWRAM.po diskutil unmount /Volumes/FLOPPYEMU/ - - diff --git a/bin/GWRAM.dbg.po b/bin/GWRAM.dbg.po index 5d02111..7ce9458 100644 Binary files a/bin/GWRAM.dbg.po and b/bin/GWRAM.dbg.po differ diff --git a/bin/GWRAM.po b/bin/GWRAM.po index 53d6729..122ce19 100644 Binary files a/bin/GWRAM.po and b/bin/GWRAM.po differ diff --git a/ram2e.c b/ram2e.c index a8d5985..b93f68b 100644 --- a/ram2e.c +++ b/ram2e.c @@ -8,6 +8,7 @@ #include "util.h" #include "gwconio.h" #include "ram2e_hal.h" +#include "ram2e_save.h" static void menu() { diff --git a/ram2e_hal.h b/ram2e_hal.h index 04b53b0..84fa3ce 100644 --- a/ram2e_hal.h +++ b/ram2e_hal.h @@ -1,5 +1,5 @@ -#ifndef RAM2GS_HAL_H -#define RAM2GS_HAL_H +#ifndef RAM2E_HAL_H +#define RAM2E_HAL_H #include #include @@ -15,58 +15,4 @@ void ram2e_erase(); void ram2e_save_start(char mask, char enled); void ram2e_save_end(char mask, char enled); -static char _rwsave[256]; -static char _rwsave0_1; -static char _rwsave0_2; -static char _rwsave0_3; -static void ramworks_save() { - __asm__("sta $C009"); // Store in ALTZP - - // Save address 0x0000 in every bank - __asm__("ldx #0"); - saveloop: - __asm__("stx $C073"); - __asm__("lda $00,X"); - __asm__("sta %v,X", _rwsave); - __asm__("inx"); - __asm__("bne %g", saveloop); - - // Save addresses 0x0001-3 in bank 0 - __asm__("ldx #0"); - __asm__("stx $C073"); - __asm__("lda $01"); - __asm__("sta %v", _rwsave0_1); - __asm__("lda $02"); - __asm__("sta %v", _rwsave0_2); - __asm__("lda $03"); - __asm__("sta %v", _rwsave0_3); - - __asm__("sta $C008"); // Don't store in ALTZP -} - -static void ramworks_restore() { - __asm__("sta $C009"); // Store in ALTZP - - // Restore address 0x0000 in every bank - __asm__("ldx #0"); - restoreloop: - __asm__("stx $C073"); - __asm__("lda %v,X", _rwsave); - __asm__("sta $00,X"); - __asm__("inx"); - __asm__("bne %g", restoreloop); - - // Restore addresses 0x0001-3 in bank 0 - __asm__("ldx #0"); - __asm__("stx $C073"); - __asm__("lda %v", _rwsave0_1); - __asm__("sta $01"); - __asm__("lda %v", _rwsave0_2); - __asm__("sta $02"); - __asm__("lda %v", _rwsave0_3); - __asm__("sta $03"); - - __asm__("sta $C008"); // Don't store in ALTZP -} - #endif \ No newline at end of file diff --git a/ram2e_save.h b/ram2e_save.h new file mode 100644 index 0000000..f8e6b63 --- /dev/null +++ b/ram2e_save.h @@ -0,0 +1,58 @@ +#ifndef RAM2E_SAVE_H +#define RAM2E_SAVE_H + +static char _rwsave[256]; +static char _rwsave0_1; +static char _rwsave0_2; +static char _rwsave0_3; +static void ramworks_save() { + __asm__("sta $C009"); // Store in ALTZP + + // Save address 0x0000 in every bank + __asm__("ldx #0"); + saveloop: + __asm__("stx $C073"); + __asm__("lda $00,X"); + __asm__("sta %v,X", _rwsave); + __asm__("inx"); + __asm__("bne %g", saveloop); + + // Save addresses 0x0001-3 in bank 0 + __asm__("ldx #0"); + __asm__("stx $C073"); + __asm__("lda $01"); + __asm__("sta %v", _rwsave0_1); + __asm__("lda $02"); + __asm__("sta %v", _rwsave0_2); + __asm__("lda $03"); + __asm__("sta %v", _rwsave0_3); + + __asm__("sta $C008"); // Don't store in ALTZP +} + +static void ramworks_restore() { + __asm__("sta $C009"); // Store in ALTZP + + // Restore address 0x0000 in every bank + __asm__("ldx #0"); + restoreloop: + __asm__("stx $C073"); + __asm__("lda %v,X", _rwsave); + __asm__("sta $00,X"); + __asm__("inx"); + __asm__("bne %g", restoreloop); + + // Restore addresses 0x0001-3 in bank 0 + __asm__("ldx #0"); + __asm__("stx $C073"); + __asm__("lda %v", _rwsave0_1); + __asm__("sta $01"); + __asm__("lda %v", _rwsave0_2); + __asm__("sta $02"); + __asm__("lda %v", _rwsave0_3); + __asm__("sta $03"); + + __asm__("sta $C008"); // Don't store in ALTZP +} + +#endif \ No newline at end of file diff --git a/ram2gs.c b/ram2gs.c index ddd5b67..a4563f0 100644 --- a/ram2gs.c +++ b/ram2gs.c @@ -49,7 +49,7 @@ static void loading_screen() int ram2gs_main(void) { char type; - uint16_t bankcount; + uint8_t bankcount; char en8meg = true; char hasled = true; char enled = false; @@ -89,6 +89,7 @@ int ram2gs_main(void) // Detect and print current capacity bankcount = ram2gs_getsize(); + en8meg = bankcount >= 128; menu_size(bankcount); // Detect and print LED menu