src/mess/machine/coupe.c
| r2624 | r2625 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | SAM Coupe Driver - Written By Lee Hammerton |
| 4 | | |
| 5 | | Functions to emulate general aspects of the machine (RAM, ROM, interrupts, |
| 6 | | I/O ports) |
| 7 | | |
| 8 | | ***************************************************************************/ |
| 9 | | |
| 10 | | #include "driver.h" |
| 11 | | #include "deprecat.h" |
| 12 | | #include "includes/coupe.h" |
| 13 | | #include "devices/basicdsk.h" |
| 14 | | #include "machine/wd17xx.h" |
| 15 | | #include "machine/msm6242.h" |
| 16 | | |
| 17 | | |
| 18 | | #define LMPR_RAM0 0x20 /* If bit set ram is paged into bank 0, else its rom0 */ |
| 19 | | #define LMPR_ROM1 0x40 /* If bit set rom1 is paged into bank 3, else its ram */ |
| 20 | | #define HMPR_MCNTRL 0x80 /* If set external RAM is enabled */ |
| 21 | | |
| 22 | | |
| 23 | | struct coupe_asic coupe_regs; |
| 24 | | |
| 25 | | |
| 26 | | static void coupe_update_bank(int bank, UINT8 *memory, int is_readonly) |
| 27 | | { |
| 28 | | read8_machine_func rh = SMH_NOP; |
| 29 | | write8_machine_func wh = SMH_NOP; |
| 30 | | |
| 31 | | if (memory) |
| 32 | | { |
| 33 | | memory_set_bankptr(bank, memory); |
| 34 | | rh = (read8_machine_func) (STATIC_BANK1 + (FPTR)bank - 1); |
| 35 | | wh = is_readonly ? SMH_UNMAP : (write8_machine_func) (STATIC_BANK1 + (FPTR)bank - 1); |
| 36 | | } |
| 37 | | |
| 38 | | memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, ((bank-1) * 0x4000), ((bank-1) * 0x4000) + 0x3FFF, 0, 0, rh); |
| 39 | | memory_install_write8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, ((bank-1) * 0x4000), ((bank-1) * 0x4000) + 0x3FFF, 0, 0, wh); |
| 40 | | } |
| 41 | | |
| 42 | | |
| 43 | | static void coupe_install_ext_mem(void) |
| 44 | | { |
| 45 | | UINT8 *mem; |
| 46 | | |
| 47 | | /* bank 3 */ |
| 48 | | if (coupe_regs.lext >> 6 < mess_ram_size >> 20) |
| 49 | | mem = &mess_ram[(mess_ram_size & 0xfffff) + (coupe_regs.lext >> 6) * 0x100000 + (coupe_regs.lext & 0x3f) * 0x4000]; |
| 50 | | else |
| 51 | | mem = NULL; |
| 52 | | |
| 53 | | coupe_update_bank(3, mem, FALSE); |
| 54 | | |
| 55 | | /* bank 4 */ |
| 56 | | if (coupe_regs.hext >> 6 < mess_ram_size >> 20) |
| 57 | | mem = &mess_ram[(mess_ram_size & 0xfffff) + (coupe_regs.hext >> 6) * 0x100000 + (coupe_regs.hext & 0x3f) * 0x4000]; |
| 58 | | else |
| 59 | | mem = NULL; |
| 60 | | |
| 61 | | coupe_update_bank(4, mem, FALSE); |
| 62 | | } |
| 63 | | |
| 64 | | |
| 65 | | void coupe_update_memory(void) |
| 66 | | { |
| 67 | | const int PAGE_MASK = ((mess_ram_size & 0xfffff) / 0x4000) - 1; |
| 68 | | UINT8 *rom = memory_region(REGION_CPU1); |
| 69 | | UINT8 *memory; |
| 70 | | int is_readonly; |
| 71 | | |
| 72 | | /* BANK1 */ |
| 73 | | if (coupe_regs.lmpr & LMPR_RAM0) /* Is ram paged in at bank 1 */ |
| 74 | | { |
| 75 | | if ((coupe_regs.lmpr & 0x1F) <= PAGE_MASK) |
| 76 | | memory = &mess_ram[(coupe_regs.lmpr & PAGE_MASK) * 0x4000]; |
| 77 | | else |
| 78 | | memory = NULL; /* Attempt to page in non existant ram region */ |
| 79 | | is_readonly = FALSE; |
| 80 | | } |
| 81 | | else |
| 82 | | { |
| 83 | | memory = rom; /* Rom0 paged in */ |
| 84 | | is_readonly = TRUE; |
| 85 | | } |
| 86 | | coupe_update_bank(1, memory, is_readonly); |
| 87 | | |
| 88 | | |
| 89 | | /* BANK2 */ |
| 90 | | if (((coupe_regs.lmpr + 1) & 0x1f) <= PAGE_MASK) |
| 91 | | memory = &mess_ram[((coupe_regs.lmpr + 1) & PAGE_MASK) * 0x4000]; |
| 92 | | else |
| 93 | | memory = NULL; /* Attempt to page in non existant ram region */ |
| 94 | | coupe_update_bank(2, memory, FALSE); |
| 95 | | |
| 96 | | /* only update bank 3 and 4 when external memory is not enabled */ |
| 97 | | if (coupe_regs.hmpr & HMPR_MCNTRL) |
| 98 | | { |
| 99 | | coupe_install_ext_mem(); |
| 100 | | } |
| 101 | | else |
| 102 | | { |
| 103 | | /* BANK3 */ |
| 104 | | if ((coupe_regs.hmpr & 0x1F) <= PAGE_MASK ) |
| 105 | | memory = &mess_ram[(coupe_regs.hmpr & PAGE_MASK)*0x4000]; |
| 106 | | else |
| 107 | | memory = NULL; /* Attempt to page in non existant ram region */ |
| 108 | | coupe_update_bank(3, memory, FALSE); |
| 109 | | |
| 110 | | |
| 111 | | /* BANK4 */ |
| 112 | | if (coupe_regs.lmpr & LMPR_ROM1) /* Is Rom1 paged in at bank 4 */ |
| 113 | | { |
| 114 | | memory = rom + 0x4000; |
| 115 | | is_readonly = TRUE; |
| 116 | | } |
| 117 | | else |
| 118 | | { |
| 119 | | if (((coupe_regs.hmpr + 1) & 0x1f) <= PAGE_MASK) |
| 120 | | memory = &mess_ram[((coupe_regs.hmpr + 1) & PAGE_MASK) * 0x4000]; |
| 121 | | else |
| 122 | | memory = NULL; /* Attempt to page in non existant ram region */ |
| 123 | | is_readonly = FALSE; |
| 124 | | } |
| 125 | | coupe_update_bank(4, memory, FALSE); |
| 126 | | } |
| 127 | | |
| 128 | | /* video memory location */ |
| 129 | | if (coupe_regs.vmpr & 0x40) /* if bit set in 2 bank screen mode */ |
| 130 | | videoram = &mess_ram[((coupe_regs.vmpr & 0x1e) & PAGE_MASK) * 0x4000]; |
| 131 | | else |
| 132 | | videoram = &mess_ram[((coupe_regs.vmpr & 0x1f) & PAGE_MASK) * 0x4000]; |
| 133 | | } |
| 134 | | |
| 135 | | |
| 136 | | WRITE8_HANDLER( coupe_ext_mem_w ) |
| 137 | | { |
| 138 | | if (offset & 1) |
| 139 | | coupe_regs.hext = data; |
| 140 | | else |
| 141 | | coupe_regs.lext = data; |
| 142 | | |
| 143 | | /* external RAM enabled? */ |
| 144 | | if (coupe_regs.hmpr & HMPR_MCNTRL) |
| 145 | | { |
| 146 | | coupe_install_ext_mem(); |
| 147 | | } |
| 148 | | } |
| 149 | | |
| 150 | | |
| 151 | | static READ8_HANDLER( coupe_rtc_r ) |
| 152 | | { |
| 153 | | const device_config *rtc = device_list_find_by_tag(machine->config->devicelist, MSM6242, "sambus_clock"); |
| 154 | | return msm6242_r(rtc, offset >> 12); |
| 155 | | } |
| 156 | | |
| 157 | | |
| 158 | | static WRITE8_HANDLER( coupe_rtc_w ) |
| 159 | | { |
| 160 | | const device_config *rtc = device_list_find_by_tag(machine->config->devicelist, MSM6242, "sambus_clock"); |
| 161 | | msm6242_w(rtc, offset >> 12, data); |
| 162 | | } |
| 163 | | |
| 164 | | |
| 165 | | MACHINE_RESET( coupe ) |
| 166 | | { |
| 167 | | memset(&coupe_regs, 0, sizeof(coupe_regs)); |
| 168 | | |
| 169 | | coupe_regs.lmpr = 0x0f; /* ROM0 paged in, ROM1 paged out RAM Banks */ |
| 170 | | coupe_regs.hmpr = 0x01; |
| 171 | | coupe_regs.vmpr = 0x81; |
| 172 | | coupe_regs.line_int = 0xff; /* line interrupts disabled */ |
| 173 | | coupe_regs.status = 0x1f; /* no interrupts active */ |
| 174 | | |
| 175 | | if (input_port_read(machine, "config") & 0x01) |
| 176 | | { |
| 177 | | /* install RTC */ |
| 178 | | memory_install_readwrite8_handler(machine, 0, ADDRESS_SPACE_IO, 0xef, 0xef, 0xffff, 0xff00, coupe_rtc_r, coupe_rtc_w); |
| 179 | | } |
| 180 | | else |
| 181 | | { |
| 182 | | /* no RTC support */ |
| 183 | | memory_install_readwrite8_handler(machine, 0, ADDRESS_SPACE_IO, 0xef, 0xef, 0xffff, 0xff00, SMH_UNMAP, SMH_UNMAP); |
| 184 | | } |
| 185 | | |
| 186 | | coupe_update_memory(); |
| 187 | | } |
| 188 | | |
| 189 | | |
| 190 | | MACHINE_START( coupe ) |
| 191 | | { |
| 192 | | wd17xx_init(machine, WD_TYPE_1772, NULL, NULL); |
| 193 | | } |
src/mess/machine/samcoupe.c
| r0 | r2625 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | SAM Coupe Driver - Written By Lee Hammerton |
| 4 | |
| 5 | Functions to emulate general aspects of the machine (RAM, ROM, interrupts, |
| 6 | I/O ports) |
| 7 | |
| 8 | ***************************************************************************/ |
| 9 | |
| 10 | #include "driver.h" |
| 11 | #include "deprecat.h" |
| 12 | #include "includes/samcoupe.h" |
| 13 | #include "devices/basicdsk.h" |
| 14 | #include "machine/wd17xx.h" |
| 15 | #include "machine/msm6242.h" |
| 16 | |
| 17 | |
| 18 | #define LMPR_RAM0 0x20 /* If bit set ram is paged into bank 0, else its rom0 */ |
| 19 | #define LMPR_ROM1 0x40 /* If bit set rom1 is paged into bank 3, else its ram */ |
| 20 | #define HMPR_MCNTRL 0x80 /* If set external RAM is enabled */ |
| 21 | |
| 22 | |
| 23 | struct samcoupe_asic samcoupe_regs; |
| 24 | |
| 25 | |
| 26 | static void samcoupe_update_bank(int bank, UINT8 *memory, int is_readonly) |
| 27 | { |
| 28 | read8_machine_func rh = SMH_NOP; |
| 29 | write8_machine_func wh = SMH_NOP; |
| 30 | |
| 31 | if (memory) |
| 32 | { |
| 33 | memory_set_bankptr(bank, memory); |
| 34 | rh = (read8_machine_func) (STATIC_BANK1 + (FPTR)bank - 1); |
| 35 | wh = is_readonly ? SMH_UNMAP : (write8_machine_func) (STATIC_BANK1 + (FPTR)bank - 1); |
| 36 | } |
| 37 | |
| 38 | memory_install_read8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, ((bank-1) * 0x4000), ((bank-1) * 0x4000) + 0x3FFF, 0, 0, rh); |
| 39 | memory_install_write8_handler(Machine, 0, ADDRESS_SPACE_PROGRAM, ((bank-1) * 0x4000), ((bank-1) * 0x4000) + 0x3FFF, 0, 0, wh); |
| 40 | } |
| 41 | |
| 42 | |
| 43 | static void samcoupe_install_ext_mem(void) |
| 44 | { |
| 45 | UINT8 *mem; |
| 46 | |
| 47 | /* bank 3 */ |
| 48 | if (samcoupe_regs.lext >> 6 < mess_ram_size >> 20) |
| 49 | mem = &mess_ram[(mess_ram_size & 0xfffff) + (samcoupe_regs.lext >> 6) * 0x100000 + (samcoupe_regs.lext & 0x3f) * 0x4000]; |
| 50 | else |
| 51 | mem = NULL; |
| 52 | |
| 53 | samcoupe_update_bank(3, mem, FALSE); |
| 54 | |
| 55 | /* bank 4 */ |
| 56 | if (samcoupe_regs.hext >> 6 < mess_ram_size >> 20) |
| 57 | mem = &mess_ram[(mess_ram_size & 0xfffff) + (samcoupe_regs.hext >> 6) * 0x100000 + (samcoupe_regs.hext & 0x3f) * 0x4000]; |
| 58 | else |
| 59 | mem = NULL; |
| 60 | |
| 61 | samcoupe_update_bank(4, mem, FALSE); |
| 62 | } |
| 63 | |
| 64 | |
| 65 | void samcoupe_update_memory(void) |
| 66 | { |
| 67 | const int PAGE_MASK = ((mess_ram_size & 0xfffff) / 0x4000) - 1; |
| 68 | UINT8 *rom = memory_region(REGION_CPU1); |
| 69 | UINT8 *memory; |
| 70 | int is_readonly; |
| 71 | |
| 72 | /* BANK1 */ |
| 73 | if (samcoupe_regs.lmpr & LMPR_RAM0) /* Is ram paged in at bank 1 */ |
| 74 | { |
| 75 | if ((samcoupe_regs.lmpr & 0x1F) <= PAGE_MASK) |
| 76 | memory = &mess_ram[(samcoupe_regs.lmpr & PAGE_MASK) * 0x4000]; |
| 77 | else |
| 78 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 79 | is_readonly = FALSE; |
| 80 | } |
| 81 | else |
| 82 | { |
| 83 | memory = rom; /* Rom0 paged in */ |
| 84 | is_readonly = TRUE; |
| 85 | } |
| 86 | samcoupe_update_bank(1, memory, is_readonly); |
| 87 | |
| 88 | |
| 89 | /* BANK2 */ |
| 90 | if (((samcoupe_regs.lmpr + 1) & 0x1f) <= PAGE_MASK) |
| 91 | memory = &mess_ram[((samcoupe_regs.lmpr + 1) & PAGE_MASK) * 0x4000]; |
| 92 | else |
| 93 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 94 | samcoupe_update_bank(2, memory, FALSE); |
| 95 | |
| 96 | /* only update bank 3 and 4 when external memory is not enabled */ |
| 97 | if (samcoupe_regs.hmpr & HMPR_MCNTRL) |
| 98 | { |
| 99 | samcoupe_install_ext_mem(); |
| 100 | } |
| 101 | else |
| 102 | { |
| 103 | /* BANK3 */ |
| 104 | if ((samcoupe_regs.hmpr & 0x1F) <= PAGE_MASK ) |
| 105 | memory = &mess_ram[(samcoupe_regs.hmpr & PAGE_MASK)*0x4000]; |
| 106 | else |
| 107 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 108 | samcoupe_update_bank(3, memory, FALSE); |
| 109 | |
| 110 | |
| 111 | /* BANK4 */ |
| 112 | if (samcoupe_regs.lmpr & LMPR_ROM1) /* Is Rom1 paged in at bank 4 */ |
| 113 | { |
| 114 | memory = rom + 0x4000; |
| 115 | is_readonly = TRUE; |
| 116 | } |
| 117 | else |
| 118 | { |
| 119 | if (((samcoupe_regs.hmpr + 1) & 0x1f) <= PAGE_MASK) |
| 120 | memory = &mess_ram[((samcoupe_regs.hmpr + 1) & PAGE_MASK) * 0x4000]; |
| 121 | else |
| 122 | memory = NULL; /* Attempt to page in non existant ram region */ |
| 123 | is_readonly = FALSE; |
| 124 | } |
| 125 | samcoupe_update_bank(4, memory, FALSE); |
| 126 | } |
| 127 | |
| 128 | /* video memory location */ |
| 129 | if (samcoupe_regs.vmpr & 0x40) /* if bit set in 2 bank screen mode */ |
| 130 | videoram = &mess_ram[((samcoupe_regs.vmpr & 0x1e) & PAGE_MASK) * 0x4000]; |
| 131 | else |
| 132 | videoram = &mess_ram[((samcoupe_regs.vmpr & 0x1f) & PAGE_MASK) * 0x4000]; |
| 133 | } |
| 134 | |
| 135 | |
| 136 | WRITE8_HANDLER( samcoupe_ext_mem_w ) |
| 137 | { |
| 138 | if (offset & 1) |
| 139 | samcoupe_regs.hext = data; |
| 140 | else |
| 141 | samcoupe_regs.lext = data; |
| 142 | |
| 143 | /* external RAM enabled? */ |
| 144 | if (samcoupe_regs.hmpr & HMPR_MCNTRL) |
| 145 | { |
| 146 | samcoupe_install_ext_mem(); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | |
| 151 | static READ8_HANDLER( samcoupe_rtc_r ) |
| 152 | { |
| 153 | const device_config *rtc = device_list_find_by_tag(machine->config->devicelist, MSM6242, "sambus_clock"); |
| 154 | return msm6242_r(rtc, offset >> 12); |
| 155 | } |
| 156 | |
| 157 | |
| 158 | static WRITE8_HANDLER( samcoupe_rtc_w ) |
| 159 | { |
| 160 | const device_config *rtc = device_list_find_by_tag(machine->config->devicelist, MSM6242, "sambus_clock"); |
| 161 | msm6242_w(rtc, offset >> 12, data); |
| 162 | } |
| 163 | |
| 164 | |
| 165 | MACHINE_RESET( samcoupe ) |
| 166 | { |
| 167 | memset(&samcoupe_regs, 0, sizeof(samcoupe_regs)); |
| 168 | |
| 169 | samcoupe_regs.lmpr = 0x0f; /* ROM0 paged in, ROM1 paged out RAM Banks */ |
| 170 | samcoupe_regs.hmpr = 0x01; |
| 171 | samcoupe_regs.vmpr = 0x81; |
| 172 | samcoupe_regs.line_int = 0xff; /* line interrupts disabled */ |
| 173 | samcoupe_regs.status = 0x1f; /* no interrupts active */ |
| 174 | |
| 175 | if (input_port_read(machine, "config") & 0x01) |
| 176 | { |
| 177 | /* install RTC */ |
| 178 | memory_install_readwrite8_handler(machine, 0, ADDRESS_SPACE_IO, 0xef, 0xef, 0xffff, 0xff00, samcoupe_rtc_r, samcoupe_rtc_w); |
| 179 | } |
| 180 | else |
| 181 | { |
| 182 | /* no RTC support */ |
| 183 | memory_install_readwrite8_handler(machine, 0, ADDRESS_SPACE_IO, 0xef, 0xef, 0xffff, 0xff00, SMH_UNMAP, SMH_UNMAP); |
| 184 | } |
| 185 | |
| 186 | samcoupe_update_memory(); |
| 187 | } |
| 188 | |
| 189 | |
| 190 | MACHINE_START( samcoupe ) |
| 191 | { |
| 192 | wd17xx_init(machine, WD_TYPE_1772, NULL, NULL); |
| 193 | } |
src/mess/drivers/coupe.c
| r2624 | r2625 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | SAM Coupe Driver - Written By Lee Hammerton |
| 4 | | |
| 5 | | |
| 6 | | Sam Coupe Memory Map - Based around the current spectrum.c (for obvious reasons!!) |
| 7 | | |
| 8 | | CPU: |
| 9 | | 0000-7fff Banked rom/ram |
| 10 | | 8000-ffff Banked rom/ram |
| 11 | | |
| 12 | | |
| 13 | | Interrupts: |
| 14 | | |
| 15 | | Changes: |
| 16 | | |
| 17 | | V0.2 - Added FDC support. - Based on 1771 document. Coupe had a 1772... (any difference?) |
| 18 | | floppy supports only read sector single mode at present will add write sector |
| 19 | | in next version. |
| 20 | | Fixed up palette - had red & green wrong way round. |
| 21 | | |
| 22 | | |
| 23 | | KT 26-Aug-2000 - Changed to use wd179x code. This is the same as the 1772. |
| 24 | | - Coupe supports the basic disk image format, but can be changed in |
| 25 | | the future to support others |
| 26 | | |
| 27 | | Note on the bioses: |
| 28 | | SAM Coupé ROM Images |
| 29 | | -------------------- |
| 30 | | |
| 31 | | This archive contains many versions of the SAM Coupé 32K ROM image, released |
| 32 | | with kind permission from the ROM author, Dr Andy Wright. |
| 33 | | |
| 34 | | Thanks to Simon N Goodwin for supplying the files, which include two dumped |
| 35 | | from pre-production hardware (and which only work with the early hardware!). |
| 36 | | |
| 37 | | Beware - the early ROMs are very buggy, and tend to go mad once BASIC starts |
| 38 | | paging. ROM 10 (version 1.0) requires the CALL after F9 or BOOT because the |
| 39 | | ROM loads the bootstrap but fails to execute it. The address depends on the |
| 40 | | RAM size: |
| 41 | | |
| 42 | | On a 256K SAM: |
| 43 | | |
| 44 | | CALL 229385 |
| 45 | | |
| 46 | | Or on a 512K (or larger) machine: |
| 47 | | |
| 48 | | CALL 491529 |
| 49 | | |
| 50 | | -- |
| 51 | | Uploaded by Simon Owen <simon.owen@simcoupe.org> |
| 52 | | |
| 53 | | ***************************************************************************/ |
| 54 | | |
| 55 | | /* core includes */ |
| 56 | | #include "driver.h" |
| 57 | | #include "includes/coupe.h" |
| 58 | | |
| 59 | | /* components */ |
| 60 | | #include "machine/wd17xx.h" |
| 61 | | #include "sound/saa1099.h" |
| 62 | | #include "sound/speaker.h" |
| 63 | | #include "machine/msm6242.h" |
| 64 | | |
| 65 | | /* devices */ |
| 66 | | #include "devices/mflopimg.h" |
| 67 | | #include "formats/coupedsk.h" |
| 68 | | |
| 69 | | |
| 70 | | #define COUPE_XTAL_X1 XTAL_24MHz |
| 71 | | #define COUPE_XTAL_X2 XTAL_4_433619MHz |
| 72 | | |
| 73 | | |
| 74 | | |
| 75 | | /************************************* |
| 76 | | * |
| 77 | | * I/O port handling |
| 78 | | * |
| 79 | | *************************************/ |
| 80 | | |
| 81 | | static READ8_HANDLER( coupe_disk_r ) |
| 82 | | { |
| 83 | | /* drive and side is encoded into bit 5 and 3 */ |
| 84 | | wd17xx_set_drive((offset >> 4) & 1); |
| 85 | | wd17xx_set_side((offset >> 2) & 1); |
| 86 | | |
| 87 | | /* bit 1 and 2 select the controller register */ |
| 88 | | switch (offset & 0x03) |
| 89 | | { |
| 90 | | case 0: return wd17xx_status_r(machine, 0); |
| 91 | | case 1: return wd17xx_track_r(machine, 0); |
| 92 | | case 2: return wd17xx_sector_r(machine, 0); |
| 93 | | case 3: return wd17xx_data_r(machine, 0); |
| 94 | | } |
| 95 | | |
| 96 | | return 0xff; |
| 97 | | } |
| 98 | | |
| 99 | | |
| 100 | | static WRITE8_HANDLER( coupe_disk_w ) |
| 101 | | { |
| 102 | | /* drive and side is encoded into bit 5 and 3 */ |
| 103 | | wd17xx_set_drive((offset >> 4) & 1); |
| 104 | | wd17xx_set_side((offset >> 2) & 1); |
| 105 | | |
| 106 | | /* bit 1 and 2 select the controller register */ |
| 107 | | switch (offset & 0x03) |
| 108 | | { |
| 109 | | case 0: wd17xx_command_w(machine, 0, data); break; |
| 110 | | case 1: wd17xx_track_w(machine, 0, data); break; |
| 111 | | case 2: wd17xx_sector_w(machine, 0, data); break; |
| 112 | | case 3: wd17xx_data_w(machine, 0, data); break; |
| 113 | | } |
| 114 | | } |
| 115 | | |
| 116 | | |
| 117 | | static READ8_HANDLER( coupe_pen_r ) |
| 118 | | { |
| 119 | | UINT8 data; |
| 120 | | |
| 121 | | if (offset & 0x100) |
| 122 | | { |
| 123 | | /* return either the current line or 192 for the vblank area */ |
| 124 | | int line = video_screen_get_vpos(machine->primary_screen); |
| 125 | | data = video_screen_get_vblank(machine->primary_screen) ? 192 : line; |
| 126 | | } |
| 127 | | else |
| 128 | | { |
| 129 | | /* horizontal position is encoded into bits 3 to 8 */ |
| 130 | | data = video_screen_get_hpos(machine->primary_screen) & 0xfc; |
| 131 | | } |
| 132 | | |
| 133 | | return data; |
| 134 | | } |
| 135 | | |
| 136 | | |
| 137 | | static WRITE8_HANDLER( coupe_clut_w ) |
| 138 | | { |
| 139 | | coupe_regs.clut[(offset >> 8) & 0x0f] = data & 0x7f; |
| 140 | | } |
| 141 | | |
| 142 | | |
| 143 | | static READ8_HANDLER( coupe_status_r ) |
| 144 | | { |
| 145 | | UINT8 data = 0xe0; |
| 146 | | UINT8 row = ~(offset >> 8); |
| 147 | | |
| 148 | | if (row & 0x80) data &= input_port_read(machine, "keyboard_row_7f") & 0xe0; |
| 149 | | if (row & 0x40) data &= input_port_read(machine, "keyboard_row_bf") & 0xe0; |
| 150 | | if (row & 0x20) data &= input_port_read(machine, "keyboard_row_df") & 0xe0; |
| 151 | | if (row & 0x10) data &= input_port_read(machine, "keyboard_row_ef") & 0xe0; |
| 152 | | if (row & 0x08) data &= input_port_read(machine, "keyboard_row_f7") & 0xe0; |
| 153 | | if (row & 0x04) data &= input_port_read(machine, "keyboard_row_fb") & 0xe0; |
| 154 | | if (row & 0x02) data &= input_port_read(machine, "keyboard_row_fd") & 0xe0; |
| 155 | | if (row & 0x01) data &= input_port_read(machine, "keyboard_row_fe") & 0xe0; |
| 156 | | |
| 157 | | return data | coupe_regs.status; |
| 158 | | } |
| 159 | | |
| 160 | | |
| 161 | | static WRITE8_HANDLER( coupe_line_int_w ) |
| 162 | | { |
| 163 | | coupe_regs.line_int = data; |
| 164 | | } |
| 165 | | |
| 166 | | |
| 167 | | static READ8_HANDLER( coupe_lmpr_r ) |
| 168 | | { |
| 169 | | return coupe_regs.lmpr; |
| 170 | | } |
| 171 | | |
| 172 | | |
| 173 | | static WRITE8_HANDLER( coupe_lmpr_w ) |
| 174 | | { |
| 175 | | coupe_regs.lmpr = data; |
| 176 | | coupe_update_memory(); |
| 177 | | } |
| 178 | | |
| 179 | | |
| 180 | | static READ8_HANDLER( coupe_hmpr_r ) |
| 181 | | { |
| 182 | | return coupe_regs.hmpr; |
| 183 | | } |
| 184 | | |
| 185 | | |
| 186 | | static WRITE8_HANDLER( coupe_hmpr_w ) |
| 187 | | { |
| 188 | | coupe_regs.hmpr = data; |
| 189 | | coupe_update_memory(); |
| 190 | | } |
| 191 | | |
| 192 | | |
| 193 | | static READ8_HANDLER( coupe_vmpr_r ) |
| 194 | | { |
| 195 | | return coupe_regs.vmpr; |
| 196 | | } |
| 197 | | |
| 198 | | |
| 199 | | static WRITE8_HANDLER( coupe_vmpr_w ) |
| 200 | | { |
| 201 | | coupe_regs.vmpr = data; |
| 202 | | coupe_update_memory(); |
| 203 | | } |
| 204 | | |
| 205 | | |
| 206 | | static READ8_HANDLER( coupe_midi_r ) |
| 207 | | { |
| 208 | | logerror("Read from midi port\n"); |
| 209 | | return 0xff; |
| 210 | | } |
| 211 | | |
| 212 | | |
| 213 | | static WRITE8_HANDLER( coupe_midi_w ) |
| 214 | | { |
| 215 | | logerror("Write to midi port: 0x%02x\n", data); |
| 216 | | } |
| 217 | | |
| 218 | | |
| 219 | | static READ8_HANDLER( coupe_keyboard_r ) |
| 220 | | { |
| 221 | | UINT8 data = 0xff; |
| 222 | | UINT8 row = ~(offset >> 8); |
| 223 | | |
| 224 | | if (row == 0) |
| 225 | | { |
| 226 | | data &= input_port_read(machine, "keyboard_row_ff") & 0x1f; |
| 227 | | } |
| 228 | | else |
| 229 | | { |
| 230 | | if (row & 0x80) data &= input_port_read(machine, "keyboard_row_7f") & 0x1f; |
| 231 | | if (row & 0x40) data &= input_port_read(machine, "keyboard_row_bf") & 0x1f; |
| 232 | | if (row & 0x20) data &= input_port_read(machine, "keyboard_row_df") & 0x1f; |
| 233 | | if (row & 0x10) data &= input_port_read(machine, "keyboard_row_ef") & 0x1f; |
| 234 | | if (row & 0x08) data &= input_port_read(machine, "keyboard_row_f7") & 0x1f; |
| 235 | | if (row & 0x04) data &= input_port_read(machine, "keyboard_row_fb") & 0x1f; |
| 236 | | if (row & 0x02) data &= input_port_read(machine, "keyboard_row_fd") & 0x1f; |
| 237 | | if (row & 0x01) data &= input_port_read(machine, "keyboard_row_fe") & 0x1f; |
| 238 | | } |
| 239 | | |
| 240 | | return data | 0xe0; |
| 241 | | } |
| 242 | | |
| 243 | | |
| 244 | | static WRITE8_HANDLER( coupe_border_w ) |
| 245 | | { |
| 246 | | coupe_regs.border = data; |
| 247 | | |
| 248 | | /* DAC output state */ |
| 249 | | speaker_level_w(0,(data >> 4) & 0x01); |
| 250 | | } |
| 251 | | |
| 252 | | |
| 253 | | static READ8_HANDLER( coupe_attributes_r ) |
| 254 | | { |
| 255 | | if (video_screen_get_vblank(machine->primary_screen)) |
| 256 | | { |
| 257 | | /* Border areas return 0xff */ |
| 258 | | return 0xff; |
| 259 | | } |
| 260 | | else |
| 261 | | { |
| 262 | | /* TODO: This actually needs to return various attributes |
| 263 | | * of the currently displayed screen data */ |
| 264 | | return 0x00; |
| 265 | | } |
| 266 | | } |
| 267 | | |
| 268 | | |
| 269 | | static WRITE8_HANDLER( coupe_sound_w ) |
| 270 | | { |
| 271 | | if (offset & 0x100) |
| 272 | | saa1099_control_port_0_w(machine, 0, data); |
| 273 | | else |
| 274 | | saa1099_write_port_0_w(machine, 0, data); |
| 275 | | } |
| 276 | | |
| 277 | | |
| 278 | | |
| 279 | | /************************************* |
| 280 | | * |
| 281 | | * Address maps |
| 282 | | * |
| 283 | | *************************************/ |
| 284 | | |
| 285 | | static ADDRESS_MAP_START( coupe_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 286 | | AM_RANGE(0x0000, 0x3fff) AM_RAMBANK(1) |
| 287 | | AM_RANGE(0x4000, 0x7fff) AM_RAMBANK(2) |
| 288 | | AM_RANGE(0x8000, 0xbfff) AM_RAMBANK(3) |
| 289 | | AM_RANGE(0xc000, 0xffff) AM_RAMBANK(4) |
| 290 | | ADDRESS_MAP_END |
| 291 | | |
| 292 | | |
| 293 | | static ADDRESS_MAP_START( coupe_io, ADDRESS_SPACE_IO, 8 ) |
| 294 | | AM_RANGE(0x80, 0x81) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_WRITE(coupe_ext_mem_w) |
| 295 | | AM_RANGE(0xe0, 0xe7) AM_MIRROR(0xff10) AM_MASK(0xffff) AM_READWRITE(coupe_disk_r, coupe_disk_w) |
| 296 | | AM_RANGE(0xf8, 0xf8) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(coupe_pen_r, coupe_clut_w) |
| 297 | | AM_RANGE(0xf9, 0xf9) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(coupe_status_r, coupe_line_int_w) |
| 298 | | AM_RANGE(0xfa, 0xfa) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(coupe_lmpr_r, coupe_lmpr_w) |
| 299 | | AM_RANGE(0xfb, 0xfb) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(coupe_hmpr_r, coupe_hmpr_w) |
| 300 | | AM_RANGE(0xfc, 0xfc) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(coupe_vmpr_r, coupe_vmpr_w) |
| 301 | | AM_RANGE(0xfd, 0xfd) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(coupe_midi_r, coupe_midi_w) |
| 302 | | AM_RANGE(0xfe, 0xfe) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(coupe_keyboard_r, coupe_border_w) |
| 303 | | AM_RANGE(0xff, 0xff) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(coupe_attributes_r, coupe_sound_w) |
| 304 | | ADDRESS_MAP_END |
| 305 | | |
| 306 | | |
| 307 | | |
| 308 | | /************************************* |
| 309 | | * |
| 310 | | * Interrupts |
| 311 | | * |
| 312 | | *************************************/ |
| 313 | | |
| 314 | | static TIMER_CALLBACK( irq_off ) |
| 315 | | { |
| 316 | | /* clear interrupt */ |
| 317 | | cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); |
| 318 | | |
| 319 | | /* adjust STATUS register */ |
| 320 | | coupe_regs.status |= param; |
| 321 | | } |
| 322 | | |
| 323 | | |
| 324 | | void coupe_irq(running_machine *machine, UINT8 src) |
| 325 | | { |
| 326 | | /* set irq and a timer to set it off again */ |
| 327 | | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 328 | | timer_set(ATTOTIME_IN_USEC(20), NULL, src, irq_off); |
| 329 | | |
| 330 | | /* adjust STATUS register */ |
| 331 | | coupe_regs.status &= ~src; |
| 332 | | } |
| 333 | | |
| 334 | | |
| 335 | | static INTERRUPT_GEN( coupe_frame_interrupt ) |
| 336 | | { |
| 337 | | /* signal frame interrupt */ |
| 338 | | coupe_irq(machine, 0x08); |
| 339 | | } |
| 340 | | |
| 341 | | |
| 342 | | |
| 343 | | /************************************* |
| 344 | | * |
| 345 | | * Input ports |
| 346 | | * |
| 347 | | *************************************/ |
| 348 | | |
| 349 | | static INPUT_PORTS_START( coupe ) |
| 350 | | PORT_START_TAG("keyboard_row_fe") |
| 351 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 352 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') |
| 353 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') PORT_CHAR('?') |
| 354 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') |
| 355 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') |
| 356 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 357 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(F2)) |
| 358 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 359 | | |
| 360 | | PORT_START_TAG("keyboard_row_fd") |
| 361 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') |
| 362 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') |
| 363 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') |
| 364 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') PORT_CHAR('{') |
| 365 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') PORT_CHAR('}') |
| 366 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(F4)) |
| 367 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(F5)) |
| 368 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(F6)) |
| 369 | | |
| 370 | | PORT_START_TAG("keyboard_row_fb") |
| 371 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') PORT_CHAR('<') |
| 372 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') PORT_CHAR('>') |
| 373 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') |
| 374 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') PORT_CHAR('[') |
| 375 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') PORT_CHAR(']') |
| 376 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(F7)) |
| 377 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(F8)) |
| 378 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(F9)) |
| 379 | | |
| 380 | | PORT_START_TAG("keyboard_row_f7") |
| 381 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') |
| 382 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@') |
| 383 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') |
| 384 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') |
| 385 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') |
| 386 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR(UCHAR_MAMEKEY(ESC)) |
| 387 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t') |
| 388 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) |
| 389 | | |
| 390 | | PORT_START_TAG("keyboard_row_ef") |
| 391 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR('~') |
| 392 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') |
| 393 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') |
| 394 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 395 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') |
| 396 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('/') |
| 397 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('+') PORT_CHAR('*') |
| 398 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("DELETE") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) |
| 399 | | |
| 400 | | PORT_START_TAG("keyboard_row_df") |
| 401 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') |
| 402 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') |
| 403 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') |
| 404 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') |
| 405 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') |
| 406 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('=') PORT_CHAR('_') |
| 407 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('"') PORT_CHAR('\xa9') |
| 408 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F0") PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(F10)) |
| 409 | | |
| 410 | | PORT_START_TAG("keyboard_row_bf") |
| 411 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 412 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') PORT_CHAR('\xa3') |
| 413 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') |
| 414 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') |
| 415 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') PORT_CHAR('^') |
| 416 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') |
| 417 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') |
| 418 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("EDIT") PORT_CODE(KEYCODE_RALT) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) |
| 419 | | |
| 420 | | PORT_START_TAG("keyboard_row_7f") |
| 421 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 422 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SYMBOL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_SHIFT_2) |
| 423 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') |
| 424 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') |
| 425 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') |
| 426 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') |
| 427 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') |
| 428 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("INV") PORT_CODE(KEYCODE_SLASH) PORT_CHAR(UCHAR_MAMEKEY(HOME)) PORT_CHAR('\\') |
| 429 | | |
| 430 | | PORT_START_TAG("keyboard_row_ff") |
| 431 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_MAMEKEY(LALT)) |
| 432 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) |
| 433 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) |
| 434 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) |
| 435 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) |
| 436 | | |
| 437 | | PORT_START_TAG("config") |
| 438 | | PORT_CONFNAME(0x01, 0x00, "Real Time Clock") |
| 439 | | PORT_CONFSETTING( 0x00, DEF_STR(None)) |
| 440 | | PORT_CONFSETTING( 0x01, "SAMBUS") |
| 441 | | INPUT_PORTS_END |
| 442 | | |
| 443 | | |
| 444 | | |
| 445 | | /************************************* |
| 446 | | * |
| 447 | | * Palette |
| 448 | | * |
| 449 | | *************************************/ |
| 450 | | |
| 451 | | /* |
| 452 | | Decode colours for the palette as follows: |
| 453 | | |
| 454 | | bit 7 6 5 4 3 2 1 0 |
| 455 | | nothing G+4 R+4 B+4 ALL+1 G+2 R+2 B+2 |
| 456 | | |
| 457 | | These values scaled up to 0-255 range would give modifiers of: |
| 458 | | |
| 459 | | +4 = +(4*36), +2 = +(2*36), +1 = *(1*36) |
| 460 | | |
| 461 | | Not quite max of 255 but close enough for me! |
| 462 | | */ |
| 463 | | static PALETTE_INIT( coupe ) |
| 464 | | { |
| 465 | | int i; |
| 466 | | |
| 467 | | for (i = 0; i < 128; i++) |
| 468 | | { |
| 469 | | UINT8 r = 0, g = 0, b = 0; |
| 470 | | |
| 471 | | /* colors */ |
| 472 | | if (i & 0x01) b += 2*36; |
| 473 | | if (i & 0x02) r += 2*36; |
| 474 | | if (i & 0x04) g += 2*36; |
| 475 | | if (i & 0x10) b += 4*36; |
| 476 | | if (i & 0x20) r += 4*36; |
| 477 | | if (i & 0x40) g += 4*36; |
| 478 | | |
| 479 | | /* intensity bit */ |
| 480 | | if (i & 0x08) |
| 481 | | { |
| 482 | | r += 1*36; |
| 483 | | g += 1*36; |
| 484 | | b += 1*36; |
| 485 | | } |
| 486 | | |
| 487 | | palette_set_color(machine, i, MAKE_RGB(r, g, b)); |
| 488 | | } |
| 489 | | } |
| 490 | | |
| 491 | | |
| 492 | | |
| 493 | | /************************************* |
| 494 | | * |
| 495 | | * Machine drivers |
| 496 | | * |
| 497 | | *************************************/ |
| 498 | | |
| 499 | | static MACHINE_DRIVER_START( coupe ) |
| 500 | | /* basic machine hardware */ |
| 501 | | MDRV_CPU_ADD(Z80, COUPE_XTAL_X1/4) /* 6 Mhz */ |
| 502 | | MDRV_CPU_PROGRAM_MAP(coupe_mem, 0) |
| 503 | | MDRV_CPU_IO_MAP(coupe_io, 0) |
| 504 | | MDRV_CPU_VBLANK_INT("main", coupe_frame_interrupt) |
| 505 | | |
| 506 | | MDRV_MACHINE_START(coupe) |
| 507 | | MDRV_MACHINE_RESET(coupe) |
| 508 | | |
| 509 | | /* video hardware */ |
| 510 | | MDRV_SCREEN_ADD("main", RASTER) |
| 511 | | MDRV_SCREEN_RAW_PARAMS(COUPE_XTAL_X1/2, 768, 0, 512, 312, 0, 192) /* border area? */ |
| 512 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 513 | | MDRV_PALETTE_LENGTH(128) |
| 514 | | MDRV_PALETTE_INIT(coupe) |
| 515 | | |
| 516 | | MDRV_VIDEO_UPDATE(coupe) |
| 517 | | MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE) |
| 518 | | |
| 519 | | /* devices */ |
| 520 | | MDRV_DEVICE_ADD("sambus_clock", MSM6242) |
| 521 | | |
| 522 | | /* sound hardware */ |
| 523 | | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 524 | | MDRV_SOUND_ADD(SPEAKER, 0) |
| 525 | | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 526 | | MDRV_SOUND_ADD(SAA1099, COUPE_XTAL_X1/3) /* 8 MHz */ |
| 527 | | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 528 | | MACHINE_DRIVER_END |
| 529 | | |
| 530 | | |
| 531 | | |
| 532 | | /************************************* |
| 533 | | * |
| 534 | | * ROM definitions |
| 535 | | * |
| 536 | | *************************************/ |
| 537 | | |
| 538 | | /* |
| 539 | | The bios is actually 32K. This is the combined version of the two old 16K MESS roms. |
| 540 | | It does match the 3.0 one the most, but the first half differs in one byte |
| 541 | | and in the second half, the case of the "plc" in the company string differs. |
| 542 | | */ |
| 543 | | ROM_START( coupe ) |
| 544 | | ROM_REGION( 0x8000, REGION_CPU1, 0 ) |
| 545 | | ROM_SYSTEM_BIOS( 0, "31", "v3.1" ) |
| 546 | | ROMX_LOAD( "rom31.z5", 0x0000, 0x8000, CRC(0b7e3585) SHA1(c86601633fb61a8c517f7657aad9af4e6870f2ee), ROM_BIOS(1) ) |
| 547 | | ROM_SYSTEM_BIOS( 1, "30", "v3.0" ) |
| 548 | | ROMX_LOAD( "rom30.z5", 0x0000, 0x8000, CRC(e535c25d) SHA1(d390f0be420dfb12b1e54a4f528b5055d7d97e2a), ROM_BIOS(2) ) |
| 549 | | ROM_SYSTEM_BIOS( 2, "25", "v2.5" ) |
| 550 | | ROMX_LOAD( "rom25.z5", 0x0000, 0x8000, CRC(ddadd358) SHA1(a25ed85a0f1134ac3a481a3225f24a8bd3a790cf), ROM_BIOS(3) ) |
| 551 | | ROM_SYSTEM_BIOS( 3, "24", "v2.4" ) |
| 552 | | ROMX_LOAD( "rom24.z5", 0x0000, 0x8000, CRC(bb23fee4) SHA1(10cd911ba237dd2cf0c2637be1ad6745b7cc89b9), ROM_BIOS(4) ) |
| 553 | | ROM_SYSTEM_BIOS( 4, "21", "v2.1" ) |
| 554 | | ROMX_LOAD( "rom21.z5", 0x0000, 0x8000, CRC(f6804b46) SHA1(11dcac5fdea782cdac03b4d0d7ac25d88547eefe), ROM_BIOS(5) ) |
| 555 | | ROM_SYSTEM_BIOS( 5, "20", "v2.0" ) |
| 556 | | ROMX_LOAD( "rom20.z5", 0x0000, 0x8000, CRC(eaf32054) SHA1(41736323f0236649f2d5fe111f900def8db93a13), ROM_BIOS(6) ) |
| 557 | | ROM_SYSTEM_BIOS( 6, "181", "v1.81" ) |
| 558 | | ROMX_LOAD( "rom181.z5", 0x0000, 0x8000, CRC(d25e1de1) SHA1(cb0fa79e4d5f7df0b57ede08ea7ecc9ae152f534), ROM_BIOS(7) ) |
| 559 | | ROM_SYSTEM_BIOS( 7, "18", "v1.8" ) |
| 560 | | ROMX_LOAD( "rom18.z5", 0x0000, 0x8000, CRC(f626063f) SHA1(485e7d9e9a4f8a70c0f93cd6e69ff12269438829), ROM_BIOS(8) ) |
| 561 | | ROM_SYSTEM_BIOS( 8, "14", "v1.4" ) |
| 562 | | ROMX_LOAD( "rom14.z5", 0x0000, 0x8000, CRC(08799596) SHA1(b4e596051f2748dee9481ea4af7d15ccddc1e1b5), ROM_BIOS(9) ) |
| 563 | | ROM_SYSTEM_BIOS( 9, "13", "v1.3" ) |
| 564 | | ROMX_LOAD( "rom13.z5", 0x0000, 0x8000, CRC(2093768c) SHA1(af8d348fd080b18a4cbe9ed69d254be7be330146), ROM_BIOS(10) ) |
| 565 | | ROM_SYSTEM_BIOS( 10, "12", "v1.2" ) |
| 566 | | ROMX_LOAD( "rom12.z5", 0x0000, 0x8000, CRC(7fe37dd8) SHA1(9339a0c1f72e8512c6f32dec15ab7d6c3bb04151), ROM_BIOS(11) ) |
| 567 | | ROM_SYSTEM_BIOS( 11, "10", "v1.0" ) |
| 568 | | ROMX_LOAD( "rom10.z5", 0x0000, 0x8000, CRC(3659d31f) SHA1(d3de7bb74e04d5b4dc7477f70de54d540b1bcc07), ROM_BIOS(12) ) |
| 569 | | ROM_SYSTEM_BIOS( 12, "04", "v0.4" ) |
| 570 | | ROMX_LOAD( "rom04.z5", 0x0000, 0x8000, CRC(f439e84e) SHA1(8bc457a5c764b0bb0aa7008c57f28c30248fc6a4), ROM_BIOS(13) ) |
| 571 | | ROM_SYSTEM_BIOS( 13, "01", "v0.1" ) |
| 572 | | ROMX_LOAD( "rom01.z5", 0x0000, 0x8000, CRC(c04acfdf) SHA1(8976ed005c14905eec1215f0a5c28aa686a7dda2), ROM_BIOS(14) ) |
| 573 | | ROM_END |
| 574 | | |
| 575 | | |
| 576 | | |
| 577 | | /************************************* |
| 578 | | * |
| 579 | | * Devices |
| 580 | | * |
| 581 | | *************************************/ |
| 582 | | |
| 583 | | static void coupe_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 584 | | { |
| 585 | | /* floppy */ |
| 586 | | switch(state) |
| 587 | | { |
| 588 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 589 | | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 590 | | |
| 591 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 592 | | case MESS_DEVINFO_PTR_FLOPPY_OPTIONS: info->p = (void *) floppyoptions_coupe; break; |
| 593 | | |
| 594 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 595 | | case MESS_DEVINFO_STR_NAME+0: strcpy(info->s = device_temp_str(), "floppydisk0"); break; |
| 596 | | case MESS_DEVINFO_STR_NAME+1: strcpy(info->s = device_temp_str(), "floppydisk1"); break; |
| 597 | | case MESS_DEVINFO_STR_SHORT_NAME+0: strcpy(info->s = device_temp_str(), "flop0"); break; |
| 598 | | case MESS_DEVINFO_STR_SHORT_NAME+1: strcpy(info->s = device_temp_str(), "flop1"); break; |
| 599 | | case MESS_DEVINFO_STR_DESCRIPTION+0: strcpy(info->s = device_temp_str(), "Floppy #0"); break; |
| 600 | | case MESS_DEVINFO_STR_DESCRIPTION+1: strcpy(info->s = device_temp_str(), "Floppy #1"); break; |
| 601 | | |
| 602 | | default: floppy_device_getinfo(devclass, state, info); break; |
| 603 | | } |
| 604 | | } |
| 605 | | |
| 606 | | |
| 607 | | SYSTEM_CONFIG_START(coupe) |
| 608 | | CONFIG_RAM(256 * 1024) |
| 609 | | CONFIG_RAM_DEFAULT(512 * 1024) |
| 610 | | CONFIG_RAM(256 * 1024 + 1 * 1024 * 1024) |
| 611 | | CONFIG_RAM(512 * 1024 + 1 * 1024 * 1024) |
| 612 | | CONFIG_RAM(256 * 1024 + 2 * 1024 * 1024) |
| 613 | | CONFIG_RAM(512 * 1024 + 2 * 1024 * 1024) |
| 614 | | CONFIG_RAM(256 * 1024 + 3 * 1024 * 1024) |
| 615 | | CONFIG_RAM(512 * 1024 + 3 * 1024 * 1024) |
| 616 | | CONFIG_RAM(256 * 1024 + 4 * 1024 * 1024) |
| 617 | | CONFIG_RAM(512 * 1024 + 4 * 1024 * 1024) |
| 618 | | CONFIG_DEVICE(coupe_floppy_getinfo) |
| 619 | | SYSTEM_CONFIG_END |
| 620 | | |
| 621 | | |
| 622 | | |
| 623 | | /************************************* |
| 624 | | * |
| 625 | | * Game drivers |
| 626 | | * |
| 627 | | *************************************/ |
| 628 | | |
| 629 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 630 | | COMP( 1989, coupe, 0, 0, coupe, coupe, 0, coupe, "Miles Gordon Technology plc", "Sam Coupe", 0 ) |
src/mess/drivers/samcoupe.c
| r0 | r2625 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | SAM Coupe Driver - Written By Lee Hammerton |
| 4 | |
| 5 | |
| 6 | Sam Coupe Memory Map - Based around the current spectrum.c (for obvious reasons!!) |
| 7 | |
| 8 | CPU: |
| 9 | 0000-7fff Banked rom/ram |
| 10 | 8000-ffff Banked rom/ram |
| 11 | |
| 12 | |
| 13 | Interrupts: |
| 14 | |
| 15 | Changes: |
| 16 | |
| 17 | V0.2 - Added FDC support. - Based on 1771 document. Coupe had a 1772... (any difference?) |
| 18 | floppy supports only read sector single mode at present will add write sector |
| 19 | in next version. |
| 20 | Fixed up palette - had red & green wrong way round. |
| 21 | |
| 22 | |
| 23 | KT 26-Aug-2000 - Changed to use wd179x code. This is the same as the 1772. |
| 24 | - Coupe supports the basic disk image format, but can be changed in |
| 25 | the future to support others |
| 26 | |
| 27 | Note on the bioses: |
| 28 | SAM Coupe ROM Images |
| 29 | -------------------- |
| 30 | |
| 31 | This archive contains many versions of the SAM Coupe 32K ROM image, released |
| 32 | with kind permission from the ROM author, Dr Andy Wright. |
| 33 | |
| 34 | Thanks to Simon N Goodwin for supplying the files, which include two dumped |
| 35 | from pre-production hardware (and which only work with the early hardware!). |
| 36 | |
| 37 | Beware - the early ROMs are very buggy, and tend to go mad once BASIC starts |
| 38 | paging. ROM 10 (version 1.0) requires the CALL after F9 or BOOT because the |
| 39 | ROM loads the bootstrap but fails to execute it. The address depends on the |
| 40 | RAM size: |
| 41 | |
| 42 | On a 256K SAM: |
| 43 | |
| 44 | CALL 229385 |
| 45 | |
| 46 | Or on a 512K (or larger) machine: |
| 47 | |
| 48 | CALL 491529 |
| 49 | |
| 50 | -- |
| 51 | Uploaded by Simon Owen <simon.owen@simcoupe.org> |
| 52 | |
| 53 | ***************************************************************************/ |
| 54 | |
| 55 | /* core includes */ |
| 56 | #include "driver.h" |
| 57 | #include "includes/samcoupe.h" |
| 58 | |
| 59 | /* components */ |
| 60 | #include "machine/wd17xx.h" |
| 61 | #include "sound/saa1099.h" |
| 62 | #include "sound/speaker.h" |
| 63 | #include "machine/msm6242.h" |
| 64 | |
| 65 | /* devices */ |
| 66 | #include "devices/mflopimg.h" |
| 67 | #include "formats/coupedsk.h" |
| 68 | |
| 69 | |
| 70 | #define SAMCOUPE_XTAL_X1 XTAL_24MHz |
| 71 | #define SAMCOUPE_XTAL_X2 XTAL_4_433619MHz |
| 72 | |
| 73 | |
| 74 | |
| 75 | /************************************* |
| 76 | * |
| 77 | * I/O port handling |
| 78 | * |
| 79 | *************************************/ |
| 80 | |
| 81 | static READ8_HANDLER( samcoupe_disk_r ) |
| 82 | { |
| 83 | /* drive and side is encoded into bit 5 and 3 */ |
| 84 | wd17xx_set_drive((offset >> 4) & 1); |
| 85 | wd17xx_set_side((offset >> 2) & 1); |
| 86 | |
| 87 | /* bit 1 and 2 select the controller register */ |
| 88 | switch (offset & 0x03) |
| 89 | { |
| 90 | case 0: return wd17xx_status_r(machine, 0); |
| 91 | case 1: return wd17xx_track_r(machine, 0); |
| 92 | case 2: return wd17xx_sector_r(machine, 0); |
| 93 | case 3: return wd17xx_data_r(machine, 0); |
| 94 | } |
| 95 | |
| 96 | return 0xff; |
| 97 | } |
| 98 | |
| 99 | |
| 100 | static WRITE8_HANDLER( samcoupe_disk_w ) |
| 101 | { |
| 102 | /* drive and side is encoded into bit 5 and 3 */ |
| 103 | wd17xx_set_drive((offset >> 4) & 1); |
| 104 | wd17xx_set_side((offset >> 2) & 1); |
| 105 | |
| 106 | /* bit 1 and 2 select the controller register */ |
| 107 | switch (offset & 0x03) |
| 108 | { |
| 109 | case 0: wd17xx_command_w(machine, 0, data); break; |
| 110 | case 1: wd17xx_track_w(machine, 0, data); break; |
| 111 | case 2: wd17xx_sector_w(machine, 0, data); break; |
| 112 | case 3: wd17xx_data_w(machine, 0, data); break; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | |
| 117 | static READ8_HANDLER( samcoupe_pen_r ) |
| 118 | { |
| 119 | UINT8 data; |
| 120 | |
| 121 | if (offset & 0x100) |
| 122 | { |
| 123 | /* return either the current line or 192 for the vblank area */ |
| 124 | int line = video_screen_get_vpos(machine->primary_screen); |
| 125 | data = video_screen_get_vblank(machine->primary_screen) ? 192 : line; |
| 126 | } |
| 127 | else |
| 128 | { |
| 129 | /* horizontal position is encoded into bits 3 to 8 */ |
| 130 | data = video_screen_get_hpos(machine->primary_screen) & 0xfc; |
| 131 | } |
| 132 | |
| 133 | return data; |
| 134 | } |
| 135 | |
| 136 | |
| 137 | static WRITE8_HANDLER( samcoupe_clut_w ) |
| 138 | { |
| 139 | samcoupe_regs.clut[(offset >> 8) & 0x0f] = data & 0x7f; |
| 140 | } |
| 141 | |
| 142 | |
| 143 | static READ8_HANDLER( samcoupe_status_r ) |
| 144 | { |
| 145 | UINT8 data = 0xe0; |
| 146 | UINT8 row = ~(offset >> 8); |
| 147 | |
| 148 | if (row & 0x80) data &= input_port_read(machine, "keyboard_row_7f") & 0xe0; |
| 149 | if (row & 0x40) data &= input_port_read(machine, "keyboard_row_bf") & 0xe0; |
| 150 | if (row & 0x20) data &= input_port_read(machine, "keyboard_row_df") & 0xe0; |
| 151 | if (row & 0x10) data &= input_port_read(machine, "keyboard_row_ef") & 0xe0; |
| 152 | if (row & 0x08) data &= input_port_read(machine, "keyboard_row_f7") & 0xe0; |
| 153 | if (row & 0x04) data &= input_port_read(machine, "keyboard_row_fb") & 0xe0; |
| 154 | if (row & 0x02) data &= input_port_read(machine, "keyboard_row_fd") & 0xe0; |
| 155 | if (row & 0x01) data &= input_port_read(machine, "keyboard_row_fe") & 0xe0; |
| 156 | |
| 157 | return data | samcoupe_regs.status; |
| 158 | } |
| 159 | |
| 160 | |
| 161 | static WRITE8_HANDLER( samcoupe_line_int_w ) |
| 162 | { |
| 163 | samcoupe_regs.line_int = data; |
| 164 | } |
| 165 | |
| 166 | |
| 167 | static READ8_HANDLER( samcoupe_lmpr_r ) |
| 168 | { |
| 169 | return samcoupe_regs.lmpr; |
| 170 | } |
| 171 | |
| 172 | |
| 173 | static WRITE8_HANDLER( samcoupe_lmpr_w ) |
| 174 | { |
| 175 | samcoupe_regs.lmpr = data; |
| 176 | samcoupe_update_memory(); |
| 177 | } |
| 178 | |
| 179 | |
| 180 | static READ8_HANDLER( samcoupe_hmpr_r ) |
| 181 | { |
| 182 | return samcoupe_regs.hmpr; |
| 183 | } |
| 184 | |
| 185 | |
| 186 | static WRITE8_HANDLER( samcoupe_hmpr_w ) |
| 187 | { |
| 188 | samcoupe_regs.hmpr = data; |
| 189 | samcoupe_update_memory(); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | static READ8_HANDLER( samcoupe_vmpr_r ) |
| 194 | { |
| 195 | return samcoupe_regs.vmpr; |
| 196 | } |
| 197 | |
| 198 | |
| 199 | static WRITE8_HANDLER( samcoupe_vmpr_w ) |
| 200 | { |
| 201 | samcoupe_regs.vmpr = data; |
| 202 | samcoupe_update_memory(); |
| 203 | } |
| 204 | |
| 205 | |
| 206 | static READ8_HANDLER( samcoupe_midi_r ) |
| 207 | { |
| 208 | logerror("Read from midi port\n"); |
| 209 | return 0xff; |
| 210 | } |
| 211 | |
| 212 | |
| 213 | static WRITE8_HANDLER( samcoupe_midi_w ) |
| 214 | { |
| 215 | logerror("Write to midi port: 0x%02x\n", data); |
| 216 | } |
| 217 | |
| 218 | |
| 219 | static READ8_HANDLER( samcoupe_keyboard_r ) |
| 220 | { |
| 221 | UINT8 data = 0xff; |
| 222 | UINT8 row = ~(offset >> 8); |
| 223 | |
| 224 | if (row == 0) |
| 225 | { |
| 226 | data &= input_port_read(machine, "keyboard_row_ff") & 0x1f; |
| 227 | } |
| 228 | else |
| 229 | { |
| 230 | if (row & 0x80) data &= input_port_read(machine, "keyboard_row_7f") & 0x1f; |
| 231 | if (row & 0x40) data &= input_port_read(machine, "keyboard_row_bf") & 0x1f; |
| 232 | if (row & 0x20) data &= input_port_read(machine, "keyboard_row_df") & 0x1f; |
| 233 | if (row & 0x10) data &= input_port_read(machine, "keyboard_row_ef") & 0x1f; |
| 234 | if (row & 0x08) data &= input_port_read(machine, "keyboard_row_f7") & 0x1f; |
| 235 | if (row & 0x04) data &= input_port_read(machine, "keyboard_row_fb") & 0x1f; |
| 236 | if (row & 0x02) data &= input_port_read(machine, "keyboard_row_fd") & 0x1f; |
| 237 | if (row & 0x01) data &= input_port_read(machine, "keyboard_row_fe") & 0x1f; |
| 238 | } |
| 239 | |
| 240 | return data | 0xe0; |
| 241 | } |
| 242 | |
| 243 | |
| 244 | static WRITE8_HANDLER( samcoupe_border_w ) |
| 245 | { |
| 246 | samcoupe_regs.border = data; |
| 247 | |
| 248 | /* DAC output state */ |
| 249 | speaker_level_w(0,(data >> 4) & 0x01); |
| 250 | } |
| 251 | |
| 252 | |
| 253 | static READ8_HANDLER( samcoupe_attributes_r ) |
| 254 | { |
| 255 | if (video_screen_get_vblank(machine->primary_screen)) |
| 256 | { |
| 257 | /* Border areas return 0xff */ |
| 258 | return 0xff; |
| 259 | } |
| 260 | else |
| 261 | { |
| 262 | /* TODO: This actually needs to return various attributes |
| 263 | * of the currently displayed screen data */ |
| 264 | return 0x00; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | |
| 269 | static WRITE8_HANDLER( samcoupe_sound_w ) |
| 270 | { |
| 271 | if (offset & 0x100) |
| 272 | saa1099_control_port_0_w(machine, 0, data); |
| 273 | else |
| 274 | saa1099_write_port_0_w(machine, 0, data); |
| 275 | } |
| 276 | |
| 277 | |
| 278 | |
| 279 | /************************************* |
| 280 | * |
| 281 | * Address maps |
| 282 | * |
| 283 | *************************************/ |
| 284 | |
| 285 | static ADDRESS_MAP_START( samcoupe_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 286 | AM_RANGE(0x0000, 0x3fff) AM_RAMBANK(1) |
| 287 | AM_RANGE(0x4000, 0x7fff) AM_RAMBANK(2) |
| 288 | AM_RANGE(0x8000, 0xbfff) AM_RAMBANK(3) |
| 289 | AM_RANGE(0xc000, 0xffff) AM_RAMBANK(4) |
| 290 | ADDRESS_MAP_END |
| 291 | |
| 292 | |
| 293 | static ADDRESS_MAP_START( samcoupe_io, ADDRESS_SPACE_IO, 8 ) |
| 294 | AM_RANGE(0x80, 0x81) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_WRITE(samcoupe_ext_mem_w) |
| 295 | AM_RANGE(0xe0, 0xe7) AM_MIRROR(0xff10) AM_MASK(0xffff) AM_READWRITE(samcoupe_disk_r, samcoupe_disk_w) |
| 296 | AM_RANGE(0xf8, 0xf8) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(samcoupe_pen_r, samcoupe_clut_w) |
| 297 | AM_RANGE(0xf9, 0xf9) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(samcoupe_status_r, samcoupe_line_int_w) |
| 298 | AM_RANGE(0xfa, 0xfa) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(samcoupe_lmpr_r, samcoupe_lmpr_w) |
| 299 | AM_RANGE(0xfb, 0xfb) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(samcoupe_hmpr_r, samcoupe_hmpr_w) |
| 300 | AM_RANGE(0xfc, 0xfc) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(samcoupe_vmpr_r, samcoupe_vmpr_w) |
| 301 | AM_RANGE(0xfd, 0xfd) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(samcoupe_midi_r, samcoupe_midi_w) |
| 302 | AM_RANGE(0xfe, 0xfe) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(samcoupe_keyboard_r, samcoupe_border_w) |
| 303 | AM_RANGE(0xff, 0xff) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(samcoupe_attributes_r, samcoupe_sound_w) |
| 304 | ADDRESS_MAP_END |
| 305 | |
| 306 | |
| 307 | |
| 308 | /************************************* |
| 309 | * |
| 310 | * Interrupts |
| 311 | * |
| 312 | *************************************/ |
| 313 | |
| 314 | static TIMER_CALLBACK( irq_off ) |
| 315 | { |
| 316 | /* clear interrupt */ |
| 317 | cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); |
| 318 | |
| 319 | /* adjust STATUS register */ |
| 320 | samcoupe_regs.status |= param; |
| 321 | } |
| 322 | |
| 323 | |
| 324 | void samcoupe_irq(running_machine *machine, UINT8 src) |
| 325 | { |
| 326 | /* set irq and a timer to set it off again */ |
| 327 | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 328 | timer_set(ATTOTIME_IN_USEC(20), NULL, src, irq_off); |
| 329 | |
| 330 | /* adjust STATUS register */ |
| 331 | samcoupe_regs.status &= ~src; |
| 332 | } |
| 333 | |
| 334 | |
| 335 | static INTERRUPT_GEN( samcoupe_frame_interrupt ) |
| 336 | { |
| 337 | /* signal frame interrupt */ |
| 338 | samcoupe_irq(machine, 0x08); |
| 339 | } |
| 340 | |
| 341 | |
| 342 | |
| 343 | /************************************* |
| 344 | * |
| 345 | * Input ports |
| 346 | * |
| 347 | *************************************/ |
| 348 | |
| 349 | static INPUT_PORTS_START( samcoupe ) |
| 350 | PORT_START_TAG("keyboard_row_fe") |
| 351 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 352 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') |
| 353 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') PORT_CHAR('?') |
| 354 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') |
| 355 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') |
| 356 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 357 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(F2)) |
| 358 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 359 | |
| 360 | PORT_START_TAG("keyboard_row_fd") |
| 361 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') |
| 362 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') |
| 363 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') |
| 364 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') PORT_CHAR('{') |
| 365 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') PORT_CHAR('}') |
| 366 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(F4)) |
| 367 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(F5)) |
| 368 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(F6)) |
| 369 | |
| 370 | PORT_START_TAG("keyboard_row_fb") |
| 371 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') PORT_CHAR('<') |
| 372 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') PORT_CHAR('>') |
| 373 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') |
| 374 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') PORT_CHAR('[') |
| 375 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') PORT_CHAR(']') |
| 376 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(F7)) |
| 377 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(F8)) |
| 378 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(F9)) |
| 379 | |
| 380 | PORT_START_TAG("keyboard_row_f7") |
| 381 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') |
| 382 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@') |
| 383 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') |
| 384 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') |
| 385 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') |
| 386 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR(UCHAR_MAMEKEY(ESC)) |
| 387 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t') |
| 388 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) |
| 389 | |
| 390 | PORT_START_TAG("keyboard_row_ef") |
| 391 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR('~') |
| 392 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') |
| 393 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') |
| 394 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 395 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') |
| 396 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('/') |
| 397 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('+') PORT_CHAR('*') |
| 398 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("DELETE") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) |
| 399 | |
| 400 | PORT_START_TAG("keyboard_row_df") |
| 401 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') |
| 402 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') |
| 403 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') |
| 404 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') |
| 405 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') |
| 406 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('=') PORT_CHAR('_') |
| 407 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('"') PORT_CHAR('\xa9') |
| 408 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F0") PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(F10)) |
| 409 | |
| 410 | PORT_START_TAG("keyboard_row_bf") |
| 411 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 412 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') PORT_CHAR('\xa3') |
| 413 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') |
| 414 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') |
| 415 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') PORT_CHAR('^') |
| 416 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') |
| 417 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') |
| 418 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("EDIT") PORT_CODE(KEYCODE_RALT) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) |
| 419 | |
| 420 | PORT_START_TAG("keyboard_row_7f") |
| 421 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 422 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SYMBOL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_SHIFT_2) |
| 423 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') |
| 424 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') |
| 425 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') |
| 426 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') |
| 427 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') |
| 428 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("INV") PORT_CODE(KEYCODE_SLASH) PORT_CHAR(UCHAR_MAMEKEY(HOME)) PORT_CHAR('\\') |
| 429 | |
| 430 | PORT_START_TAG("keyboard_row_ff") |
| 431 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_MAMEKEY(LALT)) |
| 432 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) |
| 433 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) |
| 434 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) |
| 435 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) |
| 436 | |
| 437 | PORT_START_TAG("config") |
| 438 | PORT_CONFNAME(0x01, 0x00, "Real Time Clock") |
| 439 | PORT_CONFSETTING( 0x00, DEF_STR(None)) |
| 440 | PORT_CONFSETTING( 0x01, "SAMBUS") |
| 441 | INPUT_PORTS_END |
| 442 | |
| 443 | |
| 444 | |
| 445 | /************************************* |
| 446 | * |
| 447 | * Palette |
| 448 | * |
| 449 | *************************************/ |
| 450 | |
| 451 | /* |
| 452 | Decode colours for the palette as follows: |
| 453 | |
| 454 | bit 7 6 5 4 3 2 1 0 |
| 455 | nothing G+4 R+4 B+4 ALL+1 G+2 R+2 B+2 |
| 456 | |
| 457 | These values scaled up to 0-255 range would give modifiers of: |
| 458 | |
| 459 | +4 = +(4*36), +2 = +(2*36), +1 = *(1*36) |
| 460 | |
| 461 | Not quite max of 255 but close enough for me! |
| 462 | */ |
| 463 | static PALETTE_INIT( samcoupe ) |
| 464 | { |
| 465 | int i; |
| 466 | |
| 467 | for (i = 0; i < 128; i++) |
| 468 | { |
| 469 | UINT8 r = 0, g = 0, b = 0; |
| 470 | |
| 471 | /* colors */ |
| 472 | if (i & 0x01) b += 2*36; |
| 473 | if (i & 0x02) r += 2*36; |
| 474 | if (i & 0x04) g += 2*36; |
| 475 | if (i & 0x10) b += 4*36; |
| 476 | if (i & 0x20) r += 4*36; |
| 477 | if (i & 0x40) g += 4*36; |
| 478 | |
| 479 | /* intensity bit */ |
| 480 | if (i & 0x08) |
| 481 | { |
| 482 | r += 1*36; |
| 483 | g += 1*36; |
| 484 | b += 1*36; |
| 485 | } |
| 486 | |
| 487 | palette_set_color(machine, i, MAKE_RGB(r, g, b)); |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | |
| 492 | |
| 493 | /************************************* |
| 494 | * |
| 495 | * Machine drivers |
| 496 | * |
| 497 | *************************************/ |
| 498 | |
| 499 | static MACHINE_DRIVER_START( samcoupe ) |
| 500 | /* basic machine hardware */ |
| 501 | MDRV_CPU_ADD(Z80, SAMCOUPE_XTAL_X1/4) /* 6 Mhz */ |
| 502 | MDRV_CPU_PROGRAM_MAP(samcoupe_mem, 0) |
| 503 | MDRV_CPU_IO_MAP(samcoupe_io, 0) |
| 504 | MDRV_CPU_VBLANK_INT("main", samcoupe_frame_interrupt) |
| 505 | |
| 506 | MDRV_MACHINE_START(samcoupe) |
| 507 | MDRV_MACHINE_RESET(samcoupe) |
| 508 | |
| 509 | /* video hardware */ |
| 510 | MDRV_SCREEN_ADD("main", RASTER) |
| 511 | MDRV_SCREEN_RAW_PARAMS(SAMCOUPE_XTAL_X1/2, 768, 0, 512, 312, 0, 192) /* border area? */ |
| 512 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 513 | MDRV_PALETTE_LENGTH(128) |
| 514 | MDRV_PALETTE_INIT(samcoupe) |
| 515 | |
| 516 | MDRV_VIDEO_UPDATE(samcoupe) |
| 517 | MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE) |
| 518 | |
| 519 | /* devices */ |
| 520 | MDRV_DEVICE_ADD("sambus_clock", MSM6242) |
| 521 | |
| 522 | /* sound hardware */ |
| 523 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 524 | MDRV_SOUND_ADD(SPEAKER, 0) |
| 525 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 526 | MDRV_SOUND_ADD(SAA1099, SAMCOUPE_XTAL_X1/3) /* 8 MHz */ |
| 527 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 528 | MACHINE_DRIVER_END |
| 529 | |
| 530 | |
| 531 | |
| 532 | /************************************* |
| 533 | * |
| 534 | * ROM definitions |
| 535 | * |
| 536 | *************************************/ |
| 537 | |
| 538 | /* |
| 539 | The bios is actually 32K. This is the combined version of the two old 16K MESS roms. |
| 540 | It does match the 3.0 one the most, but the first half differs in one byte |
| 541 | and in the second half, the case of the "plc" in the company string differs. |
| 542 | */ |
| 543 | ROM_START( samcoupe ) |
| 544 | ROM_REGION( 0x8000, REGION_CPU1, 0 ) |
| 545 | ROM_SYSTEM_BIOS( 0, "31", "v3.1" ) |
| 546 | ROMX_LOAD( "rom31.z5", 0x0000, 0x8000, CRC(0b7e3585) SHA1(c86601633fb61a8c517f7657aad9af4e6870f2ee), ROM_BIOS(1) ) |
| 547 | ROM_SYSTEM_BIOS( 1, "30", "v3.0" ) |
| 548 | ROMX_LOAD( "rom30.z5", 0x0000, 0x8000, CRC(e535c25d) SHA1(d390f0be420dfb12b1e54a4f528b5055d7d97e2a), ROM_BIOS(2) ) |
| 549 | ROM_SYSTEM_BIOS( 2, "25", "v2.5" ) |
| 550 | ROMX_LOAD( "rom25.z5", 0x0000, 0x8000, CRC(ddadd358) SHA1(a25ed85a0f1134ac3a481a3225f24a8bd3a790cf), ROM_BIOS(3) ) |
| 551 | ROM_SYSTEM_BIOS( 3, "24", "v2.4" ) |
| 552 | ROMX_LOAD( "rom24.z5", 0x0000, 0x8000, CRC(bb23fee4) SHA1(10cd911ba237dd2cf0c2637be1ad6745b7cc89b9), ROM_BIOS(4) ) |
| 553 | ROM_SYSTEM_BIOS( 4, "21", "v2.1" ) |
| 554 | ROMX_LOAD( "rom21.z5", 0x0000, 0x8000, CRC(f6804b46) SHA1(11dcac5fdea782cdac03b4d0d7ac25d88547eefe), ROM_BIOS(5) ) |
| 555 | ROM_SYSTEM_BIOS( 5, "20", "v2.0" ) |
| 556 | ROMX_LOAD( "rom20.z5", 0x0000, 0x8000, CRC(eaf32054) SHA1(41736323f0236649f2d5fe111f900def8db93a13), ROM_BIOS(6) ) |
| 557 | ROM_SYSTEM_BIOS( 6, "181", "v1.81" ) |
| 558 | ROMX_LOAD( "rom181.z5", 0x0000, 0x8000, CRC(d25e1de1) SHA1(cb0fa79e4d5f7df0b57ede08ea7ecc9ae152f534), ROM_BIOS(7) ) |
| 559 | ROM_SYSTEM_BIOS( 7, "18", "v1.8" ) |
| 560 | ROMX_LOAD( "rom18.z5", 0x0000, 0x8000, CRC(f626063f) SHA1(485e7d9e9a4f8a70c0f93cd6e69ff12269438829), ROM_BIOS(8) ) |
| 561 | ROM_SYSTEM_BIOS( 8, "14", "v1.4" ) |
| 562 | ROMX_LOAD( "rom14.z5", 0x0000, 0x8000, CRC(08799596) SHA1(b4e596051f2748dee9481ea4af7d15ccddc1e1b5), ROM_BIOS(9) ) |
| 563 | ROM_SYSTEM_BIOS( 9, "13", "v1.3" ) |
| 564 | ROMX_LOAD( "rom13.z5", 0x0000, 0x8000, CRC(2093768c) SHA1(af8d348fd080b18a4cbe9ed69d254be7be330146), ROM_BIOS(10) ) |
| 565 | ROM_SYSTEM_BIOS( 10, "12", "v1.2" ) |
| 566 | ROMX_LOAD( "rom12.z5", 0x0000, 0x8000, CRC(7fe37dd8) SHA1(9339a0c1f72e8512c6f32dec15ab7d6c3bb04151), ROM_BIOS(11) ) |
| 567 | ROM_SYSTEM_BIOS( 11, "10", "v1.0" ) |
| 568 | ROMX_LOAD( "rom10.z5", 0x0000, 0x8000, CRC(3659d31f) SHA1(d3de7bb74e04d5b4dc7477f70de54d540b1bcc07), ROM_BIOS(12) ) |
| 569 | ROM_SYSTEM_BIOS( 12, "04", "v0.4" ) |
| 570 | ROMX_LOAD( "rom04.z5", 0x0000, 0x8000, CRC(f439e84e) SHA1(8bc457a5c764b0bb0aa7008c57f28c30248fc6a4), ROM_BIOS(13) ) |
| 571 | ROM_SYSTEM_BIOS( 13, "01", "v0.1" ) |
| 572 | ROMX_LOAD( "rom01.z5", 0x0000, 0x8000, CRC(c04acfdf) SHA1(8976ed005c14905eec1215f0a5c28aa686a7dda2), ROM_BIOS(14) ) |
| 573 | ROM_END |
| 574 | |
| 575 | |
| 576 | |
| 577 | /************************************* |
| 578 | * |
| 579 | * Devices |
| 580 | * |
| 581 | *************************************/ |
| 582 | |
| 583 | static void samcoupe_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 584 | { |
| 585 | /* floppy */ |
| 586 | switch(state) |
| 587 | { |
| 588 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 589 | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 590 | |
| 591 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 592 | case MESS_DEVINFO_PTR_FLOPPY_OPTIONS: info->p = (void *) floppyoptions_coupe; break; |
| 593 | |
| 594 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 595 | case MESS_DEVINFO_STR_NAME+0: strcpy(info->s = device_temp_str(), "floppydisk0"); break; |
| 596 | case MESS_DEVINFO_STR_NAME+1: strcpy(info->s = device_temp_str(), "floppydisk1"); break; |
| 597 | case MESS_DEVINFO_STR_SHORT_NAME+0: strcpy(info->s = device_temp_str(), "flop0"); break; |
| 598 | case MESS_DEVINFO_STR_SHORT_NAME+1: strcpy(info->s = device_temp_str(), "flop1"); break; |
| 599 | case MESS_DEVINFO_STR_DESCRIPTION+0: strcpy(info->s = device_temp_str(), "Floppy #0"); break; |
| 600 | case MESS_DEVINFO_STR_DESCRIPTION+1: strcpy(info->s = device_temp_str(), "Floppy #1"); break; |
| 601 | |
| 602 | default: floppy_device_getinfo(devclass, state, info); break; |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | |
| 607 | SYSTEM_CONFIG_START(samcoupe) |
| 608 | CONFIG_RAM(256 * 1024) |
| 609 | CONFIG_RAM_DEFAULT(512 * 1024) |
| 610 | CONFIG_RAM(256 * 1024 + 1 * 1024 * 1024) |
| 611 | CONFIG_RAM(512 * 1024 + 1 * 1024 * 1024) |
| 612 | CONFIG_RAM(256 * 1024 + 2 * 1024 * 1024) |
| 613 | CONFIG_RAM(512 * 1024 + 2 * 1024 * 1024) |
| 614 | CONFIG_RAM(256 * 1024 + 3 * 1024 * 1024) |
| 615 | CONFIG_RAM(512 * 1024 + 3 * 1024 * 1024) |
| 616 | CONFIG_RAM(256 * 1024 + 4 * 1024 * 1024) |
| 617 | CONFIG_RAM(512 * 1024 + 4 * 1024 * 1024) |
| 618 | CONFIG_DEVICE(samcoupe_floppy_getinfo) |
| 619 | SYSTEM_CONFIG_END |
| 620 | |
| 621 | |
| 622 | |
| 623 | /************************************* |
| 624 | * |
| 625 | * Game drivers |
| 626 | * |
| 627 | *************************************/ |
| 628 | |
| 629 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 630 | COMP( 1989, samcoupe, 0, 0, samcoupe, samcoupe, 0, samcoupe, "Miles Gordon Technology plc", "Sam Coupe", 0 ) |