src/mess/machine/lisa.c
| r9699 | r9700 | |
| 50 | 50 | */ |
| 51 | 51 | |
| 52 | 52 | /* up to 2MB of 68k RAM (normally 1MB or 512kb), generally 16kb of ROM */ |
| 53 | | static UINT8 *lisa_ram_ptr; |
| 54 | | static UINT8 *lisa_rom_ptr; |
| 55 | 53 | |
| 56 | 54 | /* offsets in "maincpu" */ |
| 57 | 55 | #define RAM_OFFSET 0x004000 |
| r9699 | r9700 | |
| 60 | 58 | /* 1kb of RAM for 6504 floppy disk controller (shared with 68000), and 4kb of |
| 61 | 59 | ROM (8kb on some boards, but then only one 4kb bank is selected, according to |
| 62 | 60 | the drive type (TWIGGY or 3.5'')) */ |
| 63 | | UINT8 *lisa_fdc_ram; |
| 64 | | UINT8 *lisa_fdc_rom; |
| 65 | 61 | |
| 66 | 62 | /* special ROM (includes S/N) */ |
| 67 | | static UINT8 *videoROM_ptr; |
| 68 | 63 | |
| 69 | 64 | |
| 70 | 65 | /* |
| 71 | 66 | MMU regs |
| 72 | 67 | */ |
| 73 | 68 | |
| 74 | | static int setup; /* MMU setup mode : allows to edit the MMU regs */ |
| 75 | 69 | |
| 76 | | static int seg; /* current SEG0-1 state (-> MMU register bank) */ |
| 77 | 70 | |
| 78 | | /* lisa MMU segment regs */ |
| 79 | | typedef struct real_mmu_entry |
| 80 | | { |
| 81 | | UINT16 sorg; |
| 82 | | UINT16 slim; |
| 83 | | } real_mmu_entry; |
| 84 | 71 | |
| 85 | | /* MMU regs translated into a more efficient format */ |
| 86 | | enum mmu_entry_t { RAM_stack_r, RAM_r, RAM_stack_rw, RAM_rw, IO, invalid, special_IO }; |
| 87 | 72 | |
| 88 | | typedef struct mmu_entry |
| 89 | | { |
| 90 | | offs_t sorg; /* (real_sorg & 0x0fff) << 9 */ |
| 91 | | mmu_entry_t type; /* <-> (real_slim & 0x0f00) */ |
| 92 | | int slim; /* (~ ((real_slim & 0x00ff) << 9)) & 0x01ffff */ |
| 93 | | } mmu_entry; |
| 94 | | |
| 95 | | static real_mmu_entry real_mmu_regs[4][128]; /* 4 banks of 128 regs */ |
| 96 | | static mmu_entry mmu_regs[4][128]; |
| 97 | | |
| 98 | | |
| 99 | 73 | /* |
| 100 | 74 | parity logic - only hard errors are emulated for now, since |
| 101 | 75 | a) the ROMs power-up test only tests hard errors |
| r9699 | r9700 | |
| 104 | 78 | fix errors) |
| 105 | 79 | */ |
| 106 | 80 | |
| 107 | | static int diag2; /* -> writes wrong parity data into RAM */ |
| 108 | | static int test_parity; /* detect parity hard errors */ |
| 109 | | static UINT16 mem_err_addr_latch; /* address when parity error occured */ |
| 110 | | static int parity_error_pending; /* parity error interrupt pending */ |
| 111 | 81 | |
| 112 | | static int bad_parity_count; /* total number of bytes in RAM which have wrong parity */ |
| 113 | | static UINT8 *bad_parity_table; /* array : 1 bit set for each byte in RAM with wrong parity */ |
| 114 | 82 | |
| 115 | 83 | |
| 116 | 84 | /* |
| 117 | 85 | video |
| 118 | 86 | */ |
| 119 | | static int VTMSK; /* VBI enable */ |
| 120 | | static int VTIR; /* VBI pending */ |
| 121 | | static UINT16 video_address_latch; /* register : MSBs of screen bitmap address (LSBs are 0s) */ |
| 122 | | static UINT16 *videoram_ptr; /* screen bitmap base address (derived from video_address_latch) */ |
| 123 | 87 | |
| 124 | 88 | |
| 125 | 89 | /* |
| r9699 | r9700 | |
| 135 | 99 | static void COPS_via_irq_func(running_device *device, int val); |
| 136 | 100 | static READ8_DEVICE_HANDLER(parallel_via_in_b); |
| 137 | 101 | |
| 138 | | static int KBIR; /* COPS VIA interrupt pending */ |
| 139 | 102 | |
| 140 | 103 | const via6522_interface lisa_via6522_0_intf = |
| 141 | 104 | { |
| r9699 | r9700 | |
| 164 | 127 | floppy disk interface |
| 165 | 128 | */ |
| 166 | 129 | |
| 167 | | static int FDIR; |
| 168 | | static int DISK_DIAG; |
| 169 | 130 | |
| 170 | | static int MT1; |
| 171 | 131 | |
| 172 | | static int PWM_floppy_motor_speed; |
| 173 | 132 | |
| 174 | 133 | /* |
| 175 | 134 | lisa model identification |
| 176 | 135 | */ |
| 177 | | static enum |
| 136 | enum lisa_model_t |
| 178 | 137 | { |
| 179 | 138 | /*lisa1,*/ /* twiggy floppy drive */ |
| 180 | 139 | lisa2, /* 3.5'' Sony floppy drive */ |
| 181 | 140 | lisa210, /* modified I/O board, and internal 10Meg drive */ |
| 182 | 141 | mac_xl /* same as above with modified video */ |
| 183 | | } lisa_model; |
| 142 | }; |
| 184 | 143 | |
| 185 | | enum floppy_hardware_t |
| 186 | | { |
| 187 | | twiggy, /* twiggy drives (Lisa 1) */ |
| 188 | | sony_lisa2, /* 3.5'' drive with LisaLite adapter (Lisa 2) */ |
| 189 | | sony_lisa210 /* 3.5'' drive with modified fdc hardware (Lisa 2/10, Mac XL) */ |
| 190 | | } ; |
| 191 | 144 | |
| 192 | | static struct |
| 193 | | { |
| 194 | | unsigned int has_fast_timers : 1; /* I/O board VIAs are clocked at 1.25 MHz (?) instead of .5 MHz (?) (Lisa 2/10, Mac XL) */ |
| 195 | | /* Note that the beep routine in boot ROMs implies that |
| 196 | | VIA clock is 1.25 times faster with fast timers than with |
| 197 | | slow timers. I read the schematics again and again, and |
| 198 | | I simply don't understand : in one case the VIA is |
| 199 | | connected to the 68k E clock, which is CPUCK/10, and in |
| 200 | | another case, to a generated PH2 clock which is CPUCK/4, |
| 201 | | with additionnal logic to keep it in phase with the 68k |
| 202 | | memory cycle. After hearing the beep when MacWorks XL |
| 203 | | boots, I bet the correct values are .625 MHz and .5 MHz. |
| 204 | | Maybe the schematics are wrong, and PH2 is CPUCK/8. |
| 205 | | Maybe the board uses a 6522 variant with different |
| 206 | | timings. */ |
| 207 | | floppy_hardware_t floppy_hardware; |
| 208 | | unsigned int has_double_sided_floppy : 1; /* true on lisa 1 and *hacked* lisa 2/10 / Mac XL */ |
| 209 | | unsigned int has_mac_xl_video : 1; /* modified video for MacXL */ |
| 210 | | } lisa_features; |
| 211 | 145 | |
| 212 | 146 | /* |
| 213 | 147 | protos |
| r9699 | r9700 | |
| 223 | 157 | |
| 224 | 158 | static void lisa_field_interrupts(running_machine *machine) |
| 225 | 159 | { |
| 226 | | if (parity_error_pending) |
| 160 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 161 | if (state->parity_error_pending) |
| 227 | 162 | return; /* don't touch anything... */ |
| 228 | 163 | |
| 229 | 164 | #if 0 |
| r9699 | r9700 | |
| 241 | 176 | cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_3, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 242 | 177 | else |
| 243 | 178 | #endif |
| 244 | | if (KBIR) |
| 179 | if (state->KBIR) |
| 245 | 180 | /* COPS VIA interrupt */ |
| 246 | 181 | cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_2, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 247 | | else if (FDIR || VTIR) |
| 182 | else if (state->FDIR || state->VTIR) |
| 248 | 183 | /* floppy disk or VBl */ |
| 249 | 184 | cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_1, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 250 | 185 | else |
| r9699 | r9700 | |
| 254 | 189 | |
| 255 | 190 | static void set_parity_error_pending(running_machine *machine, int value) |
| 256 | 191 | { |
| 192 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 257 | 193 | #if 1 |
| 258 | 194 | /* does not work well due to bugs in 68k cores */ |
| 259 | | parity_error_pending = value; |
| 260 | | if (parity_error_pending) |
| 195 | state->parity_error_pending = value; |
| 196 | if (state->parity_error_pending) |
| 261 | 197 | { |
| 262 | 198 | cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 263 | 199 | } |
| r9699 | r9700 | |
| 267 | 203 | } |
| 268 | 204 | #else |
| 269 | 205 | /* work-around... */ |
| 270 | | if ((! parity_error_pending) && value) |
| 206 | if ((! state->parity_error_pending) && value) |
| 271 | 207 | { |
| 272 | | parity_error_pending = 1; |
| 208 | state->parity_error_pending = 1; |
| 273 | 209 | cputag_set_input_line_and_vector(machine, "maincpu", M68K_IRQ_7, PULSE_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 274 | 210 | } |
| 275 | | else if (parity_error_pending && (! value)) |
| 211 | else if (state->parity_error_pending && (! value)) |
| 276 | 212 | { |
| 277 | | parity_error_pending = 0; |
| 213 | state->parity_error_pending = 0; |
| 278 | 214 | lisa_field_interrupts(machine); |
| 279 | 215 | } |
| 280 | 216 | #endif |
| r9699 | r9700 | |
| 282 | 218 | |
| 283 | 219 | INLINE void set_VTIR(running_machine *machine, int value) |
| 284 | 220 | { |
| 285 | | if (VTIR != value) |
| 221 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 222 | if (state->VTIR != value) |
| 286 | 223 | { |
| 287 | | VTIR = value; |
| 288 | | if (VTIR==1) |
| 224 | state->VTIR = value; |
| 225 | if (state->VTIR==1) |
| 289 | 226 | lisa_field_interrupts(machine); |
| 290 | 227 | } |
| 291 | 228 | } |
| r9699 | r9700 | |
| 296 | 233 | keyboard interface |
| 297 | 234 | */ |
| 298 | 235 | |
| 299 | | static int COPS_Ready; /* COPS is about to read a command from VIA port A */ |
| 300 | 236 | |
| 301 | | static int COPS_command; /* keeps the data sent by the VIA to the COPS */ |
| 302 | 237 | |
| 303 | | static int fifo_data[8]; /* 8-byte FIFO used by COPS to buffer data sent to VIA */ |
| 304 | | static int fifo_size; /* current data in FIFO */ |
| 305 | | static int fifo_head; |
| 306 | | static int fifo_tail; |
| 307 | | static int mouse_data_offset; /* current offset for mouse data in FIFO (!) */ |
| 308 | 238 | |
| 309 | | static int COPS_force_unplug; /* force unplug keyboard/mouse line for COPS (comes from VIA) */ |
| 310 | 239 | |
| 311 | | static emu_timer *mouse_timer = NULL; /* timer called for mouse setup */ |
| 312 | 240 | |
| 313 | | static int hold_COPS_data; /* mirrors the state of CA2 - COPS does not send data until it is low */ |
| 314 | 241 | |
| 315 | | static int NMIcode; |
| 316 | 242 | |
| 317 | | enum clock_mode_t |
| 318 | | { |
| 319 | | clock_timer_disable = 0, |
| 320 | | timer_disable = 1, |
| 321 | | timer_interrupt = 2, /* timer underflow generates interrupt */ |
| 322 | | timer_power_on = 3 /* timer underflow turns system on if it is off and gens interrupt */ |
| 323 | | }; /* clock mode */ |
| 324 | 243 | |
| 325 | | /* clock registers */ |
| 326 | | static struct |
| 327 | | { |
| 328 | | long alarm; /* alarm (20-bit binary) */ |
| 329 | | int years; /* years (4-bit binary ) */ |
| 330 | | int days1; /* days (BCD : 1-366) */ |
| 331 | | int days2; |
| 332 | | int days3; |
| 333 | | int hours1; /* hours (BCD : 0-23) */ |
| 334 | | int hours2; |
| 335 | | int minutes1; /* minutes (BCD : 0-59) */ |
| 336 | | int minutes2; |
| 337 | | int seconds1; /* seconds (BCD : 0-59) */ |
| 338 | | int seconds2; |
| 339 | | int tenths; /* tenths of second (BCD : 0-9) */ |
| 340 | 244 | |
| 341 | | int clock_write_ptr; /* clock byte to be written next (-1 if clock write disabled) */ |
| 342 | 245 | |
| 343 | | enum clock_mode_t clock_mode; |
| 344 | | } clock_regs; |
| 345 | | |
| 346 | | |
| 347 | | |
| 348 | 246 | INLINE void COPS_send_data_if_possible(running_machine *machine) |
| 349 | 247 | { |
| 248 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 350 | 249 | via6522_device *via_0 = machine->device<via6522_device>("via6522_0"); |
| 351 | 250 | address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 352 | 251 | |
| 353 | | if ((! hold_COPS_data) && fifo_size && (! COPS_Ready)) |
| 252 | if ((! state->hold_COPS_data) && state->fifo_size && (! state->COPS_Ready)) |
| 354 | 253 | { |
| 355 | 254 | logerror("Pushing one byte of data to VIA\n"); |
| 356 | 255 | |
| 357 | | via_0->write_porta(*space, 0, fifo_data[fifo_head]); /* output data */ |
| 358 | | if (fifo_head == mouse_data_offset) |
| 359 | | mouse_data_offset = -1; /* we just phased out the mouse data in buffer */ |
| 360 | | fifo_head = (fifo_head+1) & 0x7; |
| 361 | | fifo_size--; |
| 256 | via_0->write_porta(*space, 0, state->fifo_data[state->fifo_head]); /* output data */ |
| 257 | if (state->fifo_head == state->mouse_data_offset) |
| 258 | state->mouse_data_offset = -1; /* we just phased out the mouse data in buffer */ |
| 259 | state->fifo_head = (state->fifo_head+1) & 0x7; |
| 260 | state->fifo_size--; |
| 362 | 261 | via_0->write_ca1(1); /* pulse ca1 so that VIA reads it */ |
| 363 | 262 | via_0->write_ca1(0); /* BTW, I have no idea how a real COPS does it ! */ |
| 364 | 263 | } |
| r9699 | r9700 | |
| 367 | 266 | /* send data (queue it into the FIFO if needed) */ |
| 368 | 267 | static void COPS_queue_data(running_machine *machine, const UINT8 *data, int len) |
| 369 | 268 | { |
| 269 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 370 | 270 | #if 0 |
| 371 | | if (fifo_size + len <= 8) |
| 271 | if (state->fifo_size + len <= 8) |
| 372 | 272 | #else |
| 373 | 273 | /* trash old data */ |
| 374 | | while (fifo_size > 8 - len) |
| 274 | while (state->fifo_size > 8 - len) |
| 375 | 275 | { |
| 376 | | if (fifo_head == mouse_data_offset) |
| 377 | | mouse_data_offset = -1; /* we just phased out the mouse data in buffer */ |
| 378 | | fifo_head = (fifo_head+1) & 0x7; |
| 379 | | fifo_size--; |
| 276 | if (state->fifo_head == state->mouse_data_offset) |
| 277 | state->mouse_data_offset = -1; /* we just phased out the mouse data in buffer */ |
| 278 | state->fifo_head = (state->fifo_head+1) & 0x7; |
| 279 | state->fifo_size--; |
| 380 | 280 | } |
| 381 | 281 | #endif |
| 382 | 282 | |
| r9699 | r9700 | |
| 385 | 285 | |
| 386 | 286 | while (len--) |
| 387 | 287 | { |
| 388 | | fifo_data[fifo_tail] = * (data++); |
| 389 | | fifo_tail = (fifo_tail+1) & 0x7; |
| 390 | | fifo_size++; |
| 288 | state->fifo_data[state->fifo_tail] = * (data++); |
| 289 | state->fifo_tail = (state->fifo_tail+1) & 0x7; |
| 290 | state->fifo_size++; |
| 391 | 291 | } |
| 392 | 292 | |
| 393 | 293 | /*logerror("COPS_queue_data : trying to send data to VIA\n");*/ |
| r9699 | r9700 | |
| 403 | 303 | /* shamelessly stolen from machine/mac.c :-) */ |
| 404 | 304 | |
| 405 | 305 | /* keyboard matrix to detect transition */ |
| 406 | | static int key_matrix[8]; |
| 407 | 306 | |
| 408 | 307 | static void scan_keyboard(running_machine *machine) |
| 409 | 308 | { |
| 309 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 410 | 310 | int i, j; |
| 411 | 311 | int keybuf; |
| 412 | 312 | UINT8 keycode; |
| 413 | 313 | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" }; |
| 414 | 314 | |
| 415 | | if (! COPS_force_unplug) |
| 315 | if (! state->COPS_force_unplug) |
| 416 | 316 | for (i=0; i<8; i++) |
| 417 | 317 | { |
| 418 | 318 | keybuf = input_port_read(machine, keynames[i]); |
| 419 | 319 | |
| 420 | | if (keybuf != key_matrix[i]) |
| 320 | if (keybuf != state->key_matrix[i]) |
| 421 | 321 | { /* if state has changed, find first bit which has changed */ |
| 422 | 322 | /*logerror("keyboard state changed, %d %X\n", i, keybuf);*/ |
| 423 | 323 | |
| 424 | 324 | for (j=0; j<16; j++) |
| 425 | 325 | { |
| 426 | | if (((keybuf ^ key_matrix[i]) >> j) & 1) |
| 326 | if (((keybuf ^ state->key_matrix[i]) >> j) & 1) |
| 427 | 327 | { |
| 428 | 328 | /* update key_matrix */ |
| 429 | | key_matrix[i] = (key_matrix[i] & ~ (1 << j)) | (keybuf & (1 << j)); |
| 329 | state->key_matrix[i] = (state->key_matrix[i] & ~ (1 << j)) | (keybuf & (1 << j)); |
| 430 | 330 | |
| 431 | 331 | /* create key code */ |
| 432 | 332 | keycode = (i << 4) | j; |
| r9699 | r9700 | |
| 435 | 335 | keycode |= 0x80; |
| 436 | 336 | } |
| 437 | 337 | #if 0 |
| 438 | | if (keycode == NMIcode) |
| 338 | if (keycode == state->NMIcode) |
| 439 | 339 | { /* generate NMI interrupt */ |
| 440 | 340 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_7, PULSE_LINE); |
| 441 | 341 | cpu_set_input_line_vector(machine->device("maincpu"), M68K_IRQ_7, M68K_INT_ACK_AUTOVECTOR); |
| r9699 | r9700 | |
| 452 | 352 | /* shamelessly stolen from machine/mac.c :-) */ |
| 453 | 353 | static TIMER_CALLBACK(handle_mouse) |
| 454 | 354 | { |
| 455 | | static int last_mx = 0, last_my = 0; |
| 456 | | |
| 355 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 457 | 356 | int diff_x = 0, diff_y = 0; |
| 458 | 357 | int new_mx, new_my; |
| 459 | 358 | |
| 460 | 359 | #if 0 |
| 461 | | if (COPS_force_unplug) |
| 360 | if (state->COPS_force_unplug) |
| 462 | 361 | return; /* ???? */ |
| 463 | 362 | #endif |
| 464 | 363 | |
| r9699 | r9700 | |
| 466 | 365 | new_my = input_port_read(machine, "MOUSE_Y"); |
| 467 | 366 | |
| 468 | 367 | /* see if it moved in the x coord */ |
| 469 | | if (new_mx != last_mx) |
| 368 | if (new_mx != state->last_mx) |
| 470 | 369 | { |
| 471 | | diff_x = new_mx - last_mx; |
| 370 | diff_x = new_mx - state->last_mx; |
| 472 | 371 | |
| 473 | 372 | /* check for wrap */ |
| 474 | 373 | if (diff_x > 0x80) |
| r9699 | r9700 | |
| 476 | 375 | if (diff_x < -0x80) |
| 477 | 376 | diff_x = -0x100-diff_x; |
| 478 | 377 | |
| 479 | | last_mx = new_mx; |
| 378 | state->last_mx = new_mx; |
| 480 | 379 | } |
| 481 | 380 | /* see if it moved in the y coord */ |
| 482 | | if (new_my != last_my) |
| 381 | if (new_my != state->last_my) |
| 483 | 382 | { |
| 484 | | diff_y = new_my - last_my; |
| 383 | diff_y = new_my - state->last_my; |
| 485 | 384 | |
| 486 | 385 | /* check for wrap */ |
| 487 | 386 | if (diff_y > 0x80) |
| r9699 | r9700 | |
| 489 | 388 | if (diff_y < -0x80) |
| 490 | 389 | diff_y = -0x100-diff_y; |
| 491 | 390 | |
| 492 | | last_my = new_my; |
| 391 | state->last_my = new_my; |
| 493 | 392 | } |
| 494 | 393 | |
| 495 | 394 | /* update any remaining count and then return */ |
| 496 | 395 | if (diff_x || diff_y) |
| 497 | 396 | { |
| 498 | | if (mouse_data_offset != -1) |
| 397 | if (state->mouse_data_offset != -1) |
| 499 | 398 | { |
| 500 | | fifo_data[mouse_data_offset] += diff_x; |
| 501 | | fifo_data[(mouse_data_offset+1) & 0x7] += diff_y; |
| 399 | state->fifo_data[state->mouse_data_offset] += diff_x; |
| 400 | state->fifo_data[(state->mouse_data_offset+1) & 0x7] += diff_y; |
| 502 | 401 | } |
| 503 | 402 | else |
| 504 | 403 | { |
| 505 | 404 | #if 0 |
| 506 | | if (fifo_size <= 5) |
| 405 | if (state->fifo_size <= 5) |
| 507 | 406 | #else |
| 508 | 407 | /* trash old data */ |
| 509 | | while (fifo_size > 5) |
| 408 | while (state->fifo_size > 5) |
| 510 | 409 | { |
| 511 | | fifo_head = (fifo_head+1) & 0x7; |
| 512 | | fifo_size--; |
| 410 | state->fifo_head = (state->fifo_head+1) & 0x7; |
| 411 | state->fifo_size--; |
| 513 | 412 | } |
| 514 | 413 | #endif |
| 515 | 414 | |
| 516 | 415 | { |
| 517 | 416 | /*logerror("Adding 3 bytes of mouse data to FIFO\n");*/ |
| 518 | 417 | |
| 519 | | fifo_data[fifo_tail] = 0; |
| 520 | | mouse_data_offset = fifo_tail = (fifo_tail+1) & 0x7; |
| 521 | | fifo_data[fifo_tail] = diff_x; |
| 522 | | fifo_tail = (fifo_tail+1) & 0x7; |
| 523 | | fifo_data[fifo_tail] = diff_y; |
| 524 | | fifo_tail = (fifo_tail+1) & 0x7; |
| 525 | | fifo_size += 3; |
| 418 | state->fifo_data[state->fifo_tail] = 0; |
| 419 | state->mouse_data_offset = state->fifo_tail = (state->fifo_tail+1) & 0x7; |
| 420 | state->fifo_data[state->fifo_tail] = diff_x; |
| 421 | state->fifo_tail = (state->fifo_tail+1) & 0x7; |
| 422 | state->fifo_data[state->fifo_tail] = diff_y; |
| 423 | state->fifo_tail = (state->fifo_tail+1) & 0x7; |
| 424 | state->fifo_size += 3; |
| 526 | 425 | |
| 527 | 426 | /*logerror("handle_mouse : trying to send data to VIA\n");*/ |
| 528 | 427 | COPS_send_data_if_possible(machine); |
| r9699 | r9700 | |
| 535 | 434 | /* read command from the VIA port A */ |
| 536 | 435 | static TIMER_CALLBACK(read_COPS_command) |
| 537 | 436 | { |
| 437 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 538 | 438 | int command; |
| 539 | 439 | via6522_device *via_0 = machine->device<via6522_device>("via6522_0"); |
| 540 | 440 | address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 541 | 441 | |
| 542 | | COPS_Ready = 0; |
| 442 | state->COPS_Ready = 0; |
| 543 | 443 | |
| 544 | 444 | /*logerror("read_COPS_command : trying to send data to VIA\n");*/ |
| 545 | 445 | COPS_send_data_if_possible(machine); |
| 546 | 446 | |
| 547 | 447 | /* some pull-ups allow the COPS to read 1s when the VIA port is not set as output */ |
| 548 | | command = (COPS_command | (~ via_0->read(*space, VIA_DDRA))) & 0xff; |
| 448 | command = (state->COPS_command | (~ via_0->read(*space, VIA_DDRA))) & 0xff; |
| 549 | 449 | |
| 550 | 450 | if (command & 0x80) |
| 551 | 451 | return; /* NOP */ |
| r9699 | r9700 | |
| 557 | 457 | switch ((command & 0xF0) >> 4) |
| 558 | 458 | { |
| 559 | 459 | case 0x1: /* write clock data */ |
| 560 | | if (clock_regs.clock_write_ptr != -1) |
| 460 | if (state->clock_regs.clock_write_ptr != -1) |
| 561 | 461 | { |
| 562 | | switch (clock_regs.clock_write_ptr) |
| 462 | switch (state->clock_regs.clock_write_ptr) |
| 563 | 463 | { |
| 564 | 464 | case 0: |
| 565 | 465 | case 1: |
| r9699 | r9700 | |
| 567 | 467 | case 3: |
| 568 | 468 | case 4: |
| 569 | 469 | /* alarm */ |
| 570 | | clock_regs.alarm &= ~ (0xf << (4 * (4 - clock_regs.clock_write_ptr))); |
| 571 | | clock_regs.alarm |= immediate << (4 * (4 - clock_regs.clock_write_ptr)); |
| 470 | state->clock_regs.alarm &= ~ (0xf << (4 * (4 - state->clock_regs.clock_write_ptr))); |
| 471 | state->clock_regs.alarm |= immediate << (4 * (4 - state->clock_regs.clock_write_ptr)); |
| 572 | 472 | break; |
| 573 | 473 | case 5: |
| 574 | 474 | /* year */ |
| 575 | | clock_regs.years = immediate; |
| 475 | state->clock_regs.years = immediate; |
| 576 | 476 | break; |
| 577 | 477 | case 6: |
| 578 | 478 | /* day */ |
| 579 | | clock_regs.days1 = immediate; |
| 479 | state->clock_regs.days1 = immediate; |
| 580 | 480 | break; |
| 581 | 481 | case 7: |
| 582 | 482 | /* day */ |
| 583 | | clock_regs.days2 = immediate; |
| 483 | state->clock_regs.days2 = immediate; |
| 584 | 484 | break; |
| 585 | 485 | case 8: |
| 586 | 486 | /* day */ |
| 587 | | clock_regs.days3 = immediate; |
| 487 | state->clock_regs.days3 = immediate; |
| 588 | 488 | break; |
| 589 | 489 | case 9: |
| 590 | 490 | /* hours */ |
| 591 | | clock_regs.hours1 = immediate; |
| 491 | state->clock_regs.hours1 = immediate; |
| 592 | 492 | break; |
| 593 | 493 | case 10: |
| 594 | 494 | /* hours */ |
| 595 | | clock_regs.hours2 = immediate; |
| 495 | state->clock_regs.hours2 = immediate; |
| 596 | 496 | break; |
| 597 | 497 | case 11: |
| 598 | 498 | /* minutes */ |
| 599 | | clock_regs.minutes1 = immediate; |
| 499 | state->clock_regs.minutes1 = immediate; |
| 600 | 500 | break; |
| 601 | 501 | case 12: |
| 602 | 502 | /* minutes */ |
| 603 | | clock_regs.minutes1 = immediate; |
| 503 | state->clock_regs.minutes1 = immediate; |
| 604 | 504 | break; |
| 605 | 505 | case 13: |
| 606 | 506 | /* seconds */ |
| 607 | | clock_regs.seconds1 = immediate; |
| 507 | state->clock_regs.seconds1 = immediate; |
| 608 | 508 | break; |
| 609 | 509 | case 14: |
| 610 | 510 | /* seconds */ |
| 611 | | clock_regs.seconds2 = immediate; |
| 511 | state->clock_regs.seconds2 = immediate; |
| 612 | 512 | break; |
| 613 | 513 | case 15: |
| 614 | 514 | /* tenth */ |
| 615 | | clock_regs.tenths = immediate; |
| 515 | state->clock_regs.tenths = immediate; |
| 616 | 516 | break; |
| 617 | 517 | } |
| 618 | | clock_regs.clock_write_ptr++; |
| 619 | | if (clock_regs.clock_write_ptr == 16) |
| 620 | | clock_regs.clock_write_ptr = -1; |
| 518 | state->clock_regs.clock_write_ptr++; |
| 519 | if (state->clock_regs.clock_write_ptr == 16) |
| 520 | state->clock_regs.clock_write_ptr = -1; |
| 621 | 521 | } |
| 622 | 522 | |
| 623 | 523 | break; |
| r9699 | r9700 | |
| 625 | 525 | case 0x2: /* set clock mode */ |
| 626 | 526 | if (immediate & 0x8) |
| 627 | 527 | { /* start setting the clock */ |
| 628 | | clock_regs.clock_write_ptr = 0; |
| 528 | state->clock_regs.clock_write_ptr = 0; |
| 629 | 529 | } |
| 630 | 530 | else |
| 631 | 531 | { /* clock write disabled */ |
| 632 | | clock_regs.clock_write_ptr = -1; |
| 532 | state->clock_regs.clock_write_ptr = -1; |
| 633 | 533 | } |
| 634 | 534 | |
| 635 | 535 | if (! (immediate & 0x4)) |
| r9699 | r9700 | |
| 641 | 541 | /* should never happen */ |
| 642 | 542 | } |
| 643 | 543 | |
| 644 | | clock_regs.clock_mode = (clock_mode_t)(immediate & 0x3); |
| 544 | state->clock_regs.clock_mode = (clock_mode_t)(immediate & 0x3); |
| 645 | 545 | break; |
| 646 | 546 | |
| 647 | 547 | #if 0 |
| r9699 | r9700 | |
| 656 | 556 | #endif |
| 657 | 557 | |
| 658 | 558 | case 0x5: /* set high nibble of NMI character to nnnn */ |
| 659 | | NMIcode = (NMIcode & 0x0f) | (immediate << 4); |
| 559 | state->NMIcode = (state->NMIcode & 0x0f) | (immediate << 4); |
| 660 | 560 | break; |
| 661 | 561 | |
| 662 | 562 | case 0x6: /* set low nibble of NMI character to nnnn */ |
| 663 | | NMIcode = (NMIcode & 0xf0) | immediate; |
| 563 | state->NMIcode = (state->NMIcode & 0xf0) | immediate; |
| 664 | 564 | break; |
| 665 | 565 | |
| 666 | 566 | case 0x7: /* send mouse command */ |
| 667 | 567 | if (immediate & 0x8) |
| 668 | | timer_adjust_periodic(mouse_timer, attotime_zero, 0, ATTOTIME_IN_MSEC((immediate & 0x7)*4)); /* enable mouse */ |
| 568 | timer_adjust_periodic(state->mouse_timer, attotime_zero, 0, ATTOTIME_IN_MSEC((immediate & 0x7)*4)); /* enable mouse */ |
| 669 | 569 | else |
| 670 | | timer_reset(mouse_timer, attotime_never); |
| 570 | timer_reset(state->mouse_timer, attotime_never); |
| 671 | 571 | break; |
| 672 | 572 | } |
| 673 | 573 | } |
| r9699 | r9700 | |
| 690 | 590 | UINT8 reply[7]; |
| 691 | 591 | |
| 692 | 592 | reply[0] = 0x80; |
| 693 | | reply[1] = 0xE0 | clock_regs.years; |
| 694 | | reply[2] = (clock_regs.days1 << 4) | clock_regs.days2; |
| 695 | | reply[3] = (clock_regs.days3 << 4) | clock_regs.hours1; |
| 696 | | reply[4] = (clock_regs.hours2 << 4) | clock_regs.minutes1; |
| 697 | | reply[5] = (clock_regs.minutes2 << 4) | clock_regs.seconds1; |
| 698 | | reply[6] = (clock_regs.seconds2 << 4) | clock_regs.tenths; |
| 593 | reply[1] = 0xE0 | state->clock_regs.years; |
| 594 | reply[2] = (state->clock_regs.days1 << 4) | state->clock_regs.days2; |
| 595 | reply[3] = (state->clock_regs.days3 << 4) | state->clock_regs.hours1; |
| 596 | reply[4] = (state->clock_regs.hours2 << 4) | state->clock_regs.minutes1; |
| 597 | reply[5] = (state->clock_regs.minutes2 << 4) | state->clock_regs.seconds1; |
| 598 | reply[6] = (state->clock_regs.seconds2 << 4) | state->clock_regs.tenths; |
| 699 | 599 | |
| 700 | 600 | COPS_queue_data(machine, reply, 7); |
| 701 | 601 | } |
| r9699 | r9700 | |
| 707 | 607 | /* this timer callback raises the COPS Ready line, which tells the COPS is about to read a command */ |
| 708 | 608 | static TIMER_CALLBACK(set_COPS_ready) |
| 709 | 609 | { |
| 710 | | COPS_Ready = 1; |
| 610 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 611 | state->COPS_Ready = 1; |
| 711 | 612 | |
| 712 | 613 | /* impulsion width : +/- 20us */ |
| 713 | 614 | timer_set(machine, ATTOTIME_IN_USEC(20), NULL, 0, read_COPS_command); |
| 714 | 615 | } |
| 715 | 616 | |
| 716 | | static void reset_COPS(void) |
| 617 | static void reset_COPS(lisa_state *state) |
| 717 | 618 | { |
| 718 | 619 | int i; |
| 719 | 620 | |
| 720 | | fifo_size = 0; |
| 721 | | fifo_head = 0; |
| 722 | | fifo_tail = 0; |
| 723 | | mouse_data_offset = -1; |
| 621 | state->fifo_size = 0; |
| 622 | state->fifo_head = 0; |
| 623 | state->fifo_tail = 0; |
| 624 | state->mouse_data_offset = -1; |
| 724 | 625 | |
| 725 | 626 | for (i=0; i<8; i++) |
| 726 | | key_matrix[i] = 0; |
| 627 | state->key_matrix[i] = 0; |
| 727 | 628 | |
| 728 | | timer_reset(mouse_timer, attotime_never); |
| 629 | timer_reset(state->mouse_timer, attotime_never); |
| 729 | 630 | } |
| 730 | 631 | |
| 731 | 632 | static void unplug_keyboard(running_machine *machine) |
| r9699 | r9700 | |
| 771 | 672 | /* called at power-up */ |
| 772 | 673 | static void init_COPS(running_machine *machine) |
| 773 | 674 | { |
| 774 | | COPS_Ready = 0; |
| 675 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 676 | state->COPS_Ready = 0; |
| 775 | 677 | |
| 776 | | reset_COPS(); |
| 678 | reset_COPS(state); |
| 777 | 679 | } |
| 778 | 680 | |
| 779 | 681 | |
| r9699 | r9700 | |
| 787 | 689 | */ |
| 788 | 690 | static WRITE8_DEVICE_HANDLER(COPS_via_out_a) |
| 789 | 691 | { |
| 790 | | COPS_command = data; |
| 692 | lisa_state *state = device->machine->driver_data<lisa_state>(); |
| 693 | state->COPS_command = data; |
| 791 | 694 | } |
| 792 | 695 | |
| 793 | 696 | static WRITE8_DEVICE_HANDLER(COPS_via_out_ca2) |
| 794 | 697 | { |
| 795 | | hold_COPS_data = data; |
| 698 | lisa_state *state = device->machine->driver_data<lisa_state>(); |
| 699 | state->hold_COPS_data = data; |
| 796 | 700 | |
| 797 | 701 | /*logerror("COPS CA2 line state : %d\n", val);*/ |
| 798 | 702 | |
| r9699 | r9700 | |
| 816 | 720 | */ |
| 817 | 721 | static READ8_DEVICE_HANDLER(COPS_via_in_b) |
| 818 | 722 | { |
| 723 | lisa_state *state = device->machine->driver_data<lisa_state>(); |
| 819 | 724 | int val = 0; |
| 820 | 725 | |
| 821 | | if (! COPS_Ready) |
| 726 | if (! state->COPS_Ready) |
| 822 | 727 | val |= 0x40; |
| 823 | 728 | |
| 824 | | if (FDIR) |
| 729 | if (state->FDIR) |
| 825 | 730 | val |= 0x10; |
| 826 | 731 | |
| 827 | 732 | return val; |
| r9699 | r9700 | |
| 829 | 734 | |
| 830 | 735 | static WRITE8_DEVICE_HANDLER(COPS_via_out_b) |
| 831 | 736 | { |
| 737 | lisa_state *state = device->machine->driver_data<lisa_state>(); |
| 832 | 738 | via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0"); |
| 833 | 739 | address_space *space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 834 | 740 | |
| r9699 | r9700 | |
| 837 | 743 | |
| 838 | 744 | if (data & 0x01) |
| 839 | 745 | { |
| 840 | | if (COPS_force_unplug) |
| 746 | if (state->COPS_force_unplug) |
| 841 | 747 | { |
| 842 | | COPS_force_unplug = 0; |
| 748 | state->COPS_force_unplug = 0; |
| 843 | 749 | plug_keyboard(device->machine); |
| 844 | 750 | } |
| 845 | 751 | } |
| 846 | 752 | else |
| 847 | 753 | { |
| 848 | | if (! COPS_force_unplug) |
| 754 | if (! state->COPS_force_unplug) |
| 849 | 755 | { |
| 850 | | COPS_force_unplug = 1; |
| 756 | state->COPS_force_unplug = 1; |
| 851 | 757 | unplug_keyboard(device->machine); |
| 852 | | //reset_COPS(); |
| 758 | //reset_COPS(state); |
| 853 | 759 | } |
| 854 | 760 | } |
| 855 | 761 | } |
| r9699 | r9700 | |
| 862 | 768 | |
| 863 | 769 | static void COPS_via_irq_func(running_device *device, int val) |
| 864 | 770 | { |
| 865 | | if (KBIR != val) |
| 771 | lisa_state *state = device->machine->driver_data<lisa_state>(); |
| 772 | if (state->KBIR != val) |
| 866 | 773 | { |
| 867 | | KBIR = val; |
| 774 | state->KBIR = val; |
| 868 | 775 | lisa_field_interrupts(device->machine); |
| 869 | 776 | } |
| 870 | 777 | } |
| r9699 | r9700 | |
| 891 | 798 | */ |
| 892 | 799 | static READ8_DEVICE_HANDLER(parallel_via_in_b) |
| 893 | 800 | { |
| 801 | lisa_state *state = device->machine->driver_data<lisa_state>(); |
| 894 | 802 | int val = 0; |
| 895 | 803 | |
| 896 | | if (DISK_DIAG) |
| 804 | if (state->DISK_DIAG) |
| 897 | 805 | val |= 0x40; |
| 898 | 806 | |
| 899 | 807 | /* tell there is no hard disk : */ |
| r9699 | r9700 | |
| 923 | 831 | */ |
| 924 | 832 | VIDEO_UPDATE( lisa ) |
| 925 | 833 | { |
| 834 | lisa_state *state = screen->machine->driver_data<lisa_state>(); |
| 926 | 835 | UINT16 *v; |
| 927 | 836 | int x, y; |
| 928 | 837 | /* resolution is 720*364 on lisa, vs 608*431 on mac XL */ |
| 929 | | int resx = (lisa_features.has_mac_xl_video) ? 608 : 720; /* width */ |
| 930 | | int resy = (lisa_features.has_mac_xl_video) ? 431 : 364; /* height */ |
| 838 | int resx = (state->features.has_mac_xl_video) ? 608 : 720; /* width */ |
| 839 | int resy = (state->features.has_mac_xl_video) ? 431 : 364; /* height */ |
| 931 | 840 | |
| 932 | 841 | UINT8 line_buffer[720]; |
| 933 | 842 | |
| 934 | | v = videoram_ptr; |
| 843 | v = state->videoram_ptr; |
| 935 | 844 | |
| 936 | 845 | for (y = 0; y < resy; y++) |
| 937 | 846 | { |
| r9699 | r9700 | |
| 946 | 855 | #if 0 // we can execute directly out of read handlers now, so this shouldn't be necessary any more. #if 0'd for documentation until we get everything working. |
| 947 | 856 | DIRECT_UPDATE_HANDLER (lisa_OPbaseoverride) |
| 948 | 857 | { |
| 858 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 949 | 859 | /* upper 7 bits -> segment # */ |
| 950 | 860 | int segment = (address >> 17) & 0x7f; |
| 951 | | int the_seg = seg; |
| 861 | int the_seg = state->seg; |
| 952 | 862 | |
| 953 | 863 | address &= 0xffffff; |
| 954 | 864 | |
| 955 | 865 | printf("lisa: logical address %x\n", address); |
| 956 | 866 | |
| 957 | | if (setup) |
| 867 | if (state->setup) |
| 958 | 868 | { |
| 959 | 869 | if (address & 0x004000) |
| 960 | 870 | { |
| r9699 | r9700 | |
| 968 | 878 | } |
| 969 | 879 | else |
| 970 | 880 | { /* system ROMs */ |
| 971 | | direct.explicit_configure((address & 0xffc000), (address & 0xffc000) + 0x003fff, 0xffffff, lisa_rom_ptr - (address & 0x3fff)); |
| 881 | direct.explicit_configure((address & 0xffc000), (address & 0xffc000) + 0x003fff, 0xffffff, state->rom_ptr - (address & 0x3fff)); |
| 972 | 882 | } |
| 973 | 883 | |
| 974 | 884 | return -1; |
| r9699 | r9700 | |
| 986 | 896 | int seg_offset = address & 0x01ffff; |
| 987 | 897 | |
| 988 | 898 | /* add revelant origin -> address */ |
| 989 | | offs_t mapped_address = (mmu_regs[the_seg][segment].sorg + seg_offset) & 0x1fffff; |
| 899 | offs_t mapped_address = (state->mmu_regs[the_seg][segment].sorg + seg_offset) & 0x1fffff; |
| 990 | 900 | |
| 991 | | switch ((mmu_entry_t)mmu_regs[the_seg][segment].type) |
| 901 | switch ((mmu_entry_t)state->mmu_regs[the_seg][segment].type) |
| 992 | 902 | { |
| 993 | 903 | |
| 994 | 904 | case RAM_r: |
| 995 | 905 | case RAM_rw: |
| 996 | | if (seg_offset > mmu_regs[the_seg][segment].slim) |
| 906 | if (seg_offset > state->mmu_regs[the_seg][segment].slim) |
| 997 | 907 | { |
| 998 | 908 | /* out of segment limits : bus error */ |
| 999 | 909 | printf("illegal opbase address%lX\n", (long) address); |
| 1000 | 910 | } |
| 1001 | | direct.explicit_configure((address & 0xffc000), (address & 0xffc000) + 0x003fff, 0xffffff, lisa_ram_ptr + mapped_address - address); |
| 911 | direct.explicit_configure((address & 0xffc000), (address & 0xffc000) + 0x003fff, 0xffffff, state->ram_ptr + mapped_address - address); |
| 1002 | 912 | printf("RAM\n"); |
| 1003 | 913 | break; |
| 1004 | 914 | |
| r9699 | r9700 | |
| 1011 | 921 | break; |
| 1012 | 922 | |
| 1013 | 923 | case special_IO: |
| 1014 | | direct.explicit_configure((address & 0xffc000), (address & 0xffc000) + 0x003fff, 0xffffff, lisa_rom_ptr + (mapped_address & 0x003fff) - address); |
| 924 | direct.explicit_configure((address & 0xffc000), (address & 0xffc000) + 0x003fff, 0xffffff, state->rom_ptr + (mapped_address & 0x003fff) - address); |
| 1015 | 925 | printf("ROM\n"); |
| 1016 | 926 | break; |
| 1017 | 927 | } |
| r9699 | r9700 | |
| 1025 | 935 | /* TODO : save time difference with host clock, set default date, etc */ |
| 1026 | 936 | NVRAM_HANDLER(lisa) |
| 1027 | 937 | { |
| 938 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 1028 | 939 | if (read_or_write) |
| 1029 | 940 | { |
| 1030 | | mame_fwrite(file, lisa_fdc_ram, 1024); |
| 941 | mame_fwrite(file, state->fdc_ram, 1024); |
| 1031 | 942 | } |
| 1032 | 943 | else |
| 1033 | 944 | { |
| 1034 | 945 | if (file) |
| 1035 | | mame_fread(file, lisa_fdc_ram, 1024); |
| 946 | mame_fread(file, state->fdc_ram, 1024); |
| 1036 | 947 | else |
| 1037 | | memset(lisa_fdc_ram, 0, 1024); |
| 948 | memset(state->fdc_ram, 0, 1024); |
| 1038 | 949 | |
| 1039 | 950 | { |
| 1040 | 951 | /* Now we copy the host clock into the Lisa clock */ |
| 1041 | 952 | system_time systime; |
| 1042 | 953 | machine->base_datetime(systime); |
| 1043 | 954 | |
| 1044 | | clock_regs.alarm = 0xfffffL; |
| 955 | state->clock_regs.alarm = 0xfffffL; |
| 1045 | 956 | /* The clock count starts on 1st January 1980 */ |
| 1046 | | clock_regs.years = (systime.local_time.year - 1980) & 0xf; |
| 1047 | | clock_regs.days1 = (systime.local_time.day + 1) / 100; |
| 1048 | | clock_regs.days2 = ((systime.local_time.day + 1) / 10) % 10; |
| 1049 | | clock_regs.days3 = (systime.local_time.day + 1) % 10; |
| 1050 | | clock_regs.hours1 = systime.local_time.hour / 10; |
| 1051 | | clock_regs.hours2 = systime.local_time.hour % 10; |
| 1052 | | clock_regs.minutes1 = systime.local_time.minute / 10; |
| 1053 | | clock_regs.minutes2 = systime.local_time.minute % 10; |
| 1054 | | clock_regs.seconds1 = systime.local_time.second / 10; |
| 1055 | | clock_regs.seconds2 = systime.local_time.second % 10; |
| 1056 | | clock_regs.tenths = 0; |
| 957 | state->clock_regs.years = (systime.local_time.year - 1980) & 0xf; |
| 958 | state->clock_regs.days1 = (systime.local_time.day + 1) / 100; |
| 959 | state->clock_regs.days2 = ((systime.local_time.day + 1) / 10) % 10; |
| 960 | state->clock_regs.days3 = (systime.local_time.day + 1) % 10; |
| 961 | state->clock_regs.hours1 = systime.local_time.hour / 10; |
| 962 | state->clock_regs.hours2 = systime.local_time.hour % 10; |
| 963 | state->clock_regs.minutes1 = systime.local_time.minute / 10; |
| 964 | state->clock_regs.minutes2 = systime.local_time.minute % 10; |
| 965 | state->clock_regs.seconds1 = systime.local_time.second / 10; |
| 966 | state->clock_regs.seconds2 = systime.local_time.second % 10; |
| 967 | state->clock_regs.tenths = 0; |
| 1057 | 968 | } |
| 1058 | | clock_regs.clock_mode = timer_disable; |
| 1059 | | clock_regs.clock_write_ptr = -1; |
| 969 | state->clock_regs.clock_mode = timer_disable; |
| 970 | state->clock_regs.clock_write_ptr = -1; |
| 1060 | 971 | } |
| 1061 | 972 | |
| 1062 | 973 | |
| 1063 | 974 | #if 0 |
| 1064 | 975 | UINT32 temp32; |
| 1065 | 976 | SINT8 temp8; |
| 1066 | | temp32 = (clock_regs.alarm << 12) | (clock_regs.years << 8) | (clock_regs.days1 << 4) |
| 1067 | | | clock_regs.days2; |
| 977 | temp32 = (state->clock_regs.alarm << 12) | (state->clock_regs.years << 8) | (state->clock_regs.days1 << 4) |
| 978 | | state->clock_regs.days2; |
| 1068 | 979 | |
| 1069 | | temp32 = (clock_regs.days3 << 28) | (clock_regs.hours1 << 24) | (clock_regs.hours2 << 20) |
| 1070 | | | (clock_regs.minutes1 << 16) | (clock_regs.minutes2 << 12) |
| 1071 | | | (clock_regs.seconds1 << 8) | (clock_regs.seconds2 << 4) | clock_regs.tenths; |
| 980 | temp32 = (state->clock_regs.days3 << 28) | (state->clock_regs.hours1 << 24) | (state->clock_regs.hours2 << 20) |
| 981 | | (state->clock_regs.minutes1 << 16) | (state->clock_regs.minutes2 << 12) |
| 982 | | (state->clock_regs.seconds1 << 8) | (state->clock_regs.seconds2 << 4) | state->clock_regs.tenths; |
| 1072 | 983 | |
| 1073 | 984 | temp8 = clock_mode; /* clock mode */ |
| 1074 | 985 | |
| 1075 | | temp8 = clock_regs.clock_write_ptr; /* clock byte to be written next (-1 if clock write disabled) */ |
| 986 | temp8 = state->clock_regs.clock_write_ptr; /* clock byte to be written next (-1 if clock write disabled) */ |
| 1076 | 987 | #endif |
| 1077 | 988 | } |
| 1078 | 989 | |
| 1079 | 990 | #ifdef UNUSED_FUNCTION |
| 1080 | 991 | void init_lisa1(void) |
| 1081 | 992 | { |
| 1082 | | lisa_model = lisa1; |
| 1083 | | lisa_features.has_fast_timers = 0; |
| 1084 | | lisa_features.floppy_hardware = twiggy; |
| 1085 | | lisa_features.has_double_sided_floppy = 1; |
| 1086 | | lisa_features.has_mac_xl_video = 0; |
| 993 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 994 | state->model = lisa1; |
| 995 | state->features.has_fast_timers = 0; |
| 996 | state->features.floppy_hardware = twiggy; |
| 997 | state->features.has_double_sided_floppy = 1; |
| 998 | state->features.has_mac_xl_video = 0; |
| 1087 | 999 | } |
| 1088 | 1000 | #endif |
| 1089 | 1001 | |
| 1090 | 1002 | DRIVER_INIT( lisa2 ) |
| 1091 | 1003 | { |
| 1092 | | lisa_ram_ptr = memory_region(machine, "maincpu") + RAM_OFFSET; |
| 1093 | | lisa_rom_ptr = memory_region(machine, "maincpu") + ROM_OFFSET; |
| 1094 | | lisa_model = lisa2; |
| 1095 | | lisa_features.has_fast_timers = 0; |
| 1096 | | lisa_features.floppy_hardware = sony_lisa2; |
| 1097 | | lisa_features.has_double_sided_floppy = 0; |
| 1098 | | lisa_features.has_mac_xl_video = 0; |
| 1004 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 1005 | state->ram_ptr = memory_region(machine, "maincpu") + RAM_OFFSET; |
| 1006 | state->rom_ptr = memory_region(machine, "maincpu") + ROM_OFFSET; |
| 1007 | state->model = lisa2; |
| 1008 | state->features.has_fast_timers = 0; |
| 1009 | state->features.floppy_hardware = sony_lisa2; |
| 1010 | state->features.has_double_sided_floppy = 0; |
| 1011 | state->features.has_mac_xl_video = 0; |
| 1099 | 1012 | |
| 1100 | | bad_parity_table = auto_alloc_array(machine, UINT8, 0x40000); /* 1 bit per byte of CPU RAM */ |
| 1013 | state->bad_parity_table = auto_alloc_array(machine, UINT8, 0x40000); /* 1 bit per byte of CPU RAM */ |
| 1101 | 1014 | } |
| 1102 | 1015 | |
| 1103 | 1016 | DRIVER_INIT( lisa210 ) |
| 1104 | 1017 | { |
| 1105 | | lisa_ram_ptr = memory_region(machine, "maincpu") + RAM_OFFSET; |
| 1106 | | lisa_rom_ptr = memory_region(machine, "maincpu") + ROM_OFFSET; |
| 1107 | | lisa_model = lisa210; |
| 1108 | | lisa_features.has_fast_timers = 1; |
| 1109 | | lisa_features.floppy_hardware = sony_lisa210; |
| 1110 | | lisa_features.has_double_sided_floppy = 0; |
| 1111 | | lisa_features.has_mac_xl_video = 0; |
| 1018 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 1019 | state->ram_ptr = memory_region(machine, "maincpu") + RAM_OFFSET; |
| 1020 | state->rom_ptr = memory_region(machine, "maincpu") + ROM_OFFSET; |
| 1021 | state->model = lisa210; |
| 1022 | state->features.has_fast_timers = 1; |
| 1023 | state->features.floppy_hardware = sony_lisa210; |
| 1024 | state->features.has_double_sided_floppy = 0; |
| 1025 | state->features.has_mac_xl_video = 0; |
| 1112 | 1026 | |
| 1113 | | bad_parity_table = auto_alloc_array(machine, UINT8, 0x40000); /* 1 bit per byte of CPU RAM */ |
| 1027 | state->bad_parity_table = auto_alloc_array(machine, UINT8, 0x40000); /* 1 bit per byte of CPU RAM */ |
| 1114 | 1028 | } |
| 1115 | 1029 | |
| 1116 | 1030 | DRIVER_INIT( mac_xl ) |
| 1117 | 1031 | { |
| 1118 | | lisa_ram_ptr = memory_region(machine, "maincpu") + RAM_OFFSET; |
| 1119 | | lisa_rom_ptr = memory_region(machine, "maincpu") + ROM_OFFSET; |
| 1120 | | lisa_model = mac_xl; |
| 1121 | | lisa_features.has_fast_timers = 1; |
| 1122 | | lisa_features.floppy_hardware = sony_lisa210; |
| 1123 | | lisa_features.has_double_sided_floppy = 0; |
| 1124 | | lisa_features.has_mac_xl_video = 1; |
| 1032 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 1033 | state->ram_ptr = memory_region(machine, "maincpu") + RAM_OFFSET; |
| 1034 | state->rom_ptr = memory_region(machine, "maincpu") + ROM_OFFSET; |
| 1035 | state->model = mac_xl; |
| 1036 | state->features.has_fast_timers = 1; |
| 1037 | state->features.floppy_hardware = sony_lisa210; |
| 1038 | state->features.has_double_sided_floppy = 0; |
| 1039 | state->features.has_mac_xl_video = 1; |
| 1125 | 1040 | |
| 1126 | | bad_parity_table = auto_alloc_array(machine, UINT8, 0x40000); /* 1 bit per byte of CPU RAM */ |
| 1041 | state->bad_parity_table = auto_alloc_array(machine, UINT8, 0x40000); /* 1 bit per byte of CPU RAM */ |
| 1127 | 1042 | } |
| 1128 | 1043 | |
| 1129 | 1044 | MACHINE_START( lisa ) |
| 1130 | 1045 | { |
| 1131 | | mouse_timer = timer_alloc(machine, handle_mouse, NULL); |
| 1046 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 1047 | state->mouse_timer = timer_alloc(machine, handle_mouse, NULL); |
| 1132 | 1048 | |
| 1133 | 1049 | /* read command every ms (don't know the real value) */ |
| 1134 | 1050 | timer_pulse(machine, ATTOTIME_IN_MSEC(1), NULL, 0, set_COPS_ready); |
| r9699 | r9700 | |
| 1136 | 1052 | |
| 1137 | 1053 | MACHINE_RESET( lisa ) |
| 1138 | 1054 | { |
| 1139 | | lisa_ram_ptr = memory_region(machine, "maincpu") + RAM_OFFSET; |
| 1140 | | lisa_rom_ptr = memory_region(machine, "maincpu") + ROM_OFFSET; |
| 1141 | | videoROM_ptr = memory_region(machine, "gfx1"); |
| 1055 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 1056 | state->ram_ptr = memory_region(machine, "maincpu") + RAM_OFFSET; |
| 1057 | state->rom_ptr = memory_region(machine, "maincpu") + ROM_OFFSET; |
| 1058 | state->videoROM_ptr = memory_region(machine, "gfx1"); |
| 1142 | 1059 | |
| 1143 | 1060 | // cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM)->set_direct_update_handler(direct_update_delegate_create_static(lisa_OPbaseoverride, *machine)); |
| 1144 | 1061 | // m68k_set_reset_callback(machine->device("maincpu"), /*lisa_reset_instr_callback*/NULL); |
| 1145 | 1062 | |
| 1146 | 1063 | /* init MMU */ |
| 1147 | | setup = 1; |
| 1148 | | seg = 0; |
| 1064 | state->setup = 1; |
| 1065 | state->seg = 0; |
| 1149 | 1066 | |
| 1150 | 1067 | /* init parity */ |
| 1151 | | diag2 = 0; |
| 1152 | | test_parity = 0; |
| 1153 | | parity_error_pending = 0; |
| 1068 | state->diag2 = 0; |
| 1069 | state->test_parity = 0; |
| 1070 | state->parity_error_pending = 0; |
| 1154 | 1071 | |
| 1155 | | bad_parity_count = 0; |
| 1156 | | memset(bad_parity_table, 0, 0x40000); /* Clear */ |
| 1072 | state->bad_parity_count = 0; |
| 1073 | memset(state->bad_parity_table, 0, 0x40000); /* Clear */ |
| 1157 | 1074 | |
| 1158 | 1075 | /* init video */ |
| 1159 | 1076 | |
| 1160 | | VTMSK = 0; |
| 1077 | state->VTMSK = 0; |
| 1161 | 1078 | set_VTIR(machine, 0); |
| 1162 | 1079 | |
| 1163 | | video_address_latch = 0; |
| 1164 | | videoram_ptr = (UINT16 *) lisa_ram_ptr; |
| 1080 | state->video_address_latch = 0; |
| 1081 | state->videoram_ptr = (UINT16 *) state->ram_ptr; |
| 1165 | 1082 | |
| 1166 | 1083 | /* reset COPS keyboard/mouse controller */ |
| 1167 | 1084 | init_COPS(machine); |
| r9699 | r9700 | |
| 1173 | 1090 | |
| 1174 | 1091 | /* initialize floppy */ |
| 1175 | 1092 | { |
| 1176 | | if (lisa_features.floppy_hardware == sony_lisa2) |
| 1093 | if (state->features.floppy_hardware == sony_lisa2) |
| 1177 | 1094 | { |
| 1178 | 1095 | sony_set_enable_lines(machine->device("fdc"),1); /* on lisa2, drive unit 1 is always selected (?) */ |
| 1179 | 1096 | } |
| r9699 | r9700 | |
| 1185 | 1102 | |
| 1186 | 1103 | INTERRUPT_GEN( lisa_interrupt ) |
| 1187 | 1104 | { |
| 1188 | | static int frame_count = 0; |
| 1189 | | |
| 1190 | | if ((++frame_count) == 6) |
| 1105 | lisa_state *state = device->machine->driver_data<lisa_state>(); |
| 1106 | if ((++state->frame_count) == 6) |
| 1191 | 1107 | { /* increment clock every 1/10s */ |
| 1192 | | frame_count = 0; |
| 1108 | state->frame_count = 0; |
| 1193 | 1109 | |
| 1194 | | if (clock_regs.clock_mode != clock_timer_disable) |
| 1110 | if (state->clock_regs.clock_mode != clock_timer_disable) |
| 1195 | 1111 | { |
| 1196 | | if ((++clock_regs.tenths) == 10) |
| 1112 | if ((++state->clock_regs.tenths) == 10) |
| 1197 | 1113 | { |
| 1198 | | clock_regs.tenths = 0; |
| 1114 | state->clock_regs.tenths = 0; |
| 1199 | 1115 | |
| 1200 | | if (clock_regs.clock_mode != timer_disable) |
| 1116 | if (state->clock_regs.clock_mode != timer_disable) |
| 1201 | 1117 | { |
| 1202 | | if (clock_regs.alarm == 0) |
| 1118 | if (state->clock_regs.alarm == 0) |
| 1203 | 1119 | { |
| 1204 | 1120 | /* generate reset (should cause a VIA interrupt...) */ |
| 1205 | 1121 | static const UINT8 cmd[2] = |
| r9699 | r9700 | |
| 1209 | 1125 | }; |
| 1210 | 1126 | COPS_queue_data(device->machine, cmd, 2); |
| 1211 | 1127 | |
| 1212 | | clock_regs.alarm = 0xfffffL; |
| 1128 | state->clock_regs.alarm = 0xfffffL; |
| 1213 | 1129 | } |
| 1214 | 1130 | else |
| 1215 | 1131 | { |
| 1216 | | clock_regs.alarm--; |
| 1132 | state->clock_regs.alarm--; |
| 1217 | 1133 | } |
| 1218 | 1134 | } |
| 1219 | 1135 | |
| 1220 | | if ((++clock_regs.seconds2) == 10) |
| 1136 | if ((++state->clock_regs.seconds2) == 10) |
| 1221 | 1137 | { |
| 1222 | | clock_regs.seconds2 = 0; |
| 1138 | state->clock_regs.seconds2 = 0; |
| 1223 | 1139 | |
| 1224 | | if ((++clock_regs.seconds1) == 6) |
| 1140 | if ((++state->clock_regs.seconds1) == 6) |
| 1225 | 1141 | { |
| 1226 | | clock_regs.seconds1 = 0; |
| 1142 | state->clock_regs.seconds1 = 0; |
| 1227 | 1143 | |
| 1228 | | if ((++clock_regs.minutes2) == 10) |
| 1144 | if ((++state->clock_regs.minutes2) == 10) |
| 1229 | 1145 | { |
| 1230 | | clock_regs.minutes2 = 0; |
| 1146 | state->clock_regs.minutes2 = 0; |
| 1231 | 1147 | |
| 1232 | | if ((++clock_regs.minutes1) == 6) |
| 1148 | if ((++state->clock_regs.minutes1) == 6) |
| 1233 | 1149 | { |
| 1234 | | clock_regs.minutes1 = 0; |
| 1150 | state->clock_regs.minutes1 = 0; |
| 1235 | 1151 | |
| 1236 | | if ((++clock_regs.hours2) == 10) |
| 1152 | if ((++state->clock_regs.hours2) == 10) |
| 1237 | 1153 | { |
| 1238 | | clock_regs.hours2 = 0; |
| 1154 | state->clock_regs.hours2 = 0; |
| 1239 | 1155 | |
| 1240 | | clock_regs.hours1++; |
| 1156 | state->clock_regs.hours1++; |
| 1241 | 1157 | } |
| 1242 | 1158 | |
| 1243 | | if ((clock_regs.hours1*10 + clock_regs.hours2) == 24) |
| 1159 | if ((state->clock_regs.hours1*10 + state->clock_regs.hours2) == 24) |
| 1244 | 1160 | { |
| 1245 | | clock_regs.hours1 = clock_regs.hours2 = 0; |
| 1161 | state->clock_regs.hours1 = state->clock_regs.hours2 = 0; |
| 1246 | 1162 | |
| 1247 | | if ((++clock_regs.days3) == 10) |
| 1163 | if ((++state->clock_regs.days3) == 10) |
| 1248 | 1164 | { |
| 1249 | | clock_regs.days3 = 0; |
| 1165 | state->clock_regs.days3 = 0; |
| 1250 | 1166 | |
| 1251 | | if ((++clock_regs.days2) == 10) |
| 1167 | if ((++state->clock_regs.days2) == 10) |
| 1252 | 1168 | { |
| 1253 | | clock_regs.days2 = 0; |
| 1169 | state->clock_regs.days2 = 0; |
| 1254 | 1170 | |
| 1255 | | clock_regs.days1++; |
| 1171 | state->clock_regs.days1++; |
| 1256 | 1172 | } |
| 1257 | 1173 | } |
| 1258 | 1174 | |
| 1259 | | if ((clock_regs.days1*100 + clock_regs.days2*10 + clock_regs.days3) == |
| 1260 | | ((clock_regs.years % 4) ? 366 : 367)) |
| 1175 | if ((state->clock_regs.days1*100 + state->clock_regs.days2*10 + state->clock_regs.days3) == |
| 1176 | ((state->clock_regs.years % 4) ? 366 : 367)) |
| 1261 | 1177 | { |
| 1262 | | clock_regs.days1 = clock_regs.days2 = clock_regs.days3 = 0; |
| 1178 | state->clock_regs.days1 = state->clock_regs.days2 = state->clock_regs.days3 = 0; |
| 1263 | 1179 | |
| 1264 | | clock_regs.years = (clock_regs.years + 1) & 0xf; |
| 1180 | state->clock_regs.years = (state->clock_regs.years + 1) & 0xf; |
| 1265 | 1181 | } |
| 1266 | 1182 | } |
| 1267 | 1183 | } |
| r9699 | r9700 | |
| 1273 | 1189 | } |
| 1274 | 1190 | |
| 1275 | 1191 | /* set VBI */ |
| 1276 | | if (VTMSK) |
| 1192 | if (state->VTMSK) |
| 1277 | 1193 | set_VTIR(device->machine, 1); |
| 1278 | 1194 | else |
| 1279 | 1195 | set_VTIR(device->machine, 0); |
| r9699 | r9700 | |
| 1291 | 1207 | |
| 1292 | 1208 | INLINE void lisa_fdc_ttl_glue_access(running_machine *machine, offs_t offset) |
| 1293 | 1209 | { |
| 1210 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 1294 | 1211 | switch ((offset & 0x000E) >> 1) |
| 1295 | 1212 | { |
| 1296 | 1213 | case 0: |
| r9699 | r9700 | |
| 1303 | 1220 | /* enable/disable the motor on Lisa 1 */ |
| 1304 | 1221 | /* can disable the motor on Lisa 2/10, too (although it is not useful) */ |
| 1305 | 1222 | /* On lisa 2, commands the loading of the speed register on lisalite board */ |
| 1306 | | if (lisa_features.floppy_hardware == sony_lisa2) |
| 1223 | if (state->features.floppy_hardware == sony_lisa2) |
| 1307 | 1224 | { |
| 1308 | | int oldMT1 = MT1; |
| 1309 | | MT1 = offset & 1; |
| 1310 | | if (MT1 && ! oldMT1) |
| 1225 | int oldMT1 = state->MT1; |
| 1226 | state->MT1 = offset & 1; |
| 1227 | if (state->MT1 && ! oldMT1) |
| 1311 | 1228 | { |
| 1312 | 1229 | running_device *fdc = machine->device("fdc"); |
| 1313 | 1230 | |
| 1314 | | PWM_floppy_motor_speed = (PWM_floppy_motor_speed << 1) & 0xff; |
| 1231 | state->PWM_floppy_motor_speed = (state->PWM_floppy_motor_speed << 1) & 0xff; |
| 1315 | 1232 | if (applefdc_get_lines(fdc) & APPLEFDC_PH0) |
| 1316 | | PWM_floppy_motor_speed |= 1; |
| 1317 | | sony_set_speed(((256-PWM_floppy_motor_speed) * 1.3) + 237); |
| 1233 | state->PWM_floppy_motor_speed |= 1; |
| 1234 | sony_set_speed(((256-state->PWM_floppy_motor_speed) * 1.3) + 237); |
| 1318 | 1235 | } |
| 1319 | 1236 | } |
| 1320 | 1237 | /*else |
| 1321 | | MT1 = offset & 1;*/ |
| 1238 | state->MT1 = offset & 1;*/ |
| 1322 | 1239 | break; |
| 1323 | 1240 | case 4: |
| 1324 | 1241 | /*DIS = offset & 1;*/ /* forbids access from the 68000 to our RAM */ |
| r9699 | r9700 | |
| 1326 | 1243 | case 5: |
| 1327 | 1244 | /*HDS = offset & 1;*/ /* head select (-> disk side) on twiggy */ |
| 1328 | 1245 | #if 0 |
| 1329 | | if (lisa_features.floppy_hardware == twiggy) |
| 1246 | if (state->features.floppy_hardware == twiggy) |
| 1330 | 1247 | twiggy_set_head_line(offset & 1); |
| 1331 | 1248 | else |
| 1332 | 1249 | #endif |
| 1333 | | if (lisa_features.floppy_hardware == sony_lisa210) |
| 1250 | if (state->features.floppy_hardware == sony_lisa210) |
| 1334 | 1251 | sony_set_sel_line(machine->device("fdc"), offset & 1); |
| 1335 | 1252 | break; |
| 1336 | 1253 | case 6: |
| 1337 | | DISK_DIAG = offset & 1; |
| 1254 | state->DISK_DIAG = offset & 1; |
| 1338 | 1255 | break; |
| 1339 | 1256 | case 7: |
| 1340 | | FDIR = offset & 1; /* Interrupt request to 68k */ |
| 1257 | state->FDIR = offset & 1; /* Interrupt request to 68k */ |
| 1341 | 1258 | lisa_field_interrupts(machine); |
| 1342 | 1259 | break; |
| 1343 | 1260 | } |
| r9699 | r9700 | |
| 1373 | 1290 | |
| 1374 | 1291 | WRITE8_HANDLER ( lisa_fdc_io_w ) |
| 1375 | 1292 | { |
| 1293 | lisa_state *state = space->machine->driver_data<lisa_state>(); |
| 1376 | 1294 | running_device *fdc = space->machine->device("fdc"); |
| 1377 | 1295 | |
| 1378 | 1296 | switch ((offset & 0x0030) >> 4) |
| r9699 | r9700 | |
| 1388 | 1306 | case 2: /* writes the PWM register */ |
| 1389 | 1307 | /* the written value is used to generate the motor speed control signal */ |
| 1390 | 1308 | #if 0 |
| 1391 | | if (lisa_features.floppy_hardware == twiggy) |
| 1309 | if (state->features.floppy_hardware == twiggy) |
| 1392 | 1310 | twiggy_set_speed((256-data) * 1.3 /* ??? */ + 237 /* ??? */); |
| 1393 | 1311 | else |
| 1394 | 1312 | #endif |
| 1395 | | if (lisa_features.floppy_hardware == sony_lisa210) |
| 1313 | if (state->features.floppy_hardware == sony_lisa210) |
| 1396 | 1314 | sony_set_speed(((256-data) * 1.3) + 237); |
| 1397 | 1315 | break; |
| 1398 | 1316 | |
| r9699 | r9700 | |
| 1403 | 1321 | |
| 1404 | 1322 | READ8_HANDLER ( lisa_fdc_r ) |
| 1405 | 1323 | { |
| 1324 | lisa_state *state = space->machine->driver_data<lisa_state>(); |
| 1406 | 1325 | if (! (offset & 0x1000)) |
| 1407 | 1326 | { |
| 1408 | 1327 | if (! (offset & 0x0800)) |
| 1409 | 1328 | if (! (offset & 0x0400)) |
| 1410 | | return lisa_fdc_ram[offset & 0x03ff]; |
| 1329 | return state->fdc_ram[offset & 0x03ff]; |
| 1411 | 1330 | else |
| 1412 | 1331 | return lisa_fdc_io_r(space, offset & 0x03ff); |
| 1413 | 1332 | else |
| 1414 | 1333 | return 0; /* ??? */ |
| 1415 | 1334 | } |
| 1416 | 1335 | else |
| 1417 | | return lisa_fdc_rom[offset & 0x0fff]; |
| 1336 | return state->fdc_rom[offset & 0x0fff]; |
| 1418 | 1337 | } |
| 1419 | 1338 | |
| 1420 | 1339 | READ8_HANDLER ( lisa210_fdc_r ) |
| 1421 | 1340 | { |
| 1341 | lisa_state *state = space->machine->driver_data<lisa_state>(); |
| 1422 | 1342 | if (! (offset & 0x1000)) |
| 1423 | 1343 | { |
| 1424 | 1344 | if (! (offset & 0x0400)) |
| 1425 | 1345 | if (! (offset & 0x0800)) |
| 1426 | | return lisa_fdc_ram[offset & 0x03ff]; |
| 1346 | return state->fdc_ram[offset & 0x03ff]; |
| 1427 | 1347 | else |
| 1428 | 1348 | return lisa_fdc_io_r(space, offset & 0x03ff); |
| 1429 | 1349 | else |
| 1430 | 1350 | return 0; /* ??? */ |
| 1431 | 1351 | } |
| 1432 | 1352 | else |
| 1433 | | return lisa_fdc_rom[offset & 0x0fff]; |
| 1353 | return state->fdc_rom[offset & 0x0fff]; |
| 1434 | 1354 | } |
| 1435 | 1355 | |
| 1436 | 1356 | WRITE8_HANDLER ( lisa_fdc_w ) |
| 1437 | 1357 | { |
| 1358 | lisa_state *state = space->machine->driver_data<lisa_state>(); |
| 1438 | 1359 | if (! (offset & 0x1000)) |
| 1439 | 1360 | { |
| 1440 | 1361 | if (! (offset & 0x0800)) |
| 1441 | 1362 | { |
| 1442 | 1363 | if (! (offset & 0x0400)) |
| 1443 | | lisa_fdc_ram[offset & 0x03ff] = data; |
| 1364 | state->fdc_ram[offset & 0x03ff] = data; |
| 1444 | 1365 | else |
| 1445 | 1366 | lisa_fdc_io_w(space, offset & 0x03ff, data); |
| 1446 | 1367 | } |
| r9699 | r9700 | |
| 1449 | 1370 | |
| 1450 | 1371 | WRITE8_HANDLER ( lisa210_fdc_w ) |
| 1451 | 1372 | { |
| 1373 | lisa_state *state = space->machine->driver_data<lisa_state>(); |
| 1452 | 1374 | if (! (offset & 0x1000)) |
| 1453 | 1375 | { |
| 1454 | 1376 | if (! (offset & 0x0400)) |
| 1455 | 1377 | { |
| 1456 | 1378 | if (! (offset & 0x0800)) |
| 1457 | | lisa_fdc_ram[offset & 0x03ff] = data; |
| 1379 | state->fdc_ram[offset & 0x03ff] = data; |
| 1458 | 1380 | else |
| 1459 | 1381 | lisa_fdc_io_w(space, offset & 0x03ff, data); |
| 1460 | 1382 | } |
| r9699 | r9700 | |
| 1463 | 1385 | |
| 1464 | 1386 | READ16_HANDLER ( lisa_r ) |
| 1465 | 1387 | { |
| 1388 | lisa_state *state = space->machine->driver_data<lisa_state>(); |
| 1466 | 1389 | int answer=0; |
| 1467 | 1390 | |
| 1468 | 1391 | /* segment register set */ |
| 1469 | | int the_seg = seg; |
| 1392 | int the_seg = state->seg; |
| 1470 | 1393 | |
| 1471 | 1394 | /* upper 7 bits -> segment # */ |
| 1472 | 1395 | int segment = (offset >> 16) & 0x7f; |
| 1473 | 1396 | |
| 1474 | 1397 | /*logerror("read, logical address%lX\n", offset);*/ |
| 1475 | 1398 | |
| 1476 | | if (setup) |
| 1399 | if (state->setup) |
| 1477 | 1400 | { /* special setup mode */ |
| 1478 | 1401 | if (offset & 0x002000) |
| 1479 | 1402 | { |
| r9699 | r9700 | |
| 1486 | 1409 | /*logerror("read from segment registers (%X:%X) ", the_seg, segment);*/ |
| 1487 | 1410 | if (offset & 0x000004) |
| 1488 | 1411 | { /* sorg register */ |
| 1489 | | answer = real_mmu_regs[the_seg][segment].sorg; |
| 1412 | answer = state->real_mmu_regs[the_seg][segment].sorg; |
| 1490 | 1413 | /*logerror("sorg, data = %X\n", answer);*/ |
| 1491 | 1414 | } |
| 1492 | 1415 | else |
| 1493 | 1416 | { /* slim register */ |
| 1494 | | answer = real_mmu_regs[the_seg][segment].slim; |
| 1417 | answer = state->real_mmu_regs[the_seg][segment].slim; |
| 1495 | 1418 | /*logerror("slim, data = %X\n", answer);*/ |
| 1496 | 1419 | } |
| 1497 | 1420 | } |
| 1498 | 1421 | else |
| 1499 | 1422 | { /* system ROMs */ |
| 1500 | | answer = ((UINT16*)lisa_rom_ptr)[(offset & 0x001fff)]; |
| 1423 | answer = ((UINT16*)state->rom_ptr)[(offset & 0x001fff)]; |
| 1501 | 1424 | /*logerror("dst address in ROM (setup mode)\n");*/ |
| 1502 | 1425 | } |
| 1503 | 1426 | |
| r9699 | r9700 | |
| 1514 | 1437 | int seg_offset = (offset & 0x00ffff) << 1; |
| 1515 | 1438 | |
| 1516 | 1439 | /* add revelant origin -> address */ |
| 1517 | | offs_t address = (mmu_regs[the_seg][segment].sorg + seg_offset) & 0x1fffff; |
| 1440 | offs_t address = (state->mmu_regs[the_seg][segment].sorg + seg_offset) & 0x1fffff; |
| 1518 | 1441 | |
| 1519 | 1442 | /*logerror("read, logical address%lX\n", offset); |
| 1520 | 1443 | logerror("physical address%lX\n", address);*/ |
| 1521 | 1444 | |
| 1522 | | switch (mmu_regs[the_seg][segment].type) |
| 1445 | switch (state->mmu_regs[the_seg][segment].type) |
| 1523 | 1446 | { |
| 1524 | 1447 | |
| 1525 | 1448 | case RAM_stack_r: |
| 1526 | 1449 | case RAM_stack_rw: |
| 1527 | | if (address <= mmu_regs[the_seg][segment].slim) |
| 1450 | if (address <= state->mmu_regs[the_seg][segment].slim) |
| 1528 | 1451 | { |
| 1529 | 1452 | /* out of segment limits : bus error */ |
| 1530 | 1453 | |
| 1531 | 1454 | } |
| 1532 | | answer = *(UINT16 *)(lisa_ram_ptr + address); |
| 1455 | answer = *(UINT16 *)(state->ram_ptr + address); |
| 1533 | 1456 | |
| 1534 | | if (bad_parity_count && test_parity |
| 1535 | | && (bad_parity_table[address >> 3] & (0x3 << (address & 0x7)))) |
| 1457 | if (state->bad_parity_count && state->test_parity |
| 1458 | && (state->bad_parity_table[address >> 3] & (0x3 << (address & 0x7)))) |
| 1536 | 1459 | { |
| 1537 | | mem_err_addr_latch = address >> 5; |
| 1460 | state->mem_err_addr_latch = address >> 5; |
| 1538 | 1461 | set_parity_error_pending(space->machine, 1); |
| 1539 | 1462 | } |
| 1540 | 1463 | |
| r9699 | r9700 | |
| 1542 | 1465 | |
| 1543 | 1466 | case RAM_r: |
| 1544 | 1467 | case RAM_rw: |
| 1545 | | if (address > mmu_regs[the_seg][segment].slim) |
| 1468 | if (address > state->mmu_regs[the_seg][segment].slim) |
| 1546 | 1469 | { |
| 1547 | 1470 | /* out of segment limits : bus error */ |
| 1548 | 1471 | |
| 1549 | 1472 | } |
| 1550 | | answer = *(UINT16 *)(lisa_ram_ptr + address); |
| 1473 | answer = *(UINT16 *)(state->ram_ptr + address); |
| 1551 | 1474 | |
| 1552 | | if (bad_parity_count && test_parity |
| 1553 | | && (bad_parity_table[address >> 3] & (0x3 << (address & 0x7)))) |
| 1475 | if (state->bad_parity_count && state->test_parity |
| 1476 | && (state->bad_parity_table[address >> 3] & (0x3 << (address & 0x7)))) |
| 1554 | 1477 | { |
| 1555 | | mem_err_addr_latch = address >> 5; |
| 1478 | state->mem_err_addr_latch = address >> 5; |
| 1556 | 1479 | set_parity_error_pending(space->machine, 1); |
| 1557 | 1480 | } |
| 1558 | 1481 | |
| r9699 | r9700 | |
| 1572 | 1495 | |
| 1573 | 1496 | case special_IO: |
| 1574 | 1497 | if (! (address & 0x008000)) |
| 1575 | | answer = *(UINT16 *)(lisa_rom_ptr + (address & 0x003fff)); |
| 1498 | answer = *(UINT16 *)(state->rom_ptr + (address & 0x003fff)); |
| 1576 | 1499 | else |
| 1577 | 1500 | { /* read serial number from ROM */ |
| 1578 | 1501 | /* this has to be be the least efficient way to read a ROM :-) */ |
| r9699 | r9700 | |
| 1582 | 1505 | are slightly different from timings of a bare 68k */ |
| 1583 | 1506 | /* so we use a kludge... */ |
| 1584 | 1507 | int time_in_frame = space->machine->primary_screen->vpos(); |
| 1585 | | static int videoROM_address = 0; |
| 1586 | 1508 | |
| 1587 | 1509 | /* the BOOT ROM only reads 56 bits, so there must be some wrap-around for |
| 1588 | 1510 | videoROM_address <= 56 */ |
| r9699 | r9700 | |
| 1597 | 1519 | there are no additionnal margins). |
| 1598 | 1520 | This is caused by the fact that 68k timings are wrong (memory accesses are |
| 1599 | 1521 | interlaced with the video hardware, which is not emulated). */ |
| 1600 | | if (lisa_features.has_mac_xl_video) |
| 1522 | if (state->features.has_mac_xl_video) |
| 1601 | 1523 | { |
| 1602 | 1524 | if ((time_in_frame >= 374) && (time_in_frame <= 392)) /* these values have not been tested */ |
| 1603 | | answer = videoROM_ptr[videoROM_address|0x80] << 8; |
| 1525 | answer = state->videoROM_ptr[state->videoROM_address|0x80] << 8; |
| 1604 | 1526 | else |
| 1605 | | answer = videoROM_ptr[videoROM_address] << 8; |
| 1527 | answer = state->videoROM_ptr[state->videoROM_address] << 8; |
| 1606 | 1528 | } |
| 1607 | 1529 | else |
| 1608 | 1530 | { |
| 1609 | 1531 | if ((time_in_frame >= 364) && (time_in_frame <= 375)) |
| 1610 | 1532 | { |
| 1611 | | answer = videoROM_ptr[videoROM_address|0x80] << 8; |
| 1533 | answer = state->videoROM_ptr[state->videoROM_address|0x80] << 8; |
| 1612 | 1534 | logerror("reading1 %06X=%04x PC=%06x time=%d\n", address, answer, cpu_get_pc(space->machine->device("maincpu")), time_in_frame); |
| 1613 | 1535 | } |
| 1614 | 1536 | else |
| 1615 | 1537 | { |
| 1616 | | answer = videoROM_ptr[videoROM_address] << 8; |
| 1538 | answer = state->videoROM_ptr[state->videoROM_address] << 8; |
| 1617 | 1539 | logerror("reading2 %06X=%04x PC=%06x time=%d\n", address, answer, cpu_get_pc(space->machine->device("maincpu")), time_in_frame); |
| 1618 | 1540 | } |
| 1619 | 1541 | } |
| 1620 | 1542 | |
| 1621 | 1543 | |
| 1622 | | videoROM_address = (videoROM_address + 1) & 0x7f; |
| 1623 | | if (videoROM_address == ((lisa_features.has_mac_xl_video) ? 48 : 56)) { |
| 1624 | | logerror("loop %d\n", videoROM_address); |
| 1625 | | videoROM_address = 0; |
| 1544 | state->videoROM_address = (state->videoROM_address + 1) & 0x7f; |
| 1545 | if (state->videoROM_address == ((state->features.has_mac_xl_video) ? 48 : 56)) { |
| 1546 | logerror("loop %d\n", state->videoROM_address); |
| 1547 | state->videoROM_address = 0; |
| 1626 | 1548 | } |
| 1627 | 1549 | |
| 1628 | 1550 | } |
| r9699 | r9700 | |
| 1638 | 1560 | |
| 1639 | 1561 | WRITE16_HANDLER ( lisa_w ) |
| 1640 | 1562 | { |
| 1563 | lisa_state *state = space->machine->driver_data<lisa_state>(); |
| 1641 | 1564 | /* segment register set */ |
| 1642 | | int the_seg = seg; |
| 1565 | int the_seg = state->seg; |
| 1643 | 1566 | |
| 1644 | 1567 | /* upper 7 bits -> segment # */ |
| 1645 | 1568 | int segment = (offset >> 16) & 0x7f; |
| 1646 | 1569 | |
| 1647 | 1570 | |
| 1648 | | if (setup) |
| 1571 | if (state->setup) |
| 1649 | 1572 | { |
| 1650 | 1573 | if (offset & 0x002000) |
| 1651 | 1574 | { |
| r9699 | r9700 | |
| 1659 | 1582 | if (offset & 0x000004) |
| 1660 | 1583 | { /* sorg register */ |
| 1661 | 1584 | logerror("sorg, data = %X\n", data); |
| 1662 | | real_mmu_regs[the_seg][segment].sorg = data & 0xFFF; |
| 1663 | | mmu_regs[the_seg][segment].sorg = (data & 0x0fff) << 9; |
| 1585 | state->real_mmu_regs[the_seg][segment].sorg = data & 0xFFF; |
| 1586 | state->mmu_regs[the_seg][segment].sorg = (data & 0x0fff) << 9; |
| 1664 | 1587 | } |
| 1665 | 1588 | else |
| 1666 | 1589 | { /* slim register */ |
| 1667 | 1590 | logerror("slim, data = %X\n", data); |
| 1668 | | real_mmu_regs[the_seg][segment].slim = data & 0xFFF; |
| 1669 | | mmu_regs[the_seg][segment].slim = (~ (data << 9)) & 0x01ffff; |
| 1591 | state->real_mmu_regs[the_seg][segment].slim = data & 0xFFF; |
| 1592 | state->mmu_regs[the_seg][segment].slim = (~ (data << 9)) & 0x01ffff; |
| 1670 | 1593 | switch ((data & 0x0f00) >> 8) |
| 1671 | 1594 | { |
| 1672 | 1595 | case 0x4: |
| 1673 | 1596 | /*logerror("type : RAM stack r\n");*/ |
| 1674 | | mmu_regs[the_seg][segment].type = RAM_stack_r; |
| 1597 | state->mmu_regs[the_seg][segment].type = RAM_stack_r; |
| 1675 | 1598 | break; |
| 1676 | 1599 | case 0x5: |
| 1677 | 1600 | /*logerror("type : RAM r\n");*/ |
| 1678 | | mmu_regs[the_seg][segment].type = RAM_r; |
| 1601 | state->mmu_regs[the_seg][segment].type = RAM_r; |
| 1679 | 1602 | break; |
| 1680 | 1603 | case 0x6: |
| 1681 | 1604 | /*logerror("type : RAM stack rw\n");*/ |
| 1682 | | mmu_regs[the_seg][segment].type = RAM_stack_rw; |
| 1605 | state->mmu_regs[the_seg][segment].type = RAM_stack_rw; |
| 1683 | 1606 | break; |
| 1684 | 1607 | case 0x7: |
| 1685 | 1608 | /*logerror("type : RAM rw\n");*/ |
| 1686 | | mmu_regs[the_seg][segment].type = RAM_rw; |
| 1609 | state->mmu_regs[the_seg][segment].type = RAM_rw; |
| 1687 | 1610 | break; |
| 1688 | 1611 | case 0x8: |
| 1689 | 1612 | case 0x9: /* not documented, but used by ROMs (?) */ |
| 1690 | 1613 | /*logerror("type : I/O\n");*/ |
| 1691 | | mmu_regs[the_seg][segment].type = IO; |
| 1614 | state->mmu_regs[the_seg][segment].type = IO; |
| 1692 | 1615 | break; |
| 1693 | 1616 | case 0xC: |
| 1694 | 1617 | /*logerror("type : invalid\n");*/ |
| 1695 | | mmu_regs[the_seg][segment].type = invalid; |
| 1618 | state->mmu_regs[the_seg][segment].type = invalid; |
| 1696 | 1619 | break; |
| 1697 | 1620 | case 0xF: |
| 1698 | 1621 | logerror("type : special I/O\n"); |
| 1699 | | mmu_regs[the_seg][segment].type = special_IO; |
| 1622 | state->mmu_regs[the_seg][segment].type = special_IO; |
| 1700 | 1623 | break; |
| 1701 | 1624 | default: /* "unpredictable results" */ |
| 1702 | 1625 | logerror("type : unknown\n"); |
| 1703 | | mmu_regs[the_seg][segment].type = invalid; |
| 1626 | state->mmu_regs[the_seg][segment].type = invalid; |
| 1704 | 1627 | break; |
| 1705 | 1628 | } |
| 1706 | 1629 | } |
| r9699 | r9700 | |
| 1722 | 1645 | int seg_offset = (offset & 0x00ffff) << 1; |
| 1723 | 1646 | |
| 1724 | 1647 | /* add revelant origin -> address */ |
| 1725 | | offs_t address = (mmu_regs[the_seg][segment].sorg + seg_offset) & 0x1fffff; |
| 1648 | offs_t address = (state->mmu_regs[the_seg][segment].sorg + seg_offset) & 0x1fffff; |
| 1726 | 1649 | |
| 1727 | | switch (mmu_regs[the_seg][segment].type) |
| 1650 | switch (state->mmu_regs[the_seg][segment].type) |
| 1728 | 1651 | { |
| 1729 | 1652 | |
| 1730 | 1653 | case RAM_stack_rw: |
| 1731 | | if (address <= mmu_regs[the_seg][segment].slim) |
| 1654 | if (address <= state->mmu_regs[the_seg][segment].slim) |
| 1732 | 1655 | { |
| 1733 | 1656 | /* out of segment limits : bus error */ |
| 1734 | 1657 | |
| 1735 | 1658 | } |
| 1736 | | COMBINE_DATA((UINT16 *) (lisa_ram_ptr + address)); |
| 1737 | | if (diag2) |
| 1659 | COMBINE_DATA((UINT16 *) (state->ram_ptr + address)); |
| 1660 | if (state->diag2) |
| 1738 | 1661 | { |
| 1739 | 1662 | if ((ACCESSING_BITS_0_7) |
| 1740 | | && ! (bad_parity_table[address >> 3] & (0x1 << (address & 0x7)))) |
| 1663 | && ! (state->bad_parity_table[address >> 3] & (0x1 << (address & 0x7)))) |
| 1741 | 1664 | { |
| 1742 | | bad_parity_table[address >> 3] |= 0x1 << (address & 0x7); |
| 1743 | | bad_parity_count++; |
| 1665 | state->bad_parity_table[address >> 3] |= 0x1 << (address & 0x7); |
| 1666 | state->bad_parity_count++; |
| 1744 | 1667 | } |
| 1745 | 1668 | if ((ACCESSING_BITS_8_15) |
| 1746 | | && ! (bad_parity_table[address >> 3] & (0x2 << (address & 0x7)))) |
| 1669 | && ! (state->bad_parity_table[address >> 3] & (0x2 << (address & 0x7)))) |
| 1747 | 1670 | { |
| 1748 | | bad_parity_table[address >> 3] |= 0x2 << (address & 0x7); |
| 1749 | | bad_parity_count++; |
| 1671 | state->bad_parity_table[address >> 3] |= 0x2 << (address & 0x7); |
| 1672 | state->bad_parity_count++; |
| 1750 | 1673 | } |
| 1751 | 1674 | } |
| 1752 | | else if (bad_parity_table[address >> 3] & (0x3 << (address & 0x7))) |
| 1675 | else if (state->bad_parity_table[address >> 3] & (0x3 << (address & 0x7))) |
| 1753 | 1676 | { |
| 1754 | 1677 | if ((ACCESSING_BITS_0_7) |
| 1755 | | && (bad_parity_table[address >> 3] & (0x1 << (address & 0x7)))) |
| 1678 | && (state->bad_parity_table[address >> 3] & (0x1 << (address & 0x7)))) |
| 1756 | 1679 | { |
| 1757 | | bad_parity_table[address >> 3] &= ~ (0x1 << (address & 0x7)); |
| 1758 | | bad_parity_count--; |
| 1680 | state->bad_parity_table[address >> 3] &= ~ (0x1 << (address & 0x7)); |
| 1681 | state->bad_parity_count--; |
| 1759 | 1682 | } |
| 1760 | 1683 | if ((ACCESSING_BITS_8_15) |
| 1761 | | && (bad_parity_table[address >> 3] & (0x2 << (address & 0x7)))) |
| 1684 | && (state->bad_parity_table[address >> 3] & (0x2 << (address & 0x7)))) |
| 1762 | 1685 | { |
| 1763 | | bad_parity_table[address >> 3] &= ~ (0x2 << (address & 0x7)); |
| 1764 | | bad_parity_count--; |
| 1686 | state->bad_parity_table[address >> 3] &= ~ (0x2 << (address & 0x7)); |
| 1687 | state->bad_parity_count--; |
| 1765 | 1688 | } |
| 1766 | 1689 | } |
| 1767 | 1690 | break; |
| 1768 | 1691 | |
| 1769 | 1692 | case RAM_rw: |
| 1770 | | if (address > mmu_regs[the_seg][segment].slim) |
| 1693 | if (address > state->mmu_regs[the_seg][segment].slim) |
| 1771 | 1694 | { |
| 1772 | 1695 | /* out of segment limits : bus error */ |
| 1773 | 1696 | |
| 1774 | 1697 | } |
| 1775 | | COMBINE_DATA((UINT16 *) (lisa_ram_ptr + address)); |
| 1776 | | if (diag2) |
| 1698 | COMBINE_DATA((UINT16 *) (state->ram_ptr + address)); |
| 1699 | if (state->diag2) |
| 1777 | 1700 | { |
| 1778 | 1701 | if ((ACCESSING_BITS_0_7) |
| 1779 | | && ! (bad_parity_table[address >> 3] & (0x1 << (address & 0x7)))) |
| 1702 | && ! (state->bad_parity_table[address >> 3] & (0x1 << (address & 0x7)))) |
| 1780 | 1703 | { |
| 1781 | | bad_parity_table[address >> 3] |= 0x1 << (address & 0x7); |
| 1782 | | bad_parity_count++; |
| 1704 | state->bad_parity_table[address >> 3] |= 0x1 << (address & 0x7); |
| 1705 | state->bad_parity_count++; |
| 1783 | 1706 | } |
| 1784 | 1707 | if ((ACCESSING_BITS_8_15) |
| 1785 | | && ! (bad_parity_table[address >> 3] & (0x2 << (address & 0x7)))) |
| 1708 | && ! (state->bad_parity_table[address >> 3] & (0x2 << (address & 0x7)))) |
| 1786 | 1709 | { |
| 1787 | | bad_parity_table[address >> 3] |= 0x2 << (address & 0x7); |
| 1788 | | bad_parity_count++; |
| 1710 | state->bad_parity_table[address >> 3] |= 0x2 << (address & 0x7); |
| 1711 | state->bad_parity_count++; |
| 1789 | 1712 | } |
| 1790 | 1713 | } |
| 1791 | | else if (bad_parity_table[address >> 3] & (0x3 << (address & 0x7))) |
| 1714 | else if (state->bad_parity_table[address >> 3] & (0x3 << (address & 0x7))) |
| 1792 | 1715 | { |
| 1793 | 1716 | if ((ACCESSING_BITS_0_7) |
| 1794 | | && (bad_parity_table[address >> 3] & (0x1 << (address & 0x7)))) |
| 1717 | && (state->bad_parity_table[address >> 3] & (0x1 << (address & 0x7)))) |
| 1795 | 1718 | { |
| 1796 | | bad_parity_table[address >> 3] &= ~ (0x1 << (address & 0x7)); |
| 1797 | | bad_parity_count--; |
| 1719 | state->bad_parity_table[address >> 3] &= ~ (0x1 << (address & 0x7)); |
| 1720 | state->bad_parity_count--; |
| 1798 | 1721 | } |
| 1799 | 1722 | if ((ACCESSING_BITS_8_15) |
| 1800 | | && (bad_parity_table[address >> 3] & (0x2 << (address & 0x7)))) |
| 1723 | && (state->bad_parity_table[address >> 3] & (0x2 << (address & 0x7)))) |
| 1801 | 1724 | { |
| 1802 | | bad_parity_table[address >> 3] &= ~ (0x2 << (address & 0x7)); |
| 1803 | | bad_parity_count--; |
| 1725 | state->bad_parity_table[address >> 3] &= ~ (0x2 << (address & 0x7)); |
| 1726 | state->bad_parity_count--; |
| 1804 | 1727 | } |
| 1805 | 1728 | } |
| 1806 | 1729 | break; |
| r9699 | r9700 | |
| 1847 | 1770 | |
| 1848 | 1771 | INLINE void cpu_board_control_access(running_machine *machine, offs_t offset) |
| 1849 | 1772 | { |
| 1773 | lisa_state *state = machine->driver_data<lisa_state>(); |
| 1850 | 1774 | switch ((offset & 0x03ff) << 1) |
| 1851 | 1775 | { |
| 1852 | 1776 | case 0x0002: /* Set DIAG1 Latch */ |
| 1853 | 1777 | case 0x0000: /* Reset DIAG1 Latch */ |
| 1854 | 1778 | break; |
| 1855 | 1779 | case 0x0006: /* Set Diag2 Latch */ |
| 1856 | | diag2 = 1; |
| 1780 | state->diag2 = 1; |
| 1857 | 1781 | break; |
| 1858 | 1782 | case 0x0004: /* ReSet Diag2 Latch */ |
| 1859 | | diag2 = 0; |
| 1783 | state->diag2 = 0; |
| 1860 | 1784 | break; |
| 1861 | 1785 | case 0x000A: /* SEG1 Context Selection bit SET */ |
| 1862 | 1786 | /*logerror("seg bit 0 set\n");*/ |
| 1863 | | seg |= 1; |
| 1787 | state->seg |= 1; |
| 1864 | 1788 | break; |
| 1865 | 1789 | case 0x0008: /* SEG1 Context Selection bit RESET */ |
| 1866 | 1790 | /*logerror("seg bit 0 clear\n");*/ |
| 1867 | | seg &= ~1; |
| 1791 | state->seg &= ~1; |
| 1868 | 1792 | break; |
| 1869 | 1793 | case 0x000E: /* SEG2 Context Selection bit SET */ |
| 1870 | 1794 | /*logerror("seg bit 1 set\n");*/ |
| 1871 | | seg |= 2; |
| 1795 | state->seg |= 2; |
| 1872 | 1796 | break; |
| 1873 | 1797 | case 0x000C: /* SEG2 Context Selection bit RESET */ |
| 1874 | 1798 | /*logerror("seg bit 1 clear\n");*/ |
| 1875 | | seg &= ~2; |
| 1799 | state->seg &= ~2; |
| 1876 | 1800 | break; |
| 1877 | 1801 | case 0x0010: /* SETUP register SET */ |
| 1878 | 1802 | logerror("setup SET PC=%x\n", cpu_get_pc(machine->device("maincpu"))); |
| 1879 | | setup = 1; |
| 1803 | state->setup = 1; |
| 1880 | 1804 | break; |
| 1881 | 1805 | case 0x0012: /* SETUP register RESET */ |
| 1882 | 1806 | logerror("setup UNSET PC=%x\n", cpu_get_pc(machine->device("maincpu"))); |
| 1883 | | setup = 0; |
| 1807 | state->setup = 0; |
| 1884 | 1808 | break; |
| 1885 | 1809 | case 0x001A: /* Enable Vertical Retrace Interrupt */ |
| 1886 | 1810 | logerror("enable retrace PC=%x\n", cpu_get_pc(machine->device("maincpu"))); |
| 1887 | | VTMSK = 1; |
| 1811 | state->VTMSK = 1; |
| 1888 | 1812 | break; |
| 1889 | 1813 | case 0x0018: /* Disable Vertical Retrace Interrupt */ |
| 1890 | 1814 | logerror("disable retrace PC=%x\n", cpu_get_pc(machine->device("maincpu"))); |
| 1891 | | VTMSK = 0; |
| 1815 | state->VTMSK = 0; |
| 1892 | 1816 | set_VTIR(machine, 2); |
| 1893 | 1817 | break; |
| 1894 | 1818 | case 0x0016: /* Enable Soft Error Detect. */ |
| 1895 | 1819 | case 0x0014: /* Disable Soft Error Detect. */ |
| 1896 | 1820 | break; |
| 1897 | 1821 | case 0x001E: /* Enable Hard Error Detect */ |
| 1898 | | test_parity = 1; |
| 1822 | state->test_parity = 1; |
| 1899 | 1823 | break; |
| 1900 | 1824 | case 0x001C: /* Disable Hard Error Detect */ |
| 1901 | | test_parity = 0; |
| 1825 | state->test_parity = 0; |
| 1902 | 1826 | set_parity_error_pending(machine, 0); |
| 1903 | 1827 | break; |
| 1904 | 1828 | } |
| r9699 | r9700 | |
| 1906 | 1830 | |
| 1907 | 1831 | static READ16_HANDLER ( lisa_IO_r ) |
| 1908 | 1832 | { |
| 1833 | lisa_state *state = space->machine->driver_data<lisa_state>(); |
| 1909 | 1834 | via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0"); |
| 1910 | 1835 | via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1"); |
| 1911 | 1836 | int answer=0; |
| r9699 | r9700 | |
| 1942 | 1867 | if (! (offset & 0x400)) |
| 1943 | 1868 | { |
| 1944 | 1869 | /*if (ACCESSING_BITS_0_7)*/ /* Geez, who cares ? */ |
| 1945 | | answer = lisa_fdc_ram[offset & 0x03ff] & 0xff; /* right ??? */ |
| 1870 | answer = state->fdc_ram[offset & 0x03ff] & 0xff; /* right ??? */ |
| 1946 | 1871 | } |
| 1947 | 1872 | } |
| 1948 | 1873 | else |
| r9699 | r9700 | |
| 1980 | 1905 | break; |
| 1981 | 1906 | |
| 1982 | 1907 | case 0x1: /* Video Address Latch */ |
| 1983 | | answer = video_address_latch; |
| 1908 | answer = state->video_address_latch; |
| 1984 | 1909 | break; |
| 1985 | 1910 | |
| 1986 | 1911 | case 0x2: /* Memory Error Address Latch */ |
| 1987 | | answer = mem_err_addr_latch; |
| 1912 | answer = state->mem_err_addr_latch; |
| 1988 | 1913 | break; |
| 1989 | 1914 | |
| 1990 | 1915 | case 0x3: /* Status Register */ |
| 1991 | 1916 | answer = 0; |
| 1992 | | if (! parity_error_pending) |
| 1917 | if (! state->parity_error_pending) |
| 1993 | 1918 | answer |= 0x02; |
| 1994 | | if (VTIR<=1) |
| 1919 | if (state->VTIR<=1) |
| 1995 | 1920 | // GFE : needs to be in phase with Serial NUM |
| 1996 | 1921 | { |
| 1997 | 1922 | int time_in_frame = space->machine->primary_screen->vpos(); |
| 1998 | | if (lisa_features.has_mac_xl_video) |
| 1923 | if (state->features.has_mac_xl_video) |
| 1999 | 1924 | { |
| 2000 | 1925 | if ((time_in_frame >= 374) && (time_in_frame <= 392)) /* these values have not been tested */ |
| 2001 | 1926 | { /* if VSyncing, read ROM 2nd half ? */ |
| 2002 | 1927 | } |
| 2003 | 1928 | else |
| 2004 | 1929 | { |
| 2005 | | VTIR=0; |
| 1930 | state->VTIR=0; |
| 2006 | 1931 | answer |= 0x04; |
| 2007 | 1932 | } |
| 2008 | 1933 | } |
| r9699 | r9700 | |
| 2014 | 1939 | } |
| 2015 | 1940 | else |
| 2016 | 1941 | { |
| 2017 | | VTIR=0; |
| 1942 | state->VTIR=0; |
| 2018 | 1943 | answer |= 0x04; |
| 2019 | 1944 | } |
| 2020 | 1945 | } |
| r9699 | r9700 | |
| 2035 | 1960 | |
| 2036 | 1961 | static WRITE16_HANDLER ( lisa_IO_w ) |
| 2037 | 1962 | { |
| 1963 | lisa_state *state = space->machine->driver_data<lisa_state>(); |
| 2038 | 1964 | via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0"); |
| 2039 | 1965 | via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1"); |
| 2040 | 1966 | |
| r9699 | r9700 | |
| 2071 | 1997 | if (! (offset & 0x0400)) |
| 2072 | 1998 | { |
| 2073 | 1999 | if (ACCESSING_BITS_0_7) |
| 2074 | | lisa_fdc_ram[offset & 0x03ff] = data & 0xff; |
| 2000 | state->fdc_ram[offset & 0x03ff] = data & 0xff; |
| 2075 | 2001 | } |
| 2076 | 2002 | } |
| 2077 | 2003 | else |
| r9699 | r9700 | |
| 2105 | 2031 | |
| 2106 | 2032 | case 0x1: /* Video Address Latch */ |
| 2107 | 2033 | /*logerror("video address latch write offs=%X, data=%X\n", offset, data);*/ |
| 2108 | | COMBINE_DATA(& video_address_latch); |
| 2109 | | videoram_ptr = ((UINT16 *)lisa_ram_ptr) + ((video_address_latch << 6) & 0xfc000); |
| 2110 | | /*logerror("video address latch %X -> base address %X\n", video_address_latch, |
| 2111 | | (video_address_latch << 7) & 0x1f8000);*/ |
| 2034 | COMBINE_DATA(& state->video_address_latch); |
| 2035 | state->videoram_ptr = ((UINT16 *)state->ram_ptr) + ((state->video_address_latch << 6) & 0xfc000); |
| 2036 | /*logerror("video address latch %X -> base address %X\n", state->video_address_latch, |
| 2037 | (state->video_address_latch << 7) & 0x1f8000);*/ |
| 2112 | 2038 | break; |
| 2113 | 2039 | } |
| 2114 | 2040 | break; |
src/mess/drivers/z88.c
| r9699 | r9700 | |
| 20 | 20 | #include "devices/messram.h" |
| 21 | 21 | #include "devices/messram.h" |
| 22 | 22 | |
| 23 | | struct blink_hw z88_blink; |
| 24 | 23 | |
| 25 | | static void blink_reset(void) |
| 24 | static void blink_reset(running_machine *machine) |
| 26 | 25 | { |
| 27 | | memset(&z88_blink, 0, sizeof(struct blink_hw)); |
| 26 | z88_state *state = machine->driver_data<z88_state>(); |
| 27 | memset(&state->blink, 0, sizeof(state->blink)); |
| 28 | 28 | |
| 29 | 29 | /* rams is cleared on reset */ |
| 30 | | z88_blink.com &=~(1<<2); |
| 31 | | z88_blink.sbf = 0; |
| 32 | | z88_blink.z88_state = Z88_AWAKE; |
| 30 | state->blink.com &=~(1<<2); |
| 31 | state->blink.sbf = 0; |
| 32 | state->blink.z88_state = Z88_AWAKE; |
| 33 | 33 | |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | static void z88_interrupt_refresh(running_machine *machine) |
| 38 | 38 | { |
| 39 | z88_state *state = machine->driver_data<z88_state>(); |
| 39 | 40 | /* ints enabled? */ |
| 40 | | if ((z88_blink.ints & INT_GINT)!=0) |
| 41 | if ((state->blink.ints & INT_GINT)!=0) |
| 41 | 42 | { |
| 42 | 43 | /* yes */ |
| 43 | 44 | |
| 44 | 45 | /* other ints - except timer */ |
| 45 | 46 | if ( |
| 46 | | (((z88_blink.ints & z88_blink.sta) & 0x0fc)!=0) || |
| 47 | | (((z88_blink.ints>>1) & z88_blink.sta & STA_TIME)!=0) |
| 47 | (((state->blink.ints & state->blink.sta) & 0x0fc)!=0) || |
| 48 | (((state->blink.ints>>1) & state->blink.sta & STA_TIME)!=0) |
| 48 | 49 | ) |
| 49 | 50 | { |
| 50 | 51 | logerror("set int\n"); |
| r9699 | r9700 | |
| 57 | 58 | cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE); |
| 58 | 59 | } |
| 59 | 60 | |
| 60 | | static void z88_update_rtc_interrupt(void) |
| 61 | static void z88_update_rtc_interrupt(running_machine *machine) |
| 61 | 62 | { |
| 62 | | z88_blink.sta &=~STA_TIME; |
| 63 | z88_state *state = machine->driver_data<z88_state>(); |
| 64 | state->blink.sta &=~STA_TIME; |
| 63 | 65 | |
| 64 | 66 | /* time interrupt enabled? */ |
| 65 | | if (z88_blink.ints & INT_TIME) |
| 67 | if (state->blink.ints & INT_TIME) |
| 66 | 68 | { |
| 67 | 69 | /* yes */ |
| 68 | 70 | |
| 69 | 71 | /* any ints occured? */ |
| 70 | | if ((z88_blink.tsta & 0x07)!=0) |
| 72 | if ((state->blink.tsta & 0x07)!=0) |
| 71 | 73 | { |
| 72 | 74 | /* yes, set time int */ |
| 73 | | z88_blink.sta |= STA_TIME; |
| 75 | state->blink.sta |= STA_TIME; |
| 74 | 76 | } |
| 75 | 77 | } |
| 76 | 78 | } |
| r9699 | r9700 | |
| 79 | 81 | |
| 80 | 82 | static TIMER_CALLBACK(z88_rtc_timer_callback) |
| 81 | 83 | { |
| 84 | z88_state *state = machine->driver_data<z88_state>(); |
| 82 | 85 | int refresh_ints = 0; |
| 83 | 86 | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" }; |
| 84 | 87 | |
| 85 | 88 | /* is z88 in snooze state? */ |
| 86 | | if (z88_blink.z88_state == Z88_SNOOZE) |
| 89 | if (state->blink.z88_state == Z88_SNOOZE) |
| 87 | 90 | { |
| 88 | 91 | int i; |
| 89 | 92 | unsigned char data = 0x0ff; |
| r9699 | r9700 | |
| 100 | 103 | logerror("Z88 wake up from snooze!\n"); |
| 101 | 104 | |
| 102 | 105 | /* wake up z88 */ |
| 103 | | z88_blink.z88_state = Z88_AWAKE; |
| 106 | state->blink.z88_state = Z88_AWAKE; |
| 104 | 107 | /* column has gone low in snooze/coma */ |
| 105 | | z88_blink.sta |= STA_KEY; |
| 108 | state->blink.sta |= STA_KEY; |
| 106 | 109 | |
| 107 | 110 | cpuexec_trigger(machine, Z88_SNOOZE_TRIGGER); |
| 108 | 111 | |
| r9699 | r9700 | |
| 113 | 116 | |
| 114 | 117 | |
| 115 | 118 | /* hold clock at reset? - in this mode it doesn't update */ |
| 116 | | if ((z88_blink.com & (1<<4))==0) |
| 119 | if ((state->blink.com & (1<<4))==0) |
| 117 | 120 | { |
| 118 | 121 | /* update 5 millisecond counter */ |
| 119 | | z88_blink.tim[0]++; |
| 122 | state->blink.tim[0]++; |
| 120 | 123 | |
| 121 | 124 | /* tick */ |
| 122 | | if ((z88_blink.tim[0]%10)==0) |
| 125 | if ((state->blink.tim[0]%10)==0) |
| 123 | 126 | { |
| 124 | 127 | /* set tick int has occured */ |
| 125 | | z88_blink.tsta |= RTC_TICK_INT; |
| 128 | state->blink.tsta |= RTC_TICK_INT; |
| 126 | 129 | refresh_ints = 1; |
| 127 | 130 | } |
| 128 | 131 | |
| 129 | | if (z88_blink.tim[0]==200) |
| 132 | if (state->blink.tim[0]==200) |
| 130 | 133 | { |
| 131 | | z88_blink.tim[0] = 0; |
| 134 | state->blink.tim[0] = 0; |
| 132 | 135 | |
| 133 | 136 | /* set seconds int has occured */ |
| 134 | | z88_blink.tsta |= RTC_SEC_INT; |
| 137 | state->blink.tsta |= RTC_SEC_INT; |
| 135 | 138 | refresh_ints = 1; |
| 136 | 139 | |
| 137 | | z88_blink.tim[1]++; |
| 140 | state->blink.tim[1]++; |
| 138 | 141 | |
| 139 | | if (z88_blink.tim[1]==60) |
| 142 | if (state->blink.tim[1]==60) |
| 140 | 143 | { |
| 141 | 144 | /* set minutes int has occured */ |
| 142 | | z88_blink.tsta |=RTC_MIN_INT; |
| 145 | state->blink.tsta |=RTC_MIN_INT; |
| 143 | 146 | refresh_ints = 1; |
| 144 | 147 | |
| 145 | | z88_blink.tim[1]=0; |
| 148 | state->blink.tim[1]=0; |
| 146 | 149 | |
| 147 | | z88_blink.tim[2]++; |
| 150 | state->blink.tim[2]++; |
| 148 | 151 | |
| 149 | | if (z88_blink.tim[2]==256) |
| 152 | if (state->blink.tim[2]==256) |
| 150 | 153 | { |
| 151 | | z88_blink.tim[2] = 0; |
| 154 | state->blink.tim[2] = 0; |
| 152 | 155 | |
| 153 | | z88_blink.tim[3]++; |
| 156 | state->blink.tim[3]++; |
| 154 | 157 | |
| 155 | | if (z88_blink.tim[3]==256) |
| 158 | if (state->blink.tim[3]==256) |
| 156 | 159 | { |
| 157 | | z88_blink.tim[3] = 0; |
| 160 | state->blink.tim[3] = 0; |
| 158 | 161 | |
| 159 | | z88_blink.tim[4]++; |
| 162 | state->blink.tim[4]++; |
| 160 | 163 | |
| 161 | | if (z88_blink.tim[4]==32) |
| 164 | if (state->blink.tim[4]==32) |
| 162 | 165 | { |
| 163 | | z88_blink.tim[4] = 0; |
| 166 | state->blink.tim[4] = 0; |
| 164 | 167 | } |
| 165 | 168 | } |
| 166 | 169 | } |
| r9699 | r9700 | |
| 170 | 173 | |
| 171 | 174 | if (refresh_ints) |
| 172 | 175 | { |
| 173 | | z88_update_rtc_interrupt(); |
| 176 | z88_update_rtc_interrupt(machine); |
| 174 | 177 | |
| 175 | 178 | /* refresh */ |
| 176 | 179 | z88_interrupt_refresh(machine); |
| r9699 | r9700 | |
| 229 | 232 | |
| 230 | 233 | static void z88_refresh_memory_bank(running_machine *machine, int bank) |
| 231 | 234 | { |
| 235 | z88_state *state = machine->driver_data<z88_state>(); |
| 232 | 236 | void *read_addr; |
| 233 | 237 | void *write_addr; |
| 234 | 238 | unsigned long block; |
| r9699 | r9700 | |
| 237 | 241 | assert(bank <= 3); |
| 238 | 242 | |
| 239 | 243 | /* ram? */ |
| 240 | | if (z88_blink.mem[bank]>=0x020) |
| 244 | if (state->blink.mem[bank]>=0x020) |
| 241 | 245 | { |
| 242 | | block = z88_blink.mem[bank]-0x020; |
| 246 | block = state->blink.mem[bank]-0x020; |
| 243 | 247 | |
| 244 | 248 | if (block >= 128) |
| 245 | 249 | { |
| r9699 | r9700 | |
| 253 | 257 | } |
| 254 | 258 | else |
| 255 | 259 | { |
| 256 | | block = z88_blink.mem[bank] & 0x07; |
| 260 | block = state->blink.mem[bank] & 0x07; |
| 257 | 261 | |
| 258 | 262 | /* in rom area, but rom not present */ |
| 259 | 263 | if (block>=8) |
| r9699 | r9700 | |
| 276 | 280 | /* override setting for lower 8k of bank 0 */ |
| 277 | 281 | |
| 278 | 282 | /* enable rom? */ |
| 279 | | if ((z88_blink.com & (1<<2))==0) |
| 283 | if ((state->blink.com & (1<<2))==0) |
| 280 | 284 | { |
| 281 | 285 | /* yes */ |
| 282 | 286 | read_addr = memory_region(machine, "maincpu") + 0x010000; |
| r9699 | r9700 | |
| 302 | 306 | { |
| 303 | 307 | memset(messram_get_ptr(machine->device("messram")), 0x0ff, messram_get_size(machine->device("messram"))); |
| 304 | 308 | |
| 305 | | blink_reset(); |
| 309 | blink_reset(machine); |
| 306 | 310 | |
| 307 | 311 | z88_refresh_memory_bank(machine, 0); |
| 308 | 312 | z88_refresh_memory_bank(machine, 1); |
| r9699 | r9700 | |
| 318 | 322 | AM_RANGE(0xc000, 0xffff) AM_READ_BANK("bank5") AM_WRITE_BANK("bank10") |
| 319 | 323 | ADDRESS_MAP_END |
| 320 | 324 | |
| 321 | | static void blink_pb_w(int offset, int data, int reg_index) |
| 325 | static void blink_pb_w(running_machine *machine, int offset, int data, int reg_index) |
| 322 | 326 | { |
| 327 | z88_state *state = machine->driver_data<z88_state>(); |
| 323 | 328 | unsigned short addr_written = (offset & 0x0ff00) | (data & 0x0ff); |
| 324 | 329 | |
| 325 | 330 | logerror("reg_index: %02x addr: %04x\n",reg_index,addr_written); |
| r9699 | r9700 | |
| 331 | 336 | |
| 332 | 337 | case 0x00: |
| 333 | 338 | { |
| 334 | | /**/ z88_blink.pb[0] = addr_written; |
| 335 | | z88_blink.lores0 = ((addr_written & 0x01f)<<9) | ((addr_written & 0x01fe0)<<9); // blink_pb_offset(-1, addr_written, 9); |
| 336 | | logerror("lores0 %08x\n",z88_blink.lores0); |
| 339 | /**/ state->blink.pb[0] = addr_written; |
| 340 | state->blink.lores0 = ((addr_written & 0x01f)<<9) | ((addr_written & 0x01fe0)<<9); // blink_pb_offset(-1, addr_written, 9); |
| 341 | logerror("lores0 %08x\n",state->blink.lores0); |
| 337 | 342 | } |
| 338 | 343 | break; |
| 339 | 344 | |
| 340 | 345 | case 0x01: |
| 341 | 346 | { |
| 342 | | z88_blink.pb[1] = addr_written; |
| 343 | | z88_blink.lores1 = ((addr_written & 0x01f)<<12) | ((addr_written & 0x01fe0)<<12); //blink_pb_offset(-1, addr_written, 12); |
| 344 | | logerror("lores1 %08x\n",z88_blink.lores1); |
| 347 | state->blink.pb[1] = addr_written; |
| 348 | state->blink.lores1 = ((addr_written & 0x01f)<<12) | ((addr_written & 0x01fe0)<<12); //blink_pb_offset(-1, addr_written, 12); |
| 349 | logerror("lores1 %08x\n",state->blink.lores1); |
| 345 | 350 | } |
| 346 | 351 | break; |
| 347 | 352 | |
| 348 | 353 | case 0x02: |
| 349 | 354 | { |
| 350 | | z88_blink.pb[2] = addr_written; |
| 351 | | /**/ z88_blink.hires0 = ((addr_written & 0x01f)<<13) | ((addr_written & 0x01fe0)<<13); //blink_pb_offset(-1, addr_written, 13); |
| 352 | | logerror("hires0 %08x\n", z88_blink.hires0); |
| 355 | state->blink.pb[2] = addr_written; |
| 356 | /**/ state->blink.hires0 = ((addr_written & 0x01f)<<13) | ((addr_written & 0x01fe0)<<13); //blink_pb_offset(-1, addr_written, 13); |
| 357 | logerror("hires0 %08x\n", state->blink.hires0); |
| 353 | 358 | } |
| 354 | 359 | break; |
| 355 | 360 | |
| 356 | 361 | |
| 357 | 362 | case 0x03: |
| 358 | 363 | { |
| 359 | | z88_blink.pb[3] = addr_written; |
| 360 | | z88_blink.hires1 = ((addr_written & 0x01f)<<11) | ((addr_written & 0x01fe0)<<11); //blink_pb_offset(-1, addr_written, 11); |
| 364 | state->blink.pb[3] = addr_written; |
| 365 | state->blink.hires1 = ((addr_written & 0x01f)<<11) | ((addr_written & 0x01fe0)<<11); //blink_pb_offset(-1, addr_written, 11); |
| 361 | 366 | |
| 362 | | logerror("hires1 %08x\n", z88_blink.hires1); |
| 367 | logerror("hires1 %08x\n", state->blink.hires1); |
| 363 | 368 | } |
| 364 | 369 | break; |
| 365 | 370 | |
| 366 | 371 | case 0x04: |
| 367 | 372 | { |
| 368 | | z88_blink.sbr = addr_written; |
| 373 | state->blink.sbr = addr_written; |
| 369 | 374 | |
| 370 | | z88_blink.sbf = ((addr_written & 0x01f)<<11) | ((addr_written & 0x01fe0)<<11); |
| 371 | | logerror("%08x\n", z88_blink.sbf); |
| 375 | state->blink.sbf = ((addr_written & 0x01f)<<11) | ((addr_written & 0x01fe0)<<11); |
| 376 | logerror("%08x\n", state->blink.sbf); |
| 372 | 377 | |
| 373 | 378 | } |
| 374 | 379 | break; |
| r9699 | r9700 | |
| 382 | 387 | /* segment register write */ |
| 383 | 388 | static WRITE8_HANDLER(blink_srx_w) |
| 384 | 389 | { |
| 385 | | z88_blink.mem[offset] = data; |
| 390 | z88_state *state = space->machine->driver_data<z88_state>(); |
| 391 | state->blink.mem[offset] = data; |
| 386 | 392 | |
| 387 | 393 | z88_refresh_memory_bank(space->machine, offset); |
| 388 | 394 | } |
| r9699 | r9700 | |
| 400 | 406 | |
| 401 | 407 | static WRITE8_HANDLER(z88_port_w) |
| 402 | 408 | { |
| 409 | z88_state *state = space->machine->driver_data<z88_state>(); |
| 403 | 410 | running_device *speaker = space->machine->device("speaker"); |
| 404 | 411 | unsigned char port; |
| 405 | 412 | |
| r9699 | r9700 | |
| 412 | 419 | case 0x072: |
| 413 | 420 | case 0x073: |
| 414 | 421 | case 0x074: |
| 415 | | blink_pb_w(offset, data, port & 0x0f); |
| 422 | blink_pb_w(space->machine, offset, data, port & 0x0f); |
| 416 | 423 | return; |
| 417 | 424 | |
| 418 | 425 | |
| r9699 | r9700 | |
| 422 | 429 | logerror("tack w: %02x\n", data); |
| 423 | 430 | |
| 424 | 431 | /* set acknowledge */ |
| 425 | | z88_blink.tack = data & 0x07; |
| 432 | state->blink.tack = data & 0x07; |
| 426 | 433 | /* clear ints that have occured */ |
| 427 | | z88_blink.tsta &= ~z88_blink.tack; |
| 434 | state->blink.tsta &= ~state->blink.tack; |
| 428 | 435 | |
| 429 | 436 | /* refresh ints */ |
| 430 | | z88_update_rtc_interrupt(); |
| 437 | z88_update_rtc_interrupt(space->machine); |
| 431 | 438 | z88_interrupt_refresh(space->machine); |
| 432 | 439 | } |
| 433 | 440 | return; |
| r9699 | r9700 | |
| 438 | 445 | logerror("tmk w: %02x\n", data); |
| 439 | 446 | |
| 440 | 447 | /* set new int mask */ |
| 441 | | z88_blink.tmk = data & 0x07; |
| 448 | state->blink.tmk = data & 0x07; |
| 442 | 449 | |
| 443 | 450 | /* refresh ints */ |
| 444 | | z88_update_rtc_interrupt(); |
| 451 | z88_update_rtc_interrupt(space->machine); |
| 445 | 452 | z88_interrupt_refresh(space->machine); |
| 446 | 453 | } |
| 447 | 454 | return; |
| r9699 | r9700 | |
| 452 | 459 | |
| 453 | 460 | logerror("com w: %02x\n", data); |
| 454 | 461 | |
| 455 | | changed_bits = z88_blink.com^data; |
| 456 | | z88_blink.com = data; |
| 462 | changed_bits = state->blink.com^data; |
| 463 | state->blink.com = data; |
| 457 | 464 | |
| 458 | 465 | /* reset clock? */ |
| 459 | 466 | if ((data & (1<<4))!=0) |
| 460 | 467 | { |
| 461 | | z88_blink.tim[0] = (z88_blink.tim[1] = (z88_blink.tim[2] = (z88_blink.tim[3] = (z88_blink.tim[4] = 0)))); |
| 468 | state->blink.tim[0] = (state->blink.tim[1] = (state->blink.tim[2] = (state->blink.tim[3] = (state->blink.tim[4] = 0)))); |
| 462 | 469 | } |
| 463 | 470 | |
| 464 | 471 | /* SBIT controls speaker direct? */ |
| r9699 | r9700 | |
| 492 | 499 | /* set int enables */ |
| 493 | 500 | logerror("int w: %02x\n", data); |
| 494 | 501 | |
| 495 | | z88_blink.ints = data; |
| 496 | | z88_update_rtc_interrupt(); |
| 502 | state->blink.ints = data; |
| 503 | z88_update_rtc_interrupt(space->machine); |
| 497 | 504 | z88_interrupt_refresh(space->machine); |
| 498 | 505 | } |
| 499 | 506 | return; |
| r9699 | r9700 | |
| 504 | 511 | logerror("ack w: %02x\n", data); |
| 505 | 512 | |
| 506 | 513 | /* acknowledge ints */ |
| 507 | | z88_blink.ack = data & ((1<<6) | (1<<5) | (1<<3) | (1<<2)); |
| 514 | state->blink.ack = data & ((1<<6) | (1<<5) | (1<<3) | (1<<2)); |
| 508 | 515 | |
| 509 | | z88_blink.ints &= ~z88_blink.ack; |
| 510 | | z88_update_rtc_interrupt(); |
| 516 | state->blink.ints &= ~state->blink.ack; |
| 517 | z88_update_rtc_interrupt(space->machine); |
| 511 | 518 | z88_interrupt_refresh(space->machine); |
| 512 | 519 | } |
| 513 | 520 | return; |
| r9699 | r9700 | |
| 529 | 536 | |
| 530 | 537 | static READ8_HANDLER(z88_port_r) |
| 531 | 538 | { |
| 539 | z88_state *state = space->machine->driver_data<z88_state>(); |
| 532 | 540 | unsigned char port; |
| 533 | 541 | |
| 534 | 542 | port = offset & 0x0ff; |
| r9699 | r9700 | |
| 536 | 544 | switch (port) |
| 537 | 545 | { |
| 538 | 546 | case 0x0b1: |
| 539 | | z88_blink.sta &=~(1<<1); |
| 540 | | logerror("sta r: %02x\n",z88_blink.sta); |
| 541 | | return z88_blink.sta; |
| 547 | state->blink.sta &=~(1<<1); |
| 548 | logerror("sta r: %02x\n",state->blink.sta); |
| 549 | return state->blink.sta; |
| 542 | 550 | |
| 543 | 551 | |
| 544 | 552 | case 0x0b2: |
| r9699 | r9700 | |
| 550 | 558 | lines = offset>>8; |
| 551 | 559 | |
| 552 | 560 | /* if set, reading the keyboard will put z88 into snooze */ |
| 553 | | if ((z88_blink.ints & INT_KWAIT)!=0) |
| 561 | if ((state->blink.ints & INT_KWAIT)!=0) |
| 554 | 562 | { |
| 555 | | z88_blink.z88_state = Z88_SNOOZE; |
| 563 | state->blink.z88_state = Z88_SNOOZE; |
| 556 | 564 | /* spin cycles until rtc timer */ |
| 557 | 565 | cpu_spinuntil_trigger( space->machine->device("maincpu"), Z88_SNOOZE_TRIGGER); |
| 558 | 566 | |
| r9699 | r9700 | |
| 591 | 599 | |
| 592 | 600 | /* read real time clock status */ |
| 593 | 601 | case 0x0b5: |
| 594 | | z88_blink.tsta &=~0x07; |
| 595 | | logerror("tsta r: %02x\n",z88_blink.tsta); |
| 596 | | return z88_blink.tsta; |
| 602 | state->blink.tsta &=~0x07; |
| 603 | logerror("tsta r: %02x\n",state->blink.tsta); |
| 604 | return state->blink.tsta; |
| 597 | 605 | |
| 598 | 606 | /* read real time clock counters */ |
| 599 | 607 | case 0x0d0: |
| 600 | | logerror("tim0 r: %02x\n", z88_blink.tim[0]); |
| 601 | | return z88_blink.tim[0] & 0x0ff; |
| 608 | logerror("tim0 r: %02x\n", state->blink.tim[0]); |
| 609 | return state->blink.tim[0] & 0x0ff; |
| 602 | 610 | case 0x0d1: |
| 603 | | logerror("tim1 r: %02x\n", z88_blink.tim[1]); |
| 604 | | return z88_blink.tim[1] & 0x03f; |
| 611 | logerror("tim1 r: %02x\n", state->blink.tim[1]); |
| 612 | return state->blink.tim[1] & 0x03f; |
| 605 | 613 | case 0x0d2: |
| 606 | | logerror("tim2 r: %02x\n", z88_blink.tim[2]); |
| 607 | | return z88_blink.tim[2] & 0x0ff; |
| 614 | logerror("tim2 r: %02x\n", state->blink.tim[2]); |
| 615 | return state->blink.tim[2] & 0x0ff; |
| 608 | 616 | case 0x0d3: |
| 609 | | logerror("tim3 r: %02x\n", z88_blink.tim[3]); |
| 610 | | return z88_blink.tim[3] & 0x0ff; |
| 617 | logerror("tim3 r: %02x\n", state->blink.tim[3]); |
| 618 | return state->blink.tim[3] & 0x0ff; |
| 611 | 619 | case 0x0d4: |
| 612 | | logerror("tim4 r: %02x\n", z88_blink.tim[4]); |
| 613 | | return z88_blink.tim[4] & 0x01f; |
| 620 | logerror("tim4 r: %02x\n", state->blink.tim[4]); |
| 621 | return state->blink.tim[4] & 0x01f; |
| 614 | 622 | |
| 615 | 623 | default: |
| 616 | 624 | break; |