From 4c31e2243743905fd77b6c4a907d795b21f06373 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Tue, 4 Oct 2016 19:16:22 +0300 Subject: [PATCH] Autosized Z2 mapping helper. --- cpuboard.cpp | 6 +++--- expansion.cpp | 15 +++++++++++++++ include/autoconf.h | 1 + include/memory.h | 1 + memory.cpp | 10 ++++++++++ 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/cpuboard.cpp b/cpuboard.cpp index e01a330a..12b0ca0d 100644 --- a/cpuboard.cpp +++ b/cpuboard.cpp @@ -872,8 +872,8 @@ static void REGPARAM2 blizzarde8_bput(uaecptr addr, uae_u32 b) b &= 0xff; addr &= 65535; if (addr == 0x48 && !configured) { - map_banks(&blizzardea_bank, b, blizzardea_bank.allocated_size >> 16, 0); - write_log(_T("Accelerator Z2 board autoconfigured at %02X0000\n"), b); + uae_u32 size = map_banks_z2_autosize(&blizzardea_bank, b); + write_log(_T("Accelerator Z2 board autoconfigured at %02X0000, size %08x\n"), b, size); configured = 1; expamem_next (&blizzardea_bank, NULL); return; @@ -2541,7 +2541,7 @@ bool cpuboard_autoconfig_init(struct autoconfig_info *aci) blizzardea_bank.baseaddr[i * 2 + 0] = b; } } else if (is_csmk1(p)) { - earom_size = 131072; + earom_size = 131072; // really 64k but ea and f0 use same space f0rom_size = 65536; for (int i = 0; i < 32768; i++) { uae_u8 b = 0xff; diff --git a/expansion.cpp b/expansion.cpp index d4db4e11..2f9092dc 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -2262,6 +2262,21 @@ static void add_expansions(struct uae_prefs *p, int zorro, int *fastmem_nump, in *fastmem_nump = fastmem_num; } +uae_u32 expansion_board_size(addrbank *ab) +{ + uae_u32 size = 0; + uae_u8 code = (ab->bget(0) & 0xf0) | ((ab->bget(2) & 0xf0) >> 4); + if ((code & 0xc0) == zorroII) { + // Z2 + code &= 7; + if (code == 0) + size = 8 * 1024 * 1024; + else + size = 32768 << code; + } + return size; +} + static uae_u8 autoconfig_read(const uae_u8 *autoconfig, int offset) { uae_u8 b = (autoconfig[offset] & 0xf0) | (autoconfig[offset + 2] >> 4); diff --git a/include/autoconf.h b/include/autoconf.h index ae1725b5..04b4e7b7 100644 --- a/include/autoconf.h +++ b/include/autoconf.h @@ -157,6 +157,7 @@ extern bool expansion_can_move(struct uae_prefs *p, int index); extern bool alloc_expansion_bank(addrbank *bank, struct autoconfig_info *aci); extern void free_expansion_bank(addrbank *bank); extern void expansion_map(void); +extern uae_u32 expansion_board_size(addrbank *ab); extern void uaegfx_install_code (uaecptr); diff --git a/include/memory.h b/include/memory.h index 3a259f66..15af8cc5 100644 --- a/include/memory.h +++ b/include/memory.h @@ -458,6 +458,7 @@ extern void memory_cleanup(void); extern void restore_banks(void); extern void map_banks (addrbank *bank, int first, int count, int realsize); extern void map_banks_z2(addrbank *bank, int first, int count); +extern uae_u32 map_banks_z2_autosize(addrbank *bank, int first); extern void map_banks_z3(addrbank *bank, int first, int count); extern bool validate_banks_z2(addrbank *bank, int start, int size); extern bool validate_banks_z3(addrbank *bank, int start, int size); diff --git a/memory.cpp b/memory.cpp index bca4f21d..7bd20f90 100644 --- a/memory.cpp +++ b/memory.cpp @@ -2953,6 +2953,16 @@ void map_banks_z2 (addrbank *bank, int start, int size) map_banks (bank, start, size, 0); } +uae_u32 map_banks_z2_autosize(addrbank *bank, int start) +{ + uae_u32 size = expansion_board_size(bank); + if (!size) { + error_log(_T("Z2 map_banks(%s) %08x, invalid size!\n"), bank->name, start << 16); + return 0; + } + map_banks_z2(bank, start, size >> 16); + return size; +} void map_banks_quick (addrbank *bank, int start, int size, int realsize) { -- 2.47.3