Finish migrating to new mem handling. Make carthw db external.
[picodrive.git] / pico / pico.c
index ab2302e..f2da10b 100644 (file)
@@ -40,8 +40,6 @@ void PicoInit(void)
 \r
   PicoInitMCD();\r
   PicoSVPInit();\r
-\r
-  SRam.data=0;\r
 }\r
 \r
 // to be called once on emu exit\r
@@ -52,13 +50,12 @@ void PicoExit(void)
   PicoCartUnload();\r
   z80_exit();\r
 \r
-  if (SRam.data) free(SRam.data); SRam.data=0;\r
+  if (SRam.data)\r
+    free(SRam.data);\r
 }\r
 \r
 void PicoPower(void)\r
 {\r
-  unsigned char sram_status = Pico.m.sram_status; // must be preserved\r
-\r
   Pico.m.frame_count = 0;\r
 \r
   // clear all memory of the emulated machine\r
@@ -78,7 +75,6 @@ void PicoPower(void)
   if (PicoAHW & PAHW_MCD)\r
     PicoPowerMCD();\r
 \r
-  Pico.m.sram_status = sram_status;\r
   PicoReset();\r
 }\r
 \r
@@ -141,8 +137,6 @@ PICO_INTERNAL void PicoDetectRegion(void)
 \r
 int PicoReset(void)\r
 {\r
-  unsigned char sram_status = Pico.m.sram_status; // must be preserved\r
-\r
   if (Pico.romsize <= 0)\r
     return 1;\r
 \r
@@ -194,12 +188,13 @@ int PicoReset(void)
     SekInitIdleDet();\r
 \r
   // reset sram state; enable sram access by default if it doesn't overlap with ROM\r
-  Pico.m.sram_status = sram_status & (SRS_DETECTED|SRS_EEPROM);\r
-  if (!(Pico.m.sram_status & SRS_EEPROM) && Pico.romsize <= SRam.start)\r
-    Pico.m.sram_status |= SRS_MAPPED;\r
+  Pico.m.sram_reg = 0;\r
+  if ((SRam.flags & SRF_EEPROM) || Pico.romsize <= SRam.start)\r
+    Pico.m.sram_reg |= SRR_MAPPED;\r
 \r
-  elprintf(EL_STATUS, "sram: det: %i; eeprom: %i; start: %06x; end: %06x",\r
-    !!(sram_status & SRS_DETECTED), !!(sram_status & SRS_EEPROM), SRam.start, SRam.end);\r
+  if (SRam.flags & SRF_ENABLED)\r
+    elprintf(EL_STATUS, "sram: %06x - %06x; eeprom: %i", SRam.start, SRam.end,\r
+      !!(SRam.flags & SRF_EEPROM));\r
 \r
   return 0;\r
 }\r