src/mess/machine/nascom1.c
| r1634 | r1635 | |
| 1 | 1 | /********************************************************************** |
| 2 | 2 | |
| 3 | | mess/machine/nascom1.c |
| 3 | machine/nascom1.c |
| 4 | 4 | |
| 5 | | Functions to emulate general aspects of the machine (RAM, ROM, interrups, |
| 6 | | I/O ports) |
| 7 | | |
| 8 | 5 | **********************************************************************/ |
| 9 | 6 | |
| 7 | /* Core includes */ |
| 10 | 8 | #include <stdio.h> |
| 11 | 9 | #include "driver.h" |
| 12 | | #include "mslegacy.h" |
| 13 | | #include "image.h" |
| 14 | 10 | #include "includes/nascom1.h" |
| 11 | |
| 12 | /* Components */ |
| 15 | 13 | #include "cpu/z80/z80.h" |
| 14 | #include "machine/wd17xx.h" |
| 15 | |
| 16 | /* Devices */ |
| 17 | #include "devices/basicdsk.h" |
| 16 | 18 | #include "devices/snapquik.h" |
| 17 | 19 | |
| 18 | 20 | |
| 21 | #define NASCOM1_KEY_RESET 0x02 |
| 22 | #define NASCOM1_KEY_INCR 0x01 |
| 23 | #define NASCOM1_CAS_ENABLE 0x10 |
| 19 | 24 | |
| 20 | | static int nascom1_tape_size = 0; |
| 21 | | static UINT8 *nascom1_tape_image = NULL; |
| 22 | | static int nascom1_tape_index = 0; |
| 23 | 25 | |
| 24 | 26 | |
| 27 | /************************************* |
| 28 | * |
| 29 | * Global variables |
| 30 | * |
| 31 | *************************************/ |
| 32 | |
| 33 | static int nascom1_tape_size = 0; |
| 34 | static UINT8 *nascom1_tape_image = NULL; |
| 35 | static int nascom1_tape_index = 0; |
| 36 | |
| 25 | 37 | static struct |
| 26 | 38 | { |
| 27 | 39 | UINT8 stat_flags; |
| 28 | 40 | UINT8 stat_count; |
| 29 | 41 | } nascom1_portstat; |
| 30 | 42 | |
| 31 | | #define NASCOM1_KEY_RESET 0x02 |
| 32 | | #define NASCOM1_KEY_INCR 0x01 |
| 33 | | #define NASCOM1_CAS_ENABLE 0x10 |
| 43 | static struct |
| 44 | { |
| 45 | UINT8 select; |
| 46 | UINT8 irq; |
| 47 | UINT8 drq; |
| 48 | } nascom2_fdc; |
| 34 | 49 | |
| 35 | 50 | |
| 36 | | DRIVER_INIT( nascom1 ) |
| 51 | |
| 52 | /************************************* |
| 53 | * |
| 54 | * Floppy |
| 55 | * |
| 56 | *************************************/ |
| 57 | |
| 58 | static void nascom2_fdc_callback(wd17xx_state_t event, void *param) |
| 37 | 59 | { |
| 38 | | switch (mess_ram_size) |
| 60 | switch (event) |
| 39 | 61 | { |
| 40 | | case 1 * 1024: |
| 41 | | memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM, |
| 42 | | 0x1400, 0x9000, 0, 0, MRA8_NOP, MWA8_NOP); |
| 43 | | break; |
| 62 | case WD17XX_IRQ_SET: nascom2_fdc.irq = 1; break; |
| 63 | case WD17XX_IRQ_CLR: nascom2_fdc.irq = 0; break; |
| 64 | case WD17XX_DRQ_SET: nascom2_fdc.drq = 1; break; |
| 65 | case WD17XX_DRQ_CLR: nascom2_fdc.drq = 0; break; |
| 66 | } |
| 67 | } |
| 44 | 68 | |
| 45 | | case 16 * 1024: |
| 46 | | memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM, |
| 47 | | 0x1400, 0x4fff, 0, 0, MRA8_BANK1, MWA8_BANK1); |
| 48 | | memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM, |
| 49 | | 0x5000, 0xafff, 0, 0, MRA8_NOP, MWA8_NOP); |
| 50 | | memory_set_bankptr(1, mess_ram); |
| 51 | | break; |
| 52 | 69 | |
| 53 | | case 32 * 1024: |
| 54 | | memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM, |
| 55 | | 0x1400, 0x8fff, 0, 0, MRA8_BANK1, MWA8_BANK1); |
| 56 | | memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM, |
| 57 | | 0x9000, 0xafff, 0, 0, MRA8_NOP, MWA8_NOP); |
| 58 | | memory_set_bankptr(1, mess_ram); |
| 59 | | break; |
| 70 | READ8_HANDLER( nascom2_fdc_select_r ) |
| 71 | { |
| 72 | return nascom2_fdc.select | 0xa0; |
| 73 | } |
| 60 | 74 | |
| 61 | | case 40 * 1024: |
| 62 | | memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM, |
| 63 | | 0x1400, 0xafff, 0, 0, MRA8_BANK1, MWA8_BANK1); |
| 64 | | memory_set_bankptr(1, mess_ram); |
| 65 | | break; |
| 75 | |
| 76 | WRITE8_HANDLER( nascom2_fdc_select_w ) |
| 77 | { |
| 78 | nascom2_fdc.select = data; |
| 79 | |
| 80 | logerror("nascom2_fdc_select_w: %02x\n", data); |
| 81 | |
| 82 | if (data & 0x01) wd17xx_set_drive(0); |
| 83 | if (data & 0x02) wd17xx_set_drive(1); |
| 84 | if (data & 0x04) wd17xx_set_drive(2); |
| 85 | if (data & 0x08) wd17xx_set_drive(3); |
| 86 | if (data & 0x10) wd17xx_set_side((data & 0x10) >> 4); |
| 87 | } |
| 88 | |
| 89 | |
| 90 | /* |
| 91 | * D0 -- WD1793 IRQ |
| 92 | * D1 -- NOT READY |
| 93 | * D2 to D6 -- 0 |
| 94 | * D7 -- WD1793 DRQ |
| 95 | * |
| 96 | */ |
| 97 | READ8_HANDLER( nascom2_fdc_status_r ) |
| 98 | { |
| 99 | return (nascom2_fdc.drq << 7) | nascom2_fdc.irq; |
| 100 | } |
| 101 | |
| 102 | |
| 103 | DEVICE_LOAD( nascom2_floppy ) |
| 104 | { |
| 105 | int sides, sectors; |
| 106 | |
| 107 | if (!image_has_been_created(image)) |
| 108 | { |
| 109 | switch (image_length(image)) |
| 110 | { |
| 111 | case 80 * 2 * 2 * 8 * 256: |
| 112 | sides = 2; |
| 113 | sectors = 2 * 8; |
| 114 | wd17xx_set_density(DEN_FM_HI); |
| 115 | break; |
| 116 | |
| 117 | case 80 * 1 * 2 * 8 * 256: |
| 118 | sides = 1; |
| 119 | sectors = 2 * 8; |
| 120 | wd17xx_set_density(DEN_FM_HI); |
| 121 | break; |
| 122 | |
| 123 | default: |
| 124 | return INIT_FAIL; |
| 125 | } |
| 66 | 126 | } |
| 127 | else |
| 128 | { |
| 129 | return INIT_FAIL; |
| 130 | } |
| 131 | |
| 132 | if (device_load_basicdsk_floppy(image) != INIT_PASS) |
| 133 | { |
| 134 | return INIT_FAIL; |
| 135 | } |
| 136 | |
| 137 | basicdsk_set_geometry(image, 80, sides, sectors, 256, 1, 0, FALSE); |
| 138 | |
| 139 | return INIT_PASS; |
| 67 | 140 | } |
| 68 | 141 | |
| 69 | 142 | |
| 143 | |
| 144 | /************************************* |
| 145 | * |
| 146 | * Keyboard |
| 147 | * |
| 148 | *************************************/ |
| 149 | |
| 70 | 150 | READ8_HANDLER ( nascom1_port_00_r ) |
| 71 | 151 | { |
| 72 | 152 | if (nascom1_portstat.stat_count < 9) |
| r1634 | r1635 | |
| 75 | 155 | return (0xff); |
| 76 | 156 | } |
| 77 | 157 | |
| 78 | | READ8_HANDLER( nascom1_port_01_r ) |
| 79 | | { |
| 80 | | if (nascom1_portstat.stat_flags & NASCOM1_CAS_ENABLE) |
| 81 | | return (nascom1_read_cassette()); |
| 82 | 158 | |
| 83 | | return 0; |
| 84 | | } |
| 85 | | |
| 86 | | READ8_HANDLER( nascom1_port_02_r ) |
| 87 | | { |
| 88 | | return nascom1_portstat.stat_flags & NASCOM1_CAS_ENABLE ? 0x80 : 0x00; |
| 89 | | } |
| 90 | | |
| 91 | 159 | WRITE8_HANDLER( nascom1_port_00_w ) |
| 92 | 160 | { |
| 93 | 161 | nascom1_portstat.stat_flags &= ~NASCOM1_CAS_ENABLE; |
| r1634 | r1635 | |
| 104 | 172 | } else nascom1_portstat.stat_flags = NASCOM1_KEY_INCR; |
| 105 | 173 | } |
| 106 | 174 | |
| 107 | | WRITE8_HANDLER ( nascom1_port_01_w ) |
| 175 | |
| 176 | WRITE8_HANDLER( nascom1_port_01_w ) |
| 108 | 177 | { |
| 109 | 178 | } |
| 110 | 179 | |
| 180 | |
| 181 | |
| 182 | /************************************* |
| 183 | * |
| 184 | * Cassette |
| 185 | * |
| 186 | *************************************/ |
| 187 | |
| 188 | int nascom1_read_cassette(void) |
| 189 | { |
| 190 | if (nascom1_tape_image && (nascom1_tape_index < nascom1_tape_size)) |
| 191 | return (nascom1_tape_image[nascom1_tape_index++]); |
| 192 | |
| 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | |
| 197 | READ8_HANDLER( nascom1_port_01_r ) |
| 198 | { |
| 199 | if (nascom1_portstat.stat_flags & NASCOM1_CAS_ENABLE) |
| 200 | return (nascom1_read_cassette()); |
| 201 | |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | |
| 206 | READ8_HANDLER( nascom1_port_02_r ) |
| 207 | { |
| 208 | return nascom1_portstat.stat_flags & NASCOM1_CAS_ENABLE ? 0x80 : 0x00; |
| 209 | } |
| 210 | |
| 211 | |
| 111 | 212 | DEVICE_LOAD( nascom1_cassette ) |
| 112 | 213 | { |
| 113 | 214 | nascom1_tape_size = image_length(image); |
| r1634 | r1635 | |
| 119 | 220 | return INIT_PASS; |
| 120 | 221 | } |
| 121 | 222 | |
| 223 | |
| 122 | 224 | DEVICE_UNLOAD( nascom1_cassette ) |
| 123 | 225 | { |
| 124 | 226 | nascom1_tape_image = NULL; |
| 125 | 227 | nascom1_tape_size = nascom1_tape_index = 0; |
| 126 | 228 | } |
| 127 | 229 | |
| 128 | | int nascom1_read_cassette(void) |
| 129 | | { |
| 130 | | if (nascom1_tape_image && (nascom1_tape_index < nascom1_tape_size)) |
| 131 | | return (nascom1_tape_image[nascom1_tape_index++]); |
| 132 | | return (0); |
| 133 | | } |
| 134 | 230 | |
| 135 | | /* Ascii .nas format |
| 136 | 231 | |
| 137 | | <addr> <byte> x 8 ^H^H^J |
| 138 | | . |
| 232 | /************************************* |
| 233 | * |
| 234 | * Snapshots |
| 235 | * |
| 236 | * ASCII .nas format |
| 237 | * |
| 238 | *************************************/ |
| 139 | 239 | |
| 140 | | Note <addr> and <byte> are in hex. |
| 141 | | */ |
| 142 | | |
| 143 | 240 | SNAPSHOT_LOAD( nascom1 ) |
| 144 | 241 | { |
| 145 | 242 | UINT8 line[35]; |
| r1634 | r1635 | |
| 164 | 261 | |
| 165 | 262 | return INIT_PASS; |
| 166 | 263 | } |
| 264 | |
| 265 | |
| 266 | |
| 267 | /************************************* |
| 268 | * |
| 269 | * Initialization |
| 270 | * |
| 271 | *************************************/ |
| 272 | |
| 273 | DRIVER_INIT( nascom1 ) |
| 274 | { |
| 275 | switch (mess_ram_size) |
| 276 | { |
| 277 | case 1 * 1024: |
| 278 | memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM, |
| 279 | 0x1400, 0x9000, 0, 0, MRA8_NOP, MWA8_NOP); |
| 280 | break; |
| 281 | |
| 282 | case 16 * 1024: |
| 283 | memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM, |
| 284 | 0x1400, 0x4fff, 0, 0, MRA8_BANK1, MWA8_BANK1); |
| 285 | memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM, |
| 286 | 0x5000, 0xafff, 0, 0, MRA8_NOP, MWA8_NOP); |
| 287 | memory_set_bankptr(1, mess_ram); |
| 288 | break; |
| 289 | |
| 290 | case 32 * 1024: |
| 291 | memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM, |
| 292 | 0x1400, 0x8fff, 0, 0, MRA8_BANK1, MWA8_BANK1); |
| 293 | memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM, |
| 294 | 0x9000, 0xafff, 0, 0, MRA8_NOP, MWA8_NOP); |
| 295 | memory_set_bankptr(1, mess_ram); |
| 296 | break; |
| 297 | |
| 298 | case 40 * 1024: |
| 299 | memory_install_readwrite8_handler(0, ADDRESS_SPACE_PROGRAM, |
| 300 | 0x1400, 0xafff, 0, 0, MRA8_BANK1, MWA8_BANK1); |
| 301 | memory_set_bankptr(1, mess_ram); |
| 302 | break; |
| 303 | } |
| 304 | |
| 305 | wd17xx_init(WD_TYPE_1793, nascom2_fdc_callback, NULL); |
| 306 | } |
src/mess/drivers/nascom1.c
| r1634 | r1635 | |
| 48 | 48 | |
| 49 | 49 | ************************************************************************/ |
| 50 | 50 | |
| 51 | /* Core includes */ |
| 51 | 52 | #include "driver.h" |
| 52 | 53 | #include "includes/nascom1.h" |
| 54 | |
| 55 | /* Components */ |
| 53 | 56 | #include "cpu/z80/z80.h" |
| 57 | #include "machine/wd17xx.h" |
| 58 | |
| 59 | /* Devices */ |
| 60 | #include "devices/basicdsk.h" |
| 54 | 61 | #include "devices/cartslot.h" |
| 55 | 62 | |
| 56 | 63 | |
| 57 | | /* Memory w/r functions */ |
| 58 | | static ADDRESS_MAP_START( nascom1_mem , ADDRESS_SPACE_PROGRAM, 8) |
| 64 | |
| 65 | /************************************* |
| 66 | * |
| 67 | * Memory maps |
| 68 | * |
| 69 | *************************************/ |
| 70 | |
| 71 | static ADDRESS_MAP_START( nascom1_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 59 | 72 | AM_RANGE(0x0000, 0x07ff) AM_ROM |
| 60 | 73 | AM_RANGE(0x0800, 0x0bff) AM_RAM AM_BASE(&videoram) AM_SIZE(&videoram_size) |
| 61 | 74 | AM_RANGE(0x0c00, 0x0fff) AM_RAM |
| r1634 | r1635 | |
| 66 | 79 | AM_RANGE(0xb000, 0xffff) AM_ROM |
| 67 | 80 | ADDRESS_MAP_END |
| 68 | 81 | |
| 69 | | /* port i/o functions */ |
| 70 | | static ADDRESS_MAP_START( nascom1_io , ADDRESS_SPACE_IO, 8) |
| 82 | |
| 83 | static ADDRESS_MAP_START( nascom1_io, ADDRESS_SPACE_IO, 8 ) |
| 84 | ADDRESS_MAP_FLAGS( AMEF_ABITS(4) ) |
| 85 | AM_RANGE(0x00, 0x00) AM_READWRITE(nascom1_port_00_r, nascom1_port_00_w) |
| 86 | AM_RANGE(0x01, 0x01) AM_READWRITE(nascom1_port_01_r, nascom1_port_01_w) |
| 87 | AM_RANGE(0x02, 0x02) AM_READ(nascom1_port_02_r) |
| 88 | ADDRESS_MAP_END |
| 89 | |
| 90 | |
| 91 | static ADDRESS_MAP_START( nascom2_io, ADDRESS_SPACE_IO, 8 ) |
| 71 | 92 | ADDRESS_MAP_FLAGS( AMEF_ABITS(8) ) |
| 72 | | AM_RANGE(0x00, 0x00) AM_READWRITE( nascom1_port_00_r, nascom1_port_00_w ) |
| 73 | | AM_RANGE(0x01, 0x01) AM_READWRITE( nascom1_port_01_r, nascom1_port_01_w ) |
| 74 | | AM_RANGE(0x02, 0x02) AM_READ( nascom1_port_02_r ) |
| 93 | AM_RANGE(0x00, 0x00) AM_READWRITE(nascom1_port_00_r, nascom1_port_00_w) |
| 94 | AM_RANGE(0x01, 0x01) AM_READWRITE(nascom1_port_01_r, nascom1_port_01_w) |
| 95 | AM_RANGE(0x02, 0x02) AM_READ(nascom1_port_02_r) |
| 96 | AM_RANGE(0xe0, 0xe3) AM_READWRITE(wd17xx_r, wd17xx_w) |
| 97 | AM_RANGE(0xe4, 0xe4) AM_READWRITE(nascom2_fdc_select_r, nascom2_fdc_select_w) |
| 98 | AM_RANGE(0xe5, 0xe5) AM_READ(nascom2_fdc_status_r) |
| 75 | 99 | ADDRESS_MAP_END |
| 76 | 100 | |
| 77 | | /* graphics output */ |
| 78 | 101 | |
| 102 | |
| 103 | /************************************* |
| 104 | * |
| 105 | * GFX layouts |
| 106 | * |
| 107 | *************************************/ |
| 108 | |
| 79 | 109 | static const gfx_layout nascom1_charlayout = |
| 80 | 110 | { |
| 81 | 111 | 8, 16, |
| r1634 | r1635 | |
| 88 | 118 | 8 * 16 |
| 89 | 119 | }; |
| 90 | 120 | |
| 121 | |
| 91 | 122 | static GFXDECODE_START( nascom1 ) |
| 92 | | GFXDECODE_ENTRY( REGION_GFX1, 0x0000, nascom1_charlayout, 0, 1 ) |
| 123 | GFXDECODE_ENTRY(REGION_GFX1, 0x0000, nascom1_charlayout, 0, 1) |
| 93 | 124 | GFXDECODE_END |
| 94 | 125 | |
| 126 | |
| 95 | 127 | static const gfx_layout nascom2_charlayout = |
| 96 | 128 | { |
| 97 | 129 | 8, 14, |
| r1634 | r1635 | |
| 104 | 136 | 8 * 16 |
| 105 | 137 | }; |
| 106 | 138 | |
| 139 | |
| 107 | 140 | static GFXDECODE_START( nascom2 ) |
| 108 | | GFXDECODE_ENTRY( REGION_GFX1, 0x0000, nascom2_charlayout, 0, 1 ) |
| 141 | GFXDECODE_ENTRY(REGION_GFX1, 0x0000, nascom2_charlayout, 0, 1) |
| 109 | 142 | GFXDECODE_END |
| 110 | 143 | |
| 111 | 144 | |
| 112 | | /* Keyboard input */ |
| 113 | 145 | |
| 114 | | static INPUT_PORTS_START (nascom1) |
| 115 | | PORT_START /* 0: count = 0 */ |
| 146 | /************************************* |
| 147 | * |
| 148 | * Input ports |
| 149 | * |
| 150 | *************************************/ |
| 151 | |
| 152 | static INPUT_PORTS_START( nascom1 ) |
| 153 | PORT_START_TAG("keyboard_0") |
| 116 | 154 | PORT_BIT(0x6f, IP_ACTIVE_LOW, IPT_UNUSED) |
| 117 | 155 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 118 | 156 | |
| 119 | | PORT_START /* 1: count = 1 */ |
| 157 | PORT_START_TAG("keyboard_1") |
| 120 | 158 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('H') PORT_CHAR('h') |
| 121 | 159 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('B') PORT_CHAR('b') |
| 122 | 160 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') |
| r1634 | r1635 | |
| 125 | 163 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('T') PORT_CHAR('t') |
| 126 | 164 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) |
| 127 | 165 | |
| 128 | | PORT_START /* 2: count = 2 */ |
| 166 | PORT_START_TAG("keyboard_2") |
| 129 | 167 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('J') PORT_CHAR('j') |
| 130 | 168 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('N') PORT_CHAR('n') |
| 131 | 169 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') |
| r1634 | r1635 | |
| 134 | 172 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') PORT_CHAR('y') |
| 135 | 173 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) |
| 136 | 174 | |
| 137 | | PORT_START /* 3: count = 3 */ |
| 175 | PORT_START_TAG("keyboard_3") |
| 138 | 176 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('K') PORT_CHAR('k') |
| 139 | 177 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('M') PORT_CHAR('m') |
| 140 | 178 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| r1634 | r1635 | |
| 143 | 181 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('U') PORT_CHAR('u') |
| 144 | 182 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) |
| 145 | 183 | |
| 146 | | PORT_START /* 4: count = 4 */ |
| 184 | PORT_START_TAG("keyboard_4") |
| 147 | 185 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('L') PORT_CHAR('l') |
| 148 | 186 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') |
| 149 | 187 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') |
| r1634 | r1635 | |
| 152 | 190 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('I') PORT_CHAR('i') |
| 153 | 191 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) |
| 154 | 192 | |
| 155 | | PORT_START /* 5: count = 5 */ |
| 193 | PORT_START_TAG("keyboard_5") |
| 156 | 194 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+') |
| 157 | 195 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') |
| 158 | 196 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') |
| r1634 | r1635 | |
| 161 | 199 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('O') PORT_CHAR('o') |
| 162 | 200 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) |
| 163 | 201 | |
| 164 | | PORT_START /* 6: count = 6 */ |
| 202 | PORT_START_TAG("keyboard_6") |
| 165 | 203 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*') |
| 166 | 204 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') |
| 167 | 205 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| r1634 | r1635 | |
| 170 | 208 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('P') PORT_CHAR('p') |
| 171 | 209 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) |
| 172 | 210 | |
| 173 | | PORT_START /* 7: count = 7 */ |
| 211 | PORT_START_TAG("keyboard_7") |
| 174 | 212 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('G') PORT_CHAR('g') |
| 175 | 213 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('V') PORT_CHAR('v') |
| 176 | 214 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') |
| r1634 | r1635 | |
| 179 | 217 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('R') PORT_CHAR('r') |
| 180 | 218 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) |
| 181 | 219 | |
| 182 | | PORT_START /* 8: count = 8 */ |
| 220 | PORT_START_TAG("keyboard_8") |
| 183 | 221 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Backspace ClearScreen") PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(8) |
| 184 | 222 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("New Line") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 185 | 223 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=') |
| r1634 | r1635 | |
| 187 | 225 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR(UCHAR_SHIFT_2) PORT_CHAR('@') |
| 188 | 226 | INPUT_PORTS_END |
| 189 | 227 | |
| 190 | | /* Sound output */ |
| 191 | 228 | |
| 192 | | static INTERRUPT_GEN( nascom_interrupt ) |
| 193 | | { |
| 194 | | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 195 | | } |
| 229 | static INPUT_PORTS_START( nascom2 ) |
| 230 | PORT_INCLUDE(nascom1) |
| 196 | 231 | |
| 197 | | /* Machine definition */ |
| 232 | PORT_MODIFY("keyboard_6") |
| 233 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('[') PORT_CHAR('\\') |
| 234 | |
| 235 | PORT_MODIFY("keyboard_7") |
| 236 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(']') PORT_CHAR('_') |
| 237 | |
| 238 | PORT_MODIFY("keyboard_8") |
| 239 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Back CS") PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(8) |
| 240 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Enter Escape") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) PORT_CHAR(27) |
| 241 | INPUT_PORTS_END |
| 242 | |
| 243 | |
| 244 | |
| 245 | /************************************* |
| 246 | * |
| 247 | * Machine drivers |
| 248 | * |
| 249 | *************************************/ |
| 250 | |
| 198 | 251 | static MACHINE_DRIVER_START( nascom1 ) |
| 199 | 252 | /* basic machine hardware */ |
| 200 | 253 | MDRV_CPU_ADD_TAG("main", Z80, 1000000) |
| 201 | 254 | MDRV_CPU_PROGRAM_MAP(nascom1_mem, 0) |
| 202 | 255 | MDRV_CPU_IO_MAP(nascom1_io, 0) |
| 203 | | MDRV_CPU_VBLANK_INT(nascom_interrupt, 1) |
| 204 | 256 | MDRV_SCREEN_REFRESH_RATE(50) |
| 205 | 257 | MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION) |
| 206 | 258 | |
| r1634 | r1635 | |
| 209 | 261 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 210 | 262 | MDRV_SCREEN_SIZE(48 * 8, 16 * 16) |
| 211 | 263 | MDRV_SCREEN_VISIBLE_AREA(0, 48 * 8 - 1, 0, 16 * 16 - 1) |
| 212 | | MDRV_GFXDECODE( nascom1 ) |
| 264 | MDRV_GFXDECODE(nascom1) |
| 213 | 265 | MDRV_PALETTE_LENGTH(2) |
| 214 | 266 | MDRV_PALETTE_INIT(black_and_white) |
| 215 | 267 | |
| 216 | | MDRV_VIDEO_START( generic ) |
| 217 | | MDRV_VIDEO_UPDATE( nascom1 ) |
| 268 | MDRV_VIDEO_START(generic) |
| 269 | MDRV_VIDEO_UPDATE(nascom1) |
| 218 | 270 | MACHINE_DRIVER_END |
| 219 | 271 | |
| 220 | 272 | |
| 221 | 273 | static MACHINE_DRIVER_START( nascom2 ) |
| 222 | | MDRV_IMPORT_FROM( nascom1 ) |
| 223 | | MDRV_CPU_REPLACE( "main", Z80, 2000000 ) |
| 274 | MDRV_IMPORT_FROM(nascom1) |
| 275 | MDRV_CPU_REPLACE("main", Z80, 2000000) |
| 276 | MDRV_CPU_IO_MAP(nascom2_io, 0) |
| 277 | |
| 278 | /* video hardware */ |
| 224 | 279 | MDRV_SCREEN_SIZE(48 * 8, 16 * 14) |
| 225 | 280 | MDRV_SCREEN_VISIBLE_AREA(0, 48 * 8 - 1, 0, 16 * 14 - 1) |
| 226 | | MDRV_GFXDECODE( nascom2 ) |
| 227 | | MDRV_VIDEO_UPDATE( nascom2 ) |
| 281 | MDRV_GFXDECODE(nascom2) |
| 282 | MDRV_VIDEO_UPDATE(nascom2) |
| 228 | 283 | MACHINE_DRIVER_END |
| 229 | 284 | |
| 285 | |
| 286 | |
| 287 | /************************************* |
| 288 | * |
| 289 | * ROM definitions |
| 290 | * |
| 291 | *************************************/ |
| 292 | |
| 230 | 293 | ROM_START(nascom1) |
| 231 | 294 | ROM_REGION(0x10000, REGION_CPU1,0) |
| 232 | | ROM_SYSTEM_BIOS( 0, "T4", "NasBug T4" ) |
| 295 | ROM_SYSTEM_BIOS(0, "T4", "NasBug T4") |
| 233 | 296 | ROMX_LOAD("nasbugt4.rom", 0x0000, 0x0800, CRC(f391df68) SHA1(00218652927afc6360c57e77d6a4fd32d4e34566), ROM_BIOS(1)) |
| 234 | | ROM_SYSTEM_BIOS( 1, "T1", "NasBug T1" ) |
| 297 | ROM_SYSTEM_BIOS(1, "T1", "NasBug T1") |
| 235 | 298 | ROMX_LOAD("nasbugt1.rom", 0x0000, 0x0400, CRC(8ea07054) SHA1(3f9a8632826003d6ea59d2418674d0fb09b83a4c), ROM_BIOS(2)) |
| 236 | | ROM_SYSTEM_BIOS( 2, "T2", "NasBug T2" ) |
| 299 | ROM_SYSTEM_BIOS(2, "T2", "NasBug T2") |
| 237 | 300 | ROMX_LOAD("nasbugt2.rom", 0x0000, 0x0400, CRC(e371b58a) SHA1(485b20a560b587cf9bb4208ba203b12b3841689b), ROM_BIOS(3)) |
| 238 | | ROM_REGION(0x0800, REGION_GFX1,0) |
| 239 | | ROM_LOAD("nascom1.chr", 0x0000, 0x0800, CRC(33e92a04) SHA1(be6e1cc80e7f95a032759f7df19a43c27ff93a52)) |
| 301 | ROM_REGION(0x0800, REGION_GFX1, 0) |
| 302 | ROM_LOAD("nascom1.chr", 0x0000, 0x0800, CRC(33e92a04) SHA1(be6e1cc80e7f95a032759f7df19a43c27ff93a52)) |
| 240 | 303 | ROM_END |
| 241 | 304 | |
| 305 | |
| 242 | 306 | ROM_START(nascom2) |
| 243 | 307 | ROM_REGION(0x10000, REGION_CPU1,0) |
| 244 | | ROM_SYSTEM_BIOS( 0, "NS3", "NasSys 3" ) |
| 308 | ROM_SYSTEM_BIOS( 0, "NS3", "NasSys 3") |
| 245 | 309 | ROMX_LOAD("nassys3.rom", 0x0000, 0x0800, CRC(3da17373) SHA1(5fbda15765f04e4cd08cf95c8d82ce217889f240), ROM_BIOS(1)) |
| 246 | | ROM_SYSTEM_BIOS( 1, "NS1", "NasSys 1" ) |
| 310 | ROM_SYSTEM_BIOS( 1, "NS1", "NasSys 1") |
| 247 | 311 | ROMX_LOAD("nassys1.rom", 0x0000, 0x0800, CRC(b6300716) SHA1(29da7d462ba3f569f70ed3ecd93b981f81c7adfa), ROM_BIOS(2)) |
| 248 | | ROM_LOAD("basic.rom", 0xe000, 0x2000, CRC(5cb5197b) SHA1(c41669c2b6d6dea808741a2738426d97bccc9b07)) |
| 249 | | ROM_REGION(0x1000, REGION_GFX1,0) |
| 250 | | ROM_LOAD("nascom1.chr", 0x0000, 0x0800, CRC(33e92a04) SHA1(be6e1cc80e7f95a032759f7df19a43c27ff93a52)) |
| 251 | | ROM_LOAD("nasgra.chr", 0x0800, 0x0800, CRC(2bc09d32) SHA1(d384297e9b02cbcb283c020da51b3032ff62b1ae)) |
| 312 | ROM_LOAD("nasdos.rom", 0xd000, 0x1000, CRC(54a36f6d) SHA1(1d063d04be5024f128bd589e6edc066e9a63fc1b)) |
| 313 | ROM_LOAD("basic.rom", 0xe000, 0x2000, CRC(5cb5197b) SHA1(c41669c2b6d6dea808741a2738426d97bccc9b07)) |
| 314 | ROM_REGION(0x1000, REGION_GFX1, 0) |
| 315 | ROM_LOAD("nascom1.chr", 0x0000, 0x0800, CRC(33e92a04) SHA1(be6e1cc80e7f95a032759f7df19a43c27ff93a52)) |
| 316 | ROM_LOAD("nasgra.chr", 0x0800, 0x0800, CRC(2bc09d32) SHA1(d384297e9b02cbcb283c020da51b3032ff62b1ae)) |
| 252 | 317 | ROM_END |
| 253 | 318 | |
| 254 | | SYSTEM_CONFIG_START(nascom) |
| 255 | | CONFIG_RAM(1 * 1024) |
| 256 | | CONFIG_RAM(16 * 1024) |
| 257 | | CONFIG_RAM(32 * 1024) |
| 258 | | CONFIG_RAM_DEFAULT(40 * 1024) |
| 259 | | #ifdef CART |
| 260 | | CONFIG_DEVICE_CARTSLOT_REQ(1, "nas,bin", nascom1_init_cartridge, NULL, NULL) |
| 261 | | #endif |
| 262 | | SYSTEM_CONFIG_END |
| 263 | 319 | |
| 320 | |
| 321 | /************************************* |
| 322 | * |
| 323 | * System configs |
| 324 | * |
| 325 | *************************************/ |
| 326 | |
| 264 | 327 | static void nascom1_cassette_getinfo(const device_class *devclass, UINT32 state, union devinfo *info) |
| 265 | 328 | { |
| 266 | 329 | /* cassette */ |
| r1634 | r1635 | |
| 278 | 341 | case DEVINFO_PTR_UNLOAD: info->unload = device_unload_nascom1_cassette; break; |
| 279 | 342 | |
| 280 | 343 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 281 | | case DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "nas,bin"); break; |
| 344 | case DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "cas"); break; |
| 282 | 345 | } |
| 283 | 346 | } |
| 284 | 347 | |
| 348 | |
| 285 | 349 | static void nascom1_snapshot_getinfo(const device_class *devclass, UINT32 state, union devinfo *info) |
| 286 | 350 | { |
| 287 | 351 | switch(state) |
| r1634 | r1635 | |
| 299 | 363 | } |
| 300 | 364 | } |
| 301 | 365 | |
| 302 | | SYSTEM_CONFIG_START(nascom1) |
| 303 | | CONFIG_IMPORT_FROM(nascom) |
| 304 | | CONFIG_DEVICE(nascom1_cassette_getinfo) |
| 305 | | CONFIG_DEVICE(nascom1_snapshot_getinfo) |
| 306 | | SYSTEM_CONFIG_END |
| 307 | 366 | |
| 308 | | static void nascom2_cassette_getinfo(const device_class *devclass, UINT32 state, union devinfo *info) |
| 367 | static void nascom2_floppy_getinfo(const device_class *devclass, UINT32 state, union devinfo *info) |
| 309 | 368 | { |
| 310 | | /* cassette */ |
| 369 | /* floppy */ |
| 311 | 370 | switch(state) |
| 312 | 371 | { |
| 313 | 372 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 314 | | case DEVINFO_INT_TYPE: info->i = IO_CASSETTE; break; |
| 315 | | case DEVINFO_INT_READABLE: info->i = 1; break; |
| 316 | | case DEVINFO_INT_WRITEABLE: info->i = 0; break; |
| 317 | | case DEVINFO_INT_CREATABLE: info->i = 0; break; |
| 318 | | case DEVINFO_INT_COUNT: info->i = 1; break; |
| 373 | case DEVINFO_INT_COUNT: info->i = 4; break; |
| 319 | 374 | |
| 320 | 375 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 321 | | case DEVINFO_PTR_LOAD: info->load = device_load_nascom1_cassette; break; |
| 322 | | case DEVINFO_PTR_UNLOAD: info->unload = device_unload_nascom1_cassette; break; |
| 376 | case DEVINFO_PTR_LOAD: info->load = device_load_nascom2_floppy; break; |
| 323 | 377 | |
| 324 | 378 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 325 | | case DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "cas,nas,bin"); break; |
| 379 | case DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break; |
| 380 | |
| 381 | default: legacybasicdsk_device_getinfo(devclass, state, info); break; |
| 326 | 382 | } |
| 327 | 383 | } |
| 328 | 384 | |
| 329 | | SYSTEM_CONFIG_START(nascom2) |
| 330 | | CONFIG_IMPORT_FROM(nascom) |
| 331 | | CONFIG_DEVICE(nascom2_cassette_getinfo) |
| 385 | |
| 386 | SYSTEM_CONFIG_START( nascom1 ) |
| 387 | CONFIG_RAM(1 * 1024) |
| 388 | CONFIG_RAM(16 * 1024) |
| 389 | CONFIG_RAM(32 * 1024) |
| 390 | CONFIG_RAM_DEFAULT(40 * 1024) |
| 391 | CONFIG_DEVICE(nascom1_cassette_getinfo) |
| 332 | 392 | CONFIG_DEVICE(nascom1_snapshot_getinfo) |
| 333 | 393 | SYSTEM_CONFIG_END |
| 334 | 394 | |
| 395 | |
| 396 | SYSTEM_CONFIG_START( nascom2 ) |
| 397 | CONFIG_IMPORT_FROM(nascom1) |
| 398 | CONFIG_DEVICE(nascom2_floppy_getinfo) |
| 399 | SYSTEM_CONFIG_END |
| 400 | |
| 401 | |
| 402 | |
| 403 | /************************************* |
| 404 | * |
| 405 | * Driver definitions |
| 406 | * |
| 407 | *************************************/ |
| 408 | |
| 335 | 409 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 336 | 410 | COMP( 1978, nascom1, 0, 0, nascom1, nascom1, nascom1, nascom1, "Nascom Microcomputers", "Nascom 1", 0 ) |
| 337 | | COMP( 1979, nascom2, nascom1, 0, nascom2, nascom1, nascom1, nascom2, "Nascom Microcomputers", "Nascom 2", 0 ) |
| 411 | COMP( 1979, nascom2, nascom1, 0, nascom2, nascom2, nascom1, nascom2, "Nascom Microcomputers", "Nascom 2", 0 ) |