From bc1fe36ceb404974752152a7a25f78df78c773c6 Mon Sep 17 00:00:00 2001 From: Matt Harlum Date: Fri, 12 Jan 2024 00:12:45 +1300 Subject: [PATCH] Add RIPPLE IDE --- expansion.cpp | 9 ++++ idecontrollers.cpp | 111 ++++++++++++++++++++++++++++++++++++++- include/idecontrollers.h | 3 ++ include/rommgr.h | 1 + 4 files changed, 123 insertions(+), 1 deletion(-) diff --git a/expansion.cpp b/expansion.cpp index a71f6da9..1ee008c9 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -6006,6 +6006,15 @@ const struct expansionromtype expansionroms[] = { }, #endif + { + _T("ripple"), _T("RIPPLE"), _T("Matt Harlum"), + NULL, ripple_init, NULL, ripple_add_ide_unit, ROMTYPE_RIPPLE | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, false, + NULL, 0, + true, EXPANSIONTYPE_IDE, + 0, 0, 1, false, NULL, + false, 2, NULL, + { 0xd2, 0x07, 0x00, 0x00, 0x14, 0x4A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08 } + }, /* PC Bridgeboards */ diff --git a/idecontrollers.cpp b/idecontrollers.cpp index d82695a8..27db5d2a 100644 --- a/idecontrollers.cpp +++ b/idecontrollers.cpp @@ -62,7 +62,8 @@ #define TANDEM_IDE (TRIFECTA_IDE + MAX_DUPLICATE_EXPANSION_BOARDS) #define DOTTO_IDE (TANDEM_IDE + MAX_DUPLICATE_EXPANSION_BOARDS) #define DEV_IDE (DOTTO_IDE + MAX_DUPLICATE_EXPANSION_BOARDS) -#define TOTAL_IDE (DEV_IDE + MAX_DUPLICATE_EXPANSION_BOARDS) +#define RIPPLE_IDE (DEV_IDE + MAX_DUPLICATE_EXPANSION_BOARDS) +#define TOTAL_IDE (RIPPLE_IDE + 2 * MAX_DUPLICATE_EXPANSION_BOARDS) #define ALF_ROM_OFFSET 0x0100 #define GVP_IDE_ROM_OFFSET 0x8000 @@ -128,6 +129,7 @@ static struct ide_board *trifecta_board[MAX_DUPLICATE_EXPANSION_BOARDS]; static struct ide_board *tandem_board[MAX_DUPLICATE_EXPANSION_BOARDS]; static struct ide_board *dotto_board[MAX_DUPLICATE_EXPANSION_BOARDS]; static struct ide_board *dev_board[MAX_DUPLICATE_EXPANSION_BOARDS]; +static struct ide_board *ripple_board[MAX_DUPLICATE_EXPANSION_BOARDS]; static struct ide_hdf *idecontroller_drive[TOTAL_IDE * 2]; static struct ide_thread_state idecontroller_its; @@ -648,6 +650,22 @@ static int get_dev_hd_reg(uaecptr addr, struct ide_board* board) return reg; } +static int get_ripple_reg(uaecptr addr, struct ide_board *board, int *portnum) +{ + int reg = -1; + *portnum = (addr & 0x2000) ? 1 : 0; + + if (addr & 0x3000) { + reg = (addr >> 9) & 7; + + if (addr & 0x4000) { + reg |= IDE_SECONDARY; + } + } + + return reg; +} + static int getidenum(struct ide_board *board, struct ide_board **arr) { for (int i = 0; i < MAX_DUPLICATE_EXPANSION_BOARDS; i++) { @@ -1074,6 +1092,21 @@ static uae_u32 ide_read_byte2(struct ide_board *board, uaecptr addr) } } + } else if (board->type == RIPPLE_IDE) { + if (board->rom && board->userdata == 0) { + v = board->rom[(addr & board->rom_mask)]; + return v; + } + int portnum = 0; + int regnum = get_ripple_reg(addr,board,&portnum); + if (!ide_isdrive(board->ide[portnum]) && !ide_isdrive(board->ide[portnum]->pair)) { + v = 0xff; + return v; + } + if (regnum >= 0 && board->ide[portnum]) { + v = get_ide_reg_multi(board,regnum,portnum,1); + } + } return v; @@ -1400,6 +1433,19 @@ static uae_u32 ide_read_word(struct ide_board *board, uaecptr addr) } } + } else if (board->type == RIPPLE_IDE) { + if (board->rom && board->userdata == 0) { + v = board->rom[addr & board->rom_mask]; + v <<= 8; + v |= board->rom[(addr + 1) & board->rom_mask]; + return v; + } + int portnum = 0; + int regnum = get_ripple_reg(addr,board,&portnum); + if (regnum == IDE_DATA && board->ide[portnum]) { + v = get_ide_reg_multi(board, regnum, portnum, 1); + } + } } @@ -1804,6 +1850,13 @@ static void ide_write_byte(struct ide_board *board, uaecptr addr, uae_u8 v) } + } else if (board->type == RIPPLE_IDE) { + if ((addr & 0x3000) && board->userdata == 0) board->userdata = 1; + int portnum = 0; + int reg = get_ripple_reg(addr,board,&portnum); + if (board->ide[portnum] && reg >= 0) { + put_ide_reg_multi(board,reg,v,portnum,1); + } } } } @@ -2014,6 +2067,15 @@ static void ide_write_word(struct ide_board *board, uaecptr addr, uae_u16 v) put_ide_reg(board, reg, v); } + } else if (board->type == RIPPLE_IDE) { + if ((addr & 0x3000) && board->userdata == 0) + board->userdata = 1; + if (board->configured) { + int portnum = 0; + int reg = get_ripple_reg(addr, board, &portnum); + if (reg >= 0 && board->ide[portnum]) + put_ide_reg_multi(board,reg,v,portnum,1); + } } } } @@ -3217,6 +3279,53 @@ void dev_hd_add_ide_unit(int ch, struct uaedev_config_info* ci, struct romconfig add_ide_standard_unit(ch, ci, rc, dev_board, DEV_IDE, false, true, 2); } +bool ripple_init(struct autoconfig_info *aci) +{ + const struct expansionromtype *ert = get_device_expansion_rom(ROMTYPE_RIPPLE); + + ide_add_reset(); + if (!aci->doinit) { + aci->autoconfigp = ert->autoconfig; + return true; + } + + struct ide_board *ide = getide(aci); + if (!ide) + return false; + + ide->configured = 0; + ide->bank = &ide_bank_generic; + ide->type = RIPPLE_IDE; + ide->rom_size = 131072; + ide->userdata = 0; + ide->intena = false; + ide->mask = 131072 - 1; + ide->keepautoconfig = false; + + ide->rom = xcalloc(uae_u8, ide->rom_size); + if (ide->rom) { + memset(ide->rom, 0xff, ide->rom_size); + } + + ide->rom_mask = ide->rom_size - 1; + + for (int i = 0; i < 16; i++) { + uae_u8 b = ert->autoconfig[i]; + if (i == 0 && aci->rc->autoboot_disabled) + b &= ~0x10; + ew(ide, i * 4, b); + } + + load_rom_rc(aci->rc, ROMTYPE_RIPPLE, 65536, 0, ide->rom, 131072, LOADROM_EVENONLY_ODDONE); + + aci->addrbank = ide->bank; + return true; +} + +void ripple_add_ide_unit(int ch, struct uaedev_config_info *ci, struct romconfig *rc) +{ + add_ide_standard_unit(ch, ci, rc, ripple_board, RIPPLE_IDE, false, false, 4); +} extern void x86_xt_ide_bios(struct zfile*, struct romconfig*); static bool x86_at_hd_init(struct autoconfig_info *aci, int type) diff --git a/include/idecontrollers.h b/include/idecontrollers.h index 18111528..f21aa5b2 100644 --- a/include/idecontrollers.h +++ b/include/idecontrollers.h @@ -67,6 +67,9 @@ bool dotto_init(struct autoconfig_info *aci); void dev_hd_add_ide_unit(int ch, struct uaedev_config_info* ci, struct romconfig* rc); bool dev_hd_init(struct autoconfig_info* aci); +void ripple_add_ide_unit(int ch, struct uaedev_config_info* ci, struct romconfig* rc); +bool ripple_init(struct autoconfig_info* aci); + uae_u32 REGPARAM3 apollo_ide_lget (uaecptr addr) REGPARAM; uae_u32 REGPARAM3 apollo_ide_wget (uaecptr addr) REGPARAM; uae_u32 REGPARAM3 apollo_ide_bget (uaecptr addr) REGPARAM; diff --git a/include/rommgr.h b/include/rommgr.h index de631e8a..cb4b211a 100644 --- a/include/rommgr.h +++ b/include/rommgr.h @@ -216,6 +216,7 @@ extern int decode_cloanto_rom_do(uae_u8 *mem, int size, int real_size); #define ROMTYPE_RAINBOWII 0x00100092 #define ROMTYPE_MERLIN 0x00100093 #define ROMTYPE_KBMCU 0x00100094 +#define ROMTYPE_RIPPLE 0x00100095 #define ROMTYPE_NOT 0x00800000 #define ROMTYPE_QUAD 0x01000000 -- 2.47.3