]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Autosized Z2 mapping helper.
authorToni Wilen <twilen@winuae.net>
Tue, 4 Oct 2016 16:16:22 +0000 (19:16 +0300)
committerToni Wilen <twilen@winuae.net>
Tue, 4 Oct 2016 16:16:22 +0000 (19:16 +0300)
cpuboard.cpp
expansion.cpp
include/autoconf.h
include/memory.h
memory.cpp

index e01a330ab7d373ceeab4d94936fe7e72ac8e594b..12b0ca0d4491ba6a085708b4515fe00cc5d3e77f 100644 (file)
@@ -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;
index d4db4e119daedec3b46b93db4230c8b1d5e4ba79..2f9092dc0900c4e7f82430f435a19a36c91501bb 100644 (file)
@@ -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);
index ae1725b571625bafa12c5781387c6da3c9bb754f..04b4e7b7234529e5d27d240ca750160ea8934a0b 100644 (file)
@@ -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);
 
index 3a259f669caed4d7a2d944f376be98ec82d1e5e5..15af8cc5889560639c68a4e5ded329afc7de7a64 100644 (file)
@@ -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);
index bca4f21d959c0c61e3b56ca698300f0c464617e7..7bd20f90e0ee0d1fe183fd0875ab8efedff90bd3 100644 (file)
@@ -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)
 {