From a03d104d5a1bcaf73605dc83976b1bd95fe2304a Mon Sep 17 00:00:00 2001 From: beeanyew Date: Fri, 1 Jan 2021 13:32:51 +0100 Subject: [PATCH] Update Gayle.c, emulator.c, and amiga-platform.c --- Gayle.c | 28 ++++++++++++++++++++++------ emulator.c | 5 ----- platforms/amiga/amiga-platform.c | 4 ++++ 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Gayle.c b/Gayle.c index 9b21f90..c238699 100644 --- 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))); diff --git a/emulator.c b/emulator.c index a898541..51a6f0c 100644 --- a/emulator.c +++ b/emulator.c @@ -71,11 +71,6 @@ 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 diff --git a/platforms/amiga/amiga-platform.c b/platforms/amiga/amiga-platform.c index 71fd2b5..d213425 100644 --- a/platforms/amiga/amiga-platform.c +++ b/platforms/amiga/amiga-platform.c @@ -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) { -- 2.39.2