]> git.sesse.net Git - pistorm/commitdiff
Update Gayle.c, emulator.c, and amiga-platform.c
authorbeeanyew <beeanyew@gmail.com>
Fri, 1 Jan 2021 12:32:51 +0000 (13:32 +0100)
committerbeeanyew <beeanyew@gmail.com>
Fri, 1 Jan 2021 12:32:51 +0000 (13:32 +0100)
Gayle.c
emulator.c
platforms/amiga/amiga-platform.c

diff --git a/Gayle.c b/Gayle.c
index 9b21f9002f809a0e6d02028ab07589350b6f0010..c238699d3bc5dc803d3dd65f725df586ddbe8db3 100644 (file)
--- a/Gayle.c
+++ b/Gayle.c
@@ -102,6 +102,9 @@ uint8_t rtc_type = RTC_TYPE_RICOH;
 
 char *hdd_image_file[GAYLE_MAX_HARDFILES];
 
+uint8_t cdtv_mode = 0;
+unsigned char cdtv_sram[32 * SIZE_KILO];
+
 void set_hard_drive_image_file_amiga(uint8_t index, char *filename) {
   if (hdd_image_file[index] != NULL)
     free(hdd_image_file[index]);
@@ -207,7 +210,9 @@ void writeGayleB(unsigned int address, unsigned int value) {
 
   if ((address & GAYLEMASK) == CLOCKBASE) {
     if ((address & CLOCKMASK) >= 0x8000) {
-      printf("Byte write to CDTV SRAM?\n");
+      if (cdtv_mode) {
+        cdtv_sram[(address & CLOCKMASK) - 0x8000] = value;
+      }
       return;
     }
     put_rtc_byte(address, value, rtc_type);
@@ -225,7 +230,9 @@ void writeGayle(unsigned int address, unsigned int value) {
 
   if ((address & GAYLEMASK) == CLOCKBASE) {
     if ((address & CLOCKMASK) >= 0x8000) {
-      printf("Word write to CDTV SRAM?\n");
+      if (cdtv_mode) {
+        ((short *) ((size_t)(cdtv_sram + (address & CLOCKMASK) - 0x8000)))[0] = htobe16(value);
+      }
       return;
     }
     printf("Word write to RTC.\n");
@@ -240,7 +247,9 @@ void writeGayle(unsigned int address, unsigned int value) {
 void writeGayleL(unsigned int address, unsigned int value) {
   if ((address & GAYLEMASK) == CLOCKBASE) {
     if ((address & CLOCKMASK) >= 0x8000) {
-      printf("Longword write to CDTV SRAM?\n");
+      if (cdtv_mode) {
+        ((int *) (size_t)(cdtv_sram + (address & CLOCKMASK) - 0x8000))[0] = htobe32(value);
+      }
       return;
     }
     printf("Longword write to RTC.\n");
@@ -288,7 +297,9 @@ uint8_t readGayleB(unsigned int address) {
 
   if ((address & GAYLEMASK) == CLOCKBASE) {
     if ((address & CLOCKMASK) >= 0x8000) {
-      printf("Byte read from CDTV SRAM?\n");
+      if (cdtv_mode) {
+        return cdtv_sram[(address & CLOCKMASK) - 0x8000];
+      }
       return 0;
     }
     return get_rtc_byte(address, rtc_type);
@@ -354,7 +365,10 @@ uint16_t readGayle(unsigned int address) {
 
   if ((address & GAYLEMASK) == CLOCKBASE) {
     if ((address & CLOCKMASK) >= 0x8000) {
-      printf("Word read from CDTV SRAM?\n");
+      if (cdtv_mode) {
+
+        return be16toh( (( unsigned short *) (size_t)(cdtv_sram + (address & CLOCKMASK) - 0x8000))[0]);
+      }
       return 0;
     }
     return ((get_rtc_byte(address, rtc_type) << 8) | (get_rtc_byte(address + 1, rtc_type)));
@@ -367,7 +381,9 @@ uint16_t readGayle(unsigned int address) {
 uint32_t readGayleL(unsigned int address) {
   if ((address & GAYLEMASK) == CLOCKBASE) {
     if ((address & CLOCKMASK) >= 0x8000) {
-      printf("Longword read from CDTV SRAM?\n");
+      if (cdtv_mode) {
+        return be32toh( (( unsigned short *) (size_t)(cdtv_sram + (address & CLOCKMASK) - 0x8000))[0]);
+      }
       return 0;
     }
     return ((get_rtc_byte(address, rtc_type) << 24) | (get_rtc_byte(address + 1, rtc_type) << 16) | (get_rtc_byte(address + 2, rtc_type) << 8) | (get_rtc_byte(address + 3, rtc_type)));
index a8985412fcaa20f16d0956c0f55d7a2a22e6de0f..51a6f0cfa61dd8c91b861ccc9b4fe288170965c6 100644 (file)
       reset |= (1 << (no)); \
   } while (0)
 
-#define FASTBASE 0x07FFFFFF
-#define FASTSIZE 0xFFFFFFF
-#define GAYLEBASE 0xD80000  // D7FFFF
-#define GAYLESIZE 0x6FFFF
-
 #define JOY0DAT 0xDFF00A
 #define JOY1DAT 0xDFF00C
 #define CIAAPRA 0xBFE001
index 71fd2b5d1c4c1c66bf6584171950c6627adfd8a3..d213425b8ec1475c4b9935aa671c748236fb70eb 100644 (file)
@@ -25,6 +25,7 @@ char *z3_autoconf_id = "z3_autoconf_fast";
 char *z3_autoconf_zap_id = "^3_autoconf_fast";
 
 extern const char *op_type_names[OP_TYPE_NUM];
+extern uint8_t cdtv_mode;
 
 #define min(a, b) (a < b) ? a : b
 #define max(a, b) (a > b) ? a : b
@@ -233,6 +234,9 @@ void setvar_amiga(char *var, char *val) {
         if (val && strlen(val) != 0)
             set_hard_drive_image_file_amiga(0, val);
     }
+    if (strcmp(var, "cdtv") == 0) {
+        cdtv_mode = 1;
+    }
 }
 
 void handle_reset_amiga(struct emulator_config *cfg) {