src/mess/machine/coupe.c
| r2347 | r2348 | |
| 14 | 14 | #include "machine/msm6242.h" |
| 15 | 15 | |
| 16 | 16 | |
| 17 | | #define LMPR_RAM0 0x20 /* If bit set ram is paged into bank 0, else its rom0 */ |
| 18 | | #define LMPR_ROM1 0x40 /* If bit set rom1 is paged into bank 3, else its ram */ |
| 17 | #define LMPR_RAM0 0x20 /* If bit set ram is paged into bank 0, else its rom0 */ |
| 18 | #define LMPR_ROM1 0x40 /* If bit set rom1 is paged into bank 3, else its ram */ |
| 19 | #define HMPR_MCNTRL 0x80 /* If set external RAM is enabled */ |
| 19 | 20 | |
| 20 | 21 | |
| 21 | 22 | struct coupe_asic coupe_regs; |
| r2347 | r2348 | |
| 23 | 24 | |
| 24 | 25 | static void coupe_update_bank(int bank, UINT8 *memory, int is_readonly) |
| 25 | 26 | { |
| 26 | | read8_machine_func rh; |
| 27 | | write8_machine_func wh; |
| 27 | read8_machine_func rh = SMH_NOP; |
| 28 | write8_machine_func wh = SMH_NOP; |
| 28 | 29 | |
| 29 | 30 | if (memory) |
| 31 | { |
| 30 | 32 | memory_set_bankptr(bank, memory); |
| 33 | rh = (read8_machine_func) (STATIC_BANK1 + (FPTR)bank - 1); |
| 34 | wh = is_readonly ? SMH_UNMAP : (write8_machine_func) (STATIC_BANK1 + (FPTR)bank - 1); |
| 35 | } |
| 31 | 36 | |
| 32 | | rh = !memory ? SMH_NOP : (read8_machine_func) (STATIC_BANK1 + (FPTR)bank - 1); |
| 33 | | wh = !memory ? SMH_NOP : (is_readonly ? SMH_UNMAP : (write8_machine_func) (STATIC_BANK1 + (FPTR)bank - 1)); |
| 34 | | |
| 35 | 37 | memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, ((bank-1) * 0x4000), ((bank-1) * 0x4000) + 0x3FFF, 0, 0, rh); |
| 36 | 38 | memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, ((bank-1) * 0x4000), ((bank-1) * 0x4000) + 0x3FFF, 0, 0, wh); |
| 37 | 39 | } |
| r2347 | r2348 | |
| 41 | 43 | void coupe_update_memory(void) |
| 42 | 44 | { |
| 43 | 45 | UINT8 *rom = memory_region(REGION_CPU1); |
| 44 | | int PAGE_MASK = (mess_ram_size / 0x4000) - 1; |
| 46 | int PAGE_MASK = ((mess_ram_size & 0xfffff) / 0x4000) - 1; |
| 45 | 47 | UINT8 *memory; |
| 46 | 48 | int is_readonly; |
| 47 | 49 | |
| r2347 | r2348 | |
| 69 | 71 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 70 | 72 | coupe_update_bank(2, memory, FALSE); |
| 71 | 73 | |
| 72 | | |
| 73 | | /* BANK3 */ |
| 74 | | if ( (coupe_regs.hmpr & 0x1F) <= PAGE_MASK ) |
| 75 | | memory = &mess_ram[(coupe_regs.hmpr & PAGE_MASK)*0x4000]; |
| 76 | | else |
| 77 | | memory = NULL; /* Attempt to page in non existant ram region */ |
| 78 | | coupe_update_bank(3, memory, FALSE); |
| 79 | | |
| 80 | | |
| 81 | | /* BANK4 */ |
| 82 | | if (coupe_regs.lmpr & LMPR_ROM1) /* Is Rom1 paged in at bank 4 */ |
| 74 | /* only update bank 3 and 4 when external memory is not enabled */ |
| 75 | if (!(coupe_regs.hmpr & HMPR_MCNTRL)) |
| 83 | 76 | { |
| 84 | | memory = rom + 0x4000; |
| 85 | | is_readonly = TRUE; |
| 86 | | } |
| 87 | | else |
| 88 | | { |
| 89 | | if (( (coupe_regs.hmpr+1) & 0x1F) <= PAGE_MASK) |
| 90 | | memory = &mess_ram[((coupe_regs.hmpr+1) & PAGE_MASK) * 0x4000]; |
| 77 | /* BANK3 */ |
| 78 | if ( (coupe_regs.hmpr & 0x1F) <= PAGE_MASK ) |
| 79 | memory = &mess_ram[(coupe_regs.hmpr & PAGE_MASK)*0x4000]; |
| 91 | 80 | else |
| 92 | 81 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 93 | | is_readonly = FALSE; |
| 82 | coupe_update_bank(3, memory, FALSE); |
| 83 | |
| 84 | |
| 85 | /* BANK4 */ |
| 86 | if (coupe_regs.lmpr & LMPR_ROM1) /* Is Rom1 paged in at bank 4 */ |
| 87 | { |
| 88 | memory = rom + 0x4000; |
| 89 | is_readonly = TRUE; |
| 90 | } |
| 91 | else |
| 92 | { |
| 93 | if (( (coupe_regs.hmpr+1) & 0x1F) <= PAGE_MASK) |
| 94 | memory = &mess_ram[((coupe_regs.hmpr+1) & PAGE_MASK) * 0x4000]; |
| 95 | else |
| 96 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 97 | is_readonly = FALSE; |
| 98 | } |
| 99 | coupe_update_bank(4, memory, FALSE); |
| 94 | 100 | } |
| 95 | | coupe_update_bank(4, memory, FALSE); |
| 96 | 101 | |
| 97 | | |
| 98 | 102 | if (coupe_regs.vmpr & 0x40) /* if bit set in 2 bank screen mode */ |
| 99 | 103 | videoram = &mess_ram[((coupe_regs.vmpr&0x1E) & PAGE_MASK) * 0x4000]; |
| 100 | 104 | else |
| r2347 | r2348 | |
| 102 | 106 | } |
| 103 | 107 | |
| 104 | 108 | |
| 109 | WRITE8_HANDLER( coupe_ext_mem_w ) |
| 110 | { |
| 111 | /* external RAM enabled? */ |
| 112 | if (coupe_regs.hmpr & HMPR_MCNTRL) |
| 113 | { |
| 114 | UINT8 *mem = NULL; |
| 115 | |
| 116 | /* only install if we have enough memory */ |
| 117 | if (data >> 6 < mess_ram_size >> 20) |
| 118 | mem = &mess_ram[(mess_ram_size & 0xfffff) + (data >> 6) * 0x100000 + (data & 0x3f) * 0x4000]; |
| 119 | |
| 120 | coupe_update_bank(offset & 1 ? 4 : 3, mem, FALSE); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | |
| 105 | 125 | static READ8_HANDLER( coupe_rtc_r ) |
| 106 | 126 | { |
| 107 | 127 | return msm6242_r(machine, offset >> 12); |
src/mess/drivers/coupe.c
| r2347 | r2348 | |
| 290 | 290 | |
| 291 | 291 | |
| 292 | 292 | static ADDRESS_MAP_START( coupe_io, ADDRESS_SPACE_IO, 8 ) |
| 293 | AM_RANGE(0x80, 0x81) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_WRITE(coupe_ext_mem_w) |
| 293 | 294 | AM_RANGE(0xe0, 0xe7) AM_MIRROR(0xff10) AM_MASK(0xffff) AM_READWRITE(coupe_disk_r, coupe_disk_w) |
| 294 | 295 | AM_RANGE(0xf8, 0xf8) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(coupe_pen_r, coupe_clut_w) |
| 295 | 296 | AM_RANGE(0xf9, 0xf9) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(coupe_status_r, coupe_line_int_w) |
| r2347 | r2348 | |
| 600 | 601 | |
| 601 | 602 | |
| 602 | 603 | SYSTEM_CONFIG_START(coupe) |
| 603 | | CONFIG_RAM_DEFAULT(256 * 1024) |
| 604 | | CONFIG_RAM(512 * 1024) |
| 605 | | |
| 604 | CONFIG_RAM(256 * 1024) |
| 605 | CONFIG_RAM_DEFAULT(512 * 1024) |
| 606 | CONFIG_RAM(256 * 1024 + 1 * 1024 * 1024) |
| 607 | CONFIG_RAM(512 * 1024 + 1 * 1024 * 1024) |
| 608 | CONFIG_RAM(256 * 1024 + 2 * 1024 * 1024) |
| 609 | CONFIG_RAM(512 * 1024 + 2 * 1024 * 1024) |
| 610 | CONFIG_RAM(256 * 1024 + 3 * 1024 * 1024) |
| 611 | CONFIG_RAM(512 * 1024 + 3 * 1024 * 1024) |
| 612 | CONFIG_RAM(256 * 1024 + 4 * 1024 * 1024) |
| 613 | CONFIG_RAM(512 * 1024 + 4 * 1024 * 1024) |
| 606 | 614 | CONFIG_DEVICE(coupe_floppy_getinfo) |
| 607 | 615 | SYSTEM_CONFIG_END |
| 608 | 616 | |