trunk/src/emu/bus/a7800/a78_slot.c
| r32298 | r32299 | |
| 62 | 62 | |
| 63 | 63 | void device_a78_cart_interface::rom_alloc(UINT32 size) |
| 64 | 64 | { |
| 65 | | if (m_rom == NULL) |
| 66 | | { |
| 67 | | m_rom.resize(size); |
| 68 | | |
| 69 | | // setup other helpers |
| 70 | | if ((size / 0x4000) & 1) // compensate for SuperGame carts with 9 x 16K banks (to my knowledge no other cart has m_bank_mask != power of 2) |
| 71 | | m_bank_mask = (size / 0x4000) - 2; |
| 72 | | else |
| 73 | | m_bank_mask = (size / 0x4000) - 1; |
| 74 | | |
| 75 | | // the rom is mapped to the top of the memory area |
| 76 | | // so we store the starting point of data to simplify |
| 77 | | // the access handling |
| 78 | | m_base_rom = 0x10000 - size; |
| 79 | | } |
| 65 | m_rom.resize(size); |
| 66 | |
| 67 | // setup other helpers |
| 68 | if ((size / 0x4000) & 1) // compensate for SuperGame carts with 9 x 16K banks (to my knowledge no other cart has m_bank_mask != power of 2) |
| 69 | m_bank_mask = (size / 0x4000) - 2; |
| 70 | else |
| 71 | m_bank_mask = (size / 0x4000) - 1; |
| 72 | |
| 73 | // the rom is mapped to the top of the memory area |
| 74 | // so we store the starting point of data to simplify |
| 75 | // the access handling |
| 76 | m_base_rom = 0x10000 - size; |
| 80 | 77 | } |
| 81 | 78 | |
| 82 | 79 | //------------------------------------------------- |
| r32298 | r32299 | |
| 85 | 82 | |
| 86 | 83 | void device_a78_cart_interface::ram_alloc(UINT32 size) |
| 87 | 84 | { |
| 88 | | if (m_ram == NULL) |
| 89 | | { |
| 90 | | m_ram.resize(size); |
| 91 | | device().save_item(NAME(m_ram)); |
| 92 | | } |
| 85 | m_ram.resize(size); |
| 86 | device().save_item(NAME(m_ram)); |
| 93 | 87 | } |
| 94 | 88 | |
| 95 | 89 | |
| r32298 | r32299 | |
| 99 | 93 | |
| 100 | 94 | void device_a78_cart_interface::nvram_alloc(UINT32 size) |
| 101 | 95 | { |
| 102 | | if (m_nvram == NULL) |
| 103 | | { |
| 104 | | m_nvram.resize(size); |
| 105 | | device().save_item(NAME(m_nvram)); |
| 106 | | } |
| 96 | m_nvram.resize(size); |
| 97 | device().save_item(NAME(m_nvram)); |
| 107 | 98 | } |
| 108 | 99 | |
| 109 | 100 | |
| r32298 | r32299 | |
| 120 | 111 | device_image_interface(mconfig, *this), |
| 121 | 112 | device_slot_interface(mconfig, *this) |
| 122 | 113 | { |
| 123 | | m_type = A78_NOCART; |
| 124 | 114 | } |
| 125 | 115 | |
| 126 | 116 | |
| r32298 | r32299 | |
| 321 | 311 | { A78_TYPE1_POK450, "a78_p450_t1" }, |
| 322 | 312 | { A78_TYPE6_POK450, "a78_p450_t6" }, |
| 323 | 313 | { A78_TYPEA_POK450, "a78_p450_ta" }, |
| 324 | | { A78_VERSA_POK450, "a78_p450_vb" }, |
| 325 | | { A78_NOCART, "empty" }, // the code should never get here, of course... |
| 314 | { A78_VERSA_POK450, "a78_p450_vb" } |
| 326 | 315 | }; |
| 327 | 316 | |
| 328 | 317 | static int a78_get_pcb_id(const char *slot) |
| r32298 | r32299 | |
| 508 | 497 | |
| 509 | 498 | bool a78_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) |
| 510 | 499 | { |
| 511 | | load_software_part_region(*this, swlist, swname, start_entry ); |
| 500 | load_software_part_region(*this, swlist, swname, start_entry); |
| 512 | 501 | return TRUE; |
| 513 | 502 | } |
| 514 | 503 | |
trunk/src/emu/bus/pce/pce_slot.c
| r32298 | r32299 | |
| 44 | 44 | |
| 45 | 45 | void device_pce_cart_interface::rom_alloc(UINT32 size) |
| 46 | 46 | { |
| 47 | | if (m_rom == NULL) |
| 48 | | m_rom.resize(size); |
| 47 | m_rom.resize(size); |
| 49 | 48 | } |
| 50 | 49 | |
| 51 | 50 | |
| r32298 | r32299 | |
| 55 | 54 | |
| 56 | 55 | void device_pce_cart_interface::ram_alloc(UINT32 size) |
| 57 | 56 | { |
| 58 | | if (m_ram == NULL) |
| 59 | | { |
| 60 | | m_ram.resize(size); |
| 61 | | device().save_item(NAME(m_ram)); |
| 62 | | } |
| 57 | m_ram.resize(size); |
| 58 | device().save_item(NAME(m_ram)); |
| 63 | 59 | } |
| 64 | 60 | |
| 65 | 61 | //------------------------------------------------- |
| r32298 | r32299 | |
| 69 | 65 | |
| 70 | 66 | void device_pce_cart_interface::rom_map_setup(UINT32 size) |
| 71 | 67 | { |
| 72 | | int i; |
| 73 | | |
| 74 | 68 | if (size == 0x60000) |
| 75 | 69 | { |
| 76 | 70 | // HuCard 384K are mapped with mirrored pieces |
| r32298 | r32299 | |
| 85 | 79 | } |
| 86 | 80 | else |
| 87 | 81 | { |
| 82 | int i; |
| 83 | |
| 88 | 84 | // setup the rom_bank_map array to faster ROM read |
| 89 | 85 | for (i = 0; i < size / 0x20000 && i < 8; i++) |
| 90 | 86 | rom_bank_map[i] = i; |
| r32298 | r32299 | |
| 281 | 277 | |
| 282 | 278 | bool pce_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) |
| 283 | 279 | { |
| 284 | | load_software_part_region(*this, swlist, swname, start_entry ); |
| 280 | load_software_part_region(*this, swlist, swname, start_entry); |
| 285 | 281 | return TRUE; |
| 286 | 282 | } |
| 287 | 283 | |
trunk/src/emu/bus/a800/a800_slot.c
| r32298 | r32299 | |
| 59 | 59 | |
| 60 | 60 | void device_a800_cart_interface::rom_alloc(UINT32 size) |
| 61 | 61 | { |
| 62 | | if (m_rom == NULL) |
| 63 | | { |
| 64 | | m_rom.resize(size); |
| 65 | | |
| 66 | | // setup other helpers |
| 67 | | m_bank_mask = (size / 0x2000) - 1; // code for XEGS carts makes use of this to simplify banking |
| 68 | | } |
| 62 | m_rom.resize(size); |
| 63 | |
| 64 | // setup other helpers |
| 65 | m_bank_mask = (size / 0x2000) - 1; // code for XEGS carts makes use of this to simplify banking |
| 69 | 66 | } |
| 70 | 67 | |
| 71 | 68 | //------------------------------------------------- |
| r32298 | r32299 | |
| 74 | 71 | |
| 75 | 72 | void device_a800_cart_interface::ram_alloc(UINT32 size) |
| 76 | 73 | { |
| 77 | | if (m_ram == NULL) |
| 78 | | { |
| 79 | | m_ram.resize(size); |
| 80 | | device().save_item(NAME(m_ram)); |
| 81 | | } |
| 74 | m_ram.resize(size); |
| 75 | device().save_item(NAME(m_ram)); |
| 82 | 76 | } |
| 83 | 77 | |
| 84 | 78 | |
| r32298 | r32299 | |
| 88 | 82 | |
| 89 | 83 | void device_a800_cart_interface::nvram_alloc(UINT32 size) |
| 90 | 84 | { |
| 91 | | if (m_nvram == NULL) |
| 92 | | { |
| 93 | | m_nvram.resize(size); |
| 94 | | device().save_item(NAME(m_nvram)); |
| 95 | | } |
| 85 | m_nvram.resize(size); |
| 86 | device().save_item(NAME(m_nvram)); |
| 96 | 87 | } |
| 97 | 88 | |
| 98 | 89 | |
| r32298 | r32299 | |
| 109 | 100 | device_image_interface(mconfig, *this), |
| 110 | 101 | device_slot_interface(mconfig, *this) |
| 111 | 102 | { |
| 112 | | m_type = A800_NOCART; |
| 113 | 103 | } |
| 114 | 104 | |
| 115 | 105 | a800_cart_slot_device::a800_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| r32298 | r32299 | |
| 117 | 107 | device_image_interface(mconfig, *this), |
| 118 | 108 | device_slot_interface(mconfig, *this) |
| 119 | 109 | { |
| 120 | | m_type = A800_NOCART; |
| 121 | 110 | } |
| 122 | 111 | |
| 123 | 112 | |
| r32298 | r32299 | |
| 215 | 204 | { A5200_32K, "a5200" }, |
| 216 | 205 | { A5200_16K_2CHIPS, "a5200_2chips" }, |
| 217 | 206 | { A5200_32K, "a5200" }, |
| 218 | | { A5200_BBSB, "a5200_bbsb" }, |
| 219 | | { A800_NOCART, "empty" }, |
| 207 | { A5200_BBSB, "a5200_bbsb" } |
| 220 | 208 | }; |
| 221 | 209 | |
| 222 | 210 | |
| r32298 | r32299 | |
| 314 | 302 | |
| 315 | 303 | bool a800_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) |
| 316 | 304 | { |
| 317 | | load_software_part_region(*this, swlist, swname, start_entry ); |
| 305 | load_software_part_region(*this, swlist, swname, start_entry); |
| 318 | 306 | return TRUE; |
| 319 | 307 | } |
| 320 | 308 | |
trunk/src/emu/bus/nes/nes_slot.c
| r32298 | r32299 | |
| 142 | 142 | |
| 143 | 143 | void device_nes_cart_interface::prg_alloc(size_t size) |
| 144 | 144 | { |
| 145 | | if (m_prg == NULL) |
| 145 | m_prg.resize(size); |
| 146 | m_prg_chunks = size / 0x4000; |
| 147 | if (size % 0x2000) |
| 146 | 148 | { |
| 147 | | m_prg.resize(size); |
| 148 | | m_prg_chunks = size / 0x4000; |
| 149 | | if (size % 0x2000) |
| 150 | | { |
| 151 | | // A few pirate carts have PRG made of 32K + 2K or some weird similar config |
| 152 | | // in this case we treat the banking as if this 'extra' PRG is not present and |
| 153 | | // the pcb code has to handle it by accessing directly m_prg! |
| 154 | | printf("Warning! The loaded PRG has size not a multiple of 8KB (0x%X)\n", (UINT32)size); |
| 155 | | m_prg_chunks--; |
| 156 | | } |
| 157 | | |
| 158 | | m_prg_mask = ((m_prg_chunks << 1) - 1); |
| 159 | | |
| 149 | // A few pirate carts have PRG made of 32K + 2K or some weird similar config |
| 150 | // in this case we treat the banking as if this 'extra' PRG is not present and |
| 151 | // the pcb code has to handle it by accessing directly m_prg! |
| 152 | printf("Warning! The loaded PRG has size not a multiple of 8KB (0x%X)\n", (UINT32)size); |
| 153 | m_prg_chunks--; |
| 154 | } |
| 155 | |
| 156 | m_prg_mask = ((m_prg_chunks << 1) - 1); |
| 157 | |
| 160 | 158 | // printf("first mask %x!\n", m_prg_mask); |
| 161 | | if ((m_prg_chunks << 1) & m_prg_mask) |
| 162 | | { |
| 163 | | int mask_bits = 0, temp = (m_prg_chunks << 1), mapsize; |
| 164 | | // contrary to what happens with later systems, like e.g. SNES or MD, |
| 165 | | // only half a dozen of NES carts have PRG which is not a power of 2 |
| 166 | | // so we use this bank_map only as an exception |
| 159 | if ((m_prg_chunks << 1) & m_prg_mask) |
| 160 | { |
| 161 | int mask_bits = 0, temp = (m_prg_chunks << 1), mapsize; |
| 162 | // contrary to what happens with later systems, like e.g. SNES or MD, |
| 163 | // only half a dozen of NES carts have PRG which is not a power of 2 |
| 164 | // so we use this bank_map only as an exception |
| 167 | 165 | // printf("uneven rom!\n"); |
| 168 | | |
| 169 | | // 1. redefine mask as (next power of 2)-1 |
| 170 | | for (; temp; ) |
| 171 | | { |
| 172 | | mask_bits++; |
| 173 | | temp >>= 1; |
| 174 | | } |
| 175 | | m_prg_mask = (1 << mask_bits) - 1; |
| 166 | |
| 167 | // 1. redefine mask as (next power of 2)-1 |
| 168 | for (; temp; ) |
| 169 | { |
| 170 | mask_bits++; |
| 171 | temp >>= 1; |
| 172 | } |
| 173 | m_prg_mask = (1 << mask_bits) - 1; |
| 176 | 174 | // printf("new mask %x!\n", m_prg_mask); |
| 177 | | mapsize = (1 << mask_bits)/2; |
| 178 | | |
| 179 | | // 2. create a bank_map for banks in the range mask/2 -> mask |
| 180 | | m_prg_bank_map.resize(mapsize); |
| 181 | | |
| 182 | | // 3. fill the bank_map accounting for mirrors |
| 183 | | int j; |
| 184 | | for (j = mapsize; j < (m_prg_chunks << 1); j++) |
| 185 | | m_prg_bank_map[j - mapsize] = j; |
| 186 | | |
| 187 | | while (j % mapsize) |
| 188 | | { |
| 189 | | int k = 0, repeat_banks; |
| 190 | | while ((j % (mapsize >> k)) && k < mask_bits) |
| 191 | | k++; |
| 192 | | repeat_banks = j % (mapsize >> (k - 1)); |
| 193 | | for (int l = 0; l < repeat_banks; l++) |
| 194 | | m_prg_bank_map[(j - mapsize) + l] = m_prg_bank_map[(j - mapsize) + l - repeat_banks]; |
| 195 | | j += repeat_banks; |
| 196 | | } |
| 197 | | |
| 198 | | // check bank map! |
| 175 | mapsize = (1 << mask_bits)/2; |
| 176 | |
| 177 | // 2. create a bank_map for banks in the range mask/2 -> mask |
| 178 | m_prg_bank_map.resize(mapsize); |
| 179 | |
| 180 | // 3. fill the bank_map accounting for mirrors |
| 181 | int j; |
| 182 | for (j = mapsize; j < (m_prg_chunks << 1); j++) |
| 183 | m_prg_bank_map[j - mapsize] = j; |
| 184 | |
| 185 | while (j % mapsize) |
| 186 | { |
| 187 | int k = 0, repeat_banks; |
| 188 | while ((j % (mapsize >> k)) && k < mask_bits) |
| 189 | k++; |
| 190 | repeat_banks = j % (mapsize >> (k - 1)); |
| 191 | for (int l = 0; l < repeat_banks; l++) |
| 192 | m_prg_bank_map[(j - mapsize) + l] = m_prg_bank_map[(j - mapsize) + l - repeat_banks]; |
| 193 | j += repeat_banks; |
| 194 | } |
| 195 | |
| 196 | // check bank map! |
| 199 | 197 | // for (int i = 0; i < mapsize; i++) |
| 200 | 198 | // { |
| 201 | 199 | // printf("bank %3d = %3d\t", i, m_prg_bank_map[i]); |
| 202 | 200 | // if ((i%8) == 7) |
| 203 | 201 | // printf("\n"); |
| 204 | 202 | // } |
| 205 | | } |
| 206 | 203 | } |
| 207 | 204 | } |
| 208 | 205 | |
| 209 | 206 | void device_nes_cart_interface::prgram_alloc(size_t size) |
| 210 | 207 | { |
| 211 | | if (m_prgram == NULL) |
| 212 | | m_prgram.resize(size); |
| 208 | m_prgram.resize(size); |
| 213 | 209 | } |
| 214 | 210 | |
| 215 | 211 | void device_nes_cart_interface::vrom_alloc(size_t size) |
| 216 | 212 | { |
| 217 | | if (m_vrom == NULL) |
| 218 | | { |
| 219 | | m_vrom.resize(size); |
| 220 | | m_vrom_chunks = size / 0x2000; |
| 221 | | } |
| 213 | m_vrom.resize(size); |
| 214 | m_vrom_chunks = size / 0x2000; |
| 222 | 215 | } |
| 223 | 216 | |
| 224 | 217 | void device_nes_cart_interface::vram_alloc(size_t size) |
| 225 | 218 | { |
| 226 | | if (m_vram == NULL) |
| 227 | | { |
| 228 | | m_vram.resize(size); |
| 229 | | m_vram_chunks = size / 0x2000; |
| 230 | | } |
| 219 | m_vram.resize(size); |
| 220 | m_vram_chunks = size / 0x2000; |
| 231 | 221 | } |
| 232 | 222 | |
| 233 | 223 | void device_nes_cart_interface::battery_alloc(size_t size) |
| 234 | 224 | { |
| 235 | | if (m_battery == NULL) |
| 236 | | m_battery.resize(size); |
| 225 | m_battery.resize(size); |
| 237 | 226 | } |
| 238 | 227 | |
| 239 | 228 | |
| r32298 | r32299 | |
| 905 | 894 | |
| 906 | 895 | bool nes_cart_slot_device::call_softlist_load(software_list_device &swlist, const char *swname, const rom_entry *start_entry) |
| 907 | 896 | { |
| 908 | | load_software_part_region(*this, swlist, swname, start_entry ); |
| 897 | load_software_part_region(*this, swlist, swname, start_entry); |
| 909 | 898 | return TRUE; |
| 910 | 899 | } |
| 911 | 900 | |