WIP: sram functionality
authorLukas Krickl <lukas@krickl.dev>
Sun, 17 Nov 2024 06:25:51 +0000 (07:25 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 17 Nov 2024 06:25:51 +0000 (07:25 +0100)
src/main.s
src/mem.s
src/sram.s [new file with mode: 0644]

index b6308cd5b88b320d02d54d4d09428e236e04b866..d336459780a01f7e6b10b13e4a75b5176c302a58 100644 (file)
@@ -2,6 +2,7 @@
 #include "macros.inc"
 #include "oam.s"
 #include "wram.s"
+#include "sram.s"
 
 .org 0x0
 #include "jmp.inc"
index 47ef2531d43e923f0e61fcefed5b52522a3b0d8b..d5cd13c5e94b0f555c558908558271647f12664b 100644 (file)
--- a/src/mem.s
+++ b/src/mem.s
@@ -15,7 +15,7 @@ mem_init:
   ld a, GM_GAME
   ld [game_mode], a
 
-  call mbc1_ram_enable 
+  call mbc1_init
 
   ret
 
@@ -67,7 +67,19 @@ shadow_oam_to_oam:
   ret 
 shadow_oam_to_oam_end:
 
-; MBC1 functions 
+
+; ==============
+; MBC1 functions
+; ==============
+
+  ; if the first byte of sram is not this 
+  ; value clear it all
+#define MBC1_SRAM_MAGIC 0xA1 
+
+mbc1_init:
+  call mbc1_ram_enable
+  ret
+
 
   ; ram enable mbc1
   ; TODO: it is reccomended to disable ram when not 
diff --git a/src/sram.s b/src/sram.s
new file mode 100644 (file)
index 0000000..81e48de
--- /dev/null
@@ -0,0 +1,11 @@
+#define SRAM 0xA000
+#define SRAMLEN 0x1FFF
+
+.org SRAM
+
+  ; if the first byte of sram is not this 
+  ; value clear it all
+#define SRAM_MAGIC 0xA1 
+
+  ; flag for init of sram
+sram_magic: .adv 1