src/mess/machine/nascom1.c
| r3335 | r3336 | |
| 11 | 11 | /* Components */ |
| 12 | 12 | #include "cpu/z80/z80.h" |
| 13 | 13 | #include "machine/wd17xx.h" |
| 14 | #include "machine/ay31015.h" |
| 14 | 15 | |
| 15 | 16 | /* Devices */ |
| 16 | 17 | #include "devices/basicdsk.h" |
| 17 | 18 | #include "devices/snapquik.h" |
| 19 | #include "devices/cassette.h" |
| 18 | 20 | |
| 19 | 21 | |
| 20 | 22 | #define NASCOM1_KEY_RESET 0x02 |
| 21 | 23 | #define NASCOM1_KEY_INCR 0x01 |
| 22 | | #define NASCOM1_CAS_ENABLE 0x10 |
| 23 | 24 | |
| 24 | 25 | |
| 25 | 26 | |
| r3335 | r3336 | |
| 29 | 30 | * |
| 30 | 31 | *************************************/ |
| 31 | 32 | |
| 33 | static const device_config *nascom1_hd6402; |
| 32 | 34 | static int nascom1_tape_size = 0; |
| 33 | 35 | static UINT8 *nascom1_tape_image = NULL; |
| 34 | 36 | static int nascom1_tape_index = 0; |
| r3335 | r3336 | |
| 159 | 161 | |
| 160 | 162 | WRITE8_HANDLER( nascom1_port_00_w ) |
| 161 | 163 | { |
| 162 | | nascom1_portstat.stat_flags &= ~NASCOM1_CAS_ENABLE; |
| 163 | | nascom1_portstat.stat_flags |= (data & NASCOM1_CAS_ENABLE); |
| 164 | 164 | |
| 165 | cassette_change_state( device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ), |
| 166 | ( data & 0x10 ) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR ); |
| 167 | |
| 165 | 168 | if (!(data & NASCOM1_KEY_RESET)) { |
| 166 | 169 | if (nascom1_portstat.stat_flags & NASCOM1_KEY_RESET) |
| 167 | 170 | nascom1_portstat.stat_count = 0; |
| r3335 | r3336 | |
| 174 | 177 | } |
| 175 | 178 | |
| 176 | 179 | |
| 177 | | WRITE8_HANDLER( nascom1_port_01_w ) |
| 178 | | { |
| 179 | | } |
| 180 | 180 | |
| 181 | 181 | |
| 182 | | |
| 183 | 182 | /************************************* |
| 184 | 183 | * |
| 185 | 184 | * Cassette |
| 186 | 185 | * |
| 187 | 186 | *************************************/ |
| 188 | 187 | |
| 189 | | static int nascom1_read_cassette(void) |
| 188 | |
| 189 | READ8_HANDLER( nascom1_port_01_r ) |
| 190 | 190 | { |
| 191 | | if (nascom1_tape_image && (nascom1_tape_index < nascom1_tape_size)) |
| 192 | | return (nascom1_tape_image[nascom1_tape_index++]); |
| 193 | | |
| 194 | | return 0; |
| 191 | return ay31015_get_received_data( nascom1_hd6402 ); |
| 195 | 192 | } |
| 196 | 193 | |
| 197 | 194 | |
| 198 | | READ8_HANDLER( nascom1_port_01_r ) |
| 195 | WRITE8_HANDLER( nascom1_port_01_w ) |
| 199 | 196 | { |
| 200 | | if (nascom1_portstat.stat_flags & NASCOM1_CAS_ENABLE) |
| 201 | | return (nascom1_read_cassette()); |
| 197 | ay31015_set_transmit_data( nascom1_hd6402, data ); |
| 198 | } |
| 202 | 199 | |
| 203 | | return 0; |
| 200 | READ8_HANDLER( nascom1_port_02_r ) |
| 201 | { |
| 202 | UINT8 data = 0x31; |
| 203 | |
| 204 | ay31015_set_input_pin( nascom1_hd6402, AY31015_SWE, 0 ); |
| 205 | data |= ay31015_get_output_pin( nascom1_hd6402, AY31015_OR ) ? 0x02 : 0; |
| 206 | data |= ay31015_get_output_pin( nascom1_hd6402, AY31015_PE ) ? 0x04 : 0; |
| 207 | data |= ay31015_get_output_pin( nascom1_hd6402, AY31015_FE ) ? 0x08 : 0; |
| 208 | data |= ay31015_get_output_pin( nascom1_hd6402, AY31015_TBMT ) ? 0x40 : 0; |
| 209 | data |= ay31015_get_output_pin( nascom1_hd6402, AY31015_DAV ) ? 0x80 : 0; |
| 210 | ay31015_set_input_pin( nascom1_hd6402, AY31015_SWE, 1 ); |
| 211 | |
| 212 | return data; |
| 204 | 213 | } |
| 205 | 214 | |
| 206 | 215 | |
| 207 | | READ8_HANDLER( nascom1_port_02_r ) |
| 216 | READ8_DEVICE_HANDLER( nascom1_hd6402_si ) |
| 208 | 217 | { |
| 209 | | return nascom1_portstat.stat_flags & NASCOM1_CAS_ENABLE ? 0x80 : 0x00; |
| 218 | return 1; |
| 210 | 219 | } |
| 211 | 220 | |
| 212 | 221 | |
| 222 | WRITE8_DEVICE_HANDLER( nascom1_hd6402_so ) |
| 223 | { |
| 224 | } |
| 225 | |
| 226 | |
| 213 | 227 | DEVICE_IMAGE_LOAD( nascom1_cassette ) |
| 214 | 228 | { |
| 215 | 229 | nascom1_tape_size = image_length(image); |
| r3335 | r3336 | |
| 276 | 290 | wd17xx_init(machine, WD_TYPE_1793, nascom2_fdc_callback, NULL); |
| 277 | 291 | } |
| 278 | 292 | |
| 293 | |
| 294 | MACHINE_RESET( nascom1 ) |
| 295 | { |
| 296 | nascom1_hd6402 = device_list_find_by_tag( machine->config->devicelist, AY31015, "hd6402" ); |
| 297 | |
| 298 | /* Set up hd6402 pins */ |
| 299 | ay31015_set_input_pin( nascom1_hd6402, AY31015_SWE, 1 ); |
| 300 | |
| 301 | ay31015_set_input_pin( nascom1_hd6402, AY31015_CS, 0 ); |
| 302 | ay31015_set_input_pin( nascom1_hd6402, AY31015_NP, 1 ); |
| 303 | ay31015_set_input_pin( nascom1_hd6402, AY31015_NB1, 1 ); |
| 304 | ay31015_set_input_pin( nascom1_hd6402, AY31015_NB2, 1 ); |
| 305 | ay31015_set_input_pin( nascom1_hd6402, AY31015_EPS, 1 ); |
| 306 | ay31015_set_input_pin( nascom1_hd6402, AY31015_TSB, 1 ); |
| 307 | ay31015_set_input_pin( nascom1_hd6402, AY31015_CS, 1 ); |
| 308 | } |
| 309 | |
| 310 | |
| 279 | 311 | DRIVER_INIT( nascom1 ) |
| 280 | 312 | { |
| 281 | 313 | switch (mess_ram_size) |
src/mess/drivers/nascom1.c
| r3335 | r3336 | |
| 55 | 55 | /* Components */ |
| 56 | 56 | #include "cpu/z80/z80.h" |
| 57 | 57 | #include "machine/wd17xx.h" |
| 58 | #include "machine/ay31015.h" |
| 59 | #include "machine/z80pio.h" |
| 58 | 60 | |
| 59 | 61 | /* Devices */ |
| 60 | 62 | #include "devices/basicdsk.h" |
| 61 | 63 | #include "devices/cartslot.h" |
| 64 | #include "devices/cassette.h" |
| 62 | 65 | |
| 63 | 66 | |
| 64 | 67 | |
| r3335 | r3336 | |
| 85 | 88 | AM_RANGE(0x00, 0x00) AM_READWRITE(nascom1_port_00_r, nascom1_port_00_w) |
| 86 | 89 | AM_RANGE(0x01, 0x01) AM_READWRITE(nascom1_port_01_r, nascom1_port_01_w) |
| 87 | 90 | AM_RANGE(0x02, 0x02) AM_READ(nascom1_port_02_r) |
| 91 | // AM_RANGE(0x04, 0x07) AM_READWRITE( z80pio_0_r, z80pio_0_w ) |
| 88 | 92 | ADDRESS_MAP_END |
| 89 | 93 | |
| 90 | 94 | |
| r3335 | r3336 | |
| 93 | 97 | AM_RANGE(0x00, 0x00) AM_READWRITE(nascom1_port_00_r, nascom1_port_00_w) |
| 94 | 98 | AM_RANGE(0x01, 0x01) AM_READWRITE(nascom1_port_01_r, nascom1_port_01_w) |
| 95 | 99 | AM_RANGE(0x02, 0x02) AM_READ(nascom1_port_02_r) |
| 100 | // AM_RANGE(0x04, 0x07) AM_READWRITE( z80_pio_0_r, z80pio_0_w ) |
| 96 | 101 | AM_RANGE(0xe0, 0xe3) AM_READWRITE(wd17xx_r, wd17xx_w) |
| 97 | 102 | AM_RANGE(0xe4, 0xe4) AM_READWRITE(nascom2_fdc_select_r, nascom2_fdc_select_w) |
| 98 | 103 | AM_RANGE(0xe5, 0xe5) AM_READ(nascom2_fdc_status_r) |
| r3335 | r3336 | |
| 246 | 251 | * |
| 247 | 252 | *************************************/ |
| 248 | 253 | |
| 254 | static const ay31015_config nascom1_ay31015_config = |
| 255 | { |
| 256 | AY_3_1015, |
| 257 | ( XTAL_16MHz / 16 ) / 256, |
| 258 | ( XTAL_16MHz / 16 ) / 256, |
| 259 | nascom1_hd6402_si, |
| 260 | nascom1_hd6402_so, |
| 261 | NULL |
| 262 | }; |
| 263 | |
| 264 | |
| 249 | 265 | static MACHINE_DRIVER_START( nascom1 ) |
| 250 | 266 | /* basic machine hardware */ |
| 251 | | MDRV_CPU_ADD("main", Z80, 1000000) |
| 267 | MDRV_CPU_ADD("main", Z80, XTAL_16MHz/8) |
| 252 | 268 | MDRV_CPU_PROGRAM_MAP(nascom1_mem, 0) |
| 253 | 269 | MDRV_CPU_IO_MAP(nascom1_io, 0) |
| 254 | 270 | |
| 271 | MDRV_MACHINE_RESET( nascom1 ) |
| 272 | |
| 255 | 273 | /* video hardware */ |
| 256 | 274 | MDRV_SCREEN_ADD("main", RASTER) |
| 257 | 275 | MDRV_SCREEN_REFRESH_RATE(50) |
| r3335 | r3336 | |
| 265 | 283 | |
| 266 | 284 | MDRV_VIDEO_UPDATE(nascom1) |
| 267 | 285 | |
| 286 | MDRV_AY31015_ADD( "hd6402", nascom1_ay31015_config ) |
| 287 | |
| 268 | 288 | /* devices */ |
| 269 | 289 | MDRV_SNAPSHOT_ADD(nascom1, "nas", 0.5) |
| 290 | |
| 291 | MDRV_CASSETTE_ADD( "cassette", default_cassette_config ) |
| 270 | 292 | MACHINE_DRIVER_END |
| 271 | 293 | |
| 272 | 294 | |
| 273 | 295 | static MACHINE_DRIVER_START( nascom2 ) |
| 274 | 296 | MDRV_IMPORT_FROM(nascom1) |
| 275 | | MDRV_CPU_REPLACE("main", Z80, 2000000) |
| 297 | MDRV_CPU_REPLACE("main", Z80, XTAL_16MHz/8) |
| 276 | 298 | MDRV_CPU_IO_MAP(nascom2_io, 0) |
| 277 | 299 | |
| 278 | 300 | MDRV_MACHINE_START(nascom2) |
| r3335 | r3336 | |
| 327 | 349 | * |
| 328 | 350 | *************************************/ |
| 329 | 351 | |
| 330 | | static void nascom1_cassette_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 331 | | { |
| 332 | | /* cassette */ |
| 333 | | switch(state) |
| 334 | | { |
| 335 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 336 | | case MESS_DEVINFO_INT_TYPE: info->i = IO_CASSETTE; break; |
| 337 | | case MESS_DEVINFO_INT_READABLE: info->i = 1; break; |
| 338 | | case MESS_DEVINFO_INT_WRITEABLE: info->i = 0; break; |
| 339 | | case MESS_DEVINFO_INT_CREATABLE: info->i = 0; break; |
| 340 | | case MESS_DEVINFO_INT_COUNT: info->i = 1; break; |
| 352 | //static void nascom1_cassette_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 353 | //{ |
| 354 | // /* cassette */ |
| 355 | // switch(state) |
| 356 | // { |
| 357 | // /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 358 | // case MESS_DEVINFO_INT_TYPE: info->i = IO_CASSETTE; break; |
| 359 | // case MESS_DEVINFO_INT_READABLE: info->i = 1; break; |
| 360 | // case MESS_DEVINFO_INT_WRITEABLE: info->i = 0; break; |
| 361 | // case MESS_DEVINFO_INT_CREATABLE: info->i = 0; break; |
| 362 | // case MESS_DEVINFO_INT_COUNT: info->i = 1; break; |
| 363 | // |
| 364 | // /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 365 | // case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(nascom1_cassette); break; |
| 366 | // case MESS_DEVINFO_PTR_UNLOAD: info->unload = DEVICE_IMAGE_UNLOAD_NAME(nascom1_cassette); break; |
| 367 | // |
| 368 | // /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 369 | // case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "cas"); break; |
| 370 | // } |
| 371 | //} |
| 341 | 372 | |
| 342 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 343 | | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(nascom1_cassette); break; |
| 344 | | case MESS_DEVINFO_PTR_UNLOAD: info->unload = DEVICE_IMAGE_UNLOAD_NAME(nascom1_cassette); break; |
| 345 | 373 | |
| 346 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 347 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "cas"); break; |
| 348 | | } |
| 349 | | } |
| 350 | | |
| 351 | | |
| 352 | 374 | static void nascom2_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 353 | 375 | { |
| 354 | 376 | /* floppy */ |
| r3335 | r3336 | |
| 373 | 395 | CONFIG_RAM(16 * 1024) |
| 374 | 396 | CONFIG_RAM(32 * 1024) |
| 375 | 397 | CONFIG_RAM_DEFAULT(40 * 1024) |
| 376 | | CONFIG_DEVICE(nascom1_cassette_getinfo) |
| 398 | // CONFIG_DEVICE(nascom1_cassette_getinfo) |
| 377 | 399 | SYSTEM_CONFIG_END |
| 378 | 400 | |
| 379 | 401 | |