]> git.sesse.net Git - pistorm/blobdiff - platforms/amiga/amiga-registers.c
Add setvar to Amiga platform for RTC and HDD0 image configuration
[pistorm] / platforms / amiga / amiga-registers.c
index 0357dfc1cee4e199f21ea7dba9c7874129109fd5..96aa65352fe35467934a8979526a53c8f00c0cfe 100644 (file)
@@ -4,8 +4,23 @@
 #define GAYLEBASE 0xD80000  // D7FFFF
 #define GAYLESIZE 0x6FFFF
 
+#define CLOCKBASE 0xDC0000
+#define CLOCKSIZE 0x010000
+
+uint8_t rtc_emulation_enabled = 1;
+
+void configure_rtc_emulation_amiga(uint8_t enabled) {
+    if (enabled == rtc_emulation_enabled)
+        return;
+
+    rtc_emulation_enabled = enabled;
+    printf("Amiga RTC emulation is now %s.\n", (enabled) ? "enabled" : "disabled");
+}
+
 int handle_register_read_amiga(unsigned int addr, unsigned char type, unsigned int *val) {
-    if (addr > GAYLEBASE && addr < GAYLEBASE + GAYLESIZE) {
+    if (!rtc_emulation_enabled && addr >= CLOCKBASE && addr < CLOCKBASE + CLOCKSIZE)
+        return -1;
+    if (addr >= GAYLEBASE && addr < GAYLEBASE + GAYLESIZE) {
         switch(type) {
         case OP_TYPE_BYTE:
             *val = readGayleB(addr);
@@ -28,7 +43,9 @@ int handle_register_read_amiga(unsigned int addr, unsigned char type, unsigned i
 }
 
 int handle_register_write_amiga(unsigned int addr, unsigned int value, unsigned char type) {
-    if (addr > GAYLEBASE && addr < GAYLEBASE + GAYLESIZE) {
+    if (!rtc_emulation_enabled && addr >= CLOCKBASE && addr < CLOCKBASE + CLOCKSIZE)
+        return -1;
+    if (addr >= GAYLEBASE && addr < GAYLEBASE + GAYLESIZE) {
         switch(type) {
         case OP_TYPE_BYTE:
             writeGayleB(addr, value);