]> git.sesse.net Git - pistorm/blobdiff - platforms/amiga/amiga-registers.c
Some minor optimizations, hopefully fewer jumps and such
[pistorm] / platforms / amiga / amiga-registers.c
index 96aa65352fe35467934a8979526a53c8f00c0cfe..d5e3b69389808bacec8fe5203b2dc8b758ffc6c8 100644 (file)
@@ -1,13 +1,9 @@
 #include "../../Gayle.h"
 #include "../../config_file/config_file.h"
-
-#define GAYLEBASE 0xD80000  // D7FFFF
-#define GAYLESIZE 0x6FFFF
-
-#define CLOCKBASE 0xDC0000
-#define CLOCKSIZE 0x010000
+#include "amiga-registers.h"
 
 uint8_t rtc_emulation_enabled = 1;
+extern int gayle_emulation_enabled;
 
 void configure_rtc_emulation_amiga(uint8_t enabled) {
     if (enabled == rtc_emulation_enabled)
@@ -18,50 +14,54 @@ void configure_rtc_emulation_amiga(uint8_t enabled) {
 }
 
 int handle_register_read_amiga(unsigned int addr, unsigned char type, unsigned int *val) {
-    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);
-            return 1;
-            break;
-        case OP_TYPE_WORD:
-            *val = readGayle(addr);
-            return 1;
-            break;
-        case OP_TYPE_LONGWORD:
-            *val = readGayleL(addr);
-            return 1;
-            break;
-        case OP_TYPE_MEM:
+    if (gayle_emulation_enabled) {
+        if (!rtc_emulation_enabled && addr >= CLOCKBASE && addr < CLOCKBASE + CLOCKSIZE)
             return -1;
-            break;
+        if (addr >= GAYLEBASE && addr < GAYLEBASE + GAYLESIZE) {
+            switch(type) {
+            case OP_TYPE_BYTE:
+                *val = readGayleB(addr);
+                return 1;
+                break;
+            case OP_TYPE_WORD:
+                *val = readGayle(addr);
+                return 1;
+                break;
+            case OP_TYPE_LONGWORD:
+                *val = readGayleL(addr);
+                return 1;
+                break;
+            case OP_TYPE_MEM:
+                return -1;
+                break;
+            }
         }
     }
     return -1;
 }
 
 int handle_register_write_amiga(unsigned int addr, unsigned int value, unsigned char type) {
-    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);
-            return 1;
-            break;
-        case OP_TYPE_WORD:
-            writeGayle(addr, value);
-            return 1;
-            break;
-        case OP_TYPE_LONGWORD:
-            writeGayleL(addr, value);
-            return 1;
-            break;
-        case OP_TYPE_MEM:
+    if (gayle_emulation_enabled) {
+        if (!rtc_emulation_enabled && addr >= CLOCKBASE && addr < CLOCKBASE + CLOCKSIZE)
             return -1;
-            break;
+        if (addr >= GAYLEBASE && addr < GAYLEBASE + GAYLESIZE) {
+            switch(type) {
+            case OP_TYPE_BYTE:
+                writeGayleB(addr, value);
+                return 1;
+                break;
+            case OP_TYPE_WORD:
+                writeGayle(addr, value);
+                return 1;
+                break;
+            case OP_TYPE_LONGWORD:
+                writeGayleL(addr, value);
+                return 1;
+                break;
+            case OP_TYPE_MEM:
+                return -1;
+                break;
+            }
         }
     }
     return -1;