src/mess/machine/dai.c
| r9692 | r9693 | |
| 25 | 25 | #define LOG_DAI_PORT_W(_port, _data, _comment) do { if (DEBUG_DAI_PORTS) logerror ("DAI port write: %04x, Data: %02x (%s)\n", _port, _data, _comment); } while (0) |
| 26 | 26 | |
| 27 | 27 | /* Discrete I/O devices */ |
| 28 | | UINT8 dai_noise_volume; |
| 29 | | UINT8 dai_osc_volume[3]; |
| 30 | | static UINT8 dai_paddle_select; |
| 31 | | static UINT8 dai_paddle_enable; |
| 32 | | static UINT8 dai_cassette_motor[2]; |
| 33 | | static running_device *dai_tms5501; |
| 34 | 28 | |
| 35 | 29 | |
| 36 | 30 | /* Memory */ |
| 37 | 31 | |
| 38 | 32 | WRITE8_HANDLER( dai_stack_interrupt_circuit_w ) |
| 39 | 33 | { |
| 40 | | tms5501_sensor (dai_tms5501, 1); |
| 41 | | tms5501_sensor (dai_tms5501, 0); |
| 34 | dai_state *state = space->machine->driver_data<dai_state>(); |
| 35 | tms5501_sensor (state->tms5501, 1); |
| 36 | tms5501_sensor (state->tms5501, 0); |
| 42 | 37 | } |
| 43 | 38 | |
| 44 | 39 | static void dai_update_memory(running_machine *machine, int dai_rom_bank) |
| r9692 | r9693 | |
| 51 | 46 | cpu_set_reg(machine->device("maincpu"), STATE_GENPC, 0xc000); |
| 52 | 47 | } |
| 53 | 48 | |
| 54 | | static UINT8 dai_keyboard_scan_mask = 0; |
| 55 | 49 | |
| 56 | 50 | static UINT8 dai_keyboard_read (running_device *device) |
| 57 | 51 | { |
| 52 | dai_state *state = device->machine->driver_data<dai_state>(); |
| 58 | 53 | UINT8 data = 0x00; |
| 59 | 54 | int i; |
| 60 | 55 | static const char *const keynames[] = { "IN0", "IN1", "IN2", "IN3", "IN4", "IN5", "IN6", "IN7" }; |
| 61 | 56 | |
| 62 | 57 | for (i = 0; i < 8; i++) |
| 63 | 58 | { |
| 64 | | if (dai_keyboard_scan_mask & (1 << i)) |
| 59 | if (state->keyboard_scan_mask & (1 << i)) |
| 65 | 60 | data |= input_port_read(device->machine, keynames[i]); |
| 66 | 61 | } |
| 67 | 62 | return data; |
| r9692 | r9693 | |
| 69 | 64 | |
| 70 | 65 | static void dai_keyboard_write (running_device *device, UINT8 data) |
| 71 | 66 | { |
| 72 | | dai_keyboard_scan_mask = data; |
| 67 | dai_state *state = device->machine->driver_data<dai_state>(); |
| 68 | state->keyboard_scan_mask = data; |
| 73 | 69 | } |
| 74 | 70 | |
| 75 | 71 | static void dai_interrupt_callback(running_device *device, int intreq, UINT8 vector) |
| r9692 | r9693 | |
| 100 | 96 | |
| 101 | 97 | static WRITE_LINE_DEVICE_HANDLER( dai_pit_out0 ) |
| 102 | 98 | { |
| 103 | | dai_set_input(device->machine, 0, state); |
| 99 | dai_state *drvstate = device->machine->driver_data<dai_state>(); |
| 100 | dai_set_input(drvstate->sound, 0, state); |
| 104 | 101 | } |
| 105 | 102 | |
| 106 | 103 | |
| 107 | 104 | static WRITE_LINE_DEVICE_HANDLER( dai_pit_out1 ) |
| 108 | 105 | { |
| 109 | | dai_set_input(device->machine, 1, state); |
| 106 | dai_state *drvstate = device->machine->driver_data<dai_state>(); |
| 107 | dai_set_input(drvstate->sound, 1, state); |
| 110 | 108 | } |
| 111 | 109 | |
| 112 | 110 | |
| 113 | 111 | static WRITE_LINE_DEVICE_HANDLER( dai_pit_out2 ) |
| 114 | 112 | { |
| 115 | | dai_set_input(device->machine, 2, state); |
| 113 | dai_state *drvstate = device->machine->driver_data<dai_state>(); |
| 114 | dai_set_input(drvstate->sound, 2, state); |
| 116 | 115 | } |
| 117 | 116 | |
| 118 | 117 | |
| r9692 | r9693 | |
| 139 | 138 | |
| 140 | 139 | static TIMER_CALLBACK( dai_timer ) |
| 141 | 140 | { |
| 142 | | tms5501_set_pio_bit_7 (dai_tms5501, (input_port_read(machine, "IN8") & 0x04) ? 1:0); |
| 141 | dai_state *state = machine->driver_data<dai_state>(); |
| 142 | tms5501_set_pio_bit_7 (state->tms5501, (input_port_read(machine, "IN8") & 0x04) ? 1:0); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | MACHINE_START( dai ) |
| 146 | 146 | { |
| 147 | | dai_tms5501 = machine->device("tms5501"); |
| 147 | dai_state *state = machine->driver_data<dai_state>(); |
| 148 | state->sound = machine->device("custom"); |
| 149 | state->tms5501 = machine->device("tms5501"); |
| 148 | 150 | |
| 149 | 151 | memory_configure_bank(machine, "bank2", 0, 4, memory_region(machine, "maincpu") + 0x010000, 0x1000); |
| 150 | 152 | timer_set(machine, attotime_zero, NULL, 0, dai_bootstrap_callback); |
| r9692 | r9693 | |
| 210 | 212 | |
| 211 | 213 | WRITE8_HANDLER( dai_io_discrete_devices_w ) |
| 212 | 214 | { |
| 215 | dai_state *state = space->machine->driver_data<dai_state>(); |
| 213 | 216 | switch(offset & 0x000f) { |
| 214 | 217 | case 0x04: |
| 215 | | dai_osc_volume[0] = data&0x0f; |
| 216 | | dai_osc_volume[1] = (data&0xf0)>>4; |
| 218 | dai_set_volume(state->sound, offset, data); |
| 217 | 219 | LOG_DAI_PORT_W (offset, data&0x0f, "discrete devices - osc. 0 volume"); |
| 218 | 220 | LOG_DAI_PORT_W (offset, (data&0xf0)>>4, "discrete devices - osc. 1 volume"); |
| 219 | 221 | break; |
| 220 | 222 | |
| 221 | 223 | case 0x05: |
| 222 | | dai_osc_volume[2] = data&0x0f; |
| 223 | | dai_noise_volume = (data&0xf0)>>4; |
| 224 | dai_set_volume(state->sound, offset, data); |
| 224 | 225 | LOG_DAI_PORT_W (offset, data&0x0f, "discrete devices - osc. 2 volume"); |
| 225 | 226 | LOG_DAI_PORT_W (offset, (data&0xf0)>>4, "discrete devices - noise volume"); |
| 226 | 227 | break; |
| 227 | 228 | |
| 228 | 229 | case 0x06: |
| 229 | | dai_paddle_select = (data&0x06)>>2; |
| 230 | | dai_paddle_enable = (data&0x08)>>3; |
| 231 | | dai_cassette_motor[0] = (data&0x10)>>4; |
| 232 | | dai_cassette_motor[1] = (data&0x20)>>5; |
| 233 | | cassette_change_state(space->machine->device("cassette"), dai_cassette_motor[0]?CASSETTE_MOTOR_DISABLED:CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| 230 | state->paddle_select = (data&0x06)>>2; |
| 231 | state->paddle_enable = (data&0x08)>>3; |
| 232 | state->cassette_motor[0] = (data&0x10)>>4; |
| 233 | state->cassette_motor[1] = (data&0x20)>>5; |
| 234 | cassette_change_state(space->machine->device("cassette"), state->cassette_motor[0]?CASSETTE_MOTOR_DISABLED:CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| 234 | 235 | cassette_output(space->machine->device("cassette"), (data & 0x01) ? -1.0 : 1.0); |
| 235 | 236 | dai_update_memory (space->machine, (data&0xc0)>>6); |
| 236 | 237 | LOG_DAI_PORT_W (offset, (data&0x06)>>2, "discrete devices - paddle select"); |
src/mess/video/dai.c
| r9692 | r9693 | |
| 40 | 40 | 0xff, 0xff, 0xff, /* 15 White */ |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | | static unsigned short dai_4_colours_palette[4]; |
| 44 | 43 | |
| 45 | 44 | PALETTE_INIT( dai ) |
| 46 | 45 | { |
| r9692 | r9693 | |
| 59 | 58 | |
| 60 | 59 | VIDEO_UPDATE( dai ) |
| 61 | 60 | { |
| 61 | dai_state *state = screen->machine->driver_data<dai_state>(); |
| 62 | 62 | address_space *space = cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 63 | 63 | int i, j, k, l; |
| 64 | 64 | |
| r9692 | r9693 | |
| 111 | 111 | unit_mode = (colour & 0x40) >> 6; |
| 112 | 112 | |
| 113 | 113 | if (colour & 0x80) |
| 114 | | dai_4_colours_palette[(colour & 0x30) >> 4] = colour & 0x0f; |
| 114 | state->_4_colours_palette[(colour & 0x30) >> 4] = colour & 0x0f; |
| 115 | 115 | |
| 116 | 116 | switch (display_mode) |
| 117 | 117 | { |
| r9692 | r9693 | |
| 133 | 133 | { |
| 134 | 134 | for (k=0; k<8; k++) |
| 135 | 135 | { |
| 136 | | current_colour = dai_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 136 | current_colour = state->_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 137 | 137 | for (l=0; l<12; l++) |
| 138 | 138 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*12+l) = current_colour; |
| 139 | 139 | } |
| r9692 | r9693 | |
| 150 | 150 | { |
| 151 | 151 | for (k=0; k<8; k++) |
| 152 | 152 | { |
| 153 | | current_colour = dai_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 153 | current_colour = state->_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 154 | 154 | for (l=0; l<12; l++) |
| 155 | 155 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*12+l) = current_colour; |
| 156 | 156 | } |
| r9692 | r9693 | |
| 172 | 172 | { |
| 173 | 173 | for (k=0; k<8; k++) |
| 174 | 174 | { |
| 175 | | current_colour = dai_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 175 | current_colour = state->_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 176 | 176 | for (l=0; l<6; l++) |
| 177 | 177 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*6+l) = current_colour; |
| 178 | 178 | } |
| r9692 | r9693 | |
| 189 | 189 | { |
| 190 | 190 | for (k=0; k<8; k++) |
| 191 | 191 | { |
| 192 | | current_colour = dai_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 192 | current_colour = state->_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 193 | 193 | for (l=0; l<6; l++) |
| 194 | 194 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*6+l) = current_colour; |
| 195 | 195 | } |
| r9692 | r9693 | |
| 211 | 211 | { |
| 212 | 212 | for (k=0; k<8; k++) |
| 213 | 213 | { |
| 214 | | current_colour = dai_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 214 | current_colour = state->_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 215 | 215 | for (l=0; l<3; l++) |
| 216 | 216 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*3+l) = current_colour; |
| 217 | 217 | } |
| r9692 | r9693 | |
| 227 | 227 | { |
| 228 | 228 | for (k=0; k<8; k++) |
| 229 | 229 | { |
| 230 | | current_colour = dai_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 230 | current_colour = state->_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 231 | 231 | for (l=0; l<3; l++) |
| 232 | 232 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*3+l) = current_colour; |
| 233 | 233 | } |
| r9692 | r9693 | |
| 249 | 249 | { |
| 250 | 250 | for (k=0; k<8; k++) |
| 251 | 251 | { |
| 252 | | current_colour = dai_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 252 | current_colour = state->_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 253 | 253 | for (l=0; l<2; l++) |
| 254 | 254 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*2+l) = current_colour; |
| 255 | 255 | } |
| r9692 | r9693 | |
| 265 | 265 | { |
| 266 | 266 | for (k=0; k<8; k++) |
| 267 | 267 | { |
| 268 | | current_colour = dai_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 268 | current_colour = state->_4_colours_palette[(((current_data_1>>(7-k)) & 0x01)<<1) | ((current_data_2>>(7-k)) & 0x01)]; |
| 269 | 269 | for (l=0; l<2; l++) |
| 270 | 270 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*2+l) = current_colour; |
| 271 | 271 | } |
| r9692 | r9693 | |
| 294 | 294 | { |
| 295 | 295 | for (k=0; k<8; k++) |
| 296 | 296 | { |
| 297 | | current_colour = dai_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 297 | current_colour = state->_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 298 | 298 | for (l=0; l<12; l++) |
| 299 | 299 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*12+l) = current_colour; |
| 300 | 300 | } |
| r9692 | r9693 | |
| 312 | 312 | { |
| 313 | 313 | for (k=0; k<8; k++) |
| 314 | 314 | { |
| 315 | | current_colour = dai_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 315 | current_colour = state->_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 316 | 316 | for (l=0; l<12; l++) |
| 317 | 317 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*12+l) = current_colour; |
| 318 | 318 | } |
| r9692 | r9693 | |
| 335 | 335 | { |
| 336 | 336 | for (k=0; k<8; k++) |
| 337 | 337 | { |
| 338 | | current_colour = dai_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 338 | current_colour = state->_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 339 | 339 | for (l=0; l<6; l++) |
| 340 | 340 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*6+l) = current_colour; |
| 341 | 341 | } |
| r9692 | r9693 | |
| 353 | 353 | { |
| 354 | 354 | for (k=0; k<8; k++) |
| 355 | 355 | { |
| 356 | | current_colour = dai_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 356 | current_colour = state->_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 357 | 357 | for (l=0; l<6; l++) |
| 358 | 358 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*6+l) = current_colour; |
| 359 | 359 | } |
| r9692 | r9693 | |
| 376 | 376 | { |
| 377 | 377 | for (k=0; k<8; k++) |
| 378 | 378 | { |
| 379 | | current_colour = dai_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 379 | current_colour = state->_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 380 | 380 | for (l=0; l<3; l++) |
| 381 | 381 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*3+l) = current_colour; |
| 382 | 382 | } |
| r9692 | r9693 | |
| 393 | 393 | { |
| 394 | 394 | for (k=0; k<8; k++) |
| 395 | 395 | { |
| 396 | | current_colour = dai_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 396 | current_colour = state->_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 397 | 397 | for (l=0; l<3; l++) |
| 398 | 398 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*3+l) = current_colour; |
| 399 | 399 | } |
| r9692 | r9693 | |
| 415 | 415 | { |
| 416 | 416 | for (k=0; k<8; k++) |
| 417 | 417 | { |
| 418 | | current_colour = dai_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 418 | current_colour = state->_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 419 | 419 | for (l=0; l<2; l++) |
| 420 | 420 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*2+l) = current_colour; |
| 421 | 421 | } |
| r9692 | r9693 | |
| 432 | 432 | { |
| 433 | 433 | for (k=0; k<8; k++) |
| 434 | 434 | { |
| 435 | | current_colour = dai_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 435 | current_colour = state->_4_colours_palette[(((current_data_2 >> k)&0x01)<<1) | ((char_rom[current_data_1*16+j]>>k) & 0x01)]; |
| 436 | 436 | for (l=0; l<2; l++) |
| 437 | 437 | *BITMAP_ADDR16(bitmap, current_scan_line/2 + j, (i*8+k)*2+l) = current_colour; |
| 438 | 438 | } |
src/mess/video/arcadia.c
| r9692 | r9693 | |
| 283 | 283 | // 8x user defined |
| 284 | 284 | }; |
| 285 | 285 | |
| 286 | | static struct { |
| 287 | | int line; |
| 288 | | int charline; |
| 289 | | int shift; |
| 290 | | int ad_delay; |
| 291 | | int ad_select; |
| 292 | | int ypos; |
| 293 | | int graphics; |
| 294 | | int doublescan; |
| 295 | | int lines26; |
| 296 | | int multicolor; |
| 297 | | struct { int x, y; } pos[4]; |
| 298 | | UINT8 bg[262][16+2*XPOS/8]; |
| 299 | | UINT8 rectangle[0x40][8]; |
| 300 | | UINT8 chars[0x40][8]; |
| 301 | | int breaker; |
| 302 | | union { |
| 303 | | UINT8 data[0x400]; |
| 304 | | struct { |
| 305 | | // 0x1800 |
| 306 | | UINT8 chars1[13][16]; |
| 307 | | UINT8 ram1[2][16]; |
| 308 | | struct { |
| 309 | | UINT8 y,x; |
| 310 | | } pos[4]; |
| 311 | | UINT8 ram2[4]; |
| 312 | | UINT8 vpos; |
| 313 | | UINT8 sound1, sound2; |
| 314 | | UINT8 char_line; |
| 315 | | // 0x1900 |
| 316 | | UINT8 pad1a, pad1b, pad1c, pad1d; |
| 317 | | UINT8 pad2a, pad2b, pad2c, pad2d; |
| 318 | | UINT8 keys, unmapped3[0x80-9]; |
| 319 | | UINT8 chars[8][8]; |
| 320 | | UINT8 unknown[0x38]; |
| 321 | | UINT8 pal[4]; |
| 322 | | UINT8 collision_bg, |
| 323 | | collision_sprite; |
| 324 | | UINT8 ad[2]; |
| 325 | | // 0x1a00 |
| 326 | | UINT8 chars2[13][16]; |
| 327 | | UINT8 ram3[3][16]; |
| 328 | | } d; |
| 329 | | } reg; |
| 330 | | bitmap_t *bitmap; |
| 331 | | } arcadia_video={ 0 }; |
| 332 | | |
| 333 | 286 | VIDEO_START( arcadia ) |
| 334 | 287 | { |
| 288 | arcadia_state *state = machine->driver_data<arcadia_state>(); |
| 335 | 289 | int i; |
| 336 | | memcpy(&arcadia_video.chars, chars, sizeof(chars)); |
| 290 | memcpy(&state->chars, chars, sizeof(chars)); |
| 337 | 291 | for (i=0; i<0x40; i++) |
| 338 | 292 | { |
| 339 | | arcadia_video.rectangle[i][0]=0; |
| 340 | | arcadia_video.rectangle[i][4]=0; |
| 341 | | if (i&1) arcadia_video.rectangle[i][0]|=3; |
| 342 | | if (i&2) arcadia_video.rectangle[i][0]|=0x1c; |
| 343 | | if (i&4) arcadia_video.rectangle[i][0]|=0xe0; |
| 344 | | if (i&8) arcadia_video.rectangle[i][4]|=3; |
| 345 | | if (i&0x10) arcadia_video.rectangle[i][4]|=0x1c; |
| 346 | | if (i&0x20) arcadia_video.rectangle[i][4]|=0xe0; |
| 347 | | arcadia_video.rectangle[i][1]=arcadia_video.rectangle[i][2]=arcadia_video.rectangle[i][3]=arcadia_video.rectangle[i][0]; |
| 348 | | arcadia_video.rectangle[i][5]=arcadia_video.rectangle[i][6]=arcadia_video.rectangle[i][7]=arcadia_video.rectangle[i][4]; |
| 293 | state->rectangle[i][0]=0; |
| 294 | state->rectangle[i][4]=0; |
| 295 | if (i&1) state->rectangle[i][0]|=3; |
| 296 | if (i&2) state->rectangle[i][0]|=0x1c; |
| 297 | if (i&4) state->rectangle[i][0]|=0xe0; |
| 298 | if (i&8) state->rectangle[i][4]|=3; |
| 299 | if (i&0x10) state->rectangle[i][4]|=0x1c; |
| 300 | if (i&0x20) state->rectangle[i][4]|=0xe0; |
| 301 | state->rectangle[i][1]=state->rectangle[i][2]=state->rectangle[i][3]=state->rectangle[i][0]; |
| 302 | state->rectangle[i][5]=state->rectangle[i][6]=state->rectangle[i][7]=state->rectangle[i][4]; |
| 349 | 303 | } |
| 350 | 304 | |
| 351 | 305 | { |
| 352 | 306 | screen_device *screen = screen_first(*machine); |
| 353 | 307 | int width = screen->width(); |
| 354 | 308 | int height = screen->height(); |
| 355 | | arcadia_video.bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); |
| 309 | state->bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); |
| 356 | 310 | } |
| 357 | 311 | } |
| 358 | 312 | |
| 359 | 313 | READ8_HANDLER(arcadia_video_r) |
| 360 | 314 | { |
| 315 | arcadia_state *state = space->machine->driver_data<arcadia_state>(); |
| 361 | 316 | UINT8 data=0; |
| 362 | 317 | switch (offset) { |
| 363 | | case 0xff: data=arcadia_video.charline|0xf0;break; |
| 318 | case 0xff: data=state->charline|0xf0;break; |
| 364 | 319 | case 0x100: data=input_port_read(space->machine, "controller1_col1");break; |
| 365 | 320 | case 0x101: data=input_port_read(space->machine, "controller1_col2");break; |
| 366 | 321 | case 0x102: data=input_port_read(space->machine, "controller1_col3");break; |
| r9692 | r9693 | |
| 372 | 327 | case 0x108: data=input_port_read(space->machine, "panel");break; |
| 373 | 328 | #if 0 |
| 374 | 329 | case 0x1fe: |
| 375 | | if (arcadia_video.ad_select) |
| 330 | if (state->ad_select) |
| 376 | 331 | data=input_port_read(space->machine, "controller1_joy_y")<<3; |
| 377 | 332 | else |
| 378 | 333 | data=input_port_read(space->machine, "controller1_joy_x")<<3; |
| 379 | 334 | break; |
| 380 | 335 | case 0x1ff: |
| 381 | | if (arcadia_video.ad_select) |
| 336 | if (state->ad_select) |
| 382 | 337 | data=input_port_read(space->machine, "controller2_joy_y")<<3; |
| 383 | 338 | else |
| 384 | 339 | data=input_port_read(space->machine, "controller2_joy_x")<<3; |
| r9692 | r9693 | |
| 386 | 341 | #else |
| 387 | 342 | case 0x1fe: |
| 388 | 343 | data = 0x80; |
| 389 | | if (arcadia_video.ad_select) { |
| 344 | if (state->ad_select) { |
| 390 | 345 | if (input_port_read(space->machine, "joysticks")&0x10) data=0; |
| 391 | 346 | if (input_port_read(space->machine, "joysticks")&0x20) data=0xff; |
| 392 | 347 | } else { |
| r9692 | r9693 | |
| 396 | 351 | break; |
| 397 | 352 | case 0x1ff: |
| 398 | 353 | data = 0x6f; // 0x7f too big for alien invaders (movs right) |
| 399 | | if (arcadia_video.ad_select) { |
| 354 | if (state->ad_select) { |
| 400 | 355 | if (input_port_read(space->machine, "joysticks")&0x1) data=0; |
| 401 | 356 | if (input_port_read(space->machine, "joysticks")&0x2) data=0xff; |
| 402 | 357 | } else { |
| r9692 | r9693 | |
| 406 | 361 | break; |
| 407 | 362 | #endif |
| 408 | 363 | default: |
| 409 | | data=arcadia_video.reg.data[offset]; |
| 364 | data=state->reg.data[offset]; |
| 410 | 365 | } |
| 411 | 366 | return data; |
| 412 | 367 | } |
| 413 | 368 | |
| 414 | 369 | WRITE8_HANDLER(arcadia_video_w) |
| 415 | 370 | { |
| 416 | | arcadia_video.reg.data[offset]=data; |
| 371 | arcadia_state *state = space->machine->driver_data<arcadia_state>(); |
| 372 | state->reg.data[offset]=data; |
| 417 | 373 | switch (offset) |
| 418 | 374 | { |
| 419 | 375 | case 0xfc: |
| 420 | | arcadia_video.ypos=255-data+YPOS; |
| 376 | state->ypos=255-data+YPOS; |
| 421 | 377 | break; |
| 422 | 378 | case 0xfd: |
| 423 | 379 | arcadia_soundport_w(space->machine->device("custom"), offset&3, data); |
| 424 | | arcadia_video.multicolor=data&0x80; |
| 380 | state->multicolor=data&0x80; |
| 425 | 381 | break; |
| 426 | 382 | case 0xfe: |
| 427 | 383 | arcadia_soundport_w(space->machine->device("custom"), offset&3, data); |
| 428 | | arcadia_video.shift=(data>>5); |
| 384 | state->shift=(data>>5); |
| 429 | 385 | break; |
| 430 | 386 | case 0xf0: case 0xf2: case 0xf4: case 0xf6: |
| 431 | | arcadia_video.pos[(offset>>1)&3].y=(data^0xff)+1; |
| 387 | state->pos[(offset>>1)&3].y=(data^0xff)+1; |
| 432 | 388 | break; |
| 433 | 389 | case 0xf1: case 0xf3: case 0xf5: case 0xf7: |
| 434 | | arcadia_video.pos[(offset>>1)&3].x=data-43; |
| 390 | state->pos[(offset>>1)&3].x=data-43; |
| 435 | 391 | break; |
| 436 | 392 | case 0x180: case 0x181: case 0x182: case 0x183: case 0x184: case 0x185: case 0x186: case 0x187: |
| 437 | 393 | case 0x188: case 0x189: case 0x18a: case 0x18b: case 0x18c: case 0x18d: case 0x18e: case 0x18f: |
| r9692 | r9693 | |
| 441 | 397 | case 0x1a8: case 0x1a9: case 0x1aa: case 0x1ab: case 0x1ac: case 0x1ad: case 0x1ae: case 0x1af: |
| 442 | 398 | case 0x1b0: case 0x1b1: case 0x1b2: case 0x1b3: case 0x1b4: case 0x1b5: case 0x1b6: case 0x1b7: |
| 443 | 399 | case 0x1b8: case 0x1b9: case 0x1ba: case 0x1bb: case 0x1bc: case 0x1bd: case 0x1be: case 0x1bf: |
| 444 | | arcadia_video.chars[0x38|((offset>>3)&7)][offset&7]=data; |
| 400 | state->chars[0x38|((offset>>3)&7)][offset&7]=data; |
| 445 | 401 | break; |
| 446 | 402 | case 0x1f8: |
| 447 | | arcadia_video.lines26=data&0x40; |
| 448 | | arcadia_video.graphics=data&0x80; |
| 403 | state->lines26=data&0x40; |
| 404 | state->graphics=data&0x80; |
| 449 | 405 | break; |
| 450 | 406 | case 0x1f9: |
| 451 | | arcadia_video.doublescan=!(data&0x80); |
| 452 | | arcadia_video.ad_delay=10; |
| 407 | state->doublescan=!(data&0x80); |
| 408 | state->ad_delay=10; |
| 453 | 409 | break; |
| 454 | 410 | } |
| 455 | 411 | } |
| r9692 | r9693 | |
| 457 | 413 | INLINE void arcadia_draw_char(running_machine *machine, bitmap_t *bitmap, UINT8 *ch, int charcode, |
| 458 | 414 | int y, int x) |
| 459 | 415 | { |
| 416 | arcadia_state *state = machine->driver_data<arcadia_state>(); |
| 460 | 417 | int k,b,cc,sc, colour; |
| 461 | | if (arcadia_video.multicolor) |
| 418 | if (state->multicolor) |
| 462 | 419 | { |
| 463 | 420 | if (charcode&0x40) |
| 464 | | cc=((arcadia_video.reg.d.pal[1]>>3)&7); |
| 421 | cc=((state->reg.d.pal[1]>>3)&7); |
| 465 | 422 | else |
| 466 | | cc=((arcadia_video.reg.d.pal[0]>>3)&7); |
| 423 | cc=((state->reg.d.pal[0]>>3)&7); |
| 467 | 424 | |
| 468 | 425 | if (charcode&0x80) |
| 469 | | sc=(arcadia_video.reg.d.pal[1]&7); |
| 426 | sc=(state->reg.d.pal[1]&7); |
| 470 | 427 | else |
| 471 | | sc=(arcadia_video.reg.d.pal[0]&7); |
| 428 | sc=(state->reg.d.pal[0]&7); |
| 472 | 429 | |
| 473 | 430 | } |
| 474 | 431 | else |
| 475 | 432 | { |
| 476 | | cc=((arcadia_video.reg.d.pal[1]>>3)&1)|((charcode>>5)&6); |
| 477 | | sc=(arcadia_video.reg.d.pal[1]&7); |
| 433 | cc=((state->reg.d.pal[1]>>3)&1)|((charcode>>5)&6); |
| 434 | sc=(state->reg.d.pal[1]&7); |
| 478 | 435 | } |
| 479 | 436 | colour = (((sc << 3) | cc) + 4); |
| 480 | 437 | |
| 481 | | if (arcadia_video.doublescan) |
| 438 | if (state->doublescan) |
| 482 | 439 | { |
| 483 | 440 | for (k=0; (k<8)&&(y<bitmap->height); k++, y+=2) |
| 484 | 441 | { |
| 485 | 442 | b=ch[k]; |
| 486 | | arcadia_video.bg[y][x>>3]|=b>>(x&7); |
| 487 | | arcadia_video.bg[y][(x>>3)+1]|=b<<(8-(x&7)); |
| 443 | state->bg[y][x>>3]|=b>>(x&7); |
| 444 | state->bg[y][(x>>3)+1]|=b<<(8-(x&7)); |
| 488 | 445 | |
| 489 | 446 | if (y+1<bitmap->height) { |
| 490 | | arcadia_video.bg[y+1][x>>3]|=b>>(x&7); |
| 491 | | arcadia_video.bg[y+1][(x>>3)+1]|=b<<(8-(x&7)); |
| 447 | state->bg[y+1][x>>3]|=b>>(x&7); |
| 448 | state->bg[y+1][(x>>3)+1]|=b<<(8-(x&7)); |
| 492 | 449 | drawgfx_opaque(bitmap, 0, machine->gfx[0], b,colour, |
| 493 | 450 | 0,0,x,y); |
| 494 | 451 | drawgfx_opaque(bitmap, 0, machine->gfx[0], b,colour, |
| r9692 | r9693 | |
| 501 | 458 | for (k=0; (k<8)&&(y<bitmap->height); k++, y++) |
| 502 | 459 | { |
| 503 | 460 | b=ch[k]; |
| 504 | | arcadia_video.bg[y][x>>3]|=b>>(x&7); |
| 505 | | arcadia_video.bg[y][(x>>3)+1]|=b<<(8-(x&7)); |
| 461 | state->bg[y][x>>3]|=b>>(x&7); |
| 462 | state->bg[y][(x>>3)+1]|=b<<(8-(x&7)); |
| 506 | 463 | |
| 507 | 464 | drawgfx_opaque(bitmap, 0, machine->gfx[0], b,colour, |
| 508 | 465 | 0,0,x,y); |
| r9692 | r9693 | |
| 513 | 470 | INLINE void arcadia_vh_draw_line(running_machine *machine, bitmap_t *bitmap, |
| 514 | 471 | int y, UINT8 chars1[16]) |
| 515 | 472 | { |
| 473 | arcadia_state *state = machine->driver_data<arcadia_state>(); |
| 516 | 474 | int x, ch, j, h; |
| 517 | | int graphics=arcadia_video.graphics; |
| 518 | | h=arcadia_video.doublescan?16:8; |
| 475 | int graphics=state->graphics; |
| 476 | h=state->doublescan?16:8; |
| 519 | 477 | |
| 520 | | if (bitmap->height-arcadia_video.line<h) |
| 521 | | h=bitmap->height-arcadia_video.line; |
| 478 | if (bitmap->height-state->line<h) |
| 479 | h=bitmap->height-state->line; |
| 522 | 480 | |
| 523 | | plot_box(bitmap, 0, y, bitmap->width, h, (arcadia_video.reg.d.pal[1]&7)); |
| 524 | | memset(arcadia_video.bg[y], 0, sizeof(arcadia_video.bg[0])*h); |
| 481 | plot_box(bitmap, 0, y, bitmap->width, h, (state->reg.d.pal[1]&7)); |
| 482 | memset(state->bg[y], 0, sizeof(state->bg[0])*h); |
| 525 | 483 | |
| 526 | | for (x=XPOS+arcadia_video.shift, j=0; j<16;j++,x+=8) |
| 484 | for (x=XPOS+state->shift, j=0; j<16;j++,x+=8) |
| 527 | 485 | { |
| 528 | 486 | ch=chars1[j]; |
| 529 | 487 | // hangman switches with 0x40 |
| r9692 | r9693 | |
| 539 | 497 | } |
| 540 | 498 | } |
| 541 | 499 | if (graphics) |
| 542 | | arcadia_draw_char(machine, bitmap, arcadia_video.rectangle[ch&0x3f], ch, y, x); |
| 500 | arcadia_draw_char(machine, bitmap, state->rectangle[ch&0x3f], ch, y, x); |
| 543 | 501 | else |
| 544 | | arcadia_draw_char(machine, bitmap, arcadia_video.chars[ch&0x3f], ch, y, x); |
| 502 | arcadia_draw_char(machine, bitmap, state->chars[ch&0x3f], ch, y, x); |
| 545 | 503 | } |
| 546 | 504 | } |
| 547 | 505 | |
| 548 | | static int arcadia_sprite_collision(int n1, int n2) |
| 506 | static int arcadia_sprite_collision(arcadia_state *state, int n1, int n2) |
| 549 | 507 | { |
| 550 | 508 | int k, b1, b2, x; |
| 551 | | if (arcadia_video.pos[n1].x+8<=arcadia_video.pos[n2].x) return FALSE; |
| 552 | | if (arcadia_video.pos[n1].x>=arcadia_video.pos[n2].x+8) return FALSE; |
| 509 | if (state->pos[n1].x+8<=state->pos[n2].x) return FALSE; |
| 510 | if (state->pos[n1].x>=state->pos[n2].x+8) return FALSE; |
| 553 | 511 | for (k=0; k<8; k++) { |
| 554 | | if (arcadia_video.pos[n1].y+k<arcadia_video.pos[n2].y) continue; |
| 555 | | if (arcadia_video.pos[n1].y+k>=arcadia_video.pos[n2].y+8) break; |
| 556 | | x=arcadia_video.pos[n1].x-arcadia_video.pos[n2].x; |
| 557 | | b1=arcadia_video.reg.d.chars[n1][k]; |
| 558 | | b2=arcadia_video.reg.d.chars[n2][arcadia_video.pos[n1].y+k-arcadia_video.pos[n2].y]; |
| 512 | if (state->pos[n1].y+k<state->pos[n2].y) continue; |
| 513 | if (state->pos[n1].y+k>=state->pos[n2].y+8) break; |
| 514 | x=state->pos[n1].x-state->pos[n2].x; |
| 515 | b1=state->reg.d.chars[n1][k]; |
| 516 | b2=state->reg.d.chars[n2][state->pos[n1].y+k-state->pos[n2].y]; |
| 559 | 517 | if (x<0) b2>>=-x; |
| 560 | 518 | if (x>0) b1>>=x; |
| 561 | 519 | if (b1&b2) return TRUE; |
| r9692 | r9693 | |
| 565 | 523 | |
| 566 | 524 | static void arcadia_draw_sprites(running_machine *machine, bitmap_t *bitmap) |
| 567 | 525 | { |
| 526 | arcadia_state *state = machine->driver_data<arcadia_state>(); |
| 568 | 527 | int i, k, x, y, color=0; |
| 569 | 528 | UINT8 b; |
| 570 | 529 | |
| 571 | | arcadia_video.reg.d.collision_bg|=0xf; |
| 572 | | arcadia_video.reg.d.collision_sprite|=0x3f; |
| 530 | state->reg.d.collision_bg|=0xf; |
| 531 | state->reg.d.collision_sprite|=0x3f; |
| 573 | 532 | for (i=0; i<4; i++) |
| 574 | 533 | { |
| 575 | 534 | int doublescan = FALSE; |
| 576 | | if (arcadia_video.pos[i].y<=-YPOS) continue; |
| 577 | | if (arcadia_video.pos[i].y>=bitmap->height-YPOS-8) continue; |
| 578 | | if (arcadia_video.pos[i].x<=-XPOS) continue; |
| 579 | | if (arcadia_video.pos[i].x>=128+XPOS-8) continue; |
| 535 | if (state->pos[i].y<=-YPOS) continue; |
| 536 | if (state->pos[i].y>=bitmap->height-YPOS-8) continue; |
| 537 | if (state->pos[i].x<=-XPOS) continue; |
| 538 | if (state->pos[i].x>=128+XPOS-8) continue; |
| 580 | 539 | |
| 581 | 540 | switch (i) |
| 582 | 541 | { |
| 583 | 542 | case 0: |
| 584 | | color=(arcadia_video.reg.d.pal[3]>>3)&7; |
| 585 | | doublescan=arcadia_video.reg.d.pal[3]&0x80?FALSE:TRUE; |
| 543 | color=(state->reg.d.pal[3]>>3)&7; |
| 544 | doublescan=state->reg.d.pal[3]&0x80?FALSE:TRUE; |
| 586 | 545 | break; |
| 587 | 546 | case 1: |
| 588 | | color=arcadia_video.reg.d.pal[3]&7; |
| 589 | | doublescan=arcadia_video.reg.d.pal[3]&0x40?FALSE:TRUE; |
| 547 | color=state->reg.d.pal[3]&7; |
| 548 | doublescan=state->reg.d.pal[3]&0x40?FALSE:TRUE; |
| 590 | 549 | break; |
| 591 | 550 | case 2: |
| 592 | | color=(arcadia_video.reg.d.pal[2]>>3)&7; |
| 593 | | doublescan=arcadia_video.reg.d.pal[2]&0x80?FALSE:TRUE; |
| 551 | color=(state->reg.d.pal[2]>>3)&7; |
| 552 | doublescan=state->reg.d.pal[2]&0x80?FALSE:TRUE; |
| 594 | 553 | break; |
| 595 | 554 | case 3: |
| 596 | | color=arcadia_video.reg.d.pal[2]&7; |
| 597 | | doublescan=arcadia_video.reg.d.pal[2]&0x40?FALSE:TRUE; |
| 555 | color=state->reg.d.pal[2]&7; |
| 556 | doublescan=state->reg.d.pal[2]&0x40?FALSE:TRUE; |
| 598 | 557 | break; |
| 599 | 558 | } |
| 600 | 559 | for (k=0; k<8; k++) |
| 601 | 560 | { |
| 602 | 561 | int j, m; |
| 603 | | b=arcadia_video.reg.d.chars[i][k]; |
| 604 | | x=arcadia_video.pos[i].x+XPOS; |
| 562 | b=state->reg.d.chars[i][k]; |
| 563 | x=state->pos[i].x+XPOS; |
| 605 | 564 | if (!doublescan) |
| 606 | 565 | { |
| 607 | | y=arcadia_video.pos[i].y+YPOS+k; |
| 566 | y=state->pos[i].y+YPOS+k; |
| 608 | 567 | for (j=0,m=0x80; j<8; j++, m>>=1) |
| 609 | 568 | { |
| 610 | 569 | if (b & m) |
| r9692 | r9693 | |
| 615 | 574 | } |
| 616 | 575 | else |
| 617 | 576 | { |
| 618 | | y=arcadia_video.pos[i].y+YPOS+k*2; |
| 577 | y=state->pos[i].y+YPOS+k*2; |
| 619 | 578 | for (j=0,m=0x80; j<8; j++, m>>=1) |
| 620 | 579 | { |
| 621 | 580 | if (b & m) |
| r9692 | r9693 | |
| 625 | 584 | } |
| 626 | 585 | } |
| 627 | 586 | } |
| 628 | | if (arcadia_video.reg.d.collision_bg&(1<<i)) |
| 587 | if (state->reg.d.collision_bg&(1<<i)) |
| 629 | 588 | { |
| 630 | | if ( (b<<(8-(x&7))) & ((arcadia_video.bg[y][x>>3]<<8) |
| 631 | | |arcadia_video.bg[y][(x>>3)+1]) ) |
| 632 | | arcadia_video.reg.d.collision_bg&=~(1<<i); |
| 589 | if ( (b<<(8-(x&7))) & ((state->bg[y][x>>3]<<8) |
| 590 | |state->bg[y][(x>>3)+1]) ) |
| 591 | state->reg.d.collision_bg&=~(1<<i); |
| 633 | 592 | } |
| 634 | 593 | } |
| 635 | 594 | } |
| 636 | | if (arcadia_sprite_collision(0,1)) arcadia_video.reg.d.collision_sprite&=~1; |
| 637 | | if (arcadia_sprite_collision(0,2)) arcadia_video.reg.d.collision_sprite&=~2; |
| 638 | | if (arcadia_sprite_collision(0,3)) arcadia_video.reg.d.collision_sprite&=~4; |
| 639 | | if (arcadia_sprite_collision(1,2)) arcadia_video.reg.d.collision_sprite&=~8; |
| 640 | | if (arcadia_sprite_collision(1,3)) arcadia_video.reg.d.collision_sprite&=~0x10; //guess |
| 641 | | if (arcadia_sprite_collision(2,3)) arcadia_video.reg.d.collision_sprite&=~0x20; //guess |
| 595 | if (arcadia_sprite_collision(state,0,1)) state->reg.d.collision_sprite&=~1; |
| 596 | if (arcadia_sprite_collision(state,0,2)) state->reg.d.collision_sprite&=~2; |
| 597 | if (arcadia_sprite_collision(state,0,3)) state->reg.d.collision_sprite&=~4; |
| 598 | if (arcadia_sprite_collision(state,1,2)) state->reg.d.collision_sprite&=~8; |
| 599 | if (arcadia_sprite_collision(state,1,3)) state->reg.d.collision_sprite&=~0x10; //guess |
| 600 | if (arcadia_sprite_collision(state,2,3)) state->reg.d.collision_sprite&=~0x20; //guess |
| 642 | 601 | } |
| 643 | 602 | |
| 644 | 603 | INTERRUPT_GEN( arcadia_video_line ) |
| 645 | 604 | { |
| 605 | arcadia_state *state = device->machine->driver_data<arcadia_state>(); |
| 646 | 606 | screen_device *screen = screen_first(*device->machine); |
| 647 | 607 | int width = screen->width(); |
| 648 | 608 | |
| 649 | | if (arcadia_video.ad_delay<=0) |
| 650 | | arcadia_video.ad_select=arcadia_video.reg.d.pal[1]&0x40; |
| 651 | | else arcadia_video.ad_delay--; |
| 609 | if (state->ad_delay<=0) |
| 610 | state->ad_select=state->reg.d.pal[1]&0x40; |
| 611 | else state->ad_delay--; |
| 652 | 612 | |
| 653 | | arcadia_video.line++; |
| 654 | | arcadia_video.line%=262; |
| 613 | state->line++; |
| 614 | state->line%=262; |
| 655 | 615 | // unbelievable, reflects only charline, but alien invaders uses it for |
| 656 | 616 | // alien scrolling |
| 657 | 617 | |
| 658 | | if (arcadia_video.line<arcadia_video.ypos) |
| 618 | if (state->line<state->ypos) |
| 659 | 619 | { |
| 660 | | plot_box(arcadia_video.bitmap, 0, arcadia_video.line, width, 1, (arcadia_video.reg.d.pal[1])&7); |
| 661 | | memset(arcadia_video.bg[arcadia_video.line], 0, sizeof(arcadia_video.bg[0])); |
| 620 | plot_box(state->bitmap, 0, state->line, width, 1, (state->reg.d.pal[1])&7); |
| 621 | memset(state->bg[state->line], 0, sizeof(state->bg[0])); |
| 662 | 622 | } |
| 663 | 623 | else |
| 664 | 624 | { |
| 665 | | int h=arcadia_video.doublescan?16:8; |
| 625 | int h=state->doublescan?16:8; |
| 666 | 626 | |
| 667 | | arcadia_video.charline=(arcadia_video.line-arcadia_video.ypos)/h; |
| 627 | state->charline=(state->line-state->ypos)/h; |
| 668 | 628 | |
| 669 | | if (arcadia_video.charline<13) |
| 629 | if (state->charline<13) |
| 670 | 630 | { |
| 671 | | if (((arcadia_video.line-arcadia_video.ypos)&(h-1))==0) |
| 631 | if (((state->line-state->ypos)&(h-1))==0) |
| 672 | 632 | { |
| 673 | | arcadia_vh_draw_line(device->machine, arcadia_video.bitmap, arcadia_video.charline*h+arcadia_video.ypos, |
| 674 | | arcadia_video.reg.d.chars1[arcadia_video.charline]); |
| 633 | arcadia_vh_draw_line(device->machine, state->bitmap, state->charline*h+state->ypos, |
| 634 | state->reg.d.chars1[state->charline]); |
| 675 | 635 | } |
| 676 | 636 | } |
| 677 | 637 | else |
| 678 | | if (arcadia_video.lines26 && (arcadia_video.charline<26)) |
| 638 | if (state->lines26 && (state->charline<26)) |
| 679 | 639 | { |
| 680 | | if (((arcadia_video.line-arcadia_video.ypos)&(h-1))==0) |
| 640 | if (((state->line-state->ypos)&(h-1))==0) |
| 681 | 641 | { |
| 682 | | arcadia_vh_draw_line(device->machine, arcadia_video.bitmap, arcadia_video.charline*h+arcadia_video.ypos, |
| 683 | | arcadia_video.reg.d.chars2[arcadia_video.charline-13]); |
| 642 | arcadia_vh_draw_line(device->machine, state->bitmap, state->charline*h+state->ypos, |
| 643 | state->reg.d.chars2[state->charline-13]); |
| 684 | 644 | } |
| 685 | | arcadia_video.charline-=13; |
| 645 | state->charline-=13; |
| 686 | 646 | } |
| 687 | 647 | else |
| 688 | 648 | { |
| 689 | | arcadia_video.charline=0xd; |
| 690 | | plot_box(arcadia_video.bitmap, 0, arcadia_video.line, width, 1, (arcadia_video.reg.d.pal[1])&7); |
| 691 | | memset(arcadia_video.bg[arcadia_video.line], 0, sizeof(arcadia_video.bg[0])); |
| 649 | state->charline=0xd; |
| 650 | plot_box(state->bitmap, 0, state->line, width, 1, (state->reg.d.pal[1])&7); |
| 651 | memset(state->bg[state->line], 0, sizeof(state->bg[0])); |
| 692 | 652 | } |
| 693 | 653 | } |
| 694 | | if (arcadia_video.line==261) |
| 695 | | arcadia_draw_sprites(device->machine, arcadia_video.bitmap); |
| 654 | if (state->line==261) |
| 655 | arcadia_draw_sprites(device->machine, state->bitmap); |
| 696 | 656 | } |
| 697 | 657 | |
| 698 | 658 | READ8_HANDLER(arcadia_vsync_r) |
| 699 | 659 | { |
| 700 | | return arcadia_video.line>=216?0x80:0; |
| 660 | arcadia_state *state = space->machine->driver_data<arcadia_state>(); |
| 661 | return state->line>=216?0x80:0; |
| 701 | 662 | } |
| 702 | 663 | |
| 703 | 664 | VIDEO_UPDATE( arcadia ) |
| 704 | 665 | { |
| 705 | | copybitmap(bitmap, arcadia_video.bitmap, 0, 0, 0, 0, cliprect); |
| 666 | arcadia_state *state = screen->machine->driver_data<arcadia_state>(); |
| 667 | copybitmap(bitmap, state->bitmap, 0, 0, 0, 0, cliprect); |
| 706 | 668 | return 0; |
| 707 | 669 | } |
src/mess/drivers/fmtowns.c
| r9692 | r9693 | |
| 564 | 564 | |
| 565 | 565 | static TIMER_CALLBACK( poll_keyboard ) |
| 566 | 566 | { |
| 567 | | const char* kb_ports[4] = { "key1", "key2", "key3", "key4" }; |
| 568 | | static UINT32 kb_prev[4]; |
| 567 | towns_state *state = machine->driver_data<towns_state>(); |
| 568 | static const char *const kb_ports[4] = { "key1", "key2", "key3", "key4" }; |
| 569 | 569 | int port,bit; |
| 570 | 570 | UINT8 scan; |
| 571 | 571 | UINT32 portval; |
| r9692 | r9693 | |
| 576 | 576 | portval = input_port_read(machine,kb_ports[port]); |
| 577 | 577 | for(bit=0;bit<32;bit++) |
| 578 | 578 | { |
| 579 | | if(((portval & (1<<bit))) != ((kb_prev[port] & (1<<bit)))) |
| 579 | if(((portval & (1<<bit))) != ((state->kb_prev[port] & (1<<bit)))) |
| 580 | 580 | { // bit changed |
| 581 | 581 | if((portval & (1<<bit)) == 0) // release |
| 582 | 582 | towns_kb_sendcode(machine,scan,1); |
| r9692 | r9693 | |
| 585 | 585 | } |
| 586 | 586 | scan++; |
| 587 | 587 | } |
| 588 | | kb_prev[port] = portval; |
| 588 | state->kb_prev[port] = portval; |
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | |
| r9692 | r9693 | |
| 896 | 896 | static WRITE32_HANDLER(towns_pad_mask_w) |
| 897 | 897 | { |
| 898 | 898 | towns_state* state = space->machine->driver_data<towns_state>(); |
| 899 | | static UINT8 prev; |
| 900 | | static UINT8 prev_x,prev_y; |
| 901 | 899 | UINT8 current_x,current_y; |
| 902 | 900 | UINT32 type = input_port_read(space->machine,"ctrltype"); |
| 903 | 901 | |
| r9692 | r9693 | |
| 906 | 904 | state->towns_pad_mask = (data & 0x00ff0000) >> 16; |
| 907 | 905 | if((type & 0x0f) == 0x02) // mouse |
| 908 | 906 | { |
| 909 | | if((state->towns_pad_mask & 0x10) != 0 && (prev & 0x10) == 0) |
| 907 | if((state->towns_pad_mask & 0x10) != 0 && (state->prev_pad_mask & 0x10) == 0) |
| 910 | 908 | { |
| 911 | 909 | if(state->towns_mouse_output == MOUSE_START) |
| 912 | 910 | { |
| 913 | 911 | state->towns_mouse_output = MOUSE_X_HIGH; |
| 914 | 912 | current_x = input_port_read(space->machine,"mouse2"); |
| 915 | 913 | current_y = input_port_read(space->machine,"mouse3"); |
| 916 | | state->towns_mouse_x = prev_x - current_x; |
| 917 | | state->towns_mouse_y = prev_y - current_y; |
| 918 | | prev_x = current_x; |
| 919 | | prev_y = current_y; |
| 914 | state->towns_mouse_x = state->prev_x - current_x; |
| 915 | state->towns_mouse_y = state->prev_y - current_y; |
| 916 | state->prev_x = current_x; |
| 917 | state->prev_y = current_y; |
| 920 | 918 | } |
| 921 | 919 | else |
| 922 | 920 | state->towns_mouse_output++; |
| 923 | 921 | timer_adjust_periodic(state->towns_mouse_timer,ATTOTIME_IN_USEC(600),0,attotime_zero); |
| 924 | 922 | } |
| 925 | | if((state->towns_pad_mask & 0x10) == 0 && (prev & 0x10) != 0) |
| 923 | if((state->towns_pad_mask & 0x10) == 0 && (state->prev_pad_mask & 0x10) != 0) |
| 926 | 924 | { |
| 927 | 925 | if(state->towns_mouse_output == MOUSE_START) |
| 928 | 926 | { |
| 929 | 927 | state->towns_mouse_output = MOUSE_SYNC; |
| 930 | 928 | current_x = input_port_read(space->machine,"mouse2"); |
| 931 | 929 | current_y = input_port_read(space->machine,"mouse3"); |
| 932 | | state->towns_mouse_x = prev_x - current_x; |
| 933 | | state->towns_mouse_y = prev_y - current_y; |
| 934 | | prev_x = current_x; |
| 935 | | prev_y = current_y; |
| 930 | state->towns_mouse_x = state->prev_x - current_x; |
| 931 | state->towns_mouse_y = state->prev_y - current_y; |
| 932 | state->prev_x = current_x; |
| 933 | state->prev_y = current_y; |
| 936 | 934 | } |
| 937 | 935 | else |
| 938 | 936 | state->towns_mouse_output++; |
| 939 | 937 | timer_adjust_periodic(state->towns_mouse_timer,ATTOTIME_IN_USEC(600),0,attotime_zero); |
| 940 | 938 | } |
| 941 | | prev = state->towns_pad_mask; |
| 939 | state->prev_pad_mask = state->towns_pad_mask; |
| 942 | 940 | } |
| 943 | 941 | if((type & 0xf0) == 0x20) // mouse |
| 944 | 942 | { |
| 945 | | if((state->towns_pad_mask & 0x20) != 0 && (prev & 0x20) == 0) |
| 943 | if((state->towns_pad_mask & 0x20) != 0 && (state->prev_pad_mask & 0x20) == 0) |
| 946 | 944 | { |
| 947 | 945 | if(state->towns_mouse_output == MOUSE_START) |
| 948 | 946 | { |
| 949 | 947 | state->towns_mouse_output = MOUSE_X_HIGH; |
| 950 | 948 | current_x = input_port_read(space->machine,"mouse2"); |
| 951 | 949 | current_y = input_port_read(space->machine,"mouse3"); |
| 952 | | state->towns_mouse_x = prev_x - current_x; |
| 953 | | state->towns_mouse_y = prev_y - current_y; |
| 954 | | prev_x = current_x; |
| 955 | | prev_y = current_y; |
| 950 | state->towns_mouse_x = state->prev_x - current_x; |
| 951 | state->towns_mouse_y = state->prev_y - current_y; |
| 952 | state->prev_x = current_x; |
| 953 | state->prev_y = current_y; |
| 956 | 954 | } |
| 957 | 955 | else |
| 958 | 956 | state->towns_mouse_output++; |
| 959 | 957 | timer_adjust_periodic(state->towns_mouse_timer,ATTOTIME_IN_USEC(600),0,attotime_zero); |
| 960 | 958 | } |
| 961 | | if((state->towns_pad_mask & 0x20) == 0 && (prev & 0x20) != 0) |
| 959 | if((state->towns_pad_mask & 0x20) == 0 && (state->prev_pad_mask & 0x20) != 0) |
| 962 | 960 | { |
| 963 | 961 | if(state->towns_mouse_output == MOUSE_START) |
| 964 | 962 | { |
| 965 | 963 | state->towns_mouse_output = MOUSE_SYNC; |
| 966 | 964 | current_x = input_port_read(space->machine,"mouse2"); |
| 967 | 965 | current_y = input_port_read(space->machine,"mouse3"); |
| 968 | | state->towns_mouse_x = prev_x - current_x; |
| 969 | | state->towns_mouse_y = prev_y - current_y; |
| 970 | | prev_x = current_x; |
| 971 | | prev_y = current_y; |
| 966 | state->towns_mouse_x = state->prev_x - current_x; |
| 967 | state->towns_mouse_y = state->prev_y - current_y; |
| 968 | state->prev_x = current_x; |
| 969 | state->prev_y = current_y; |
| 972 | 970 | } |
| 973 | 971 | else |
| 974 | 972 | state->towns_mouse_output++; |
| 975 | 973 | timer_adjust_periodic(state->towns_mouse_timer,ATTOTIME_IN_USEC(600),0,attotime_zero); |
| 976 | 974 | } |
| 977 | | prev = state->towns_pad_mask; |
| 975 | state->prev_pad_mask = state->towns_pad_mask; |
| 978 | 976 | } |
| 979 | 977 | } |
| 980 | 978 | } |
src/mess/drivers/supercon.c
| r9692 | r9693 | |
| 23 | 23 | |
| 24 | 24 | #include "supercon.lh" |
| 25 | 25 | |
| 26 | |
| 27 | class supercon_state : public driver_device |
| 28 | { |
| 29 | public: |
| 30 | supercon_state(running_machine &machine, const driver_device_config_base &config) |
| 31 | : driver_device(machine, config) { } |
| 32 | |
| 33 | UINT8 *ram; |
| 34 | emu_timer* timer_update_irq; |
| 35 | int emu_started; |
| 36 | int moving_piece; |
| 37 | UINT8 data_1E00; |
| 38 | UINT8 data_1F00; |
| 39 | UINT8 LED_18; |
| 40 | UINT8 LED_AH; |
| 41 | UINT8 LED_ST; |
| 42 | UINT8 *last_LED; |
| 43 | UINT8 last_LED_value; |
| 44 | int led_update; |
| 45 | int remove_led_flag; |
| 46 | int selecting; |
| 47 | int confirm_board_click; |
| 48 | int *current_field; |
| 49 | int m_board[64]; |
| 50 | int save_board[64]; |
| 51 | }; |
| 52 | |
| 53 | |
| 26 | 54 | #define VERBOSE 0 |
| 27 | 55 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 28 | 56 | |
| r9692 | r9693 | |
| 60 | 88 | #define TAKE 1 |
| 61 | 89 | #define SET 2 |
| 62 | 90 | |
| 63 | | static UINT8 *supercon_ram; |
| 64 | | static emu_timer* timer_update_irq; |
| 65 | 91 | |
| 66 | | static int emu_started=FALSE; |
| 67 | 92 | |
| 68 | | static int moving_piece=0; |
| 69 | 93 | |
| 70 | | static UINT8 data_1E00=0; |
| 71 | | static UINT8 data_1F00=0; |
| 72 | 94 | |
| 73 | | static UINT8 LED_18=0; |
| 74 | | static UINT8 LED_AH=0; |
| 75 | | static UINT8 LED_ST=0; |
| 76 | | static UINT8 *last_LED=NULL; |
| 77 | | static UINT8 last_LED_value=0; |
| 78 | 95 | |
| 79 | | static int led_update; |
| 80 | | static int remove_led_flag; |
| 81 | 96 | |
| 82 | | static int selecting=NO_ACTION; |
| 83 | | static int confirm_board_click=FALSE; |
| 84 | | static int *current_field; |
| 85 | 97 | |
| 86 | | static int m_board[64]; |
| 87 | | static int save_board[64]; |
| 88 | 98 | |
| 89 | 99 | /* artwork board */ |
| 90 | 100 | static const int start_board[64] = |
| r9692 | r9693 | |
| 102 | 112 | static const UINT8 border_pieces[12] = {WK,WQ,WR,WB,WN,WP,BK,BQ,BR,BB,BN,BP,}; |
| 103 | 113 | |
| 104 | 114 | |
| 105 | | static void set_board( void ) |
| 115 | static void set_board( supercon_state *state ) |
| 106 | 116 | { |
| 107 | 117 | int i; |
| 108 | 118 | for (i=0;i<64;i++) |
| 109 | | m_board[i]=start_board[i]; |
| 119 | state->m_board[i]=start_board[i]; |
| 110 | 120 | } |
| 111 | 121 | |
| 112 | | static void set_pieces (void) |
| 122 | static void set_pieces (supercon_state *state) |
| 113 | 123 | { |
| 114 | 124 | int i; |
| 115 | 125 | for (i=0;i<64;i++) |
| 116 | | output_set_indexed_value("P", i, m_board[i]); |
| 126 | output_set_indexed_value("P", i, state->m_board[i]); |
| 117 | 127 | } |
| 118 | 128 | |
| 119 | 129 | static void set_boarder_pieces (void) |
| r9692 | r9693 | |
| 124 | 134 | output_set_indexed_value("Q", i, border_pieces[i]); |
| 125 | 135 | } |
| 126 | 136 | |
| 127 | | static void clear_pieces() |
| 137 | static void clear_pieces(supercon_state *state) |
| 128 | 138 | { |
| 129 | 139 | int i; |
| 130 | 140 | for (i=0;i<64;i++) |
| 131 | 141 | { |
| 132 | 142 | output_set_indexed_value("P", i, EM); |
| 133 | | m_board[i]=EM; |
| 143 | state->m_board[i]=EM; |
| 134 | 144 | } |
| 135 | 145 | } |
| 136 | 146 | |
| r9692 | r9693 | |
| 157 | 167 | } |
| 158 | 168 | |
| 159 | 169 | |
| 160 | | static void update_leds( void ) |
| 170 | static void update_leds( supercon_state *state ) |
| 161 | 171 | { |
| 162 | 172 | int i; |
| 163 | 173 | |
| 164 | 174 | for (i = 0; i < 8; i++) |
| 165 | 175 | { |
| 166 | | if (BIT(LED_18, i)) |
| 176 | if (BIT(state->LED_18, i)) |
| 167 | 177 | output_set_led_value(i + 1, 1); |
| 168 | 178 | else |
| 169 | 179 | output_set_led_value(i + 1, 0); |
| 170 | 180 | |
| 171 | | if (BIT(LED_AH, i)) |
| 181 | if (BIT(state->LED_AH, i)) |
| 172 | 182 | output_set_led_value(i + 9, 1); |
| 173 | 183 | else |
| 174 | 184 | output_set_led_value(i + 9, 0); |
| 175 | 185 | |
| 176 | | if (BIT(LED_ST, i)) |
| 186 | if (BIT(state->LED_ST, i)) |
| 177 | 187 | output_set_led_value(i + 17, 1); |
| 178 | 188 | else |
| 179 | 189 | output_set_led_value(i + 17, 0); |
| r9692 | r9693 | |
| 182 | 192 | |
| 183 | 193 | static void mouse_update(running_machine *machine) |
| 184 | 194 | { |
| 195 | supercon_state *state = machine->driver_data<supercon_state>(); |
| 185 | 196 | UINT8 port_input, m_left; |
| 186 | 197 | int i; |
| 187 | 198 | |
| 188 | 199 | /* Set-remove piece after mouse release and confirmation of a board click = beep */ |
| 189 | 200 | |
| 190 | 201 | m_left=input_port_read(machine, "BUTTON_L"); |
| 191 | | if (!m_left && selecting) |
| 202 | if (!m_left && state->selecting) |
| 192 | 203 | { |
| 193 | | if (confirm_board_click) |
| 204 | if (state->confirm_board_click) |
| 194 | 205 | { |
| 195 | | if (selecting==SET) |
| 206 | if (state->selecting==SET) |
| 196 | 207 | { |
| 197 | | *current_field=moving_piece; |
| 198 | | moving_piece=EM; |
| 208 | *state->current_field=state->moving_piece; |
| 209 | state->moving_piece=EM; |
| 199 | 210 | }else |
| 200 | 211 | { |
| 201 | | moving_piece=*current_field; |
| 202 | | *current_field=EM; |
| 212 | state->moving_piece=*state->current_field; |
| 213 | *state->current_field=EM; |
| 203 | 214 | } |
| 204 | | set_pieces(); |
| 205 | | output_set_value("MOVING",moving_piece); |
| 215 | set_pieces(state); |
| 216 | output_set_value("MOVING",state->moving_piece); |
| 206 | 217 | } |
| 207 | 218 | |
| 208 | | selecting=NO_ACTION; |
| 209 | | confirm_board_click=FALSE; |
| 219 | state->selecting=NO_ACTION; |
| 220 | state->confirm_board_click=FALSE; |
| 210 | 221 | } |
| 211 | 222 | |
| 212 | 223 | /* Boarder pieces and moving pice */ |
| r9692 | r9693 | |
| 215 | 226 | if (port_input) |
| 216 | 227 | { |
| 217 | 228 | i=get_first_bit(port_input); |
| 218 | | moving_piece=border_pieces[i]; |
| 219 | | output_set_value("MOVING",moving_piece); |
| 229 | state->moving_piece=border_pieces[i]; |
| 230 | output_set_value("MOVING",state->moving_piece); |
| 220 | 231 | return; |
| 221 | 232 | } |
| 222 | 233 | |
| r9692 | r9693 | |
| 225 | 236 | if (port_input) |
| 226 | 237 | { |
| 227 | 238 | i=get_first_bit(port_input); |
| 228 | | moving_piece=border_pieces[6+i]; |
| 229 | | output_set_value("MOVING",moving_piece); |
| 239 | state->moving_piece=border_pieces[6+i]; |
| 240 | output_set_value("MOVING",state->moving_piece); |
| 230 | 241 | return; |
| 231 | 242 | } |
| 232 | 243 | |
| r9692 | r9693 | |
| 234 | 245 | port_input=input_port_read(machine, "B_CLR"); |
| 235 | 246 | if (port_input) |
| 236 | 247 | { |
| 237 | | if (moving_piece) |
| 248 | if (state->moving_piece) |
| 238 | 249 | { |
| 239 | | moving_piece=0; |
| 240 | | output_set_value("MOVING",moving_piece); |
| 250 | state->moving_piece=0; |
| 251 | output_set_value("MOVING",state->moving_piece); |
| 241 | 252 | return; |
| 242 | 253 | } |
| 243 | 254 | } |
| r9692 | r9693 | |
| 247 | 258 | |
| 248 | 259 | static DRIVER_INIT(supercon) |
| 249 | 260 | { |
| 250 | | LED_18=0; |
| 251 | | LED_AH=0; |
| 252 | | LED_ST=0; |
| 261 | supercon_state *state = machine->driver_data<supercon_state>(); |
| 262 | state->LED_18=0; |
| 263 | state->LED_AH=0; |
| 264 | state->LED_ST=0; |
| 253 | 265 | |
| 254 | | moving_piece=0; |
| 266 | state->moving_piece=0; |
| 255 | 267 | } |
| 256 | 268 | |
| 257 | 269 | /* Read 1C000 */ |
| r9692 | r9693 | |
| 274 | 286 | |
| 275 | 287 | static READ8_HANDLER( supercon_port3_r ) |
| 276 | 288 | { |
| 289 | supercon_state *state = space->machine->driver_data<supercon_state>(); |
| 277 | 290 | int i; |
| 278 | 291 | UINT8 key_data=0; |
| 279 | 292 | |
| r9692 | r9693 | |
| 284 | 297 | |
| 285 | 298 | /* remove last bit (only if it was not already set) */ |
| 286 | 299 | |
| 287 | | if ( data_1F00 & LED_LINE_AH ) |
| 300 | if ( state->data_1F00 & LED_LINE_AH ) |
| 288 | 301 | { |
| 289 | | if (last_LED_value != LED_AH) |
| 290 | | LED_AH=LED_AH & ~data_1E00; |
| 302 | if (state->last_LED_value != state->LED_AH) |
| 303 | state->LED_AH=state->LED_AH & ~state->data_1E00; |
| 291 | 304 | } |
| 292 | | else if ( data_1F00 & LED_LINE_ST) |
| 305 | else if ( state->data_1F00 & LED_LINE_ST) |
| 293 | 306 | { |
| 294 | | if (last_LED_value != LED_ST) |
| 295 | | LED_ST=LED_ST & ~data_1E00; |
| 307 | if (state->last_LED_value != state->LED_ST) |
| 308 | state->LED_ST=state->LED_ST & ~state->data_1E00; |
| 296 | 309 | } |
| 297 | | else if ( data_1F00 & LED_LINE_18 ) |
| 310 | else if ( state->data_1F00 & LED_LINE_18 ) |
| 298 | 311 | { |
| 299 | | if (last_LED_value != LED_18) |
| 300 | | LED_18=LED_18 & ~data_1E00; |
| 312 | if (state->last_LED_value != state->LED_18) |
| 313 | state->LED_18=state->LED_18 & ~state->data_1E00; |
| 301 | 314 | } |
| 302 | 315 | |
| 303 | 316 | |
| 304 | | LOG(("LED_18 from %02x \n",LED_18)); |
| 305 | | LOG(("LED_AH from %02x \n",LED_AH)); |
| 306 | | LOG(("LED_ST from %02x \n",LED_ST)); |
| 317 | LOG(("LED_18 from %02x \n",state->LED_18)); |
| 318 | LOG(("LED_AH from %02x \n",state->LED_AH)); |
| 319 | LOG(("LED_ST from %02x \n",state->LED_ST)); |
| 307 | 320 | |
| 308 | | if (led_update) /*No LED Update if Port 1C00,1D00 was read */ |
| 309 | | update_leds(); |
| 321 | if (state->led_update) /*No LED Update if Port 1C00,1D00 was read */ |
| 322 | update_leds(state); |
| 310 | 323 | |
| 311 | | remove_led_flag=TRUE; |
| 312 | | led_update=TRUE; |
| 324 | state->remove_led_flag=TRUE; |
| 325 | state->led_update=TRUE; |
| 313 | 326 | |
| 314 | | LED_18=0; |
| 315 | | LED_AH=0; |
| 316 | | LED_ST=0; |
| 327 | state->LED_18=0; |
| 328 | state->LED_AH=0; |
| 329 | state->LED_ST=0; |
| 317 | 330 | |
| 318 | 331 | |
| 319 | 332 | /* Start */ |
| 320 | 333 | |
| 321 | | if (!emu_started) |
| 334 | if (!state->emu_started) |
| 322 | 335 | return 0xbf; |
| 323 | 336 | else |
| 324 | | timer_adjust_periodic( timer_update_irq, attotime_zero, 0, ATTOTIME_IN_HZ(598) ); //HACK adjust timer after start ??? |
| 337 | timer_adjust_periodic( state->timer_update_irq, attotime_zero, 0, ATTOTIME_IN_HZ(598) ); //HACK adjust timer after start ??? |
| 325 | 338 | |
| 326 | 339 | |
| 327 | 340 | /* Buttons */ |
| 328 | 341 | |
| 329 | | i=get_first_bit(data_1E00); |
| 342 | i=get_first_bit(state->data_1E00); |
| 330 | 343 | if (i==NOT_VALID) |
| 331 | 344 | return 0xff; |
| 332 | 345 | |
| r9692 | r9693 | |
| 340 | 353 | |
| 341 | 354 | if (i==0 && key_data==0x80) |
| 342 | 355 | { |
| 343 | | set_board(); |
| 344 | | set_pieces(); |
| 356 | set_board(state); |
| 357 | set_pieces(state); |
| 345 | 358 | |
| 346 | | emu_started=FALSE; |
| 359 | state->emu_started=FALSE; |
| 347 | 360 | } |
| 348 | 361 | |
| 349 | 362 | /* Button: Clear Board -> remove all pieces */ |
| 350 | 363 | |
| 351 | 364 | if (i==3 && key_data==0x80) |
| 352 | | clear_pieces(); |
| 365 | clear_pieces(state); |
| 353 | 366 | |
| 354 | 367 | if (key_data != 0xff ) |
| 355 | 368 | return key_data; |
| r9692 | r9693 | |
| 363 | 376 | |
| 364 | 377 | static READ8_HANDLER( supercon_port4_r ) |
| 365 | 378 | { |
| 379 | supercon_state *state = space->machine->driver_data<supercon_state>(); |
| 366 | 380 | int i_18, i_AH; |
| 367 | 381 | UINT8 key_data = 0x00;; |
| 368 | 382 | |
| r9692 | r9693 | |
| 373 | 387 | |
| 374 | 388 | /* Board buttons */ |
| 375 | 389 | |
| 376 | | i_18=get_first_bit(data_1E00); |
| 390 | i_18=get_first_bit(state->data_1E00); |
| 377 | 391 | if (i_18==NOT_VALID) |
| 378 | 392 | return 0xff; |
| 379 | 393 | |
| r9692 | r9693 | |
| 389 | 403 | /* Set or remove pieces */ |
| 390 | 404 | |
| 391 | 405 | i_AH=7-get_first_cleared_bit(key_data); |
| 392 | | LOG(("Press -> AH: %d 18: %d Piece: %d\n",i_AH,i_18,m_board[i_18*8 + i_AH]);); |
| 406 | LOG(("Press -> AH: %d 18: %d Piece: %d\n",i_AH,i_18,state->m_board[i_18*8 + i_AH]);); |
| 393 | 407 | |
| 394 | | if (selecting==NO_ACTION) |
| 408 | if (state->selecting==NO_ACTION) |
| 395 | 409 | { |
| 396 | | current_field=&m_board[i_18*8 + i_AH]; |
| 410 | state->current_field=&state->m_board[i_18*8 + i_AH]; |
| 397 | 411 | |
| 398 | | if (moving_piece) |
| 399 | | selecting=SET; |
| 412 | if (state->moving_piece) |
| 413 | state->selecting=SET; |
| 400 | 414 | else |
| 401 | | selecting=TAKE; |
| 415 | state->selecting=TAKE; |
| 402 | 416 | } |
| 403 | 417 | return key_data; |
| 404 | 418 | } |
| r9692 | r9693 | |
| 411 | 425 | |
| 412 | 426 | static WRITE8_HANDLER( supercon_port1_w ) |
| 413 | 427 | { |
| 428 | supercon_state *state = space->machine->driver_data<supercon_state>(); |
| 414 | 429 | LOG(("Write from %04x data: %02x\n",0x1C00,data)); |
| 415 | | led_update=FALSE; |
| 430 | state->led_update=FALSE; |
| 416 | 431 | } |
| 417 | 432 | |
| 418 | 433 | /* Write Port $1D00 */ |
| 419 | 434 | |
| 420 | 435 | static WRITE8_HANDLER( supercon_port2_w ) |
| 421 | 436 | { |
| 437 | supercon_state *state = space->machine->driver_data<supercon_state>(); |
| 422 | 438 | |
| 423 | 439 | LOG(("Write from %04x data: %02x\n",0x1D00,data)); |
| 424 | | led_update=FALSE; |
| 440 | state->led_update=FALSE; |
| 425 | 441 | } |
| 426 | 442 | |
| 427 | 443 | /* Write Port $1E00 */ |
| 428 | 444 | |
| 429 | 445 | static WRITE8_HANDLER( supercon_port3_w ) |
| 430 | 446 | { |
| 447 | supercon_state *state = space->machine->driver_data<supercon_state>(); |
| 431 | 448 | |
| 432 | 449 | if (data) |
| 433 | 450 | LOG(("Write from %04x data: %02x\n",0x1E00,data)); |
| 434 | 451 | |
| 435 | 452 | if (data) |
| 436 | 453 | { |
| 437 | | data_1E00=data; |
| 454 | state->data_1E00=data; |
| 438 | 455 | |
| 439 | 456 | /* Set bits for LED's */ |
| 440 | 457 | |
| 441 | | if ( data_1F00) |
| 458 | if ( state->data_1F00) |
| 442 | 459 | { |
| 443 | 460 | |
| 444 | | if (data_1F00 & LED_LINE_AH ) |
| 461 | if (state->data_1F00 & LED_LINE_AH ) |
| 445 | 462 | { |
| 446 | | last_LED = &LED_AH; /* save last value */ |
| 447 | | last_LED_value = *last_LED; |
| 463 | state->last_LED = &state->LED_AH; /* save last value */ |
| 464 | state->last_LED_value = *state->last_LED; |
| 448 | 465 | |
| 449 | | LED_AH=LED_AH | data_1E00; |
| 466 | state->LED_AH=state->LED_AH | state->data_1E00; |
| 450 | 467 | } |
| 451 | | else if (data_1F00 & LED_LINE_ST ) |
| 468 | else if (state->data_1F00 & LED_LINE_ST ) |
| 452 | 469 | { |
| 453 | | last_LED = &LED_ST; |
| 454 | | last_LED_value = *last_LED; |
| 470 | state->last_LED = &state->LED_ST; |
| 471 | state->last_LED_value = *state->last_LED; |
| 455 | 472 | |
| 456 | | LED_ST=LED_ST | data_1E00; |
| 473 | state->LED_ST=state->LED_ST | state->data_1E00; |
| 457 | 474 | } |
| 458 | | else if (data_1F00 & LED_LINE_18) |
| 475 | else if (state->data_1F00 & LED_LINE_18) |
| 459 | 476 | { |
| 460 | | last_LED = &LED_18; |
| 461 | | last_LED_value = *last_LED; |
| 477 | state->last_LED = &state->LED_18; |
| 478 | state->last_LED_value = *state->last_LED; |
| 462 | 479 | |
| 463 | | LED_18=LED_18 | data_1E00; |
| 480 | state->LED_18=state->LED_18 | state->data_1E00; |
| 464 | 481 | } |
| 465 | 482 | } |
| 466 | 483 | |
| r9692 | r9693 | |
| 472 | 489 | |
| 473 | 490 | static WRITE8_HANDLER( supercon_port4_w ) |
| 474 | 491 | { |
| 492 | supercon_state *state = space->machine->driver_data<supercon_state>(); |
| 475 | 493 | running_device *speaker = space->machine->device("beep"); |
| 476 | 494 | |
| 477 | 495 | if (data) |
| 478 | 496 | LOG(("Write from %04x data: %02x\n",0x1F00,data)); |
| 479 | 497 | |
| 480 | 498 | if (data) |
| 481 | | data_1F00=data; |
| 499 | state->data_1F00=data; |
| 482 | 500 | |
| 483 | 501 | /* Bit 7 is set -> Buzzer on */ |
| 484 | 502 | |
| 485 | | if ( data_1F00 & 0x80 ) |
| 503 | if ( state->data_1F00 & 0x80 ) |
| 486 | 504 | { |
| 487 | 505 | beep_set_state(speaker,1); |
| 488 | | emu_started=TRUE; |
| 506 | state->emu_started=TRUE; |
| 489 | 507 | |
| 490 | | if (selecting) /* fast mouse clicks are recognized by the artwork but not by the emulation */ |
| 491 | | confirm_board_click=TRUE; /* therefore a beep must confirm each click on the board */ |
| 508 | if (state->selecting) /* fast mouse clicks are recognized by the artwork but not by the emulation */ |
| 509 | state->confirm_board_click=TRUE; /* therefore a beep must confirm each click on the board */ |
| 492 | 510 | } |
| 493 | 511 | else |
| 494 | 512 | beep_set_state(speaker,0); |
| r9692 | r9693 | |
| 510 | 528 | |
| 511 | 529 | static STATE_PRESAVE( m_board_presave ) |
| 512 | 530 | { |
| 531 | supercon_state *state = machine->driver_data<supercon_state>(); |
| 513 | 532 | int i; |
| 514 | 533 | for (i=0;i<64;i++) |
| 515 | | save_board[i]=m_board[i]; |
| 534 | state->save_board[i]=state->m_board[i]; |
| 516 | 535 | } |
| 517 | 536 | |
| 518 | 537 | static STATE_POSTLOAD( m_board_postload ) |
| 519 | 538 | { |
| 539 | supercon_state *state = machine->driver_data<supercon_state>(); |
| 520 | 540 | int i; |
| 521 | 541 | for (i=0;i<64;i++) |
| 522 | | m_board[i]=save_board[i]; |
| 542 | state->m_board[i]=state->save_board[i]; |
| 523 | 543 | |
| 524 | | set_pieces(); |
| 544 | set_pieces(state); |
| 525 | 545 | } |
| 526 | 546 | |
| 527 | 547 | static MACHINE_START( supercon ) |
| 528 | 548 | { |
| 529 | | led_update=TRUE; |
| 530 | | remove_led_flag=TRUE; |
| 549 | supercon_state *state = machine->driver_data<supercon_state>(); |
| 550 | state->led_update=TRUE; |
| 551 | state->remove_led_flag=TRUE; |
| 531 | 552 | |
| 532 | | timer_update_irq = timer_alloc(machine,update_irq,NULL); |
| 533 | | timer_adjust_periodic( timer_update_irq, attotime_zero, 0, ATTOTIME_IN_HZ(1000) ); |
| 553 | state->timer_update_irq = timer_alloc(machine,update_irq,NULL); |
| 554 | timer_adjust_periodic( state->timer_update_irq, attotime_zero, 0, ATTOTIME_IN_HZ(1000) ); |
| 534 | 555 | |
| 535 | 556 | timer_pulse(machine, ATTOTIME_IN_HZ(20), NULL, 0, update_artwork); |
| 536 | 557 | |
| 537 | | state_save_register_global_array(machine,save_board); |
| 558 | state_save_register_global_array(machine,state->save_board); |
| 538 | 559 | state_save_register_postload(machine,m_board_postload,NULL); |
| 539 | 560 | state_save_register_presave(machine,m_board_presave,NULL); |
| 540 | 561 | } |
| 541 | 562 | |
| 542 | 563 | static MACHINE_RESET( supercon ) |
| 543 | 564 | { |
| 544 | | set_board(); |
| 545 | | set_pieces(); |
| 565 | supercon_state *state = machine->driver_data<supercon_state>(); |
| 566 | set_board(state); |
| 567 | set_pieces(state); |
| 546 | 568 | set_boarder_pieces(); |
| 547 | 569 | |
| 548 | | emu_started=FALSE; |
| 570 | state->emu_started=FALSE; |
| 549 | 571 | } |
| 550 | 572 | |
| 551 | 573 | /* Address maps */ |
| 552 | 574 | |
| 553 | 575 | static ADDRESS_MAP_START(supercon_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 554 | | AM_RANGE( 0x0000, 0x0fff) AM_RAM AM_BASE(&supercon_ram ) |
| 576 | AM_RANGE( 0x0000, 0x0fff) AM_RAM AM_BASE_MEMBER(supercon_state, ram ) |
| 555 | 577 | AM_RANGE( 0x2000, 0x7fff) AM_ROM |
| 556 | 578 | AM_RANGE( 0x8000, 0xffff) AM_ROM |
| 557 | 579 | |
| r9692 | r9693 | |
| 725 | 747 | INPUT_PORTS_END |
| 726 | 748 | |
| 727 | 749 | /* Machine driver */ |
| 728 | | static MACHINE_CONFIG_START( supercon, driver_device ) |
| 750 | static MACHINE_CONFIG_START( supercon, supercon_state ) |
| 729 | 751 | |
| 730 | 752 | /* basic machine hardware */ |
| 731 | 753 | MDRV_CPU_ADD("maincpu",M6502,MAIN_CLOCK) |