trunk/src/emu/bus/msx_cart/nomapper.c
| r31011 | r31012 | |
| 20 | 20 | void msx_cart_nomapper::initialize_cartridge() |
| 21 | 21 | { |
| 22 | 22 | UINT32 size = get_rom_size(); |
| 23 | UINT8 *rom = get_rom_base(); |
| 23 | 24 | |
| 25 | // determine start address |
| 26 | // default to $4000 |
| 24 | 27 | m_start_address = 0x4000; |
| 25 | | |
| 26 | | if (size <= 0x4000) |
| 28 | |
| 29 | switch (size) |
| 27 | 30 | { |
| 28 | | // Check if this ROM should be in page 2 |
| 29 | | |
| 30 | | UINT8 *rom = get_rom_base(); |
| 31 | | |
| 32 | | if (rom[0] == 'A' && rom[1] == 'B' && (rom[3] & 0x80)) |
| 31 | /* 8KB/16KB */ |
| 32 | case 0x2000: case 0x4000: |
| 33 | 33 | { |
| 34 | | m_start_address = 0x8000; |
| 34 | UINT16 start = rom[3] << 8 | rom[2]; |
| 35 | |
| 36 | // start address of $0000: call address in the $4000 region: $4000, else $8000 |
| 37 | if (start == 0) |
| 38 | { |
| 39 | if ((rom[5] & 0xc0) == 0x40) |
| 40 | m_start_address = 0x4000; |
| 41 | else |
| 42 | m_start_address = 0x8000; |
| 43 | } |
| 44 | |
| 45 | // start address in the $8000 region: $8000, else default |
| 46 | else if ((start & 0xc000) == 0x8000) |
| 47 | m_start_address = 0x8000; |
| 48 | |
| 49 | break; |
| 35 | 50 | } |
| 36 | | } |
| 37 | 51 | |
| 38 | | if (size == 0x10000) |
| 39 | | { |
| 40 | | m_start_address = 0; |
| 52 | /* 32KB */ |
| 53 | case 0x8000: |
| 54 | // take default, check when no "AB" at $0000, but "AB" at $4000 |
| 55 | if (rom[0] != 'A' && rom[1] != 'B' && rom[0x4000] == 'A' && rom[0x4001] == 'B') |
| 56 | { |
| 57 | UINT16 start = rom[0x4003] << 8 | rom[0x4002]; |
| 58 | |
| 59 | // start address of $0000 and call address in the $4000 region, or start address outside the $8000 region: $0000, else default |
| 60 | if ((start == 0 && (rom[0x4005] & 0xc0) == 0x40) || start < 0x8000 || start >= 0xc000) |
| 61 | m_start_address = 0; |
| 62 | } |
| 63 | |
| 64 | break; |
| 65 | |
| 66 | /* 48KB */ |
| 67 | case 0xc000: |
| 68 | // "AB" at $0000, but no "AB" at $4000, not "AB": $0000 |
| 69 | if (rom[0] == 'A' && rom[1] == 'B' && rom[0x4000] != 'A' && rom[0x4001] != 'B') |
| 70 | m_start_address = 0x4000; |
| 71 | else |
| 72 | m_start_address = 0; |
| 73 | |
| 74 | break; |
| 75 | |
| 76 | /* 64KB */ |
| 77 | default: |
| 78 | m_start_address = 0; |
| 79 | break; |
| 41 | 80 | } |
| 42 | 81 | |
| 43 | 82 | m_end_address = MIN(m_start_address + size, 0x10000); |