src/mame/drivers/filetto.c
| r4149 | r4150 | |
| 1 | | /****************************************************************************************** |
| 2 | | |
| 3 | | Filetto (c) 1990 Novarmatic |
| 4 | | |
| 5 | | driver by Angelo Salese & Chris Hardy |
| 6 | | |
| 7 | | TODO: |
| 8 | | - Use the MESS implementation of the CGA video emulation; |
| 9 | | - Add a proper FDC device,if you enable it will give a boot error,probably because it |
| 10 | | expects that in the floppy drive shouldn't be anything,there's currently a kludge that |
| 11 | | does the trick; |
| 12 | | - Add sound,"buzzer" PC sound plus the UM5100 sound chip,might be connected to the |
| 13 | | prototyping card; |
| 14 | | |
| 15 | | ******************************************************************************************** |
| 16 | | HW notes: |
| 17 | | The PCB is a un-modified IBM-PC with a CGA adapter & a prototyping card that controls the |
| 18 | | interface between the pc and the Jamma connectors.Additionally there's also a UM5100 sound |
| 19 | | chip for the sound. |
| 20 | | PCB Part Number: S/N 90289764 NOVARXT |
| 21 | | PCB Contents: |
| 22 | | 1x UMC 8923S-UM5100 voice processor (upper board) |
| 23 | | 1x MMI PAL16L8ACN-940CRK9 (upper board) |
| 24 | | 1x AMD AMPAL16R8APC-8804DM (upper board) |
| 25 | | 1x AMD P8088-1 main processor 8.000MHz (lower board) |
| 26 | | 1x Proton PT8010AF PLCC 28.636MHz (lower board) |
| 27 | | 1x UMC 8928LP-UM8272A floppy disk controller (lower board) |
| 28 | | 1x UMC 8935CS-UM82C11 Printer Adapter Interface (lower board) |
| 29 | | 1x UMC 8936CS-UM8250B Programmable asynchronous communications element (lower board) |
| 30 | | There isn't any keyboard found connected to the pcb. |
| 31 | | ******************************************************************************************** |
| 32 | | SW notes: |
| 33 | | The software of this game can be extracted with a normal Windows program extractor. |
| 34 | | The files names are: |
| 35 | | -command.com (1) |
| 36 | | -ibmbio.com (1) |
| 37 | | -ibmdos.com (1) |
| 38 | | -ansi.sys (1) |
| 39 | | -config.sys (2) |
| 40 | | -autoexec.bat (3) |
| 41 | | -x.exe (4) |
| 42 | | (1)This is an old Italian version of MS-DOS (v3.30 18th March 1987). |
| 43 | | (2)Contains "device=ansi.sys",it's an hook-up for the graphics used by the BIOS. |
| 44 | | (3)It has an Echo off (as you can notice from the game itself) and then the loading of the |
| 45 | | main program (x.exe). |
| 46 | | (4)The main program,done in plain Basic with several Italian comments in it.The date of |
| 47 | | the main program is 9th October 1990. |
| 48 | | |
| 49 | | ******************************************************************************************** |
| 50 | | Vector & irq notes (Mainly a memo for me): |
| 51 | | |
| 52 | | 7c69 -> int $13 (FDC check),done |
| 53 | | 7c6c |
| 54 | | 16ef9 -> read dsw |
| 55 | | 159cd [] |
| 56 | | [2361c] |
| 57 | | 12eae |
| 58 | | int $10 (vector number 0x0040) cmds |
| 59 | | AH |
| 60 | | 0x00 - Set Video mode ($449) |
| 61 | | 0x01 - |
| 62 | | 0x02 - Set Cursor position (BH=$00 IP=$ff71b DX=$0600) |
| 63 | | 0x0e - Teletype output (IP=$7d3c) (Note: This types "Errore di Boot") |
| 64 | | ******************************************************************************************/ |
| 65 | | |
| 66 | | #include "driver.h" |
| 67 | | #include "cpu/i86/i86.h" |
| 68 | | #include "video/generic.h" |
| 69 | | #include "machine/pit8253.h" |
| 70 | | #include "machine/8255ppi.h" |
| 71 | | #include "machine/8237dma.h" |
| 72 | | #include "machine/pic8259.h" |
| 73 | | #include "machine/mc146818.h" |
| 74 | | #include "sound/hc55516.h" |
| 75 | | |
| 76 | | #define SET_VISIBLE_AREA(_x_,_y_) \ |
| 77 | | { \ |
| 78 | | rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); \ |
| 79 | | visarea.min_x = 0; \ |
| 80 | | visarea.max_x = _x_-1; \ |
| 81 | | visarea.min_y = 0; \ |
| 82 | | visarea.max_y = _y_-1; \ |
| 83 | | video_screen_configure(machine->primary_screen, _x_, _y_, &visarea, video_screen_get_frame_period(machine->primary_screen).attoseconds ); \ |
| 84 | | } \ |
| 85 | | |
| 86 | | |
| 87 | | static UINT8 *vga_vram,*work_ram; |
| 88 | | static UINT8 video_regs[0x19]; |
| 89 | | static UINT8 *vga_mode; |
| 90 | | static UINT8 hv_blank; |
| 91 | | |
| 92 | | static int bank; |
| 93 | | static int lastvalue; |
| 94 | | |
| 95 | | /*Add here Video regs defines...*/ |
| 96 | | |
| 97 | | |
| 98 | | #define RES_320x200 0 |
| 99 | | #define RES_640x200 1 |
| 100 | | |
| 101 | | static void cga_alphanumeric_tilemap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,UINT16 size,UINT32 map_offs); |
| 102 | | |
| 103 | | static VIDEO_START( filetto ) |
| 104 | | { |
| 105 | | } |
| 106 | | |
| 107 | | static READ8_HANDLER( vga_hvretrace_r ) |
| 108 | | { |
| 109 | | /* |
| 110 | | Read-Only lower 8 bits,TRUSTED |
| 111 | | ---- x--- Vertical Retrace |
| 112 | | ---- ---x Horizontal Retrace |
| 113 | | */ |
| 114 | | static UINT8 res; |
| 115 | | static int h,w; |
| 116 | | res = 0; |
| 117 | | h = video_screen_get_height(space->machine->primary_screen); |
| 118 | | w = video_screen_get_width(space->machine->primary_screen); |
| 119 | | |
| 120 | | // popmessage("%d %d",h,w); |
| 121 | | |
| 122 | | if (video_screen_get_hpos(space->machine->primary_screen) > h) |
| 123 | | res|= 1; |
| 124 | | |
| 125 | | if (video_screen_get_vpos(space->machine->primary_screen) > w) |
| 126 | | res|= 8; |
| 127 | | |
| 128 | | return res; |
| 129 | | } |
| 130 | | |
| 131 | | //Note: this should be converted to red/green/brown instead of magenta/cyan/white |
| 132 | | /*Basic Graphic mode */ |
| 133 | | static void cga_graphic_bitmap(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,UINT16 size,UINT32 map_offs) |
| 134 | | { |
| 135 | | static UINT16 x,y,pen = 0; |
| 136 | | static UINT32 offs; |
| 137 | | |
| 138 | | SET_VISIBLE_AREA(320,200); |
| 139 | | offs = map_offs; |
| 140 | | for(y=0;y<200;y+=2) |
| 141 | | for(x=0;x<320;x+=4) |
| 142 | | { |
| 143 | | switch((vga_vram[offs] & 0xc0) >> 6) |
| 144 | | { |
| 145 | | case 0: pen = 0xf0; break; |
| 146 | | case 1: pen = 0xfb; break; |
| 147 | | case 2: pen = 0xfd; break; |
| 148 | | case 3: pen = 0xff; break; |
| 149 | | } |
| 150 | | *BITMAP_ADDR16(bitmap, y, x) = pen; |
| 151 | | switch((vga_vram[offs] & 0x30) >> 4) |
| 152 | | { |
| 153 | | case 0: pen = 0xf0; break; |
| 154 | | case 1: pen = 0xfb; break; |
| 155 | | case 2: pen = 0xfd; break; |
| 156 | | case 3: pen = 0xff; break; |
| 157 | | } |
| 158 | | *BITMAP_ADDR16(bitmap, y, x+1) = pen; |
| 159 | | switch((vga_vram[offs] & 0x0c) >> 2) |
| 160 | | { |
| 161 | | case 0: pen = 0xf0; break; |
| 162 | | case 1: pen = 0xfb; break; |
| 163 | | case 2: pen = 0xfd; break; |
| 164 | | case 3: pen = 0xff; break; |
| 165 | | } |
| 166 | | *BITMAP_ADDR16(bitmap, y, x+2) = pen; |
| 167 | | switch((vga_vram[offs] & 0x03) >> 0) |
| 168 | | { |
| 169 | | case 0: pen = 0xf0; break; |
| 170 | | case 1: pen = 0xfb; break; |
| 171 | | case 2: pen = 0xfd; break; |
| 172 | | case 3: pen = 0xff; break; |
| 173 | | } |
| 174 | | *BITMAP_ADDR16(bitmap, y, x+3) = pen; |
| 175 | | offs++; |
| 176 | | } |
| 177 | | |
| 178 | | offs = 0x2000+map_offs; |
| 179 | | for(y=1;y<200;y+=2) |
| 180 | | for(x=0;x<320;x+=4) |
| 181 | | { |
| 182 | | switch((vga_vram[offs] & 0xc0) >> 6) |
| 183 | | { |
| 184 | | case 0: pen = 0xf0; break; |
| 185 | | case 1: pen = 0xfb; break; |
| 186 | | case 2: pen = 0xfd; break; |
| 187 | | case 3: pen = 0xff; break; |
| 188 | | } |
| 189 | | *BITMAP_ADDR16(bitmap, y, x) = pen; |
| 190 | | switch((vga_vram[offs] & 0x30) >> 4) |
| 191 | | { |
| 192 | | case 0: pen = 0xf0; break; |
| 193 | | case 1: pen = 0xfb; break; |
| 194 | | case 2: pen = 0xfd; break; |
| 195 | | case 3: pen = 0xff; break; |
| 196 | | } |
| 197 | | *BITMAP_ADDR16(bitmap, y, x+1) = pen; |
| 198 | | switch((vga_vram[offs] & 0x0c) >> 2) |
| 199 | | { |
| 200 | | case 0: pen = 0xf0; break; |
| 201 | | case 1: pen = 0xfb; break; |
| 202 | | case 2: pen = 0xfd; break; |
| 203 | | case 3: pen = 0xff; break; |
| 204 | | } |
| 205 | | *BITMAP_ADDR16(bitmap, y, x+2) = pen; |
| 206 | | switch((vga_vram[offs] & 0x03) >> 0) |
| 207 | | { |
| 208 | | case 0: pen = 0xf0; break; |
| 209 | | case 1: pen = 0xfb; break; |
| 210 | | case 2: pen = 0xfd; break; |
| 211 | | case 3: pen = 0xff; break; |
| 212 | | } |
| 213 | | *BITMAP_ADDR16(bitmap, y, x+3) = pen; |
| 214 | | offs++; |
| 215 | | } |
| 216 | | |
| 217 | | } |
| 218 | | |
| 219 | | |
| 220 | | |
| 221 | | static void cga_alphanumeric_tilemap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,UINT16 size,UINT32 map_offs) |
| 222 | | { |
| 223 | | static UINT32 offs,x,y,max_x,max_y; |
| 224 | | |
| 225 | | /*define the visible area*/ |
| 226 | | switch(size) |
| 227 | | { |
| 228 | | case RES_320x200: |
| 229 | | SET_VISIBLE_AREA(320,200); |
| 230 | | max_x = 40; |
| 231 | | max_y = 25; |
| 232 | | break; |
| 233 | | case RES_640x200: |
| 234 | | SET_VISIBLE_AREA(640,200); |
| 235 | | max_x = 80; |
| 236 | | max_y = 25; |
| 237 | | break; |
| 238 | | } |
| 239 | | |
| 240 | | offs = map_offs; |
| 241 | | |
| 242 | | for(y=0;y<max_y;y++) |
| 243 | | for(x=0;x<max_x;x++) |
| 244 | | { |
| 245 | | int tile = vga_vram[offs] & 0xff; |
| 246 | | int color = vga_vram[offs+1] & 0x0f; |
| 247 | | |
| 248 | | drawgfx(bitmap,machine->gfx[2], |
| 249 | | tile, |
| 250 | | color, |
| 251 | | 0,0, |
| 252 | | x*8,y*8, |
| 253 | | cliprect,TRANSPARENCY_NONE,0); |
| 254 | | |
| 255 | | offs+=2; |
| 256 | | } |
| 257 | | } |
| 258 | | |
| 259 | | |
| 260 | | static VIDEO_UPDATE( filetto ) |
| 261 | | { |
| 262 | | /* xx1x xxxx Attribute bit 7. 0=blink, 1=Intesity |
| 263 | | xxx1 xxxx 640x200 mode |
| 264 | | xxxx 1xxx Enable video signal |
| 265 | | xxxx x1xx Select B/W mode |
| 266 | | xxxx xx1x Select graphics |
| 267 | | xxxx xxx1 80x25 text |
| 268 | | */ |
| 269 | | bitmap_fill(bitmap, cliprect, 0); |
| 270 | | |
| 271 | | if(vga_mode[0] & 8) |
| 272 | | { |
| 273 | | if(vga_mode[0] & 2) |
| 274 | | cga_graphic_bitmap(screen->machine,bitmap,cliprect,0,0x18000); |
| 275 | | else |
| 276 | | { |
| 277 | | switch(vga_mode[0] & 1) |
| 278 | | { |
| 279 | | case 0x00: |
| 280 | | cga_alphanumeric_tilemap(screen->machine,bitmap,cliprect,RES_320x200,0x18000); |
| 281 | | break; |
| 282 | | case 0x01: |
| 283 | | cga_alphanumeric_tilemap(screen->machine,bitmap,cliprect,RES_640x200,0x18000); |
| 284 | | break; |
| 285 | | } |
| 286 | | } |
| 287 | | } |
| 288 | | |
| 289 | | return 0; |
| 290 | | } |
| 291 | | |
| 292 | | static READ8_HANDLER( vga_regs_r ) |
| 293 | | { |
| 294 | | logerror("(PC=%05x) Warning: VGA reg port read\n",cpu_get_pc(space->cpu)); |
| 295 | | return 0xff; |
| 296 | | } |
| 297 | | |
| 298 | | static WRITE8_HANDLER( vga_regs_w ) |
| 299 | | { |
| 300 | | static UINT8 video_index; |
| 301 | | |
| 302 | | if(offset == 0) |
| 303 | | { |
| 304 | | video_index = data; |
| 305 | | } |
| 306 | | if(offset == 1) |
| 307 | | { |
| 308 | | if(video_index <= 0x18) |
| 309 | | { |
| 310 | | video_regs[video_index] = data; |
| 311 | | //logerror("write %02x to video register [%02x]",data,video_index); |
| 312 | | } |
| 313 | | else |
| 314 | | logerror("(PC=%05x) Warning: Undefined VGA reg port write (I=%02x D=%02x)\n",cpu_get_pc(space->cpu),video_index,data); |
| 315 | | } |
| 316 | | } |
| 317 | | |
| 318 | | static WRITE8_HANDLER( vga_vram_w ) |
| 319 | | { |
| 320 | | vga_vram[offset] = data; |
| 321 | | } |
| 322 | | |
| 323 | | /*end of Video HW file*/ |
| 324 | | |
| 325 | | static struct { |
| 326 | | const device_config *pit8253; |
| 327 | | const device_config *pic8259_1; |
| 328 | | const device_config *pic8259_2; |
| 329 | | const device_config *dma8237_1; |
| 330 | | const device_config *dma8237_2; |
| 331 | | } filetto_devices; |
| 332 | | |
| 333 | | |
| 334 | | static UINT8 disk_data[2]; |
| 335 | | |
| 336 | | static READ8_HANDLER( disk_iobank_r ) |
| 337 | | { |
| 338 | | //printf("Read Prototyping card [%02x] @ PC=%05x\n",offset,cpu_get_pc(space->cpu)); |
| 339 | | //if(offset == 0) return input_port_read(space->machine, "DSW"); |
| 340 | | if(offset == 1) return input_port_read(space->machine, "IN1"); |
| 341 | | |
| 342 | | return disk_data[offset]; |
| 343 | | } |
| 344 | | |
| 345 | | static WRITE8_HANDLER( disk_iobank_w ) |
| 346 | | { |
| 347 | | /* |
| 348 | | BIOS does a single out $0310,$F0 on reset |
| 349 | | |
| 350 | | Then does 2 outs to set the bank.. |
| 351 | | |
| 352 | | X1 X2 |
| 353 | | |
| 354 | | $F0 $F2 = m0 |
| 355 | | $F1 $F2 = m1 |
| 356 | | $F0 $F3 = m2 |
| 357 | | $F1 $F3 = m3 |
| 358 | | |
| 359 | | The sequence of |
| 360 | | |
| 361 | | out $0310,X1 |
| 362 | | out $0310,X2 |
| 363 | | |
| 364 | | sets the selected rom that appears in $C0000-$CFFFF |
| 365 | | |
| 366 | | */ |
| 367 | | int newbank = 0; |
| 368 | | |
| 369 | | // printf("bank %d set to %02X\n", offset,data); |
| 370 | | |
| 371 | | if (data == 0xF0) |
| 372 | | { |
| 373 | | newbank = 0; |
| 374 | | } |
| 375 | | else |
| 376 | | { |
| 377 | | if((lastvalue == 0xF0) && (data == 0xF2)) |
| 378 | | newbank = 0; |
| 379 | | else if ((lastvalue == 0xF1) && (data == 0xF2)) |
| 380 | | newbank = 1; |
| 381 | | else if ((lastvalue == 0xF0) && (data == 0xF3)) |
| 382 | | newbank = 2; |
| 383 | | else if ((lastvalue == 0xF1) && (data == 0xF3)) |
| 384 | | newbank = 3; |
| 385 | | } |
| 386 | | |
| 387 | | // printf("newbank = %d\n", newbank); |
| 388 | | |
| 389 | | if (newbank != bank) |
| 390 | | { |
| 391 | | bank = newbank; |
| 392 | | memory_set_bankptr(space->machine, 1,memory_region(space->machine, "user1") + 0x10000 * bank ); |
| 393 | | } |
| 394 | | |
| 395 | | lastvalue = data; |
| 396 | | |
| 397 | | disk_data[offset] = data; |
| 398 | | } |
| 399 | | |
| 400 | | /********************************* |
| 401 | | Pit8253 |
| 402 | | *********************************/ |
| 403 | | |
| 404 | | static PIT8253_OUTPUT_CHANGED( pc_timer0_w ) |
| 405 | | { |
| 406 | | pic8259_set_irq_line(filetto_devices.pic8259_1, 0, state); |
| 407 | | } |
| 408 | | |
| 409 | | static const struct pit8253_config pc_pit8253_config = |
| 410 | | { |
| 411 | | { |
| 412 | | { |
| 413 | | 4772720/4, /* heartbeat IRQ */ |
| 414 | | pc_timer0_w |
| 415 | | }, { |
| 416 | | 4772720/4, /* dram refresh */ |
| 417 | | NULL |
| 418 | | }, { |
| 419 | | 4772720/4, /* pio port c pin 4, and speaker polling enough */ |
| 420 | | NULL |
| 421 | | } |
| 422 | | } |
| 423 | | }; |
| 424 | | |
| 425 | | static UINT8 port_b_data; |
| 426 | | static UINT8 wss1_data,wss2_data; |
| 427 | | |
| 428 | | static READ8_DEVICE_HANDLER( port_a_r ) |
| 429 | | { |
| 430 | | if(!(port_b_data & 0x80))//??? |
| 431 | | { |
| 432 | | /* |
| 433 | | x--- ---- Undefined (Always 0) |
| 434 | | -x-- ---- B: Floppy disk drive installed. |
| 435 | | --xx ---- Default Display Mode |
| 436 | | ---- xx-- Undefined (Always 1) |
| 437 | | ---- --x- 8087 NDP installed |
| 438 | | ---- ---x Undefined (Always 1) |
| 439 | | */ |
| 440 | | return wss1_data; |
| 441 | | } |
| 442 | | else//keyboard emulation |
| 443 | | { |
| 444 | | //cpu_set_input_line(device->machine->cpu[0],1,PULSE_LINE); |
| 445 | | return 0x00;//Keyboard is disconnected |
| 446 | | //return 0xaa;//Keyboard code |
| 447 | | } |
| 448 | | } |
| 449 | | |
| 450 | | static READ8_DEVICE_HANDLER( port_b_r ) |
| 451 | | { |
| 452 | | return port_b_data; |
| 453 | | } |
| 454 | | |
| 455 | | static READ8_DEVICE_HANDLER( port_c_r ) |
| 456 | | { |
| 457 | | return wss2_data;//??? |
| 458 | | } |
| 459 | | |
| 460 | | /*'buzzer' sound routes here*/ |
| 461 | | static WRITE8_DEVICE_HANDLER( port_b_w ) |
| 462 | | { |
| 463 | | port_b_data = data; |
| 464 | | // hc55516_digit_w(0, data); |
| 465 | | // popmessage("%02x",data); |
| 466 | | } |
| 467 | | |
| 468 | | static WRITE8_DEVICE_HANDLER( wss_1_w ) |
| 469 | | { |
| 470 | | wss1_data = data; |
| 471 | | } |
| 472 | | |
| 473 | | static WRITE8_DEVICE_HANDLER( wss_2_w ) |
| 474 | | { |
| 475 | | wss2_data = data; |
| 476 | | } |
| 477 | | |
| 478 | | static WRITE8_DEVICE_HANDLER( sys_reset_w ) |
| 479 | | { |
| 480 | | cpu_set_input_line(device->machine->cpu[0],INPUT_LINE_RESET,PULSE_LINE); |
| 481 | | } |
| 482 | | |
| 483 | | |
| 484 | | static const ppi8255_interface filetto_ppi8255_intf[2] = |
| 485 | | { |
| 486 | | { |
| 487 | | port_a_r, /* Port A read */ |
| 488 | | port_b_r, /* Port B read */ |
| 489 | | port_c_r, /* Port C read */ |
| 490 | | NULL, /* Port A write */ |
| 491 | | port_b_w, /* Port B write */ |
| 492 | | NULL /* Port C write */ |
| 493 | | }, |
| 494 | | { |
| 495 | | NULL, /* Port A read */ |
| 496 | | NULL, /* Port B read */ |
| 497 | | NULL, /* Port C read */ |
| 498 | | wss_1_w, /* Port A write */ |
| 499 | | wss_2_w, /* Port B write */ |
| 500 | | sys_reset_w /* Port C write */ |
| 501 | | } |
| 502 | | }; |
| 503 | | |
| 504 | | /*Floppy Disk Controller 765 device*/ |
| 505 | | /*Currently we only emulate it at a point that the BIOS will pass the checks*/ |
| 506 | | static UINT8 status; |
| 507 | | |
| 508 | | #define FDC_BUSY 0x10 |
| 509 | | #define FDC_WRITE 0x40 |
| 510 | | #define FDC_READ 0x00 /*~0x40*/ |
| 511 | | |
| 512 | | static READ8_HANDLER( fdc765_status_r ) |
| 513 | | { |
| 514 | | static UINT8 tmp,clr_status; |
| 515 | | // popmessage("Read FDC status @ PC=%05x",cpu_get_pc(space->cpu)); |
| 516 | | tmp = status | 0x80; |
| 517 | | clr_status++; |
| 518 | | if(clr_status == 0x10) |
| 519 | | { |
| 520 | | status = 0; |
| 521 | | clr_status = 0; |
| 522 | | } |
| 523 | | return tmp; |
| 524 | | } |
| 525 | | |
| 526 | | static READ8_HANDLER( fdc765_data_r ) |
| 527 | | { |
| 528 | | status = (FDC_READ); |
| 529 | | return 0xc0; |
| 530 | | } |
| 531 | | |
| 532 | | static WRITE8_HANDLER( fdc765_data_w ) |
| 533 | | { |
| 534 | | status = (FDC_WRITE); |
| 535 | | } |
| 536 | | |
| 537 | | static UINT8 drive_data; |
| 538 | | |
| 539 | | static WRITE8_HANDLER( drive_selection_w ) |
| 540 | | { |
| 541 | | drive_data = data; |
| 542 | | /*write to this area then expects that location [43e] has the bit 7 activated*/ |
| 543 | | work_ram[0x3e] = 0x80; |
| 544 | | } |
| 545 | | |
| 546 | | /****************** |
| 547 | | DMA8237 Controller |
| 548 | | ******************/ |
| 549 | | |
| 550 | | static UINT8 dma_offset[2][4]; |
| 551 | | static UINT8 at_pages[0x10]; |
| 552 | | |
| 553 | | static DMA8237_MEM_READ( pc_dma_read_byte ) |
| 554 | | { |
| 555 | | const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 556 | | offs_t page_offset = (((offs_t) dma_offset[0][channel]) << 16) |
| 557 | | & 0xFF0000; |
| 558 | | |
| 559 | | return memory_read_byte(space, page_offset + offset); |
| 560 | | } |
| 561 | | |
| 562 | | |
| 563 | | static DMA8237_MEM_WRITE( pc_dma_write_byte ) |
| 564 | | { |
| 565 | | const address_space *space = cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 566 | | offs_t page_offset = (((offs_t) dma_offset[0][channel]) << 16) |
| 567 | | & 0xFF0000; |
| 568 | | |
| 569 | | memory_write_byte(space, page_offset + offset, data); |
| 570 | | } |
| 571 | | |
| 572 | | static READ8_HANDLER(dma_page_select_r) |
| 573 | | { |
| 574 | | UINT8 data = at_pages[offset % 0x10]; |
| 575 | | |
| 576 | | switch(offset % 8) { |
| 577 | | case 1: |
| 578 | | data = dma_offset[(offset / 8) & 1][2]; |
| 579 | | break; |
| 580 | | case 2: |
| 581 | | data = dma_offset[(offset / 8) & 1][3]; |
| 582 | | break; |
| 583 | | case 3: |
| 584 | | data = dma_offset[(offset / 8) & 1][1]; |
| 585 | | break; |
| 586 | | case 7: |
| 587 | | data = dma_offset[(offset / 8) & 1][0]; |
| 588 | | break; |
| 589 | | } |
| 590 | | return data; |
| 591 | | } |
| 592 | | |
| 593 | | |
| 594 | | static WRITE8_HANDLER(dma_page_select_w) |
| 595 | | { |
| 596 | | at_pages[offset % 0x10] = data; |
| 597 | | |
| 598 | | switch(offset % 8) { |
| 599 | | case 1: |
| 600 | | dma_offset[(offset / 8) & 1][2] = data; |
| 601 | | break; |
| 602 | | case 2: |
| 603 | | dma_offset[(offset / 8) & 1][3] = data; |
| 604 | | break; |
| 605 | | case 3: |
| 606 | | dma_offset[(offset / 8) & 1][1] = data; |
| 607 | | break; |
| 608 | | case 7: |
| 609 | | dma_offset[(offset / 8) & 1][0] = data; |
| 610 | | break; |
| 611 | | } |
| 612 | | } |
| 613 | | |
| 614 | | |
| 615 | | static const struct dma8237_interface dma8237_1_config = |
| 616 | | { |
| 617 | | "main", |
| 618 | | 1.0e-6, // 1us |
| 619 | | |
| 620 | | pc_dma_read_byte, |
| 621 | | pc_dma_write_byte, |
| 622 | | |
| 623 | | { 0, 0, NULL, NULL }, |
| 624 | | { 0, 0, NULL, NULL }, |
| 625 | | NULL |
| 626 | | }; |
| 627 | | |
| 628 | | /****************** |
| 629 | | 8259 IRQ controller |
| 630 | | ******************/ |
| 631 | | |
| 632 | | static PIC8259_SET_INT_LINE( pic8259_1_set_int_line ) { |
| 633 | | cpu_set_input_line(device->machine->cpu[0], 0, interrupt ? HOLD_LINE : CLEAR_LINE); |
| 634 | | } |
| 635 | | |
| 636 | | static const struct pic8259_interface pic8259_1_config = { |
| 637 | | pic8259_1_set_int_line |
| 638 | | }; |
| 639 | | |
| 640 | | static PIC8259_SET_INT_LINE( pic8259_2_set_int_line ) { |
| 641 | | pic8259_set_irq_line( filetto_devices.pic8259_1, 2, interrupt); |
| 642 | | } |
| 643 | | |
| 644 | | static const struct pic8259_interface pic8259_2_config = { |
| 645 | | pic8259_2_set_int_line |
| 646 | | }; |
| 647 | | |
| 648 | | static IRQ_CALLBACK(irq_callback) |
| 649 | | { |
| 650 | | int r = 0; |
| 651 | | r = pic8259_acknowledge(filetto_devices.pic8259_2); |
| 652 | | if (r==0) |
| 653 | | { |
| 654 | | r = pic8259_acknowledge(filetto_devices.pic8259_1); |
| 655 | | } |
| 656 | | return r; |
| 657 | | } |
| 658 | | |
| 659 | | static ADDRESS_MAP_START( filetto_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 660 | | AM_RANGE(0x00000, 0x003ff) AM_RAM //irq vectors |
| 661 | | AM_RANGE(0x00400, 0x007ff) AM_RAM AM_BASE(&work_ram) |
| 662 | | AM_RANGE(0x00800, 0x9ffff) AM_RAM //work RAM 640KB |
| 663 | | AM_RANGE(0xa0000, 0xbffff) AM_READWRITE(SMH_RAM,vga_vram_w) AM_BASE(&vga_vram)//VGA RAM |
| 664 | | AM_RANGE(0xc0000, 0xcffff) AM_READ(SMH_BANK1) |
| 665 | | AM_RANGE(0xf0000, 0xfffff) AM_ROM |
| 666 | | ADDRESS_MAP_END |
| 667 | | |
| 668 | | static ADDRESS_MAP_START( filetto_io, ADDRESS_SPACE_IO, 8 ) |
| 669 | | AM_RANGE(0x0000, 0x000f) AM_DEVREADWRITE(DMA8237, "dma8237_1", dma8237_r, dma8237_w ) //8237 DMA Controller |
| 670 | | AM_RANGE(0x0020, 0x002f) AM_DEVREADWRITE(PIC8259, "pic8259_1", pic8259_r, pic8259_w ) //8259 Interrupt control |
| 671 | | AM_RANGE(0x0040, 0x0043) AM_DEVREADWRITE(PIT8253, "pit8253", pit8253_r, pit8253_w) //8253 PIT |
| 672 | | AM_RANGE(0x0060, 0x0063) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w) //PPI 8255 |
| 673 | | AM_RANGE(0x0064, 0x0066) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w) //PPI 8255 |
| 674 | | AM_RANGE(0x0070, 0x007f) AM_READWRITE(mc146818_port_r,mc146818_port_w) |
| 675 | | AM_RANGE(0x0080, 0x0087) AM_READWRITE(dma_page_select_r,dma_page_select_w) |
| 676 | | AM_RANGE(0x00a0, 0x00af) AM_DEVREADWRITE(PIC8259, "pic8259_2", pic8259_r, pic8259_w ) |
| 677 | | // AM_RANGE(0x0200, 0x020f) AM_RAM //game port |
| 678 | | AM_RANGE(0x0201, 0x0201) AM_READ_PORT("COIN") //game port |
| 679 | | AM_RANGE(0x0278, 0x027f) AM_RAM //printer (parallel) port latch |
| 680 | | AM_RANGE(0x02f8, 0x02ff) AM_RAM //Modem port |
| 681 | | AM_RANGE(0x0310, 0x0311) AM_READWRITE(disk_iobank_r,disk_iobank_w) //Prototyping card |
| 682 | | AM_RANGE(0x0312, 0x0312) AM_READ_PORT("IN0") //Prototyping card,read only |
| 683 | | AM_RANGE(0x0378, 0x037f) AM_RAM //printer (parallel) port |
| 684 | | AM_RANGE(0x03bc, 0x03bf) AM_RAM //printer port |
| 685 | | AM_RANGE(0x03b4, 0x03b5) AM_READWRITE(vga_regs_r,vga_regs_w) //various VGA/CGA/EGA regs |
| 686 | | AM_RANGE(0x03d4, 0x03d5) AM_READWRITE(vga_regs_r,vga_regs_w) //mirror of above |
| 687 | | AM_RANGE(0x03d8, 0x03d9) AM_RAM AM_BASE(&vga_mode) |
| 688 | | AM_RANGE(0x03ba, 0x03bb) AM_READ(vga_hvretrace_r)//Controls H-Blank/V-Blank |
| 689 | | AM_RANGE(0x03da, 0x03db) AM_READ(vga_hvretrace_r)//mirror of above |
| 690 | | AM_RANGE(0x03f2, 0x03f2) AM_WRITE(drive_selection_w) |
| 691 | | AM_RANGE(0x03f4, 0x03f4) AM_READ(fdc765_status_r) //765 Floppy Disk Controller (FDC) Status |
| 692 | | AM_RANGE(0x03f5, 0x03f5) AM_READWRITE(fdc765_data_r,fdc765_data_w)//FDC Data |
| 693 | | AM_RANGE(0x03f8, 0x03ff) AM_RAM //rs232c (serial) port |
| 694 | | ADDRESS_MAP_END |
| 695 | | |
| 696 | | static INPUT_PORTS_START( filetto ) |
| 697 | | PORT_START("IN0") |
| 698 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_PLAYER(1) |
| 699 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_PLAYER(1) |
| 700 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_PLAYER(1) |
| 701 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) |
| 702 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_PLAYER(2) |
| 703 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_PLAYER(2) |
| 704 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_PLAYER(2) |
| 705 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) |
| 706 | | |
| 707 | | PORT_START("IN1") |
| 708 | | PORT_DIPNAME( 0x01, 0x01, DEF_STR( Coinage ) ) |
| 709 | | PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) ) |
| 710 | | PORT_DIPSETTING( 0x01, DEF_STR( 1C_1C ) ) |
| 711 | | PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) |
| 712 | | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) |
| 713 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 714 | | PORT_DIPNAME( 0x04, 0x04, "Extra Play" ) |
| 715 | | PORT_DIPSETTING( 0x04, DEF_STR( No ) ) |
| 716 | | PORT_DIPSETTING( 0x00, "Play at 6th match reached" ) |
| 717 | | PORT_DIPNAME( 0x08, 0x08, DEF_STR( Difficulty ) ) |
| 718 | | PORT_DIPSETTING( 0x00, DEF_STR( Normal ) ) |
| 719 | | PORT_DIPSETTING( 0x08, DEF_STR( Hard ) ) |
| 720 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 ) |
| 721 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 ) |
| 722 | | PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 723 | | |
| 724 | | PORT_START("COIN") |
| 725 | | PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 726 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 ) |
| 727 | | PORT_BIT( 0xe0, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 728 | | INPUT_PORTS_END |
| 729 | | |
| 730 | | static const gfx_layout dos_chars = |
| 731 | | { |
| 732 | | 8,16, |
| 733 | | 256, |
| 734 | | 1, |
| 735 | | { 0 }, |
| 736 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 737 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, |
| 738 | | (0x4000)+(0*8),(0x4000)+(1*8),(0x4000)+(2*8),(0x4000)+(3*8),(0x4000)+(4*8),(0x4000)+(5*8),(0x4000)+(6*8),(0x4000)+(7*8) }, |
| 739 | | 8*8 |
| 740 | | }; |
| 741 | | |
| 742 | | static const gfx_layout dos_chars2 = |
| 743 | | { |
| 744 | | 8,8, |
| 745 | | 256, |
| 746 | | 1, |
| 747 | | { 0 }, |
| 748 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 749 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 750 | | 8*8 |
| 751 | | }; |
| 752 | | |
| 753 | | static GFXDECODE_START( filetto ) |
| 754 | | GFXDECODE_ENTRY( "gfx1", 0x0000, dos_chars, 0, 16 ) |
| 755 | | GFXDECODE_ENTRY( "gfx1", 0x1000, dos_chars2, 0, 16 ) |
| 756 | | GFXDECODE_ENTRY( "gfx1", 0x1800, dos_chars2, 0, 16 ) |
| 757 | | GFXDECODE_END |
| 758 | | |
| 759 | | |
| 760 | | /* |
| 761 | | BLACK = 0 |
| 762 | | BLUE = 1 |
| 763 | | GREEN = 2 |
| 764 | | CYAN = 3 |
| 765 | | RED = 4 |
| 766 | | MAGENTA = 5 |
| 767 | | BROWN = 6 |
| 768 | | LIGHT GRAY = 7 |
| 769 | | */ |
| 770 | | |
| 771 | | static PALETTE_INIT(filetto) |
| 772 | | { |
| 773 | | /*Note:palette colors are 6bpp... |
| 774 | | xxxx xx-- |
| 775 | | */ |
| 776 | | int i; |
| 777 | | |
| 778 | | for(i=0;i<0x100;i++) |
| 779 | | palette_set_color(machine, i,MAKE_RGB(0x00,0x00,0x00)); |
| 780 | | |
| 781 | | palette_set_color(machine, 0+2,MAKE_RGB(0x00,0x00,0x00)); |
| 782 | | palette_set_color(machine, 1+2,MAKE_RGB(0x00,0x00,0x9f)); |
| 783 | | palette_set_color(machine, 3+2,MAKE_RGB(0x00,0x9f,0x00)); |
| 784 | | palette_set_color(machine, 5+2,MAKE_RGB(0x00,0x9f,0x9f)); |
| 785 | | palette_set_color(machine, 7+2,MAKE_RGB(0x9f,0x00,0x00)); |
| 786 | | palette_set_color(machine, 9+2,MAKE_RGB(0x9f,0x00,0x9f)); |
| 787 | | palette_set_color(machine, 11+2,MAKE_RGB(0x9f,0x9f,0x00)); |
| 788 | | palette_set_color(machine, 13+2,MAKE_RGB(0x9f,0x9f,0x9f)); |
| 789 | | palette_set_color(machine, 15+2,MAKE_RGB(0x3f,0x3f,0x3f)); |
| 790 | | palette_set_color(machine, 17+2,MAKE_RGB(0x3f,0x3f,0xff)); |
| 791 | | palette_set_color(machine, 19+2,MAKE_RGB(0x3f,0xff,0x3f)); |
| 792 | | palette_set_color(machine, 21+2,MAKE_RGB(0x3f,0xff,0xff)); |
| 793 | | palette_set_color(machine, 23+2,MAKE_RGB(0xff,0x3f,0x10)); |
| 794 | | palette_set_color(machine, 25+2,MAKE_RGB(0xff,0x3f,0xff)); |
| 795 | | palette_set_color(machine, 27+2,MAKE_RGB(0xff,0xff,0x3f)); |
| 796 | | palette_set_color(machine, 29+2,MAKE_RGB(0xff,0xff,0xff)); |
| 797 | | |
| 798 | | palette_set_color(machine, 0xf0,MAKE_RGB(0x00,0x00,0x00)); |
| 799 | | palette_set_color(machine, 0xf1,MAKE_RGB(0x00,0x00,0xaa)); |
| 800 | | palette_set_color(machine, 0xf2,MAKE_RGB(0x00,0xaa,0x00)); |
| 801 | | palette_set_color(machine, 0xf3,MAKE_RGB(0x00,0xaa,0xaa)); |
| 802 | | palette_set_color(machine, 0xf4,MAKE_RGB(0xaa,0x00,0x00)); |
| 803 | | palette_set_color(machine, 0xf5,MAKE_RGB(0xaa,0x00,0xaa)); |
| 804 | | palette_set_color(machine, 0xf6,MAKE_RGB(0xaa,0xaa,0x00)); |
| 805 | | palette_set_color(machine, 0xf7,MAKE_RGB(0xaa,0xaa,0xaa)); |
| 806 | | palette_set_color(machine, 0xf8,MAKE_RGB(0x55,0x55,0x55)); |
| 807 | | palette_set_color(machine, 0xf9,MAKE_RGB(0x55,0x55,0xff)); |
| 808 | | palette_set_color(machine, 0xfa,MAKE_RGB(0x55,0xff,0x55)); |
| 809 | | palette_set_color(machine, 0xfb,MAKE_RGB(0x55,0xff,0xff)); |
| 810 | | palette_set_color(machine, 0xfc,MAKE_RGB(0xff,0x55,0x55)); |
| 811 | | palette_set_color(machine, 0xfd,MAKE_RGB(0xff,0x55,0xff)); |
| 812 | | palette_set_color(machine, 0xfe,MAKE_RGB(0xff,0xff,0x55)); |
| 813 | | palette_set_color(machine, 0xff,MAKE_RGB(0xff,0xff,0xff)); |
| 814 | | } |
| 815 | | |
| 816 | | static MACHINE_RESET( filetto ) |
| 817 | | { |
| 818 | | bank = -1; |
| 819 | | lastvalue = -1; |
| 820 | | hv_blank = 0; |
| 821 | | cpu_set_irq_callback(machine->cpu[0], irq_callback); |
| 822 | | filetto_devices.pit8253 = device_list_find_by_tag( machine->config->devicelist, PIT8253, "pit8253" ); |
| 823 | | filetto_devices.pic8259_1 = device_list_find_by_tag( machine->config->devicelist, PIC8259, "pic8259_1" ); |
| 824 | | filetto_devices.pic8259_2 = device_list_find_by_tag( machine->config->devicelist, PIC8259, "pic8259_2" ); |
| 825 | | filetto_devices.dma8237_1 = device_list_find_by_tag( machine->config->devicelist, DMA8237, "dma8237_1" ); |
| 826 | | filetto_devices.dma8237_2 = device_list_find_by_tag( machine->config->devicelist, DMA8237, "dma8237_2" ); |
| 827 | | } |
| 828 | | |
| 829 | | static MACHINE_DRIVER_START( filetto ) |
| 830 | | MDRV_CPU_ADD("main", I8088, 8000000) |
| 831 | | MDRV_CPU_PROGRAM_MAP(filetto_map,0) |
| 832 | | MDRV_CPU_IO_MAP(filetto_io,0) |
| 833 | | |
| 834 | | MDRV_MACHINE_RESET( filetto ) |
| 835 | | |
| 836 | | MDRV_PIT8253_ADD( "pit8253", pc_pit8253_config ) |
| 837 | | |
| 838 | | MDRV_PPI8255_ADD( "ppi8255_0", filetto_ppi8255_intf[0] ) |
| 839 | | MDRV_PPI8255_ADD( "ppi8255_1", filetto_ppi8255_intf[1] ) |
| 840 | | |
| 841 | | MDRV_DMA8237_ADD( "dma8237_1", dma8237_1_config ) |
| 842 | | |
| 843 | | MDRV_PIC8259_ADD( "pic8259_1", pic8259_1_config ) |
| 844 | | |
| 845 | | MDRV_PIC8259_ADD( "pic8259_2", pic8259_2_config ) |
| 846 | | |
| 847 | | MDRV_GFXDECODE(filetto) |
| 848 | | |
| 849 | | MDRV_SCREEN_ADD("main", RASTER) |
| 850 | | MDRV_SCREEN_REFRESH_RATE(60) |
| 851 | | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) |
| 852 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 853 | | MDRV_SCREEN_SIZE(640, 480) |
| 854 | | MDRV_SCREEN_VISIBLE_AREA(0*8, 640-1, 0*8, 480-1) |
| 855 | | |
| 856 | | MDRV_PALETTE_LENGTH(0x100) |
| 857 | | |
| 858 | | MDRV_PALETTE_INIT(filetto) |
| 859 | | |
| 860 | | MDRV_VIDEO_START(filetto) |
| 861 | | MDRV_VIDEO_UPDATE(filetto) |
| 862 | | |
| 863 | | /*Sound Hardware*/ |
| 864 | | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 865 | | |
| 866 | | MDRV_SOUND_ADD("voice", HC55516, 8000000/4)//8923S-UM5100 is a HC55536 with ROM hook-up |
| 867 | | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) |
| 868 | | |
| 869 | | // PC "buzzer" sound |
| 870 | | MACHINE_DRIVER_END |
| 871 | | |
| 872 | | |
| 873 | | ROM_START( filetto ) |
| 874 | | ROM_REGION( 0x100000, "main", 0 ) |
| 875 | | ROM_LOAD("u49.bin", 0xfc000, 0x2000, CRC(1be6948a) SHA1(9c433f63d347c211ee4663f133e8417221bc4bf0)) |
| 876 | | ROM_RELOAD( 0xf8000, 0x2000 ) |
| 877 | | ROM_RELOAD( 0xf4000, 0x2000 ) |
| 878 | | ROM_RELOAD( 0xf0000, 0x2000 ) |
| 879 | | ROM_LOAD("u55.bin", 0xfe000, 0x2000, CRC(1e455ed7) SHA1(786d18ce0ab1af45fc538a2300853e497488f0d4) ) |
| 880 | | ROM_RELOAD( 0xfa000, 0x2000 ) |
| 881 | | ROM_RELOAD( 0xf6000, 0x2000 ) |
| 882 | | ROM_RELOAD( 0xf2000, 0x2000 ) |
| 883 | | |
| 884 | | ROM_REGION( 0x40000, "user1", 0 ) // program data |
| 885 | | ROM_LOAD( "m0.u1", 0x00000, 0x10000, CRC(2408289d) SHA1(eafc144a557a79b58bcb48545cb9c9778e61fcd3) ) |
| 886 | | ROM_LOAD( "m1.u2", 0x10000, 0x10000, CRC(5b623114) SHA1(0d9a14e6b7f57ce4fa09762343b610a973910f58) ) |
| 887 | | ROM_LOAD( "m2.u3", 0x20000, 0x10000, CRC(abc64869) SHA1(564fc9d90d241a7b7776160b3fd036fb08037355) ) |
| 888 | | ROM_LOAD( "m3.u4", 0x30000, 0x10000, CRC(0c1e8a67) SHA1(f1b9280c65fcfcb5ec481cae48eb6f52d6cdbc9d) ) |
| 889 | | |
| 890 | | ROM_REGION( 0x2000, "gfx1", ROMREGION_DISPOSE ) |
| 891 | | ROM_LOAD("u67.bin", 0x0000, 0x2000, CRC(09710122) SHA1(de84bdd9245df287bbd3bb808f0c3531d13a3545) ) |
| 892 | | |
| 893 | | ROM_REGION( 0x40000, "user2", ROMREGION_DISPOSE ) // UM5100 sample roms? |
| 894 | | ROM_LOAD16_BYTE("v1.u15", 0x00000, 0x20000, CRC(613ddd07) SHA1(ebda3d559315879819cb7034b5696f8e7861fe42) ) |
| 895 | | ROM_LOAD16_BYTE("v2.u14", 0x00001, 0x20000, CRC(427e012e) SHA1(50514a6307e63078fe7444a96e39d834684db7df) ) |
| 896 | | ROM_END |
| 897 | | |
| 898 | | static DRIVER_INIT( filetto ) |
| 899 | | { |
| 900 | | //... |
| 901 | | } |
| 902 | | |
| 903 | | GAME( 1990, filetto, 0, filetto, filetto, filetto, ROT0, "Novarmatic", "Filetto (v1.05 901009)",GAME_NO_SOUND | GAME_IMPERFECT_COLORS) |
| 904 | | |
src/mame/drivers/smstrv.c
| r4149 | r4150 | |
| 1 | | /* |
| 2 | | SMS Manufacturing PCB Driver |
| 3 | | By Reip |
| 4 | | |
| 5 | | |
| 6 | | smstrv (Reip): |
| 7 | | Triva looking board |
| 8 | | Silk screened on front... |
| 9 | | P/N 1001 |
| 10 | | Etched in copper on font... |
| 11 | | COMPONENT SIDE REV 02 |
| 12 | | Etched in copper on back... |
| 13 | | COPYRIGHT SMS 1983 S/N MADE IN USA |
| 14 | | mfg corp |
| 15 | | |
| 16 | | Serial number A4675 etched in board |
| 17 | | |
| 18 | | Large chips |
| 19 | | P8088 |
| 20 | | AY-3-8910 |
| 21 | | CDM6116 x2 |
| 22 | | P8255A-5 |
| 23 | | P8254 |
| 24 | | D8255AC-5 |
| 25 | | D780C-1 (Z80A) |
| 26 | | |
| 27 | | 16 Mhz crystal by D780C (U21) |
| 28 | | 24 Mhz crystal by P8088 (u53) |
| 29 | | |
| 30 | | Open sockets at U50 (40 pin), U15 (24 pin), U2 (40 pin), U25 (24 pin) |
| 31 | | |
| 32 | | Bottom Board |
| 33 | | .U17 - 27128 |
| 34 | | .U16 - 27128 |
| 35 | | .U26 - 2732 - stickered #26 073184 |
| 36 | | .U38 - DMPAL10L8NC - 3 blue dots on it - saved in jedec format |
| 37 | | .U39 - DMPAL10L8NC - 3 green dots on it - saved in jedec format |
| 38 | | .U40 - DMPAL10L8NC - 1 pink dot on it - saved in jedec format |
| 39 | | .U110 - DMPAL10L8NC - 2 pink dots on it - saved in jedec format |
| 40 | | .U52 - DMPAL10L8NC - not labeled - checksum was 0 |
| 41 | | .U32 - DMPAL10L8NC - stickered trivia U32 - couldn't read "device overcurrent" |
| 42 | | .U58 - DMPAL10H8NC - 3 brown dots on it - saved in jedec format |
| 43 | | .U80 - DMPAL10H8NC - 2 blue dots on it - saved in jedec format |
| 44 | | .U130 - DMPAL10H8NC - 3 pink dots on it - saved in jedec format |
| 45 | | .U129 - DMPAL10H8NC - pink-green-pink dots on it - saved in jedec format |
| 46 | | .U128 - DMPAL10H8NC - blue-brown-blue dots on it - saved in jedec format |
| 47 | | .U145 - DMPAL14H4NC - brown dot on it - saved in jedec format |
| 48 | | .U144 - DMPAL14H4NC - brown dot on it - saved in jedec format |
| 49 | | .U143 - DMPAL14H4NC - brown dot on it - saved in jedec format |
| 50 | | .U142 - DMPAL14H4NC - brown dot on it - saved in jedec format |
| 51 | | .U141 - DMPAL14H4NC - brown dot on it - saved in jedec format |
| 52 | | .U140 - DMPAL14H4NC - brown dot on it - saved in jedec format |
| 53 | | U.145-U.140 had the same checksum |
| 54 | | |
| 55 | | .U94 - DMPAL14H4NC - 2 green dots on it - saved in jedec format |
| 56 | | .U109 - DMPAL14H4NC - 2 brown dots on it - saved in jedec format |
| 57 | | |
| 58 | | Daughter Board |
| 59 | | Etched in copper on top... |
| 60 | | SMS MFG M?I 2685 ? = a cage looking symbol |
| 61 | | |
| 62 | | Read starting at top row, closest to connector to main board |
| 63 | | .D0 - DMPAL10L8NC - 1 orange dot on it - saved in jedec format |
| 64 | | .D1 - 27128 - couldn't read sticker - |
| 65 | | .D2 - 27128 - couldn't read sticker - |
| 66 | | .D3 - 27128 - couldn't read sticker - |
| 67 | | .D4 - 27128 - stickered 4 MOVIES .1 ?2485 ? = can't read |
| 68 | | .D5 - 27128 - stickered 3 ANYTHING .4 042485 |
| 69 | | .D6 - 27128 - stickered 2 ANYTHING .3 042485 |
| 70 | | .D7 - 27128 - stickered 1 ANYTHING .2 042485 |
| 71 | | .D8 - 27128 - stickered 0 ANYTHING .1 042485 |
| 72 | | |
| 73 | | 2nd row - left to right |
| 74 | | .D9 - 27128 - stickered 12 MUSIC .1 042485 |
| 75 | | .D10 - 27128 - stickered 13 MUSIC .1 042485 |
| 76 | | .D11 - 27128 - stickered 14 MUSIC .1 042485 |
| 77 | | .D12 - 27128 - stickered 15 MUSIC .1 042485 |
| 78 | | |
| 79 | | 3rd row - left to right |
| 80 | | .D13 - 27128 - stickered 11 SPORTS .4 042485 |
| 81 | | .D14 - 27128 - stickered 10 SPORTS .3 042485 |
| 82 | | .D15 - 27128 - stickered 9 SPORTS .2 042485 |
| 83 | | .D16 - 27128 - stickered 8 SPORTS .1 042485 |
| 84 | | .D17 - DMPAL10L8NC - 1 white dot on it - saved in jedec format |
| 85 | | |
| 86 | | |
| 87 | | ROM text showed... |
| 88 | | COPYRIGHT 1984 SMS MFG CORP |
| 89 | | TRIVIA HANGUP |
| 90 | | SMART ALECS |
| 91 | | |
| 92 | | |
| 93 | | |
| 94 | | |
| 95 | | smssshot (Lord Nightmare) |
| 96 | | SMS Sure Shot (poker?) |
| 97 | | * Same exact board as sms trivia, but "COMPONENT SIDE REV 01" |
| 98 | | instead of rev 02. |
| 99 | | * 3 chips were removed from the board; two are shown as removed |
| 100 | | in the schematic, one was removed later (an apparently |
| 101 | | unnecessary data buffer on one of the z80 external latches) |
| 102 | | * Does NOT have a daughterboard with additional roms; in fact, |
| 103 | | connector J1 for the ribbon cable to the daughterboard isn't |
| 104 | | populated with pins at all |
| 105 | | * Serial Number A-108 etched in board, on back. |
| 106 | | |
| 107 | | |
| 108 | | smsbingo (Lord Nightmare) |
| 109 | | SMS Bingo |
| 110 | | Someone on the MW forums has this iirc, but it isn't dumped yet - LN |
| 111 | | |
| 112 | | |
| 113 | | |
| 114 | | **** Notes from schematics (applies to all drivers): |
| 115 | | Framebuffer is six tms4416 16384*4 chips; chips are arranged as three |
| 116 | | planes of 16384*8 bits per plane, one plane per color channel. |
| 117 | | Screen resolution is probably either 212x256 (two bits per plane, per |
| 118 | | pixel) or 424x256 (one bit per plane per pixel), depending on the pals |
| 119 | | installed. See schematics on page 6. The counters at U137 and U139 |
| 120 | | compare against binary 0b110101 (53) in comparitor at U138, and as soon |
| 121 | | as it hits that, HDONE is pulled high on the next MCLR clock. |
| 122 | | This means there will be 53 (0-52) counts in the X counter before HDONE; |
| 123 | | as each count refers to one 8 bit address, and the addressed 4416 rams |
| 124 | | have between all of them 24 bits of output (8 per plane), the minimum |
| 125 | | horizontal displayed resolution is 53x256 (8 bits per color per pixel), |
| 126 | | and maximum is 8 times that. With proper pals (and proper mixing |
| 127 | | resistors or other PWM fun) it should be possible to get: |
| 128 | | 53x256 8,8,8 RGB |
| 129 | | 106x256 4,4,4 RGB |
| 130 | | 212x256 2,2,2 RGB <- this seems the most likely to me (LN) |
| 131 | | 424x256 1,1,1 RGB |
| 132 | | |
| 133 | | |
| 134 | | * The socket at U50 and the 3 pin connector J3 is for an |
| 135 | | undumped intel 8050 MCU used for rs232 serial communication, |
| 136 | | for either linking together machines, or more likely for factory |
| 137 | | testing. The function of this internal rom is probably simple |
| 138 | | enough to HLE or to even rewrite from scratch, but I doubt the code |
| 139 | | on any of the dumped games even touches it, it was probably for use |
| 140 | | with a specific game or for a set of hardware test roms to report |
| 141 | | errors. |
| 142 | | (schematic page 4) |
| 143 | | The pinout of J3 is: |
| 144 | | pin 1 (toward bottom of pcb): rs232 input to pcb |
| 145 | | (pre-level shifted to 5v i.e. with a max232 or mc1489) |
| 146 | | pin 2 : ground |
| 147 | | pin 3 : rs232 output to elsewhere (to be sent to a max232 or |
| 148 | | mc1488 to shift to rs232 voltage levels) |
| 149 | | |
| 150 | | * The 8255 PPI at U13 (connected to the 8088) is connected to 75451 |
| 151 | | drivers on all pins EXCEPT pins PC3 thru PC0. |
| 152 | | (schematic page 3) |
| 153 | | PA7 - Display Light 1 |
| 154 | | PA6 - Display Light 2 |
| 155 | | PA5 - Display Light 3 |
| 156 | | PA4 - Display Light 4 |
| 157 | | PA3 - Display Light 5 |
| 158 | | PA2 - Bet Light |
| 159 | | PA1 - Deal Light |
| 160 | | PA0 - Draw Light |
| 161 | | PB7 - Stand Light |
| 162 | | PB6 - Cancel Light |
| 163 | | PB5 - Coin Lock out A |
| 164 | | PB4 - Coin Lock out B |
| 165 | | PB3 - Setup Light |
| 166 | | PB2 - Hopper Motor |
| 167 | | PB1 - Coin in Counter (mechanical counter inside the machine) |
| 168 | | PB0 - Knock off Counter (tilt? probably also a mechanical counter) |
| 169 | | PC7 - unused |
| 170 | | PC6 - unused |
| 171 | | PC5 - unused |
| 172 | | PC4 - Battery Charge control (for 8088 ram backup 3.6v Nicad) |
| 173 | | PC3 - (pulled high externally, input) - unused? possibly for an ABC hopper |
| 174 | | PC2 - (pulled high externally, input) - unused? possibly for an ABC hopper |
| 175 | | PC1 - (pulled high externally, input) - "Hopper Count", |
| 176 | | probably a beam to check the hopper coin out |
| 177 | | PC0 - "Video BZ" (Video Blanking Zone, is an input) |
| 178 | | |
| 179 | | * The 8255 PPI at U2 (connected to the z80) is unused and not populated. |
| 180 | | (All 3 ports have +5V pullups on all pins) |
| 181 | | |
| 182 | | * The 8255 PPI at U1 (connected to the z80) is used as follows: |
| 183 | | (All 3 ports have +5V pullups on all pins) |
| 184 | | PA7 - Lighted Button 1 (input) |
| 185 | | PA6 - Lighted Button 2 (input) |
| 186 | | PA5 - Lighted Button 3 (input) |
| 187 | | PA4 - Lighted Button 4 (input) |
| 188 | | PA3 - Lighted Button 5 (input) |
| 189 | | PA2 - Bet Button (input) |
| 190 | | PA1 - Deal Button (input) |
| 191 | | PA0 - Draw Button (input) |
| 192 | | PB7 - Stand Button (input) |
| 193 | | PB6 - Cancel Button (input) |
| 194 | | PB5 - Alt Coin (input) |
| 195 | | PB4 - Remote Knockoff (tilt? input) |
| 196 | | PB3 - Operator Mode (input) |
| 197 | | PB2 - Coin Error reset (input) |
| 198 | | PB1 - unused |
| 199 | | PB0 - unused |
| 200 | | PC7 - unused |
| 201 | | PC6 - unused |
| 202 | | PC5 - unused |
| 203 | | PC4 - unused |
| 204 | | PC3 - unused |
| 205 | | PC2 - unused |
| 206 | | PC1 - unused |
| 207 | | PC0 - Coin (input) |
| 208 | | |
| 209 | | |
| 210 | | * The function of the pals is: |
| 211 | | LOCATION DOTS TYPE PURPOSE |
| 212 | | U32 1Green DMPAL10L8NC Decodes the gated by U33/U34) |
| 213 | | high address lines of the 8088, for mainboard ROM mapping. A |
| 214 | | different pal is probably used depending on whether the |
| 215 | | mainboard has 2764 or 27128 roms installed. |
| 216 | | SMS Sure Shot: dumped ok as truth table, mainboard has 4 2764s |
| 217 | | SMS Trivia: bad (chip shorted internally), mainboard has 2 27128s |
| 218 | | SMS Bingo: not dumped |
| 219 | | (schematic page 2) |
| 220 | | U38 3Blue PAL10L8CN Decodes the (gated by U36) |
| 221 | | high address lines of the z80 address bus, for mapping of the z80 |
| 222 | | ROM, RAM, Counter control, 4 z80-to-8088 ports (2 one direction, |
| 223 | | 2 the other), the ay-3-8910, and the two 8255 PPIs. |
| 224 | | (schematic page 10) |
| 225 | | U39 3Green PAL10L8CN Accessory decoder to U38, helps |
| 226 | | with the 4 z80-to-8088 ports. |
| 227 | | (schematic page 10) |
| 228 | | U40 1Red PAL10L8CN Connects to the low bits of the |
| 229 | | 8088 address bus for decoding writing to/reading from the 8088 side of |
| 230 | | the 4 z80-to-8088 ports. |
| 231 | | (schematic page 10, note this chip is mismarked as U9 on the page, |
| 232 | | it is the chip in the lower left) |
| 233 | | U52 1Blue PAL10L8CN Decodes the (gated by U33/U34) |
| 234 | | high address lines of the 8088, for main memory mapping of ram, |
| 235 | | z80 communication, video, serial I/O (to U50), and the output-only |
| 236 | | 8255 at U13 (which controls button lights and the coin hopper) |
| 237 | | SMS Sure Shot: dumped ok as truth table |
| 238 | | SMS Trivia: checksum 0, probably bad |
| 239 | | SMS Bingo: not dumped |
| 240 | | (schematic page 1) |
| 241 | | U58 3Brown DMPAL10H8NC Controls BDIR and BC1 on the |
| 242 | | ay-3-8910 given the low two address bits of the z80 bits, the |
| 243 | | ay-3-8910 enable line, and the buffered z80 RD and WR lines. |
| 244 | | (schematic page 12) |
| 245 | | U80 2Blue PAL10H8CN State machine which controls StartH, |
| 246 | | StartV, and the related functions involving the shifters for framebuffer |
| 247 | | address and framebuffer output. Also lets framebuffer know when in hblank |
| 248 | | or vblank. Is separate from the other "Video BZ" thing. |
| 249 | | (schematic page 6) |
| 250 | | U94 2Green PAL14H4CN State machine controls the |
| 251 | | read-modify-write logic for accessing the frame buffer (while outside |
| 252 | | of vblank and hblank?), may allow writing red green and blue plane bytes |
| 253 | | all to one address, one after the other |
| 254 | | (schematic page 7) |
| 255 | | U109 2Brown PAL14H4CN Determines next state of the |
| 256 | | 'Pixel control' hardware, i.e. H and V current line counters |
| 257 | | Also determines VBLANK/"Video BZ" |
| 258 | | (schematic page 5) |
| 259 | | U110 2Red PAL10L8CN Translates output of U109 |
| 260 | | before being sent to counters/color reg latch/etc. |
| 261 | | (schematic page 5) |
| 262 | | U128 Blue-Brown-Blue PAL10H8CN One of three 'sync' pals which |
| 263 | | control the memory and other timing subsystem, fed by a 4 bit counter. |
| 264 | | this particular pal has one external feedback bit. |
| 265 | | (schematic page 6) |
| 266 | | U129 Red-Green-Red DMPAL10H8NC Second of three 'sync' pals |
| 267 | | This one has 2 external feedback bits. |
| 268 | | (schematic page 6) |
| 269 | | U130 3Red PAL10H8CN Third of three 'sync' pals' |
| 270 | | This one has 3 external feedback bits plus three extra inputs from elsewhere |
| 271 | | which are not readable on the schematic. Will trace them later. |
| 272 | | (schematic page 6) |
| 273 | | U140 1Brown PAL14H4CN This and the next 5 pals are used |
| 274 | | to shift the framebuffer data, 4 bits at a time. This is done in parallel |
| 275 | | (8 bits per channel) for output. all 6 pals are the same. |
| 276 | | (schematic page 7) |
| 277 | | U141 1Brown PAL14H4CN |
| 278 | | U142 1Brown PAL14H4CN |
| 279 | | U143 1Brown PAL14H4CN |
| 280 | | U144 1Brown PAL14H4CN |
| 281 | | U145 1Brown PAL14H4CN |
| 282 | | |
| 283 | | |
| 284 | | |
| 285 | | */ |
| 286 | | |
| 287 | | #include "driver.h" |
| 288 | | #include "cpu/i86/i86.h" |
| 289 | | #include "sound/ay8910.h" |
| 290 | | #include "machine/8255ppi.h" |
| 291 | | |
| 292 | | INPUT_PORTS_EXTERN(ettrivia); |
| 293 | | |
| 294 | | |
| 295 | | static READ8_DEVICE_HANDLER( r1 ) |
| 296 | | { |
| 297 | | int pc = cpu_get_pc(device->machine->cpu[0]); |
| 298 | | if(pc != 0x81cb) |
| 299 | | printf("r1 @ %X\n",pc); |
| 300 | | return mame_rand(device->machine); |
| 301 | | } |
| 302 | | static READ8_DEVICE_HANDLER( r2 ) |
| 303 | | { |
| 304 | | int pc = cpu_get_pc(device->machine->cpu[0]); |
| 305 | | if(pc != 0x81cb) |
| 306 | | printf("r2 @ %X\n",pc); |
| 307 | | return mame_rand(device->machine); |
| 308 | | } |
| 309 | | static READ8_DEVICE_HANDLER( r3 ) |
| 310 | | { |
| 311 | | int pc = cpu_get_pc(device->machine->cpu[0]); |
| 312 | | if(pc != 0x81cb && pc != 0x90fa && pc != 0x911b && pc != 0x90d3 && pc != 0x90c4) |
| 313 | | printf("r3 @ %X\n",pc); |
| 314 | | return mame_rand(device->machine) & ~1; //with 1 jumps back (infinite loop): a status ready for something? |
| 315 | | } |
| 316 | | static READ8_DEVICE_HANDLER( r4 ) |
| 317 | | { |
| 318 | | int pc = cpu_get_pc(device->machine->cpu[0]); |
| 319 | | if(pc != 0x81cb) |
| 320 | | printf("r4 @ %X\n",pc); |
| 321 | | return mame_rand(device->machine); |
| 322 | | } |
| 323 | | static READ8_DEVICE_HANDLER( r5 ) |
| 324 | | { |
| 325 | | int pc = cpu_get_pc(device->machine->cpu[0]); |
| 326 | | if(pc != 0x81cb) |
| 327 | | printf("r5 @ %X\n",pc); |
| 328 | | return mame_rand(device->machine); |
| 329 | | } |
| 330 | | static READ8_DEVICE_HANDLER( r6 ) |
| 331 | | { |
| 332 | | int pc = cpu_get_pc(device->machine->cpu[0]); |
| 333 | | if(pc != 0x81cb) |
| 334 | | printf("r6 @ %X\n",pc); |
| 335 | | |
| 336 | | return mame_rand(device->machine); |
| 337 | | } |
| 338 | | |
| 339 | | static WRITE8_DEVICE_HANDLER( w1 ) |
| 340 | | { |
| 341 | | /* |
| 342 | | static int old = 0; |
| 343 | | if(data != old) |
| 344 | | printf("w1 = %02X\n",old=data); |
| 345 | | */ |
| 346 | | } |
| 347 | | static WRITE8_DEVICE_HANDLER( w2 ) |
| 348 | | { |
| 349 | | /* |
| 350 | | static int old = 0; |
| 351 | | if(data != old) |
| 352 | | printf("w2 = %02X\n",old=data); |
| 353 | | */ |
| 354 | | } |
| 355 | | static WRITE8_DEVICE_HANDLER( w3 ) |
| 356 | | { |
| 357 | | /* |
| 358 | | static int old = 0; |
| 359 | | if(data != old) |
| 360 | | printf("w3 = %02X\n",old=data); |
| 361 | | */ |
| 362 | | } |
| 363 | | static WRITE8_DEVICE_HANDLER( w4 ) |
| 364 | | { |
| 365 | | /* |
| 366 | | static int old = 0; |
| 367 | | if(data != old) |
| 368 | | printf("w4 = %02X\n",old=data); |
| 369 | | */ |
| 370 | | } |
| 371 | | static WRITE8_DEVICE_HANDLER( w5 ) |
| 372 | | { |
| 373 | | /* |
| 374 | | static int old = 0; |
| 375 | | if(data != old) |
| 376 | | printf("w5 = %02X\n",old=data); |
| 377 | | */ |
| 378 | | } |
| 379 | | static WRITE8_DEVICE_HANDLER( w6 ) |
| 380 | | { |
| 381 | | /* |
| 382 | | static int old = 0; |
| 383 | | if(data != old) |
| 384 | | printf("w6 = %02X\n",old=data); |
| 385 | | */ |
| 386 | | } |
| 387 | | |
| 388 | | static ADDRESS_MAP_START( smstrv_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 389 | | AM_RANGE(0x00000, 0x007ff) AM_RAM |
| 390 | | AM_RANGE(0x00800, 0x00803) AM_DEVREADWRITE(PPI8255, "ppi8255_0", ppi8255_r, ppi8255_w) |
| 391 | | AM_RANGE(0x01000, 0x01005) AM_RAM |
| 392 | | AM_RANGE(0x01800, 0x01803) AM_DEVREADWRITE(PPI8255, "ppi8255_1", ppi8255_r, ppi8255_w) |
| 393 | | AM_RANGE(0x08000, 0x0ffff) AM_ROM |
| 394 | | AM_RANGE(0xf8000, 0xfffff) AM_ROM // mirror for vectors |
| 395 | | ADDRESS_MAP_END |
| 396 | | |
| 397 | | |
| 398 | | static VIDEO_START( smstrv ) |
| 399 | | { |
| 400 | | } |
| 401 | | |
| 402 | | static VIDEO_UPDATE( smstrv ) |
| 403 | | { |
| 404 | | return 0; |
| 405 | | } |
| 406 | | |
| 407 | | static const ppi8255_interface ppi8255_intf[2] = |
| 408 | | { |
| 409 | | { |
| 410 | | r1, /* Port A read */ |
| 411 | | r2, /* Port B read */ |
| 412 | | r3, /* Port C read */ |
| 413 | | w1, /* Port A write */ |
| 414 | | w2, /* Port B write */ |
| 415 | | w3 /* Port C write */ |
| 416 | | }, |
| 417 | | { |
| 418 | | r4, /* Port A read */ |
| 419 | | r5, /* Port B read */ |
| 420 | | r6, /* Port C read */ |
| 421 | | w4, /* Port A write */ |
| 422 | | w5, /* Port B write */ |
| 423 | | w6 /* Port C write */ |
| 424 | | } |
| 425 | | }; |
| 426 | | |
| 427 | | |
| 428 | | static MACHINE_DRIVER_START( smstrv ) |
| 429 | | MDRV_CPU_ADD("main", I8088,24000000/2) |
| 430 | | MDRV_CPU_PROGRAM_MAP(smstrv_map,0) |
| 431 | | // MDRV_CPU_IO_MAP(io_map,0) |
| 432 | | MDRV_CPU_VBLANK_INT("main", nmi_line_pulse) |
| 433 | | |
| 434 | | // MDRV_NVRAM_HANDLER(generic_0fill) |
| 435 | | |
| 436 | | MDRV_PPI8255_ADD( "ppi8255_0", ppi8255_intf[0] ) |
| 437 | | MDRV_PPI8255_ADD( "ppi8255_1", ppi8255_intf[1] ) |
| 438 | | |
| 439 | | /* video hardware */ |
| 440 | | MDRV_SCREEN_ADD("main", RASTER) |
| 441 | | MDRV_SCREEN_REFRESH_RATE(60) |
| 442 | | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) |
| 443 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 444 | | MDRV_SCREEN_SIZE(256, 256) |
| 445 | | MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1) |
| 446 | | |
| 447 | | MDRV_PALETTE_LENGTH(256) |
| 448 | | |
| 449 | | // MDRV_PALETTE_INIT(naughtyb) |
| 450 | | MDRV_VIDEO_START(smstrv) |
| 451 | | MDRV_VIDEO_UPDATE(smstrv) |
| 452 | | |
| 453 | | /* sound hardware */ |
| 454 | | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 455 | | |
| 456 | | MDRV_SOUND_ADD("ay", AY8910, 1500000) |
| 457 | | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 458 | | MACHINE_DRIVER_END |
| 459 | | |
| 460 | | ROM_START( smstrv ) |
| 461 | | ROM_REGION( 0x100000, "main", 0 ) |
| 462 | | ROM_LOAD( "sms.17", 0xf8000, 0x04000, CRC(af6ef980) SHA1(f0f98d1f91de718a63b87c5f1c6ee3bd854d1c1b) ) |
| 463 | | ROM_LOAD( "sms.16", 0xfc000, 0x04000, CRC(b827d883) SHA1(68d6c2127ef9e537471c414ca7baa89c63997bbb) ) |
| 464 | | ROM_COPY( "main", 0xf8000, 0x08000, 0x8000 ) |
| 465 | | |
| 466 | | ROM_REGION( 0x10000, "cpu1", 0 ) |
| 467 | | ROM_LOAD( "sms.26", 0x0000, 0x1000, CRC(e04bb922) SHA1(1df90720f11a5b736273f43272d7727b3020f848) ) |
| 468 | | |
| 469 | | ROM_REGION( 0x4000, "user1", 0 ) |
| 470 | | ROM_LOAD( "sms.d1", 0x000000, 0x4000, CRC(04f627c0) SHA1(c656b66c60059a1b068c4a7262f07f4c136c34c1) ) |
| 471 | | ROM_LOAD( "sms.d2", 0x000000, 0x4000, CRC(13c9fe08) SHA1(6b7d055621ce578446d320f98f7a4cd095e756b0) ) |
| 472 | | ROM_LOAD( "sms.d3", 0x000000, 0x4000, CRC(8c5f62ef) SHA1(34ac235358a71620a6619dbb16255c363f34df53) ) |
| 473 | | ROM_LOAD( "sms.d4", 0x000000, 0x4000, CRC(76993bd1) SHA1(b9a97ab7c6d35f5fdda04342e0b3773618deedef) ) |
| 474 | | ROM_LOAD( "sms.d5", 0x000000, 0x4000, CRC(f1a37ed7) SHA1(687a610319b21091cbc53232b47eb99dabe12f02) ) |
| 475 | | ROM_LOAD( "sms.d6", 0x000000, 0x4000, CRC(5b12fd09) SHA1(15804480e65bfb3207d24a1679bb78d1ad491d70) ) |
| 476 | | ROM_LOAD( "sms.d7", 0x000000, 0x4000, CRC(d09946b6) SHA1(b5827945ce380f09ee758c4296f06f00ef3cbd0a) ) |
| 477 | | ROM_LOAD( "sms.d8", 0x000000, 0x4000, CRC(80096807) SHA1(a38b1b13365577c0c588b8e196ee1a6c774ce3a3) ) |
| 478 | | ROM_LOAD( "sms.d9", 0x000000, 0x4000, CRC(c1691ec9) SHA1(95725fa315944c0786e2a32d483703173eb2e730) ) |
| 479 | | ROM_LOAD( "sms.d10", 0x000000, 0x4000, CRC(df0da39f) SHA1(29103dca8b0c1967791e8ddd722153874e16bbda) ) |
| 480 | | ROM_LOAD( "sms.d11", 0x000000, 0x4000, CRC(114b4aa6) SHA1(2621d1042b0774d60be88cc8d62613aa07c12552) ) |
| 481 | | ROM_LOAD( "sms.d12", 0x000000, 0x4000, CRC(59a40e4f) SHA1(e726ce624c76ee527edc51c1e5757b7d433dcf8c) ) |
| 482 | | ROM_LOAD( "sms.d13", 0x000000, 0x4000, CRC(9bb8dbad) SHA1(0dd9ed23e6794a86a12906b326e984a2d58cc4c6) ) |
| 483 | | ROM_LOAD( "sms.d14", 0x000000, 0x4000, CRC(3bfe9b52) SHA1(0cdd9ec6ed784fab9272d50821994be5b0fd0532) ) |
| 484 | | ROM_LOAD( "sms.d15", 0x000000, 0x4000, CRC(bec225fe) SHA1(13252894eca30e06354885a21ecad43965cfd3ef) ) |
| 485 | | ROM_LOAD( "sms.d16", 0x000000, 0x4000, CRC(b700e7e6) SHA1(42b2c12c6af5f15d909e15ee3e7ca2e13e0142c2) ) |
| 486 | | |
| 487 | | |
| 488 | | |
| 489 | | |
| 490 | | |
| 491 | | /* |
| 492 | | ROM_LOAD( "sms.d17", 0x000000, 0x0001f3, CRC(e9eb78e7) SHA1(688e854e82c230d367c211f611e9a8298ab64399) ) |
| 493 | | ROM_LOAD( "sms.38", 0x000000, 0x0001f3, CRC(be17ebde) SHA1(22c05eeafeadc8f55b55951c2060fb4873146cba) ) |
| 494 | | ROM_LOAD( "sms.39", 0x000000, 0x0001f3, CRC(3299e803) SHA1(12f361d27497f6347ee26838fa9f675f6aac12c2) ) |
| 495 | | ROM_LOAD( "sms.40", 0x000000, 0x0001f3, CRC(22881f1c) SHA1(646fdc4e4a423e1432b448140f2d92dd2304ff71) ) |
| 496 | | ROM_LOAD( "sms.52", 0x000000, 0x0001f3, CRC(2e43ba5f) SHA1(8b87ee8ce21f5241260f2d0de4878096d8ecb5f5) ) |
| 497 | | ROM_LOAD( "sms.58", 0x000000, 0x0001f3, CRC(020b5108) SHA1(f3221fbce40a9d6fdc2eece606e4eded3faf5f02) ) |
| 498 | | ROM_LOAD( "sms.80", 0x000000, 0x0001f3, CRC(66e21ee5) SHA1(31c29a250f50dcdf531810e59068adfea4d2d9a3) ) |
| 499 | | ROM_LOAD( "sms.94", 0x000000, 0x000283, CRC(c5fda3df) SHA1(4fdd597d25ed893cb005165b68e48567fbd2b1ce) ) |
| 500 | | ROM_LOAD( "sms.109", 0x000000, 0x000283, CRC(15d05aaa) SHA1(57500b4825a1da943d79ee7df657efed56c4320e) ) |
| 501 | | ROM_LOAD( "sms.110", 0x000000, 0x0001f3, CRC(6263b1e1) SHA1(6c8d92bcbbc2d196b5ac7765888eaf171671d651) ) |
| 502 | | ROM_LOAD( "sms.128", 0x000000, 0x0001f3, CRC(fbaea5b0) SHA1(85a757485c26304d4ce718fd954aa4736cdc4752) ) |
| 503 | | ROM_LOAD( "sms.129", 0x000000, 0x0001f3, CRC(4722fb3b) SHA1(adc0a3c0721acaa5b447c7aee771703caab80dd9) ) |
| 504 | | ROM_LOAD( "sms.130", 0x000000, 0x0001f3, CRC(d3f0a6a5) SHA1(5e08b6104dfd3e463031b2b12619589a8f7b453c) ) |
| 505 | | ROM_LOAD( "sms.140", 0x000000, 0x000283, CRC(031f662d) SHA1(6fa072db3203cdb95262d7778a6ee8310423b3df) ) |
| 506 | | ROM_LOAD( "sms.141", 0x000000, 0x000283, CRC(031f662d) SHA1(6fa072db3203cdb95262d7778a6ee8310423b3df) ) |
| 507 | | ROM_LOAD( "sms.142", 0x000000, 0x000283, CRC(031f662d) SHA1(6fa072db3203cdb95262d7778a6ee8310423b3df) ) |
| 508 | | ROM_LOAD( "sms.143", 0x000000, 0x000283, CRC(031f662d) SHA1(6fa072db3203cdb95262d7778a6ee8310423b3df) ) |
| 509 | | ROM_LOAD( "sms.144", 0x000000, 0x000283, CRC(031f662d) SHA1(6fa072db3203cdb95262d7778a6ee8310423b3df) ) |
| 510 | | ROM_LOAD( "sms.145", 0x000000, 0x000283, CRC(031f662d) SHA1(6fa072db3203cdb95262d7778a6ee8310423b3df) ) |
| 511 | | ROM_LOAD( "sms.d0", 0x000000, 0x0001f3, CRC(b1c221a7) SHA1(f63a022199a2d7b52c4c4827b170d49aae85e4e3) ) |
| 512 | | */ |
| 513 | | ROM_END |
| 514 | | |
| 515 | | GAME( 1984, smstrv, 0, smstrv, ettrivia, 0, ROT0, "SMS MFG CORP", "Trivia (sms)", GAME_NOT_WORKING ) |
src/emu/cpu/cop400/410ops.c
| r4149 | r4150 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | 410ops.c |
| 4 | | |
| 5 | | National Semiconductor COP410 Emulator. |
| 6 | | |
| 7 | | Copyright Nicola Salmoria and the MAME Team. |
| 8 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | | |
| 10 | | ***************************************************************************/ |
| 11 | | |
| 12 | | #define UINT1 UINT8 |
| 13 | | #define UINT4 UINT8 |
| 14 | | #define UINT6 UINT8 |
| 15 | | #define UINT10 UINT16 |
| 16 | | |
| 17 | | typedef struct _cop400_state cop400_state; |
| 18 | | struct _cop400_state |
| 19 | | { |
| 20 | | const cop400_interface *intf; |
| 21 | | |
| 22 | | const address_space *program; |
| 23 | | const address_space *data; |
| 24 | | const address_space *io; |
| 25 | | |
| 26 | | /* registers */ |
| 27 | | UINT10 pc; /* 11-bit ROM address program counter */ |
| 28 | | UINT10 prevpc; /* previous value of program counter */ |
| 29 | | UINT4 a; /* 4-bit accumulator */ |
| 30 | | UINT8 b; /* 5/6/7-bit RAM address register */ |
| 31 | | UINT1 c; /* 1-bit carry register */ |
| 32 | | UINT4 en; /* 4-bit enable register */ |
| 33 | | UINT4 g; /* 4-bit general purpose I/O port */ |
| 34 | | UINT8 q; /* 8-bit latch for L port */ |
| 35 | | UINT10 sa, sb, sc; /* subroutine save registers */ |
| 36 | | UINT4 sio; /* 4-bit shift register and counter */ |
| 37 | | UINT1 skl; /* 1-bit latch for SK output */ |
| 38 | | UINT8 si; /* serial input */ |
| 39 | | UINT4 h; /* 4-bit general purpose I/O port (COP440 only) */ |
| 40 | | UINT8 r; /* 8-bit general purpose I/O port (COP440 only) */ |
| 41 | | |
| 42 | | /* counter */ |
| 43 | | UINT8 t; /* 8-bit timer */ |
| 44 | | int skt_latch; /* timer overflow latch */ |
| 45 | | |
| 46 | | /* input/output ports */ |
| 47 | | UINT8 g_mask; /* G port mask */ |
| 48 | | UINT8 d_mask; /* D port mask */ |
| 49 | | UINT8 in_mask; /* IN port mask */ |
| 50 | | UINT4 il; /* IN latch */ |
| 51 | | UINT4 in[4]; /* IN port shift register */ |
| 52 | | |
| 53 | | /* skipping logic */ |
| 54 | | int skip; /* skip next instruction */ |
| 55 | | int skip_lbi; /* skip until next non-LBI instruction */ |
| 56 | | int last_skip; /* last value of skip */ |
| 57 | | int halt; /* halt mode */ |
| 58 | | int idle; /* idle mode */ |
| 59 | | |
| 60 | | /* microbus */ |
| 61 | | int microbus_int; /* microbus interrupt */ |
| 62 | | |
| 63 | | /* execution logic */ |
| 64 | | int InstLen[256]; /* instruction length in bytes */ |
| 65 | | int LBIops[256]; |
| 66 | | int LBIops33[256]; |
| 67 | | int icount; /* instruction counter */ |
| 68 | | |
| 69 | | const device_config *device; |
| 70 | | |
| 71 | | /* timers */ |
| 72 | | emu_timer *serial_timer; |
| 73 | | emu_timer *counter_timer; |
| 74 | | emu_timer *inil_timer; |
| 75 | | emu_timer *microbus_timer; |
| 76 | | }; |
| 77 | | |
| 78 | | /* The opcode table now is a combination of cycle counts and function pointers */ |
| 79 | | typedef struct { |
| 80 | | unsigned cycles; |
| 81 | | void (*function) (cop400_state *cop400, UINT8 opcode); |
| 82 | | } s_opcode; |
| 83 | | |
| 84 | | #define INSTRUCTION(mnemonic) INLINE void (mnemonic)(cop400_state *cop400, UINT8 opcode) |
| 85 | | |
| 86 | | #define ROM(a) memory_decrypted_read_byte(cop400->program, a) |
| 87 | | #define RAM_R(a) memory_read_byte_8le(cop400->data, a) |
| 88 | | #define RAM_W(a, v) memory_write_byte_8le(cop400->data, a, v) |
| 89 | | #define IN(a) memory_read_byte_8le(cop400->io, a) |
| 90 | | #define OUT(a, v) memory_write_byte_8le(cop400->io, a, v) |
| 91 | | |
| 92 | | #define A cop400->a |
| 93 | | #define B cop400->b |
| 94 | | #define C cop400->c |
| 95 | | #define G cop400->g |
| 96 | | #define Q cop400->q |
| 97 | | #define EN cop400->en |
| 98 | | #define SA cop400->sa |
| 99 | | #define SB cop400->sb |
| 100 | | #define SIO cop400->sio |
| 101 | | #define SKL cop400->skl |
| 102 | | #define PC cop400->pc |
| 103 | | #define prevPC cop400->prevpc |
| 104 | | |
| 105 | | #define IN_G() IN(COP400_PORT_G) |
| 106 | | #define IN_L() IN(COP400_PORT_L) |
| 107 | | #define IN_SI() BIT(IN(COP400_PORT_SIO), 0) |
| 108 | | #define IN_CKO() BIT(IN(COP400_PORT_CKO), 0) |
| 109 | | #define OUT_G(A) OUT(COP400_PORT_G, (A) & cop400->g_mask) |
| 110 | | #define OUT_L(A) OUT(COP400_PORT_L, (A)) |
| 111 | | #define OUT_D(A) OUT(COP400_PORT_D, (A) & cop400->d_mask) |
| 112 | | #define OUT_SK(A) OUT(COP400_PORT_SK, (A)) |
| 113 | | #define OUT_SO(A) OUT(COP400_PORT_SIO, (A)) |
| 114 | | |
| 115 | | #ifndef PUSH |
| 116 | | #define PUSH(addr) { SB = SA; SA = addr; } |
| 117 | | #define POP() { PC = SA; SA = SB; } |
| 118 | | #endif |
| 119 | | |
| 120 | | /* Serial I/O */ |
| 121 | | |
| 122 | | static TIMER_CALLBACK( cop400_serial_tick ) |
| 123 | | { |
| 124 | | cop400_state *cop400 = ptr; |
| 125 | | |
| 126 | | if (BIT(EN, 0)) |
| 127 | | { |
| 128 | | /* |
| 129 | | |
| 130 | | SIO is an asynchronous binary counter decrementing its value by one upon each low-going pulse ("1" to "0") occurring on the SI input. |
| 131 | | Each pulse must remain at each logic level at least two instruction cycles. SK outputs the value of the C upon the execution of an XAS |
| 132 | | and remains latched until the execution of another XAS instruction. The SO output is equal to the value of EN3. |
| 133 | | |
| 134 | | */ |
| 135 | | |
| 136 | | // serial output |
| 137 | | |
| 138 | | OUT_SO(BIT(EN, 3)); |
| 139 | | |
| 140 | | // serial clock |
| 141 | | |
| 142 | | OUT_SK(SKL); |
| 143 | | |
| 144 | | // serial input |
| 145 | | |
| 146 | | cop400->si <<= 1; |
| 147 | | cop400->si = (cop400->si & 0x0e) | IN_SI(); |
| 148 | | |
| 149 | | if ((cop400->si & 0x0f) == 0x0c) // 1100 |
| 150 | | { |
| 151 | | SIO--; |
| 152 | | SIO &= 0x0f; |
| 153 | | } |
| 154 | | } |
| 155 | | else |
| 156 | | { |
| 157 | | /* |
| 158 | | |
| 159 | | SIO is a serial shift register, shifting continuously left each instruction cycle time. The data present at SI goes into the least |
| 160 | | significant bit of SIO: SO can be enabled to output the most significant bit of SIO each cycle time. SK output becomes a logic- |
| 161 | | controlled clock, providing a SYNC signal each instruction time. It will start outputting a SYNC pulse upon the execution of an XAS |
| 162 | | instruction with C = "1," stopping upon the execution of a subsequent XAS with C = "0". |
| 163 | | |
| 164 | | If EN0 is changed from "1" to "0" ("0" to "1") the SK output will change from "1" to SYNC (SYNC to "1") without the execution of |
| 165 | | an XAS instruction. |
| 166 | | |
| 167 | | */ |
| 168 | | |
| 169 | | // serial output |
| 170 | | |
| 171 | | if (BIT(EN, 3)) |
| 172 | | { |
| 173 | | OUT_SO(BIT(SIO, 3)); |
| 174 | | } |
| 175 | | else |
| 176 | | { |
| 177 | | OUT_SO(0); |
| 178 | | } |
| 179 | | |
| 180 | | // serial clock |
| 181 | | |
| 182 | | if (SKL) |
| 183 | | { |
| 184 | | OUT_SK(1); // SYNC |
| 185 | | } |
| 186 | | else |
| 187 | | { |
| 188 | | OUT_SK(0); |
| 189 | | } |
| 190 | | |
| 191 | | // serial input |
| 192 | | |
| 193 | | SIO = ((SIO << 1) | IN_SI()) & 0x0f; |
| 194 | | } |
| 195 | | } |
| 196 | | |
| 197 | | INLINE void WRITE_Q(cop400_state *cop400, UINT8 data) |
| 198 | | { |
| 199 | | Q = data; |
| 200 | | |
| 201 | | if (BIT(EN, 2)) |
| 202 | | { |
| 203 | | OUT_L(Q); |
| 204 | | } |
| 205 | | } |
| 206 | | |
| 207 | | INLINE void WRITE_G(cop400_state *cop400, UINT8 data) |
| 208 | | { |
| 209 | | if (cop400->intf->microbus == COP400_MICROBUS_ENABLED) |
| 210 | | { |
| 211 | | data = (data & 0x0e) | cop400->microbus_int; |
| 212 | | } |
| 213 | | |
| 214 | | G = data; |
| 215 | | |
| 216 | | OUT_G(G); |
| 217 | | } |
| 218 | | |
| 219 | | INSTRUCTION(illegal) |
| 220 | | { |
| 221 | | logerror("COP400: PC = %04x, Illegal opcode = %02x\n", PC-1, ROM(PC-1)); |
| 222 | | } |
| 223 | | |
| 224 | | /* Arithmetic Instructions */ |
| 225 | | |
| 226 | | /* |
| 227 | | |
| 228 | | Mnemonic: ASC |
| 229 | | |
| 230 | | Hex Code: 30 |
| 231 | | Binary: 0 0 1 1 0 0 0 0 |
| 232 | | |
| 233 | | Data Flow: A + C + RAM(B) -> A |
| 234 | | Carry -> C |
| 235 | | |
| 236 | | Skip Conditions: Carry |
| 237 | | |
| 238 | | Description: Add with Carry, Skip on Carry |
| 239 | | |
| 240 | | */ |
| 241 | | |
| 242 | | INSTRUCTION(asc) |
| 243 | | { |
| 244 | | A = A + C + RAM_R(B); |
| 245 | | |
| 246 | | if (A > 0xF) |
| 247 | | { |
| 248 | | C = 1; |
| 249 | | cop400->skip = 1; |
| 250 | | A &= 0xF; |
| 251 | | } |
| 252 | | else |
| 253 | | { |
| 254 | | C = 0; |
| 255 | | } |
| 256 | | } |
| 257 | | |
| 258 | | /* |
| 259 | | |
| 260 | | Mnemonic: ADD |
| 261 | | |
| 262 | | Hex Code: 31 |
| 263 | | Binary: 0 0 1 1 0 0 0 1 |
| 264 | | |
| 265 | | Data Flow: A + RAM(B) -> A |
| 266 | | |
| 267 | | Description: Add RAM to A |
| 268 | | |
| 269 | | */ |
| 270 | | |
| 271 | | INSTRUCTION( add ) |
| 272 | | { |
| 273 | | A = (A + RAM_R(B)) & 0x0F; |
| 274 | | } |
| 275 | | |
| 276 | | /* |
| 277 | | |
| 278 | | Mnemonic: AISC |
| 279 | | |
| 280 | | Operand: y |
| 281 | | Hex Code: 5- |
| 282 | | Binary: 0 1 0 1 y3 y2 y1 y0 |
| 283 | | |
| 284 | | Data Flow: A + y -> A |
| 285 | | |
| 286 | | Skip Conditions: Carry |
| 287 | | |
| 288 | | Description: Add Immediate, Skip on Carry (y != 0) |
| 289 | | |
| 290 | | */ |
| 291 | | |
| 292 | | INSTRUCTION( aisc ) |
| 293 | | { |
| 294 | | UINT4 y = opcode & 0x0f; |
| 295 | | |
| 296 | | A = A + y; |
| 297 | | |
| 298 | | if (A > 0x0f) |
| 299 | | { |
| 300 | | cop400->skip = 1; |
| 301 | | A &= 0xF; |
| 302 | | } |
| 303 | | } |
| 304 | | |
| 305 | | /* |
| 306 | | |
| 307 | | Mnemonic: CLRA |
| 308 | | |
| 309 | | Hex Code: 00 |
| 310 | | Binary: 0 0 0 0 0 0 0 0 |
| 311 | | |
| 312 | | Data Flow: 0 -> A |
| 313 | | |
| 314 | | Description: Clear A |
| 315 | | |
| 316 | | */ |
| 317 | | |
| 318 | | INSTRUCTION( clra ) |
| 319 | | { |
| 320 | | A = 0; |
| 321 | | } |
| 322 | | |
| 323 | | /* |
| 324 | | |
| 325 | | Mnemonic: COMP |
| 326 | | |
| 327 | | Hex Code: 40 |
| 328 | | Binary: 0 1 0 0 0 0 0 0 |
| 329 | | |
| 330 | | Data Flow: ~A -> A |
| 331 | | |
| 332 | | Description: Ones Complement of A to A |
| 333 | | |
| 334 | | */ |
| 335 | | |
| 336 | | INSTRUCTION( comp ) |
| 337 | | { |
| 338 | | A = A ^ 0xF; |
| 339 | | } |
| 340 | | |
| 341 | | /* |
| 342 | | |
| 343 | | Mnemonic: NOP |
| 344 | | |
| 345 | | Hex Code: 44 |
| 346 | | Binary: 0 1 0 0 0 1 0 0 |
| 347 | | |
| 348 | | Description: No Operation |
| 349 | | |
| 350 | | */ |
| 351 | | |
| 352 | | INSTRUCTION( nop ) |
| 353 | | { |
| 354 | | // do nothing |
| 355 | | } |
| 356 | | |
| 357 | | /* |
| 358 | | |
| 359 | | Mnemonic: RC |
| 360 | | |
| 361 | | Hex Code: 32 |
| 362 | | Binary: 0 0 1 1 0 0 1 0 |
| 363 | | |
| 364 | | Data Flow: "0" -> C |
| 365 | | |
| 366 | | Description: Reset C |
| 367 | | |
| 368 | | */ |
| 369 | | |
| 370 | | INSTRUCTION( rc ) |
| 371 | | { |
| 372 | | C = 0; |
| 373 | | } |
| 374 | | |
| 375 | | /* |
| 376 | | |
| 377 | | Mnemonic: SC |
| 378 | | |
| 379 | | Hex Code: 22 |
| 380 | | Binary: 0 0 1 0 0 0 1 0 |
| 381 | | |
| 382 | | Data Flow: "1" -> C |
| 383 | | |
| 384 | | Description: Set C |
| 385 | | |
| 386 | | */ |
| 387 | | |
| 388 | | INSTRUCTION( sc ) |
| 389 | | { |
| 390 | | C = 1; |
| 391 | | } |
| 392 | | |
| 393 | | /* |
| 394 | | |
| 395 | | Mnemonic: XOR |
| 396 | | |
| 397 | | Hex Code: 02 |
| 398 | | Binary: 0 0 0 0 0 0 1 0 |
| 399 | | |
| 400 | | Data Flow: A ^ RAM(B) -> A |
| 401 | | |
| 402 | | Description: Exclusive-OR RAM with A |
| 403 | | |
| 404 | | */ |
| 405 | | |
| 406 | | INSTRUCTION( xor ) |
| 407 | | { |
| 408 | | A = A ^ RAM_R(B); |
| 409 | | } |
| 410 | | |
| 411 | | /* Transfer-of-Control Instructions */ |
| 412 | | |
| 413 | | /* |
| 414 | | |
| 415 | | Mnemonic: JID |
| 416 | | |
| 417 | | Hex Code: FF |
| 418 | | Binary: 1 1 1 1 1 1 1 1 |
| 419 | | |
| 420 | | Data Flow: ROM(PC9:8,A,M) -> PC7:0 |
| 421 | | |
| 422 | | Description: Jump Indirect |
| 423 | | |
| 424 | | */ |
| 425 | | |
| 426 | | INSTRUCTION( jid ) |
| 427 | | { |
| 428 | | UINT16 addr = (PC & 0x300) | (A << 4) | RAM_R(B); |
| 429 | | PC = (PC & 0x300) | ROM(addr); |
| 430 | | } |
| 431 | | |
| 432 | | /* |
| 433 | | |
| 434 | | Mnemonic: JMP |
| 435 | | |
| 436 | | Operand: a |
| 437 | | Hex Code: 6- -- |
| 438 | | Binary: 0 1 1 0 0 0 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 |
| 439 | | |
| 440 | | Data Flow: a -> PC |
| 441 | | |
| 442 | | Description: Jump |
| 443 | | |
| 444 | | */ |
| 445 | | |
| 446 | | INSTRUCTION( jmp ) |
| 447 | | { |
| 448 | | UINT16 a = ((opcode & 0x03) << 8) | ROM(PC); |
| 449 | | |
| 450 | | PC = a; |
| 451 | | } |
| 452 | | |
| 453 | | /* |
| 454 | | |
| 455 | | Mnemonic: JP |
| 456 | | |
| 457 | | Operand: a |
| 458 | | Hex Code: -- |
| 459 | | Binary: 1 a6 a5 a4 a3 a2 a1 a0 |
| 460 | | (pages 2,3 only) |
| 461 | | |
| 462 | | 1 1 a5 a4 a3 a2 a1 a0 |
| 463 | | (all other pages) |
| 464 | | |
| 465 | | Data Flow: a -> PC6:0 |
| 466 | | |
| 467 | | a -> PC5:0 |
| 468 | | |
| 469 | | Description: Jump within Page |
| 470 | | |
| 471 | | */ |
| 472 | | |
| 473 | | INSTRUCTION( jp ) |
| 474 | | { |
| 475 | | UINT4 page = PC >> 6; |
| 476 | | |
| 477 | | if (page == 2 || page == 3) |
| 478 | | { |
| 479 | | UINT8 a = opcode & 0x7f; |
| 480 | | PC = (PC & 0x380) | a; |
| 481 | | } |
| 482 | | else if ((opcode & 0xc0) == 0xc0) |
| 483 | | { |
| 484 | | UINT8 a = opcode & 0x3f; |
| 485 | | PC = (PC & 0x3c0) | a; |
| 486 | | } |
| 487 | | else |
| 488 | | { |
| 489 | | // JSRP |
| 490 | | UINT8 a = opcode & 0x3f; |
| 491 | | PUSH(PC); |
| 492 | | PC = 0x80 | a; |
| 493 | | } |
| 494 | | } |
| 495 | | |
| 496 | | /* |
| 497 | | |
| 498 | | Mnemonic: JSR |
| 499 | | |
| 500 | | Operand: a |
| 501 | | Hex Code: 6- -- |
| 502 | | Binary: 0 1 1 0 1 0 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 |
| 503 | | |
| 504 | | Data Flow: PC + 1 -> SA -> SB -> SC |
| 505 | | a -> PC |
| 506 | | |
| 507 | | Description: Jump to Subroutine |
| 508 | | |
| 509 | | */ |
| 510 | | |
| 511 | | INSTRUCTION( jsr ) |
| 512 | | { |
| 513 | | UINT16 a = ((opcode & 0x03) << 8) | ROM(PC); |
| 514 | | |
| 515 | | PUSH(PC + 1); |
| 516 | | PC = a; |
| 517 | | } |
| 518 | | |
| 519 | | /* |
| 520 | | |
| 521 | | Mnemonic: RET |
| 522 | | |
| 523 | | Hex Code: 48 |
| 524 | | Binary: 0 1 0 0 1 0 0 0 |
| 525 | | |
| 526 | | Data Flow: SC -> SB -> SA -> PC |
| 527 | | |
| 528 | | Description: Return from Subroutine |
| 529 | | |
| 530 | | */ |
| 531 | | |
| 532 | | INSTRUCTION( ret ) |
| 533 | | { |
| 534 | | POP(); |
| 535 | | } |
| 536 | | |
| 537 | | /* |
| 538 | | |
| 539 | | Mnemonic: RETSK |
| 540 | | |
| 541 | | Hex Code: 49 |
| 542 | | Binary: 0 1 0 0 1 0 0 1 |
| 543 | | |
| 544 | | Data Flow: SC -> SB -> SA -> PC |
| 545 | | |
| 546 | | Skip Conditions: Always Skip on Return |
| 547 | | |
| 548 | | Description: Return from Subroutine then Skip |
| 549 | | |
| 550 | | */ |
| 551 | | |
| 552 | | INSTRUCTION( retsk ) |
| 553 | | { |
| 554 | | POP(); |
| 555 | | cop400->skip = 1; |
| 556 | | } |
| 557 | | |
| 558 | | /* |
| 559 | | |
| 560 | | Processor: COP410C/COP411C |
| 561 | | |
| 562 | | Mnemonic: HALT |
| 563 | | |
| 564 | | Hex Code: 33 38 |
| 565 | | Binary: 0 0 1 1 0 0 1 1 0 0 1 1 1 0 0 0 |
| 566 | | |
| 567 | | Description: Halt processor |
| 568 | | |
| 569 | | */ |
| 570 | | |
| 571 | | INSTRUCTION( halt ) |
| 572 | | { |
| 573 | | cop400->halt = 1; |
| 574 | | } |
| 575 | | |
| 576 | | /* Memory Reference Instructions */ |
| 577 | | |
| 578 | | /* |
| 579 | | |
| 580 | | Mnemonic: CAMQ |
| 581 | | |
| 582 | | Hex Code: 33 3C |
| 583 | | Binary: 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 |
| 584 | | |
| 585 | | Data Flow: A -> Q7:4 |
| 586 | | RAM(B) -> Q3:0 |
| 587 | | |
| 588 | | Description: Copy A, RAM to Q |
| 589 | | |
| 590 | | */ |
| 591 | | |
| 592 | | INSTRUCTION( camq ) |
| 593 | | { |
| 594 | | /* |
| 595 | | |
| 596 | | Excerpt from the COP410L data sheet: |
| 597 | | |
| 598 | | False states may be generated on L0-L7 during the execution of the CAMQ instruction. |
| 599 | | The L-ports should not be used as clocks for edge sensitive devices such as flip-flops, |
| 600 | | counters, shift registers, etc. the following short program that illustrates this situation. |
| 601 | | |
| 602 | | START: |
| 603 | | CLRA ;ENABLE THE Q |
| 604 | | LEI 4 ;REGISTER TO L LINES |
| 605 | | LBI TEST |
| 606 | | STII 3 |
| 607 | | AISC 12 |
| 608 | | LOOP: |
| 609 | | LBI TEST ;LOAD Q WITH X'C3 |
| 610 | | CAMQ |
| 611 | | JP LOOP |
| 612 | | |
| 613 | | In this program the internal Q register is enabled onto the L lines and a steady bit |
| 614 | | pattern of logic highs is output on L0, L1, L6, L7, and logic lows on L2-L5 via the |
| 615 | | two-byte CAMQ instruction. Timing constraints on the device are such that the Q |
| 616 | | register may be temporarily loaded with the second byte of the CAMQ opcode (3C) prior |
| 617 | | to receiving the valid data pattern. If this occurs, the opcode will ripple onto the L |
| 618 | | lines and cause negative-going glitches on L0, L1, L6, L7, and positive glitches on |
| 619 | | L2-L5. Glitch durations are under 2 ms, although the exact value may vary due to data |
| 620 | | patterns, processing parameters, and L line loading. These false states are peculiar |
| 621 | | only to the CAMQ instruction and the L lines. |
| 622 | | |
| 623 | | */ |
| 624 | | |
| 625 | | UINT8 data = (A << 4) | RAM_R(B); |
| 626 | | |
| 627 | | WRITE_Q(cop400, data); |
| 628 | | |
| 629 | | #ifdef CAMQ_BUG |
| 630 | | WRITE_Q(cop400, 0x3c); |
| 631 | | WRITE_Q(cop400, data); |
| 632 | | #endif |
| 633 | | } |
| 634 | | |
| 635 | | /* |
| 636 | | |
| 637 | | Mnemonic: LD |
| 638 | | |
| 639 | | Operand: r |
| 640 | | Hex Code: -5 |
| 641 | | Binary: 0 0 r1 r0 0 1 0 1 |
| 642 | | |
| 643 | | Data Flow: RAM(B) -> A |
| 644 | | Br ^ r -> Br |
| 645 | | |
| 646 | | Description: Load RAM into A, Exclusive-OR Br with r |
| 647 | | |
| 648 | | */ |
| 649 | | |
| 650 | | INSTRUCTION( ld ) |
| 651 | | { |
| 652 | | UINT8 r = opcode & 0x30; |
| 653 | | |
| 654 | | A = RAM_R(B); |
| 655 | | B = B ^ r; |
| 656 | | } |
| 657 | | |
| 658 | | /* |
| 659 | | |
| 660 | | Mnemonic: LQID |
| 661 | | |
| 662 | | Hex Code: BF |
| 663 | | Binary: 1 0 1 1 1 1 1 1 |
| 664 | | |
| 665 | | Data Flow: ROM(PC9:8,A,M) -> Q |
| 666 | | SB -> SC |
| 667 | | |
| 668 | | Description: Load Q Indirect |
| 669 | | |
| 670 | | */ |
| 671 | | |
| 672 | | INSTRUCTION( lqid ) |
| 673 | | { |
| 674 | | PUSH(PC); |
| 675 | | PC = (PC & 0x300) | (A << 4) | RAM_R(B); |
| 676 | | WRITE_Q(cop400, ROM(PC)); |
| 677 | | POP(); |
| 678 | | } |
| 679 | | |
| 680 | | /* |
| 681 | | |
| 682 | | Mnemonic: RMB |
| 683 | | |
| 684 | | Operand: 0 |
| 685 | | 1 |
| 686 | | 2 |
| 687 | | 3 |
| 688 | | |
| 689 | | Hex Code: 4C |
| 690 | | 45 |
| 691 | | 42 |
| 692 | | 43 |
| 693 | | |
| 694 | | Binary: 0 1 0 0 1 1 0 0 |
| 695 | | 0 1 0 0 0 1 0 1 |
| 696 | | 0 1 0 0 0 0 1 0 |
| 697 | | 0 1 0 0 0 0 1 1 |
| 698 | | |
| 699 | | Data Flow: 0 -> RAM(B)0 |
| 700 | | 0 -> RAM(B)1 |
| 701 | | 0 -> RAM(B)2 |
| 702 | | 0 -> RAM(B)3 |
| 703 | | |
| 704 | | Description: Reset RAM Bit |
| 705 | | |
| 706 | | */ |
| 707 | | |
| 708 | | INSTRUCTION( rmb0 ) { RAM_W(B, RAM_R(B) & 0xE); } |
| 709 | | INSTRUCTION( rmb1 ) { RAM_W(B, RAM_R(B) & 0xD); } |
| 710 | | INSTRUCTION( rmb2 ) { RAM_W(B, RAM_R(B) & 0xB); } |
| 711 | | INSTRUCTION( rmb3 ) { RAM_W(B, RAM_R(B) & 0x7); } |
| 712 | | |
| 713 | | /* |
| 714 | | |
| 715 | | Mnemonic: SMB |
| 716 | | |
| 717 | | Operand: 0 |
| 718 | | 1 |
| 719 | | 2 |
| 720 | | 3 |
| 721 | | |
| 722 | | Hex Code: 4D |
| 723 | | 47 |
| 724 | | 46 |
| 725 | | 4B |
| 726 | | |
| 727 | | Binary: 0 1 0 0 1 1 0 1 |
| 728 | | 0 1 0 0 0 1 1 1 |
| 729 | | 0 1 0 0 0 1 1 0 |
| 730 | | 0 1 0 0 1 0 1 1 |
| 731 | | |
| 732 | | Data Flow: 1 -> RAM(B)0 |
| 733 | | 1 -> RAM(B)1 |
| 734 | | 1 -> RAM(B)2 |
| 735 | | 1 -> RAM(B)3 |
| 736 | | |
| 737 | | Description: Set RAM Bit |
| 738 | | |
| 739 | | */ |
| 740 | | |
| 741 | | INSTRUCTION( smb0 ) { RAM_W(B, RAM_R(B) | 0x1); } |
| 742 | | INSTRUCTION( smb1 ) { RAM_W(B, RAM_R(B) | 0x2); } |
| 743 | | INSTRUCTION( smb2 ) { RAM_W(B, RAM_R(B) | 0x4); } |
| 744 | | INSTRUCTION( smb3 ) { RAM_W(B, RAM_R(B) | 0x8); } |
| 745 | | |
| 746 | | /* |
| 747 | | |
| 748 | | Mnemonic: STII |
| 749 | | |
| 750 | | Operand: y |
| 751 | | Hex Code: 7- |
| 752 | | Binary: 0 1 1 1 y3 y2 y1 y0 |
| 753 | | |
| 754 | | Data Flow: y -> RAM(B) |
| 755 | | Bd + 1 -> Bd |
| 756 | | |
| 757 | | Description: Store Memory Immediate and Increment Bd |
| 758 | | |
| 759 | | */ |
| 760 | | |
| 761 | | INSTRUCTION( stii ) |
| 762 | | { |
| 763 | | UINT4 y = opcode & 0x0f; |
| 764 | | UINT16 Bd; |
| 765 | | |
| 766 | | RAM_W(B, y); |
| 767 | | |
| 768 | | Bd = ((B & 0x0f) + 1) & 0x0f; |
| 769 | | B = (B & 0x30) + Bd; |
| 770 | | } |
| 771 | | |
| 772 | | /* |
| 773 | | |
| 774 | | Mnemonic: X |
| 775 | | |
| 776 | | Operand: r |
| 777 | | Hex Code: -6 |
| 778 | | Binary: 0 0 r1 r0 0 1 1 0 |
| 779 | | |
| 780 | | Data Flow: RAM(B) <-> A |
| 781 | | Br ^ r -> Br |
| 782 | | |
| 783 | | Description: Exchange RAM with A, Exclusive-OR Br with r |
| 784 | | |
| 785 | | */ |
| 786 | | |
| 787 | | INSTRUCTION( x ) |
| 788 | | { |
| 789 | | UINT4 r = opcode & 0x30; |
| 790 | | UINT8 t = RAM_R(B); |
| 791 | | |
| 792 | | RAM_W(B, A); |
| 793 | | |
| 794 | | A = t; |
| 795 | | B = B ^ r; |
| 796 | | } |
| 797 | | |
| 798 | | /* |
| 799 | | |
| 800 | | Mnemonic: XAD |
| 801 | | |
| 802 | | Operand: r,d |
| 803 | | Hex Code: 23 -- |
| 804 | | Binary: 0 0 1 0 0 0 1 1 1 0 r1 r0 d3 d2 d1 d0 |
| 805 | | |
| 806 | | Data Flow: RAM(r,d) <-> A |
| 807 | | |
| 808 | | Description: Exchange A with RAM pointed to directly by r,d |
| 809 | | |
| 810 | | */ |
| 811 | | |
| 812 | | INSTRUCTION( xad ) |
| 813 | | { |
| 814 | | UINT8 rd = opcode & 0x3f; |
| 815 | | UINT8 t = A; |
| 816 | | |
| 817 | | A = RAM_R(rd); |
| 818 | | |
| 819 | | RAM_W(rd, t); |
| 820 | | } |
| 821 | | |
| 822 | | /* |
| 823 | | |
| 824 | | Mnemonic: XDS |
| 825 | | |
| 826 | | Operand: r |
| 827 | | Hex Code: -7 |
| 828 | | Binary: 0 0 r1 r0 0 1 1 1 |
| 829 | | |
| 830 | | Data Flow: RAM(B) <-> A |
| 831 | | Bd - 1 -> Bd |
| 832 | | Br ^ r -> Br |
| 833 | | |
| 834 | | Skip Conditions: Bd decrements past 0 |
| 835 | | |
| 836 | | Description: Exchange RAM with A and Decrement Bd, Exclusive-OR Br with r |
| 837 | | |
| 838 | | */ |
| 839 | | |
| 840 | | INSTRUCTION( xds ) |
| 841 | | { |
| 842 | | UINT8 t, Bd; |
| 843 | | UINT4 r = opcode & 0x30; |
| 844 | | |
| 845 | | t = RAM_R(B); |
| 846 | | RAM_W(B, A); |
| 847 | | A = t; |
| 848 | | |
| 849 | | Bd = ((B & 0x0f) - 1) & 0x0f; |
| 850 | | B = (B & 0x30) | Bd; |
| 851 | | |
| 852 | | B = B ^ r; |
| 853 | | |
| 854 | | if (Bd == 0x0f) cop400->skip = 1; |
| 855 | | } |
| 856 | | |
| 857 | | /* |
| 858 | | |
| 859 | | Mnemonic: XIS |
| 860 | | |
| 861 | | Operand: r |
| 862 | | Hex Code: -4 |
| 863 | | Binary: 0 0 r1 r0 0 1 0 0 |
| 864 | | |
| 865 | | Data Flow: RAM(B) <-> A |
| 866 | | Bd + 1 -> Bd |
| 867 | | Br ^ r -> Br |
| 868 | | |
| 869 | | Skip Conditions: Bd increments past 15 |
| 870 | | |
| 871 | | Description: Exchange RAM with A and Increment Bd, Exclusive-OR Br with r |
| 872 | | |
| 873 | | */ |
| 874 | | |
| 875 | | INSTRUCTION( xis ) |
| 876 | | { |
| 877 | | UINT8 t, Bd; |
| 878 | | UINT4 r = opcode & 0x30; |
| 879 | | |
| 880 | | t = RAM_R(B); |
| 881 | | RAM_W(B, A); |
| 882 | | A = t; |
| 883 | | |
| 884 | | Bd = ((B & 0x0f) + 1) & 0x0f; |
| 885 | | B = (B & 0x30) | Bd; |
| 886 | | |
| 887 | | B = B ^ r; |
| 888 | | |
| 889 | | if (Bd == 0x00) cop400->skip = 1; |
| 890 | | } |
| 891 | | |
| 892 | | /* Register Reference Instructions */ |
| 893 | | |
| 894 | | /* |
| 895 | | |
| 896 | | Mnemonic: CAB |
| 897 | | |
| 898 | | Hex Code: 50 |
| 899 | | Binary: 0 1 0 1 0 0 0 0 0 |
| 900 | | |
| 901 | | Data Flow: A -> Bd |
| 902 | | |
| 903 | | Description: Copy A to Bd |
| 904 | | |
| 905 | | */ |
| 906 | | |
| 907 | | INSTRUCTION( cab ) |
| 908 | | { |
| 909 | | B = (B & 0x30) | A; |
| 910 | | } |
| 911 | | |
| 912 | | /* |
| 913 | | |
| 914 | | Mnemonic: CBA |
| 915 | | |
| 916 | | Hex Code: 4E |
| 917 | | Binary: 0 1 0 0 1 1 1 0 |
| 918 | | |
| 919 | | Data Flow: Bd -> A |
| 920 | | |
| 921 | | Description: Copy Bd to A |
| 922 | | |
| 923 | | */ |
| 924 | | |
| 925 | | INSTRUCTION( cba ) |
| 926 | | { |
| 927 | | A = B & 0xF; |
| 928 | | } |
| 929 | | |
| 930 | | /* |
| 931 | | |
| 932 | | Mnemonic: LBI |
| 933 | | |
| 934 | | Operand: r,d |
| 935 | | Hex Code: -- |
| 936 | | 33 -- |
| 937 | | |
| 938 | | Binary: 0 0 r1 r0 d3 d2 d1 d0 (d-1) |
| 939 | | 0 0 1 1 0 0 1 1 1 0 r1 r0 d3 d2 d1 d0 |
| 940 | | |
| 941 | | Data Flow: r,d -> B |
| 942 | | |
| 943 | | Skip Conditions: Skip until not a LBI |
| 944 | | |
| 945 | | Description: Load B Immediate with r,d |
| 946 | | |
| 947 | | */ |
| 948 | | |
| 949 | | INSTRUCTION( lbi ) |
| 950 | | { |
| 951 | | if (opcode & 0x80) |
| 952 | | { |
| 953 | | B = opcode & 0x3f; |
| 954 | | } |
| 955 | | else |
| 956 | | { |
| 957 | | B = (opcode & 0x30) | (((opcode & 0x0f) + 1) & 0x0f); |
| 958 | | } |
| 959 | | |
| 960 | | cop400->skip_lbi = 1; |
| 961 | | } |
| 962 | | |
| 963 | | /* |
| 964 | | |
| 965 | | Mnemonic: LEI |
| 966 | | |
| 967 | | Operand: y |
| 968 | | Hex Code: 33 6- |
| 969 | | Binary: 0 0 1 1 0 0 1 1 0 1 1 0 y3 y2 y1 y0 |
| 970 | | |
| 971 | | Data Flow: y -> EN |
| 972 | | |
| 973 | | Description: Load EN Immediate |
| 974 | | |
| 975 | | */ |
| 976 | | |
| 977 | | INSTRUCTION( lei ) |
| 978 | | { |
| 979 | | UINT4 y = opcode & 0x0f; |
| 980 | | |
| 981 | | EN = y; |
| 982 | | |
| 983 | | if (BIT(EN, 2)) |
| 984 | | { |
| 985 | | OUT_L(Q); |
| 986 | | } |
| 987 | | } |
| 988 | | |
| 989 | | /* Test Instructions */ |
| 990 | | |
| 991 | | /* |
| 992 | | |
| 993 | | Mnemonic: SKC |
| 994 | | |
| 995 | | Hex Code: 20 |
| 996 | | Binary: 0 0 1 0 0 0 0 0 |
| 997 | | |
| 998 | | Skip Conditions: C = "1" |
| 999 | | |
| 1000 | | Description: Skip if C is True |
| 1001 | | |
| 1002 | | */ |
| 1003 | | |
| 1004 | | INSTRUCTION( skc ) |
| 1005 | | { |
| 1006 | | if (C == 1) cop400->skip = 1; |
| 1007 | | } |
| 1008 | | |
| 1009 | | /* |
| 1010 | | |
| 1011 | | Mnemonic: SKE |
| 1012 | | |
| 1013 | | Hex Code: 21 |
| 1014 | | Binary: 0 0 1 0 0 0 0 1 |
| 1015 | | |
| 1016 | | Skip Conditions: A = RAM(B) |
| 1017 | | |
| 1018 | | Description: Skip if A Equals RAM |
| 1019 | | |
| 1020 | | */ |
| 1021 | | |
| 1022 | | INSTRUCTION( ske ) |
| 1023 | | { |
| 1024 | | if (A == RAM_R(B)) cop400->skip = 1; |
| 1025 | | } |
| 1026 | | |
| 1027 | | /* |
| 1028 | | |
| 1029 | | Mnemonic: SKGZ |
| 1030 | | |
| 1031 | | Hex Code: 33 21 |
| 1032 | | Binary: 00 0 1 1 0 0 1 1 0 0 1 0 0 0 0 1 |
| 1033 | | |
| 1034 | | Skip Conditions: G3:0 = 0 |
| 1035 | | |
| 1036 | | Description: Skip if G is Zero (all 4 bits) |
| 1037 | | |
| 1038 | | */ |
| 1039 | | |
| 1040 | | INSTRUCTION( skgz ) |
| 1041 | | { |
| 1042 | | if (IN_G() == 0) cop400->skip = 1; |
| 1043 | | } |
| 1044 | | |
| 1045 | | /* |
| 1046 | | |
| 1047 | | Mnemonic: SKGBZ |
| 1048 | | |
| 1049 | | Hex Code: 33 01 |
| 1050 | | 33 11 |
| 1051 | | 33 03 |
| 1052 | | 33 13 |
| 1053 | | |
| 1054 | | Binary: |
| 1055 | | |
| 1056 | | Skip Conditions: G0 = 0 |
| 1057 | | G1 = 0 |
| 1058 | | G2 = 0 |
| 1059 | | G3 = 0 |
| 1060 | | |
| 1061 | | Description: Skip if G Bit is Zero |
| 1062 | | |
| 1063 | | */ |
| 1064 | | |
| 1065 | | INLINE void skgbz(cop400_state *cop400, int bit) |
| 1066 | | { |
| 1067 | | if (!BIT(IN_G(), bit)) cop400->skip = 1; |
| 1068 | | } |
| 1069 | | |
| 1070 | | INSTRUCTION( skgbz0 ) { skgbz(cop400, 0); } |
| 1071 | | INSTRUCTION( skgbz1 ) { skgbz(cop400, 1); } |
| 1072 | | INSTRUCTION( skgbz2 ) { skgbz(cop400, 2); } |
| 1073 | | INSTRUCTION( skgbz3 ) { skgbz(cop400, 3); } |
| 1074 | | |
| 1075 | | /* |
| 1076 | | |
| 1077 | | Mnemonic: SKMBZ |
| 1078 | | |
| 1079 | | Hex Code: 01 |
| 1080 | | 11 |
| 1081 | | 03 |
| 1082 | | 13 |
| 1083 | | |
| 1084 | | Binary: |
| 1085 | | |
| 1086 | | Skip Conditions: RAM(B)0 = 0 |
| 1087 | | RAM(B)0 = 1 |
| 1088 | | RAM(B)0 = 2 |
| 1089 | | RAM(B)0 = 3 |
| 1090 | | |
| 1091 | | Description: Skip if RAM Bit is Zero |
| 1092 | | |
| 1093 | | */ |
| 1094 | | |
| 1095 | | INLINE void skmbz(cop400_state *cop400, int bit) |
| 1096 | | { |
| 1097 | | if (!BIT(RAM_R(B), bit)) cop400->skip = 1; |
| 1098 | | } |
| 1099 | | |
| 1100 | | INSTRUCTION( skmbz0 ) { skmbz(cop400, 0); } |
| 1101 | | INSTRUCTION( skmbz1 ) { skmbz(cop400, 1); } |
| 1102 | | INSTRUCTION( skmbz2 ) { skmbz(cop400, 2); } |
| 1103 | | INSTRUCTION( skmbz3 ) { skmbz(cop400, 3); } |
| 1104 | | |
| 1105 | | /* Input/Output Instructions */ |
| 1106 | | |
| 1107 | | /* |
| 1108 | | |
| 1109 | | Mnemonic: ING |
| 1110 | | |
| 1111 | | Hex Code: 33 2A |
| 1112 | | Binary: |
| 1113 | | |
| 1114 | | Data Flow: G -> A |
| 1115 | | |
| 1116 | | Description: Input G Ports to A |
| 1117 | | |
| 1118 | | */ |
| 1119 | | |
| 1120 | | INSTRUCTION( ing ) |
| 1121 | | { |
| 1122 | | A = IN_G(); |
| 1123 | | } |
| 1124 | | |
| 1125 | | /* |
| 1126 | | |
| 1127 | | Mnemonic: INL |
| 1128 | | |
| 1129 | | Hex Code: 33 2E |
| 1130 | | Binary: |
| 1131 | | |
| 1132 | | Data Flow: L7:4 -> RAM(B) |
| 1133 | | L3:0 -> A |
| 1134 | | |
| 1135 | | Description: Input L Ports to RAM,A |
| 1136 | | |
| 1137 | | */ |
| 1138 | | |
| 1139 | | INSTRUCTION( inl ) |
| 1140 | | { |
| 1141 | | UINT8 L = IN_L(); |
| 1142 | | |
| 1143 | | RAM_W(B, L >> 4); |
| 1144 | | A = L & 0xF; |
| 1145 | | } |
| 1146 | | |
| 1147 | | /* |
| 1148 | | |
| 1149 | | Mnemonic: OBD |
| 1150 | | |
| 1151 | | Hex Code: 33 3E |
| 1152 | | Binary: |
| 1153 | | |
| 1154 | | Data Flow: Bd -> D |
| 1155 | | |
| 1156 | | Description: Output Bd to D Outputs |
| 1157 | | |
| 1158 | | */ |
| 1159 | | |
| 1160 | | INSTRUCTION( obd ) |
| 1161 | | { |
| 1162 | | OUT_D(B & 0x0f); |
| 1163 | | } |
| 1164 | | |
| 1165 | | /* |
| 1166 | | |
| 1167 | | Mnemonic: OMG |
| 1168 | | |
| 1169 | | Hex Code: 33 3A |
| 1170 | | Binary: |
| 1171 | | |
| 1172 | | Data Flow: RAM(B) -> G |
| 1173 | | |
| 1174 | | Description: Output RAM to G Ports |
| 1175 | | |
| 1176 | | */ |
| 1177 | | |
| 1178 | | INSTRUCTION( omg ) |
| 1179 | | { |
| 1180 | | WRITE_G(cop400, RAM_R(B)); |
| 1181 | | } |
| 1182 | | |
| 1183 | | /* |
| 1184 | | |
| 1185 | | Mnemonic: XAS |
| 1186 | | |
| 1187 | | Hex Code: 4F |
| 1188 | | Binary: 0 1 0 0 1 1 1 1 |
| 1189 | | |
| 1190 | | Data Flow: A <-> SIO |
| 1191 | | C -> SK |
| 1192 | | |
| 1193 | | Description: Exchange A with SIO |
| 1194 | | |
| 1195 | | */ |
| 1196 | | |
| 1197 | | INSTRUCTION( xas ) |
| 1198 | | { |
| 1199 | | UINT8 t = SIO; |
| 1200 | | SIO = A; |
| 1201 | | A = t; |
| 1202 | | |
| 1203 | | SKL = C; |
| 1204 | | } |
src/emu/cpu/cop400/cop410.c
| r4149 | r4150 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | cop410.c |
| 4 | | |
| 5 | | National Semiconductor COP410 Emulator. |
| 6 | | |
| 7 | | Copyright Nicola Salmoria and the MAME Team. |
| 8 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | | |
| 10 | | ***************************************************************************/ |
| 11 | | |
| 12 | | /* |
| 13 | | |
| 14 | | TODO: |
| 15 | | |
| 16 | | - COP413/COP414/COP415/COP405 |
| 17 | | - get rid of LBIOps/InstLen |
| 18 | | - run interrupt test suite |
| 19 | | - run production test suite |
| 20 | | - run microbus test suite |
| 21 | | |
| 22 | | */ |
| 23 | | |
| 24 | | #include "driver.h" |
| 25 | | #include "cpuintrf.h" |
| 26 | | #include "debugger.h" |
| 27 | | #include "cop400.h" |
| 28 | | |
| 29 | | #include "410ops.c" |
| 30 | | |
| 31 | | /* Opcode Maps */ |
| 32 | | |
| 33 | | static const s_opcode COP410_OPCODE_23_MAP[]= |
| 34 | | { |
| 35 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 36 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 37 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 38 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 39 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 40 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 41 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 42 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 43 | | |
| 44 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 45 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 46 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 47 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 48 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 49 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 50 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 51 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 52 | | |
| 53 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 54 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 55 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 56 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 57 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 58 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 59 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 60 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, xad }, |
| 61 | | |
| 62 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 63 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 64 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 65 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 66 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 67 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 68 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 69 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal } |
| 70 | | }; |
| 71 | | |
| 72 | | static void cop410_op23(cop400_state *cop400, UINT8 opcode) |
| 73 | | { |
| 74 | | UINT8 opcode23 = ROM(PC++); |
| 75 | | |
| 76 | | (*(COP410_OPCODE_23_MAP[opcode23].function))(cop400, opcode23); |
| 77 | | } |
| 78 | | |
| 79 | | static const s_opcode COP410_OPCODE_33_MAP[]= |
| 80 | | { |
| 81 | | {1, illegal },{1, skgbz0 },{1, illegal },{1, skgbz2 },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 82 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 83 | | {1, illegal },{1, skgbz1 },{1, illegal },{1, skgbz3 },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 84 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 85 | | {1, illegal },{1, skgz },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 86 | | {1, illegal },{1, illegal },{1, ing },{1, illegal },{1, illegal },{1, illegal },{1, inl },{1, illegal }, |
| 87 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 88 | | {1, halt },{1, illegal },{1, omg },{1, illegal },{1, camq },{1, illegal },{1, obd },{1, illegal }, |
| 89 | | |
| 90 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 91 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 92 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 93 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 94 | | {1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei }, |
| 95 | | {1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei }, |
| 96 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 97 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 98 | | |
| 99 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 100 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 101 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 102 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 103 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 104 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 105 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 106 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 107 | | |
| 108 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 109 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 110 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 111 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 112 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 113 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 114 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 115 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal } |
| 116 | | }; |
| 117 | | |
| 118 | | static void cop410_op33(cop400_state *cop400, UINT8 opcode) |
| 119 | | { |
| 120 | | UINT8 opcode33 = ROM(PC++); |
| 121 | | |
| 122 | | (*(COP410_OPCODE_33_MAP[opcode33].function))(cop400, opcode33); |
| 123 | | } |
| 124 | | |
| 125 | | static const s_opcode COP410_OPCODE_MAP[]= |
| 126 | | { |
| 127 | | {1, clra },{1, skmbz0 },{1, xor },{1, skmbz2 },{1, xis },{1, ld },{1, x },{1, xds }, |
| 128 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 129 | | {0, illegal },{1, skmbz1 },{0, illegal },{1, skmbz3 },{1, xis },{1, ld },{1, x },{1, xds }, |
| 130 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 131 | | {1, skc },{1, ske },{1, sc },{1, cop410_op23 },{1, xis },{1, ld },{1, x },{1, xds }, |
| 132 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 133 | | {1, asc },{1, add },{1, rc },{1, cop410_op33 },{1, xis },{1, ld },{1, x },{1, xds }, |
| 134 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 135 | | |
| 136 | | {1, comp },{0, illegal },{1, rmb2 },{1, rmb3 },{1, nop },{1, rmb1 },{1, smb2 },{1, smb1 }, |
| 137 | | {1, ret },{1, retsk },{0, illegal },{1, smb3 },{1, rmb0 },{1, smb0 },{1, cba },{1, xas }, |
| 138 | | {1, cab },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc }, |
| 139 | | {1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc }, |
| 140 | | {2, jmp },{2, jmp },{0, illegal },{0, illegal },{0, illegal },{0, illegal },{0, illegal },{0, illegal }, |
| 141 | | {2, jsr },{2, jsr },{0, illegal },{0, illegal },{0, illegal },{0, illegal },{0, illegal },{0, illegal }, |
| 142 | | {1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii }, |
| 143 | | {1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii }, |
| 144 | | |
| 145 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 146 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 147 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 148 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 149 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 150 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 151 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 152 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{2, lqid }, |
| 153 | | |
| 154 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 155 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 156 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 157 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 158 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 159 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 160 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 161 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{2, jid } |
| 162 | | }; |
| 163 | | |
| 164 | | /* Memory Maps */ |
| 165 | | |
| 166 | | static ADDRESS_MAP_START( cop410_internal_rom, ADDRESS_SPACE_PROGRAM, 8 ) |
| 167 | | AM_RANGE(0x000, 0x1ff) AM_ROM |
| 168 | | ADDRESS_MAP_END |
| 169 | | |
| 170 | | static ADDRESS_MAP_START( cop410_internal_ram, ADDRESS_SPACE_DATA, 8 ) |
| 171 | | AM_RANGE(0x00, 0x3f) AM_RAM |
| 172 | | ADDRESS_MAP_END |
| 173 | | |
| 174 | | /**************************************************************************** |
| 175 | | * Initialize emulation |
| 176 | | ****************************************************************************/ |
| 177 | | static CPU_INIT( cop410 ) |
| 178 | | { |
| 179 | | cop400_state *cop400 = device->token; |
| 180 | | int i; |
| 181 | | |
| 182 | | cop400->device = device; |
| 183 | | cop400->intf = (cop400_interface *) device->static_config; |
| 184 | | |
| 185 | | /* get address spaces */ |
| 186 | | |
| 187 | | cop400->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM); |
| 188 | | cop400->data = memory_find_address_space(device, ADDRESS_SPACE_DATA); |
| 189 | | cop400->io = memory_find_address_space(device, ADDRESS_SPACE_IO); |
| 190 | | |
| 191 | | /* set output pin masks */ |
| 192 | | |
| 193 | | cop400->g_mask = 0x0f; |
| 194 | | cop400->d_mask = 0x0f; |
| 195 | | |
| 196 | | /* set clock divider */ |
| 197 | | |
| 198 | | device_set_info_int(device, CPUINFO_INT_CLOCK_DIVIDER, cop400->intf->cki); |
| 199 | | |
| 200 | | /* allocate serial timer */ |
| 201 | | |
| 202 | | cop400->serial_timer = timer_alloc(device->machine, cop400_serial_tick, cop400); |
| 203 | | timer_adjust_periodic(cop400->serial_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16)); |
| 204 | | |
| 205 | | /* initialize instruction length array */ |
| 206 | | |
| 207 | | for (i=0; i<256; i++) cop400->InstLen[i]=1; |
| 208 | | |
| 209 | | cop400->InstLen[0x60] = cop400->InstLen[0x61] = cop400->InstLen[0x68] = cop400->InstLen[0x69] = cop400->InstLen[0x33] = cop400->InstLen[0x23] = 2; |
| 210 | | |
| 211 | | /* initialize LBI opcode array */ |
| 212 | | |
| 213 | | for (i=0; i<256; i++) cop400->LBIops[i] = 0; |
| 214 | | for (i=0x08; i<0x10; i++) cop400->LBIops[i] = 1; |
| 215 | | for (i=0x18; i<0x20; i++) cop400->LBIops[i] = 1; |
| 216 | | for (i=0x28; i<0x30; i++) cop400->LBIops[i] = 1; |
| 217 | | for (i=0x38; i<0x40; i++) cop400->LBIops[i] = 1; |
| 218 | | |
| 219 | | /* register for state saving */ |
| 220 | | |
| 221 | | state_save_register_device_item(device, 0, cop400->pc); |
| 222 | | state_save_register_device_item(device, 0, cop400->prevpc); |
| 223 | | state_save_register_device_item(device, 0, cop400->a); |
| 224 | | state_save_register_device_item(device, 0, cop400->b); |
| 225 | | state_save_register_device_item(device, 0, cop400->c); |
| 226 | | state_save_register_device_item(device, 0, cop400->en); |
| 227 | | state_save_register_device_item(device, 0, cop400->g); |
| 228 | | state_save_register_device_item(device, 0, cop400->q); |
| 229 | | state_save_register_device_item(device, 0, cop400->sa); |
| 230 | | state_save_register_device_item(device, 0, cop400->sb); |
| 231 | | state_save_register_device_item(device, 0, cop400->sio); |
| 232 | | state_save_register_device_item(device, 0, cop400->skl); |
| 233 | | state_save_register_device_item(device, 0, cop400->skip); |
| 234 | | state_save_register_device_item(device, 0, cop400->skip_lbi); |
| 235 | | state_save_register_device_item(device, 0, cop400->g_mask); |
| 236 | | state_save_register_device_item(device, 0, cop400->d_mask); |
| 237 | | state_save_register_device_item(device, 0, cop400->si); |
| 238 | | state_save_register_device_item(device, 0, cop400->microbus_int); |
| 239 | | state_save_register_device_item(device, 0, cop400->halt); |
| 240 | | } |
| 241 | | |
| 242 | | static CPU_INIT( cop411 ) |
| 243 | | { |
| 244 | | cop400_state *cop400 = device->token; |
| 245 | | |
| 246 | | CPU_INIT_CALL(cop410); |
| 247 | | |
| 248 | | /* the COP411 is like the COP410, just with less output ports */ |
| 249 | | cop400->g_mask = 0x07; |
| 250 | | cop400->d_mask = 0x03; |
| 251 | | } |
| 252 | | |
| 253 | | /**************************************************************************** |
| 254 | | * Reset registers to their initial values |
| 255 | | ****************************************************************************/ |
| 256 | | static CPU_RESET( cop410 ) |
| 257 | | { |
| 258 | | cop400_state *cop400 = device->token; |
| 259 | | |
| 260 | | PC = 0; |
| 261 | | A = 0; |
| 262 | | B = 0; |
| 263 | | C = 0; |
| 264 | | OUT_D(0); |
| 265 | | EN = 0; |
| 266 | | WRITE_G(cop400, 0); |
| 267 | | SKL = 1; |
| 268 | | |
| 269 | | cop400->halt = 0; |
| 270 | | } |
| 271 | | |
| 272 | | /**************************************************************************** |
| 273 | | * Execute cycles CPU cycles. Return number of cycles really executed |
| 274 | | ****************************************************************************/ |
| 275 | | static CPU_EXECUTE( cop410 ) |
| 276 | | { |
| 277 | | cop400_state *cop400 = device->token; |
| 278 | | |
| 279 | | UINT8 opcode; |
| 280 | | |
| 281 | | cop400->icount = cycles; |
| 282 | | |
| 283 | | do |
| 284 | | { |
| 285 | | prevPC = PC; |
| 286 | | |
| 287 | | debugger_instruction_hook(device, PC); |
| 288 | | |
| 289 | | if (cop400->intf->cko == COP400_CKO_HALT_IO_PORT) |
| 290 | | { |
| 291 | | cop400->halt = IN_CKO(); |
| 292 | | } |
| 293 | | |
| 294 | | if (cop400->halt) |
| 295 | | { |
| 296 | | cop400->icount -= 1; |
| 297 | | continue; |
| 298 | | } |
| 299 | | |
| 300 | | opcode = ROM(PC); |
| 301 | | |
| 302 | | if (cop400->skip_lbi) |
| 303 | | { |
| 304 | | if (cop400->LBIops[opcode]) |
| 305 | | { |
| 306 | | cop400->icount -= COP410_OPCODE_MAP[opcode].cycles; |
| 307 | | |
| 308 | | PC += cop400->InstLen[opcode]; |
| 309 | | } |
| 310 | | else |
| 311 | | { |
| 312 | | cop400->skip_lbi = 0; |
| 313 | | } |
| 314 | | } |
| 315 | | |
| 316 | | if (!cop400->skip_lbi) |
| 317 | | { |
| 318 | | int inst_cycles = COP410_OPCODE_MAP[opcode].cycles; |
| 319 | | PC++; |
| 320 | | (*(COP410_OPCODE_MAP[opcode].function))(cop400, opcode); |
| 321 | | cop400->icount -= inst_cycles; |
| 322 | | |
| 323 | | // skip next instruction? |
| 324 | | |
| 325 | | if (cop400->skip) |
| 326 | | { |
| 327 | | void *function = COP410_OPCODE_MAP[ROM(PC)].function; |
| 328 | | |
| 329 | | opcode = ROM(PC); |
| 330 | | |
| 331 | | if ((function == lqid) || (function == jid)) |
| 332 | | { |
| 333 | | cop400->icount -= 1; |
| 334 | | } |
| 335 | | else |
| 336 | | { |
| 337 | | cop400->icount -= COP410_OPCODE_MAP[opcode].cycles; |
| 338 | | } |
| 339 | | |
| 340 | | PC += cop400->InstLen[opcode]; |
| 341 | | |
| 342 | | cop400->skip = 0; |
| 343 | | } |
| 344 | | } |
| 345 | | } while (cop400->icount > 0); |
| 346 | | |
| 347 | | return cycles - cop400->icount; |
| 348 | | } |
| 349 | | |
| 350 | | /************************************************************************** |
| 351 | | * Validity check |
| 352 | | **************************************************************************/ |
| 353 | | static CPU_VALIDITY_CHECK( cop410 ) |
| 354 | | { |
| 355 | | int error = FALSE; |
| 356 | | const cop400_interface *intf = (const cop400_interface *) config; |
| 357 | | |
| 358 | | if ((intf == NULL) || (intf->cki <= 0)) |
| 359 | | { |
| 360 | | mame_printf_error("%s: %s has an invalid CPU configuration\n", driver->source_file, driver->name); |
| 361 | | error = TRUE; |
| 362 | | } |
| 363 | | |
| 364 | | return error; |
| 365 | | } |
| 366 | | |
| 367 | | /************************************************************************** |
| 368 | | * Generic set_info |
| 369 | | **************************************************************************/ |
| 370 | | |
| 371 | | static CPU_SET_INFO( cop410 ) |
| 372 | | { |
| 373 | | cop400_state *cop400 = device->token; |
| 374 | | |
| 375 | | switch (state) |
| 376 | | { |
| 377 | | /* --- the following bits of info are set as 64-bit signed integers --- */ |
| 378 | | case CPUINFO_INT_PC: |
| 379 | | case CPUINFO_INT_REGISTER + COP400_PC: PC = info->i; break; |
| 380 | | |
| 381 | | case CPUINFO_INT_REGISTER + COP400_A: A = info->i; break; |
| 382 | | case CPUINFO_INT_REGISTER + COP400_B: B = info->i; break; |
| 383 | | case CPUINFO_INT_REGISTER + COP400_C: C = info->i; break; |
| 384 | | case CPUINFO_INT_REGISTER + COP400_EN: EN = info->i; break; |
| 385 | | case CPUINFO_INT_REGISTER + COP400_G: G = info->i; break; |
| 386 | | case CPUINFO_INT_REGISTER + COP400_Q: Q = info->i; break; |
| 387 | | case CPUINFO_INT_REGISTER + COP400_SA: SA = info->i; break; |
| 388 | | case CPUINFO_INT_REGISTER + COP400_SB: SB = info->i; break; |
| 389 | | case CPUINFO_INT_REGISTER + COP400_SIO: SIO = info->i; break; |
| 390 | | case CPUINFO_INT_REGISTER + COP400_SKL: SKL = info->i; break; |
| 391 | | } |
| 392 | | } |
| 393 | | |
| 394 | | /************************************************************************** |
| 395 | | * Generic get_info |
| 396 | | **************************************************************************/ |
| 397 | | |
| 398 | | CPU_GET_INFO( cop410 ) |
| 399 | | { |
| 400 | | cop400_state *cop400 = (device != NULL) ? device->token : NULL; |
| 401 | | |
| 402 | | switch (state) |
| 403 | | { |
| 404 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 405 | | case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(cop400_state); break; |
| 406 | | case CPUINFO_INT_INPUT_LINES: info->i = 0; break; |
| 407 | | case CPUINFO_INT_DEFAULT_IRQ_VECTOR: info->i = 0; break; |
| 408 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 409 | | case CPUINFO_INT_CLOCK_MULTIPLIER: info->i = 1; break; |
| 410 | | case CPUINFO_INT_CLOCK_DIVIDER: info->i = 16; break; |
| 411 | | case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 1; break; |
| 412 | | case CPUINFO_INT_MAX_INSTRUCTION_BYTES: info->i = 2; break; |
| 413 | | case CPUINFO_INT_MIN_CYCLES: info->i = 1; break; |
| 414 | | case CPUINFO_INT_MAX_CYCLES: info->i = 2; break; |
| 415 | | |
| 416 | | case CPUINFO_INT_DATABUS_WIDTH_PROGRAM: info->i = 8; break; |
| 417 | | case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM: info->i = 9; break; |
| 418 | | case CPUINFO_INT_ADDRBUS_SHIFT_PROGRAM: info->i = 0; break; |
| 419 | | case CPUINFO_INT_DATABUS_WIDTH_DATA: info->i = 8; break; |
| 420 | | case CPUINFO_INT_ADDRBUS_WIDTH_DATA: info->i = 6; break; |
| 421 | | case CPUINFO_INT_ADDRBUS_SHIFT_DATA: info->i = 0; break; |
| 422 | | case CPUINFO_INT_DATABUS_WIDTH_IO: info->i = 8; break; |
| 423 | | case CPUINFO_INT_ADDRBUS_WIDTH_IO: info->i = 9; break; |
| 424 | | case CPUINFO_INT_ADDRBUS_SHIFT_IO: info->i = 0; break; |
| 425 | | |
| 426 | | case CPUINFO_INT_INPUT_STATE + 0: info->i = 0; break; |
| 427 | | |
| 428 | | case CPUINFO_INT_PREVIOUSPC: info->i = prevPC; break; |
| 429 | | |
| 430 | | case CPUINFO_INT_PC: |
| 431 | | case CPUINFO_INT_REGISTER + COP400_PC: info->i = PC; break; |
| 432 | | case CPUINFO_INT_REGISTER + COP400_A: info->i = A; break; |
| 433 | | case CPUINFO_INT_REGISTER + COP400_B: info->i = B; break; |
| 434 | | case CPUINFO_INT_REGISTER + COP400_C: info->i = C; break; |
| 435 | | case CPUINFO_INT_REGISTER + COP400_EN: info->i = EN; break; |
| 436 | | case CPUINFO_INT_REGISTER + COP400_G: info->i = G; break; |
| 437 | | case CPUINFO_INT_REGISTER + COP400_Q: info->i = Q; break; |
| 438 | | case CPUINFO_INT_REGISTER + COP400_SA: info->i = SA; break; |
| 439 | | case CPUINFO_INT_REGISTER + COP400_SB: info->i = SB; break; |
| 440 | | case CPUINFO_INT_REGISTER + COP400_SIO: info->i = SIO; break; |
| 441 | | case CPUINFO_INT_REGISTER + COP400_SKL: info->i = SKL; break; |
| 442 | | |
| 443 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 444 | | case CPUINFO_FCT_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(cop410); break; |
| 445 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop410); break; |
| 446 | | case CPUINFO_FCT_RESET: info->reset = CPU_RESET_NAME(cop410); break; |
| 447 | | case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(cop410); break; |
| 448 | | case CPUINFO_FCT_BURN: info->burn = NULL; break; |
| 449 | | case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(cop410); break; |
| 450 | | case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cop400->icount; break; |
| 451 | | case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop410); break; |
| 452 | | |
| 453 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM: |
| 454 | | info->internal_map8 = ADDRESS_MAP_NAME(cop410_internal_rom); break; |
| 455 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA: |
| 456 | | info->internal_map8 = ADDRESS_MAP_NAME(cop410_internal_ram); break; |
| 457 | | |
| 458 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 459 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP410"); break; |
| 460 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 461 | | case CPUINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break; |
| 462 | | case CPUINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break; |
| 463 | | case CPUINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright MAME Team"); break; |
| 464 | | |
| 465 | | case CPUINFO_STR_FLAGS: |
| 466 | | sprintf(info->s, " "); |
| 467 | | break; |
| 468 | | |
| 469 | | case CPUINFO_STR_REGISTER + COP400_PC: sprintf(info->s, "PC:%04X", PC); break; |
| 470 | | case CPUINFO_STR_REGISTER + COP400_A: sprintf(info->s, "A:%01X", A ); break; |
| 471 | | case CPUINFO_STR_REGISTER + COP400_B: sprintf(info->s, "B:%02X", B ); break; |
| 472 | | case CPUINFO_STR_REGISTER + COP400_C: sprintf(info->s, "C:%01X", C); break; |
| 473 | | case CPUINFO_STR_REGISTER + COP400_EN: sprintf(info->s, "EN:%01X", EN); break; |
| 474 | | case CPUINFO_STR_REGISTER + COP400_G: sprintf(info->s, "G:%01X", G); break; |
| 475 | | case CPUINFO_STR_REGISTER + COP400_Q: sprintf(info->s, "Q:%02X", Q); break; |
| 476 | | case CPUINFO_STR_REGISTER + COP400_SA: sprintf(info->s, "SA:%04X", SA); break; |
| 477 | | case CPUINFO_STR_REGISTER + COP400_SB: sprintf(info->s, "SB:%04X", SB); break; |
| 478 | | case CPUINFO_STR_REGISTER + COP400_SIO: sprintf(info->s, "SIO:%01X", SIO); break; |
| 479 | | case CPUINFO_STR_REGISTER + COP400_SKL: sprintf(info->s, "SKL:%01X", SKL); break; |
| 480 | | } |
| 481 | | } |
| 482 | | |
| 483 | | CPU_GET_INFO( cop411 ) |
| 484 | | { |
| 485 | | // COP411 is a 20-pin package version of the COP410, missing D2/D3/G3/CKO |
| 486 | | |
| 487 | | switch (state) |
| 488 | | { |
| 489 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 490 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop411); break; |
| 491 | | |
| 492 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 493 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP411"); break; |
| 494 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 495 | | |
| 496 | | default: CPU_GET_INFO_CALL(cop410); break; |
| 497 | | } |
| 498 | | } |
| 499 | | |
| 500 | | CPU_GET_INFO( cop401 ) |
| 501 | | { |
| 502 | | // COP401 is a ROMless version of the COP410 |
| 503 | | |
| 504 | | switch (state) |
| 505 | | { |
| 506 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP401"); break; |
| 507 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 508 | | |
| 509 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM: |
| 510 | | info->internal_map8 = NULL; break; |
| 511 | | |
| 512 | | default: CPU_GET_INFO_CALL(cop410); break; |
| 513 | | } |
| 514 | | } |
src/emu/cpu/cop400/cop420.c
| r4149 | r4150 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | cop420.c |
| 4 | | |
| 5 | | National Semiconductor COP420 Emulator. |
| 6 | | |
| 7 | | Copyright Nicola Salmoria and the MAME Team. |
| 8 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | | |
| 10 | | ***************************************************************************/ |
| 11 | | |
| 12 | | /* |
| 13 | | |
| 14 | | TODO: |
| 15 | | |
| 16 | | - get rid of LBIOps/InstLen |
| 17 | | - when is the microbus int cleared? |
| 18 | | - CKO sync input |
| 19 | | - save internal RAM when CKO is RAM power supply pin |
| 20 | | - run interrupt test suite |
| 21 | | - run production test suite |
| 22 | | - run microbus test suite |
| 23 | | |
| 24 | | */ |
| 25 | | |
| 26 | | #include "driver.h" |
| 27 | | #include "cpuintrf.h" |
| 28 | | #include "debugger.h" |
| 29 | | #include "cop400.h" |
| 30 | | |
| 31 | | #include "420ops.c" |
| 32 | | |
| 33 | | /* Opcode Maps */ |
| 34 | | |
| 35 | | static const s_opcode COP420_OPCODE_23_MAP[]= |
| 36 | | { |
| 37 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 38 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 39 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 40 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 41 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 42 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 43 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 44 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 45 | | |
| 46 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 47 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 48 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 49 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 50 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 51 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 52 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 53 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 54 | | |
| 55 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 56 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 57 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 58 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 59 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 60 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 61 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 62 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 63 | | |
| 64 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 65 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 66 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 67 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 68 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 69 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 70 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 71 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal } |
| 72 | | }; |
| 73 | | |
| 74 | | static void cop420_op23(cop400_state *cop400, UINT8 opcode) |
| 75 | | { |
| 76 | | UINT8 opcode23 = ROM(PC++); |
| 77 | | |
| 78 | | (*(COP420_OPCODE_23_MAP[opcode23].function))(cop400, opcode23); |
| 79 | | } |
| 80 | | |
| 81 | | static const s_opcode COP420_OPCODE_33_MAP[]= |
| 82 | | { |
| 83 | | {1, illegal },{1, skgbz0 },{1, illegal },{1, skgbz2 },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 84 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 85 | | {1, illegal },{1, skgbz1 },{1, illegal },{1, skgbz3 },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 86 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 87 | | {1, illegal },{1, skgz },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 88 | | {1, inin },{1, inil },{1, ing },{1, illegal },{1, cqma },{1, illegal },{1, inl },{1, illegal }, |
| 89 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 90 | | {1, illegal },{1, illegal },{1, omg },{1, illegal },{1, camq },{1, illegal },{1, obd },{1, illegal }, |
| 91 | | |
| 92 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 93 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 94 | | {1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi }, |
| 95 | | {1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi }, |
| 96 | | {1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei }, |
| 97 | | {1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei }, |
| 98 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 99 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 100 | | |
| 101 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 102 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 103 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 104 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 105 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 106 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 107 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 108 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 109 | | |
| 110 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 111 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 112 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 113 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 114 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 115 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 116 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 117 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal } |
| 118 | | }; |
| 119 | | |
| 120 | | static void cop420_op33(cop400_state *cop400, UINT8 opcode) |
| 121 | | { |
| 122 | | UINT8 opcode33 = ROM(PC++); |
| 123 | | |
| 124 | | (*(COP420_OPCODE_33_MAP[opcode33].function))(cop400, opcode33); |
| 125 | | } |
| 126 | | |
| 127 | | static const s_opcode COP420_OPCODE_MAP[]= |
| 128 | | { |
| 129 | | {1, clra },{1, skmbz0 },{1, xor },{1, skmbz2 },{1, xis },{1, ld },{1, x },{1, xds }, |
| 130 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 131 | | {1, casc },{1, skmbz1 },{1, xabr },{1, skmbz3 },{1, xis },{1, ld },{1, x },{1, xds }, |
| 132 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 133 | | {1, skc },{1, ske },{1, sc },{1, cop420_op23 },{1, xis },{1, ld },{1, x },{1, xds }, |
| 134 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 135 | | {1, asc },{1, add },{1, rc },{1, cop420_op33 },{1, xis },{1, ld },{1, x },{1, xds }, |
| 136 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 137 | | |
| 138 | | {1, comp },{1, skt },{1, rmb2 },{1, rmb3 },{1, nop },{1, rmb1 },{1, smb2 },{1, smb1 }, |
| 139 | | {1, cop420_ret },{1, retsk },{1, adt },{1, smb3 },{1, rmb0 },{1, smb0 },{1, cba },{1, xas }, |
| 140 | | {1, cab },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc }, |
| 141 | | {1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc }, |
| 142 | | {2, jmp },{2, jmp },{2, jmp },{2, jmp },{0, illegal },{0, illegal },{0, illegal },{0, illegal }, |
| 143 | | {2, jsr },{2, jsr },{2, jsr },{2, jsr },{0, illegal },{0, illegal },{0, illegal },{0, illegal }, |
| 144 | | {1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii }, |
| 145 | | {1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii }, |
| 146 | | |
| 147 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 148 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 149 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 150 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 151 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 152 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 153 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 154 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{2, lqid }, |
| 155 | | |
| 156 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 157 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 158 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 159 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 160 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 161 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 162 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 163 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{2, jid } |
| 164 | | }; |
| 165 | | |
| 166 | | /* Memory Maps */ |
| 167 | | |
| 168 | | static ADDRESS_MAP_START( cop420_internal_rom, ADDRESS_SPACE_PROGRAM, 8 ) |
| 169 | | AM_RANGE(0x000, 0x3ff) AM_ROM |
| 170 | | ADDRESS_MAP_END |
| 171 | | |
| 172 | | static ADDRESS_MAP_START( cop420_internal_ram, ADDRESS_SPACE_DATA, 8 ) |
| 173 | | AM_RANGE(0x00, 0x3f) AM_RAM |
| 174 | | ADDRESS_MAP_END |
| 175 | | |
| 176 | | /**************************************************************************** |
| 177 | | * Initialize emulation |
| 178 | | ****************************************************************************/ |
| 179 | | static CPU_INIT( cop420 ) |
| 180 | | { |
| 181 | | cop400_state *cop400 = device->token; |
| 182 | | int i; |
| 183 | | |
| 184 | | cop400->device = device; |
| 185 | | cop400->intf = (cop400_interface *) device->static_config; |
| 186 | | |
| 187 | | /* get address spaces */ |
| 188 | | |
| 189 | | cop400->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM); |
| 190 | | cop400->data = memory_find_address_space(device, ADDRESS_SPACE_DATA); |
| 191 | | cop400->io = memory_find_address_space(device, ADDRESS_SPACE_IO); |
| 192 | | |
| 193 | | /* set output pin masks */ |
| 194 | | |
| 195 | | cop400->g_mask = 0x0f; // G0-G3 available |
| 196 | | cop400->d_mask = 0x0f; // D0-D3 available |
| 197 | | cop400->in_mask = 0x0f; // IN0-IN3 available |
| 198 | | |
| 199 | | /* set clock divider */ |
| 200 | | |
| 201 | | device_set_info_int(device, CPUINFO_INT_CLOCK_DIVIDER, cop400->intf->cki); |
| 202 | | |
| 203 | | /* allocate serial timer */ |
| 204 | | |
| 205 | | cop400->serial_timer = timer_alloc(device->machine, cop400_serial_tick, cop400); |
| 206 | | timer_adjust_periodic(cop400->serial_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16)); |
| 207 | | |
| 208 | | /* allocate counter timer */ |
| 209 | | |
| 210 | | cop400->counter_timer = timer_alloc(device->machine, cop400_counter_tick, cop400); |
| 211 | | timer_adjust_periodic(cop400->counter_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16 / 4)); |
| 212 | | |
| 213 | | /* allocate IN latch timer */ |
| 214 | | |
| 215 | | cop400->inil_timer = timer_alloc(device->machine, cop400_inil_tick, cop400); |
| 216 | | timer_adjust_periodic(cop400->inil_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16)); |
| 217 | | |
| 218 | | /* allocate Microbus timer */ |
| 219 | | |
| 220 | | if (cop400->intf->microbus == COP400_MICROBUS_ENABLED) |
| 221 | | { |
| 222 | | cop400->microbus_timer = timer_alloc(device->machine, cop400_microbus_tick, cop400); |
| 223 | | timer_adjust_periodic(cop400->microbus_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16)); |
| 224 | | } |
| 225 | | |
| 226 | | /* initialize instruction length array */ |
| 227 | | |
| 228 | | for (i=0; i<256; i++) cop400->InstLen[i]=1; |
| 229 | | |
| 230 | | cop400->InstLen[0x60] = cop400->InstLen[0x61] = cop400->InstLen[0x62] = cop400->InstLen[0x63] = |
| 231 | | cop400->InstLen[0x68] = cop400->InstLen[0x69] = cop400->InstLen[0x6a] = cop400->InstLen[0x6b] = |
| 232 | | cop400->InstLen[0x33] = cop400->InstLen[0x23] = 2; |
| 233 | | |
| 234 | | /* initialize LBI opcode array */ |
| 235 | | |
| 236 | | for (i=0; i<256; i++) cop400->LBIops[i] = 0; |
| 237 | | for (i=0x08; i<0x10; i++) cop400->LBIops[i] = 1; |
| 238 | | for (i=0x18; i<0x20; i++) cop400->LBIops[i] = 1; |
| 239 | | for (i=0x28; i<0x30; i++) cop400->LBIops[i] = 1; |
| 240 | | for (i=0x38; i<0x40; i++) cop400->LBIops[i] = 1; |
| 241 | | |
| 242 | | for (i=0; i<256; i++) cop400->LBIops33[i] = 0; |
| 243 | | for (i=0x80; i<0xc0; i++) cop400->LBIops33[i] = 1; |
| 244 | | |
| 245 | | /* register for state saving */ |
| 246 | | |
| 247 | | state_save_register_device_item(device, 0, cop400->pc); |
| 248 | | state_save_register_device_item(device, 0, cop400->prevpc); |
| 249 | | state_save_register_device_item(device, 0, cop400->a); |
| 250 | | state_save_register_device_item(device, 0, cop400->b); |
| 251 | | state_save_register_device_item(device, 0, cop400->c); |
| 252 | | state_save_register_device_item(device, 0, cop400->en); |
| 253 | | state_save_register_device_item(device, 0, cop400->g); |
| 254 | | state_save_register_device_item(device, 0, cop400->q); |
| 255 | | state_save_register_device_item(device, 0, cop400->sa); |
| 256 | | state_save_register_device_item(device, 0, cop400->sb); |
| 257 | | state_save_register_device_item(device, 0, cop400->sc); |
| 258 | | state_save_register_device_item(device, 0, cop400->sio); |
| 259 | | state_save_register_device_item(device, 0, cop400->skl); |
| 260 | | state_save_register_device_item(device, 0, cop400->skip); |
| 261 | | state_save_register_device_item(device, 0, cop400->skip_lbi); |
| 262 | | state_save_register_device_item(device, 0, cop400->t); |
| 263 | | state_save_register_device_item(device, 0, cop400->skt_latch); |
| 264 | | state_save_register_device_item(device, 0, cop400->g_mask); |
| 265 | | state_save_register_device_item(device, 0, cop400->d_mask); |
| 266 | | state_save_register_device_item(device, 0, cop400->in_mask); |
| 267 | | state_save_register_device_item(device, 0, cop400->si); |
| 268 | | state_save_register_device_item(device, 0, cop400->last_skip); |
| 269 | | state_save_register_device_item_array(device, 0, cop400->in); |
| 270 | | state_save_register_device_item(device, 0, cop400->microbus_int); |
| 271 | | state_save_register_device_item(device, 0, cop400->halt); |
| 272 | | } |
| 273 | | |
| 274 | | static CPU_INIT( cop421 ) |
| 275 | | { |
| 276 | | cop400_state *cop400 = device->token; |
| 277 | | |
| 278 | | CPU_INIT_CALL(cop420); |
| 279 | | |
| 280 | | /* set output pin masks */ |
| 281 | | cop400->in_mask = 0; // IN lines not available |
| 282 | | } |
| 283 | | |
| 284 | | static CPU_INIT( cop422 ) |
| 285 | | { |
| 286 | | cop400_state *cop400 = device->token; |
| 287 | | |
| 288 | | CPU_INIT_CALL(cop420); |
| 289 | | |
| 290 | | /* set output pin masks */ |
| 291 | | cop400->g_mask = 0x0e; // only G2, G3 available |
| 292 | | cop400->d_mask = 0x0e; // only D2, D3 available |
| 293 | | cop400->in_mask = 0; // IN lines not available |
| 294 | | } |
| 295 | | |
| 296 | | /**************************************************************************** |
| 297 | | * Reset registers to their initial values |
| 298 | | ****************************************************************************/ |
| 299 | | static CPU_RESET( cop420 ) |
| 300 | | { |
| 301 | | cop400_state *cop400 = device->token; |
| 302 | | |
| 303 | | PC = 0; |
| 304 | | A = 0; |
| 305 | | B = 0; |
| 306 | | C = 0; |
| 307 | | OUT_D(0); |
| 308 | | EN = 0; |
| 309 | | WRITE_G(cop400, 0); |
| 310 | | SKL = 1; |
| 311 | | |
| 312 | | T = 0; |
| 313 | | cop400->skt_latch = 1; |
| 314 | | } |
| 315 | | |
| 316 | | /**************************************************************************** |
| 317 | | * Execute cycles CPU cycles. Return number of cycles really executed |
| 318 | | ****************************************************************************/ |
| 319 | | static CPU_EXECUTE( cop420 ) |
| 320 | | { |
| 321 | | cop400_state *cop400 = device->token; |
| 322 | | |
| 323 | | UINT8 opcode; |
| 324 | | |
| 325 | | cop400->icount = cycles; |
| 326 | | |
| 327 | | do |
| 328 | | { |
| 329 | | prevPC = PC; |
| 330 | | |
| 331 | | debugger_instruction_hook(device, PC); |
| 332 | | |
| 333 | | opcode = ROM(PC); |
| 334 | | |
| 335 | | if (cop400->skip_lbi) |
| 336 | | { |
| 337 | | int is_lbi = 0; |
| 338 | | |
| 339 | | if (opcode == 0x33) |
| 340 | | { |
| 341 | | is_lbi = cop400->LBIops33[ROM(PC+1)]; |
| 342 | | } |
| 343 | | else |
| 344 | | { |
| 345 | | is_lbi = cop400->LBIops[opcode]; |
| 346 | | } |
| 347 | | |
| 348 | | if (is_lbi) |
| 349 | | { |
| 350 | | cop400->icount -= COP420_OPCODE_MAP[opcode].cycles; |
| 351 | | |
| 352 | | PC += cop400->InstLen[opcode]; |
| 353 | | } |
| 354 | | else |
| 355 | | { |
| 356 | | cop400->skip_lbi = 0; |
| 357 | | } |
| 358 | | } |
| 359 | | |
| 360 | | if (!cop400->skip_lbi) |
| 361 | | { |
| 362 | | int inst_cycles = COP420_OPCODE_MAP[opcode].cycles; |
| 363 | | PC++; |
| 364 | | (*(COP420_OPCODE_MAP[opcode].function))(cop400, opcode); |
| 365 | | cop400->icount -= inst_cycles; |
| 366 | | |
| 367 | | // check for interrupt |
| 368 | | |
| 369 | | if (BIT(EN, 1) && BIT(IL, 1)) |
| 370 | | { |
| 371 | | void *function = COP420_OPCODE_MAP[ROM(PC)].function; |
| 372 | | |
| 373 | | if ((function != jp) && (function != jmp) && (function != jsr)) |
| 374 | | { |
| 375 | | // store skip logic |
| 376 | | cop400->last_skip = cop400->skip; |
| 377 | | cop400->skip = 0; |
| 378 | | |
| 379 | | // push next PC |
| 380 | | PUSH(PC); |
| 381 | | |
| 382 | | // jump to interrupt service routine |
| 383 | | PC = 0x0ff; |
| 384 | | |
| 385 | | // disable interrupt |
| 386 | | EN &= ~0x02; |
| 387 | | } |
| 388 | | |
| 389 | | IL &= ~2; |
| 390 | | } |
| 391 | | |
| 392 | | // skip next instruction? |
| 393 | | |
| 394 | | if (cop400->skip) |
| 395 | | { |
| 396 | | void *function = COP420_OPCODE_MAP[ROM(PC)].function; |
| 397 | | |
| 398 | | opcode = ROM(PC); |
| 399 | | |
| 400 | | if ((function == lqid) || (function == jid)) |
| 401 | | { |
| 402 | | cop400->icount -= 1; |
| 403 | | } |
| 404 | | else |
| 405 | | { |
| 406 | | cop400->icount -= COP420_OPCODE_MAP[opcode].cycles; |
| 407 | | } |
| 408 | | |
| 409 | | PC += cop400->InstLen[opcode]; |
| 410 | | |
| 411 | | cop400->skip = 0; |
| 412 | | } |
| 413 | | } |
| 414 | | } while (cop400->icount > 0); |
| 415 | | |
| 416 | | return cycles - cop400->icount; |
| 417 | | } |
| 418 | | |
| 419 | | /************************************************************************** |
| 420 | | * Validity check |
| 421 | | **************************************************************************/ |
| 422 | | static CPU_VALIDITY_CHECK( cop420 ) |
| 423 | | { |
| 424 | | int error = FALSE; |
| 425 | | const cop400_interface *intf = (const cop400_interface *) config; |
| 426 | | |
| 427 | | if ((intf == NULL) || (intf->cki <= 0)) |
| 428 | | { |
| 429 | | mame_printf_error("%s: %s has an invalid CPU configuration\n", driver->source_file, driver->name); |
| 430 | | error = TRUE; |
| 431 | | } |
| 432 | | |
| 433 | | return error; |
| 434 | | } |
| 435 | | |
| 436 | | static CPU_VALIDITY_CHECK( cop421 ) |
| 437 | | { |
| 438 | | int error = FALSE; |
| 439 | | const cop400_interface *intf = (const cop400_interface *) config; |
| 440 | | |
| 441 | | if ((intf == NULL) || (intf->cki <= 0) || (intf->microbus == COP400_MICROBUS_ENABLED)) |
| 442 | | { |
| 443 | | mame_printf_error("%s: %s has an invalid CPU configuration\n", driver->source_file, driver->name); |
| 444 | | error = TRUE; |
| 445 | | } |
| 446 | | |
| 447 | | return error; |
| 448 | | } |
| 449 | | |
| 450 | | /************************************************************************** |
| 451 | | * Generic set_info |
| 452 | | **************************************************************************/ |
| 453 | | |
| 454 | | static CPU_SET_INFO( cop420 ) |
| 455 | | { |
| 456 | | cop400_state *cop400 = device->token; |
| 457 | | |
| 458 | | switch (state) |
| 459 | | { |
| 460 | | /* --- the following bits of info are set as 64-bit signed integers --- */ |
| 461 | | case CPUINFO_INT_PC: |
| 462 | | case CPUINFO_INT_REGISTER + COP400_PC: PC = info->i; break; |
| 463 | | |
| 464 | | case CPUINFO_INT_REGISTER + COP400_A: A = info->i; break; |
| 465 | | case CPUINFO_INT_REGISTER + COP400_B: B = info->i; break; |
| 466 | | case CPUINFO_INT_REGISTER + COP400_C: C = info->i; break; |
| 467 | | case CPUINFO_INT_REGISTER + COP400_EN: EN = info->i; break; |
| 468 | | case CPUINFO_INT_REGISTER + COP400_G: G = info->i; break; |
| 469 | | case CPUINFO_INT_REGISTER + COP400_Q: Q = info->i; break; |
| 470 | | case CPUINFO_INT_REGISTER + COP400_SA: SA = info->i; break; |
| 471 | | case CPUINFO_INT_REGISTER + COP400_SB: SB = info->i; break; |
| 472 | | case CPUINFO_INT_REGISTER + COP400_SC: SC = info->i; break; |
| 473 | | case CPUINFO_INT_REGISTER + COP400_SIO: SIO = info->i; break; |
| 474 | | case CPUINFO_INT_REGISTER + COP400_SKL: SKL = info->i; break; |
| 475 | | } |
| 476 | | } |
| 477 | | |
| 478 | | /************************************************************************** |
| 479 | | * Generic get_info |
| 480 | | **************************************************************************/ |
| 481 | | |
| 482 | | CPU_GET_INFO( cop420 ) |
| 483 | | { |
| 484 | | cop400_state *cop400 = (device != NULL) ? device->token : NULL; |
| 485 | | |
| 486 | | switch (state) |
| 487 | | { |
| 488 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 489 | | case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(cop400_state); break; |
| 490 | | case CPUINFO_INT_INPUT_LINES: info->i = 0; break; |
| 491 | | case CPUINFO_INT_DEFAULT_IRQ_VECTOR: info->i = 0; break; |
| 492 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 493 | | case CPUINFO_INT_CLOCK_MULTIPLIER: info->i = 1; break; |
| 494 | | case CPUINFO_INT_CLOCK_DIVIDER: info->i = 16; break; |
| 495 | | case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 1; break; |
| 496 | | case CPUINFO_INT_MAX_INSTRUCTION_BYTES: info->i = 2; break; |
| 497 | | case CPUINFO_INT_MIN_CYCLES: info->i = 1; break; |
| 498 | | case CPUINFO_INT_MAX_CYCLES: info->i = 2; break; |
| 499 | | |
| 500 | | case CPUINFO_INT_DATABUS_WIDTH_PROGRAM: info->i = 8; break; |
| 501 | | case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM: info->i = 10; break; |
| 502 | | case CPUINFO_INT_ADDRBUS_SHIFT_PROGRAM: info->i = 0; break; |
| 503 | | case CPUINFO_INT_DATABUS_WIDTH_DATA: info->i = 8; break; |
| 504 | | case CPUINFO_INT_ADDRBUS_WIDTH_DATA: info->i = 6; break; |
| 505 | | case CPUINFO_INT_ADDRBUS_SHIFT_DATA: info->i = 0; break; |
| 506 | | case CPUINFO_INT_DATABUS_WIDTH_IO: info->i = 8; break; |
| 507 | | case CPUINFO_INT_ADDRBUS_WIDTH_IO: info->i = 9; break; |
| 508 | | case CPUINFO_INT_ADDRBUS_SHIFT_IO: info->i = 0; break; |
| 509 | | |
| 510 | | case CPUINFO_INT_INPUT_STATE + 0: info->i = 0; break; |
| 511 | | |
| 512 | | case CPUINFO_INT_PREVIOUSPC: info->i = prevPC; break; |
| 513 | | |
| 514 | | case CPUINFO_INT_PC: |
| 515 | | case CPUINFO_INT_REGISTER + COP400_PC: info->i = PC; break; |
| 516 | | case CPUINFO_INT_REGISTER + COP400_A: info->i = A; break; |
| 517 | | case CPUINFO_INT_REGISTER + COP400_B: info->i = B; break; |
| 518 | | case CPUINFO_INT_REGISTER + COP400_C: info->i = C; break; |
| 519 | | case CPUINFO_INT_REGISTER + COP400_EN: info->i = EN; break; |
| 520 | | case CPUINFO_INT_REGISTER + COP400_G: info->i = G; break; |
| 521 | | case CPUINFO_INT_REGISTER + COP400_Q: info->i = Q; break; |
| 522 | | case CPUINFO_INT_REGISTER + COP400_SA: info->i = SA; break; |
| 523 | | case CPUINFO_INT_REGISTER + COP400_SB: info->i = SB; break; |
| 524 | | case CPUINFO_INT_REGISTER + COP400_SC: info->i = SC; break; |
| 525 | | case CPUINFO_INT_REGISTER + COP400_SIO: info->i = SIO; break; |
| 526 | | case CPUINFO_INT_REGISTER + COP400_SKL: info->i = SKL; break; |
| 527 | | |
| 528 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 529 | | case CPUINFO_FCT_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(cop420); break; |
| 530 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop420); break; |
| 531 | | case CPUINFO_FCT_RESET: info->reset = CPU_RESET_NAME(cop420); break; |
| 532 | | case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(cop420); break; |
| 533 | | case CPUINFO_FCT_BURN: info->burn = NULL; break; |
| 534 | | case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(cop420); break; |
| 535 | | case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cop400->icount; break; |
| 536 | | case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop420); break; |
| 537 | | |
| 538 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM: |
| 539 | | info->internal_map8 = ADDRESS_MAP_NAME(cop420_internal_rom); break; |
| 540 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA: |
| 541 | | info->internal_map8 = ADDRESS_MAP_NAME(cop420_internal_ram); break; |
| 542 | | |
| 543 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 544 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP420"); break; |
| 545 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 546 | | case CPUINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break; |
| 547 | | case CPUINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break; |
| 548 | | case CPUINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright MAME Team"); break; |
| 549 | | |
| 550 | | case CPUINFO_STR_FLAGS: |
| 551 | | sprintf(info->s, " "); |
| 552 | | break; |
| 553 | | |
| 554 | | case CPUINFO_STR_REGISTER + COP400_PC: sprintf(info->s, "PC:%04X", PC); break; |
| 555 | | case CPUINFO_STR_REGISTER + COP400_A: sprintf(info->s, "A:%01X", A ); break; |
| 556 | | case CPUINFO_STR_REGISTER + COP400_B: sprintf(info->s, "B:%02X", B ); break; |
| 557 | | case CPUINFO_STR_REGISTER + COP400_C: sprintf(info->s, "C:%01X", C); break; |
| 558 | | case CPUINFO_STR_REGISTER + COP400_EN: sprintf(info->s, "EN:%01X", EN); break; |
| 559 | | case CPUINFO_STR_REGISTER + COP400_G: sprintf(info->s, "G:%01X", G); break; |
| 560 | | case CPUINFO_STR_REGISTER + COP400_Q: sprintf(info->s, "Q:%02X", Q); break; |
| 561 | | case CPUINFO_STR_REGISTER + COP400_SA: sprintf(info->s, "SA:%04X", SA); break; |
| 562 | | case CPUINFO_STR_REGISTER + COP400_SB: sprintf(info->s, "SB:%04X", SB); break; |
| 563 | | case CPUINFO_STR_REGISTER + COP400_SC: sprintf(info->s, "SC:%04X", SC); break; |
| 564 | | case CPUINFO_STR_REGISTER + COP400_SIO: sprintf(info->s, "SIO:%01X", SIO); break; |
| 565 | | case CPUINFO_STR_REGISTER + COP400_SKL: sprintf(info->s, "SKL:%01X", SKL); break; |
| 566 | | } |
| 567 | | } |
| 568 | | |
| 569 | | CPU_GET_INFO( cop421 ) |
| 570 | | { |
| 571 | | // COP421 is a 24-pin package version of the COP420, lacking the IN ports |
| 572 | | |
| 573 | | switch (state) |
| 574 | | { |
| 575 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 576 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop421); break; |
| 577 | | case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop421); break; |
| 578 | | |
| 579 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 580 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP421"); break; |
| 581 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 582 | | |
| 583 | | default: CPU_GET_INFO_CALL(cop420); break; |
| 584 | | } |
| 585 | | } |
| 586 | | |
| 587 | | CPU_GET_INFO( cop422 ) |
| 588 | | { |
| 589 | | // COP422 is a 20-pin package version of the COP420, lacking G0/G1, D0/D1, and the IN ports |
| 590 | | |
| 591 | | switch (state) |
| 592 | | { |
| 593 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 594 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop422); break; |
| 595 | | case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop421); break; |
| 596 | | |
| 597 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 598 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP422"); break; |
| 599 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 600 | | |
| 601 | | default: CPU_GET_INFO_CALL(cop420); break; |
| 602 | | } |
| 603 | | } |
| 604 | | |
| 605 | | CPU_GET_INFO( cop402 ) |
| 606 | | { |
| 607 | | // COP402 is a ROMless version of the COP420 |
| 608 | | |
| 609 | | switch (state) |
| 610 | | { |
| 611 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 612 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM: |
| 613 | | info->internal_map8 = NULL; break; |
| 614 | | |
| 615 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 616 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP402"); break; |
| 617 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 618 | | |
| 619 | | default: CPU_GET_INFO_CALL(cop420); break; |
| 620 | | } |
| 621 | | } |
src/emu/cpu/cop400/cop440.c
| r4149 | r4150 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | cop440.c |
| 4 | | |
| 5 | | National Semiconductor COP420 Emulator. |
| 6 | | |
| 7 | | Copyright Nicola Salmoria and the MAME Team. |
| 8 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | | |
| 10 | | ***************************************************************************/ |
| 11 | | |
| 12 | | /* |
| 13 | | |
| 14 | | TODO: |
| 15 | | |
| 16 | | - rename this file to cop444.c |
| 17 | | - COP440/COP441/COP442 (new registers: 4-bit H, 8-bit R; some new opcodes, 2Kx8 ROM, 160x4 RAM) |
| 18 | | - COP404 emulation configuration inputs |
| 19 | | - RAM bus width |
| 20 | | - get rid of LBIOps/InstLen |
| 21 | | - when is the microbus int cleared? |
| 22 | | - CKO sync input |
| 23 | | - save internal RAM when CKO is RAM power supply pin |
| 24 | | - run interrupt test suite |
| 25 | | - run production test suite |
| 26 | | - run microbus test suite |
| 27 | | |
| 28 | | */ |
| 29 | | |
| 30 | | #include "driver.h" |
| 31 | | #include "cpuintrf.h" |
| 32 | | #include "debugger.h" |
| 33 | | #include "cop400.h" |
| 34 | | |
| 35 | | #include "440ops.c" |
| 36 | | |
| 37 | | /* Opcode Maps */ |
| 38 | | |
| 39 | | static const s_opcode COP440_OPCODE_23_MAP[256]= |
| 40 | | { |
| 41 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 42 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 43 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 44 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 45 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 46 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 47 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 48 | | {1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd },{1, ldd }, |
| 49 | | |
| 50 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 51 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 52 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 53 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 54 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 55 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 56 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 57 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 58 | | |
| 59 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 60 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 61 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 62 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 63 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 64 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 65 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 66 | | {1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad },{1, xad }, |
| 67 | | |
| 68 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 69 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 70 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 71 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 72 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 73 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 74 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 75 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal } |
| 76 | | }; |
| 77 | | |
| 78 | | static void cop440_op23(cop400_state *cop400, UINT8 opcode) |
| 79 | | { |
| 80 | | UINT8 opcode23 = ROM(PC++); |
| 81 | | |
| 82 | | (*(COP440_OPCODE_23_MAP[opcode23].function))(cop400, opcode23); |
| 83 | | } |
| 84 | | |
| 85 | | static const s_opcode COP440_OPCODE_33_MAP[256]= |
| 86 | | { |
| 87 | | {1, illegal },{1, skgbz0 },{1, illegal },{1, skgbz2 },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 88 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 89 | | {1, illegal },{1, skgbz1 },{1, illegal },{1, skgbz3 },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 90 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 91 | | {1, illegal },{1, skgz },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 92 | | {1, inin },{1, inil },{1, ing },{1, illegal },{1, cqma },{1, illegal },{1, inl },{1, ctma }, |
| 93 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 94 | | {1, it },{1, illegal },{1, omg },{1, illegal },{1, camq },{1, illegal },{1, obd },{1, camt }, |
| 95 | | |
| 96 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 97 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 98 | | {1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi }, |
| 99 | | {1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi },{1, ogi }, |
| 100 | | {1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei }, |
| 101 | | {1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei },{1, lei }, |
| 102 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 103 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 104 | | |
| 105 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 106 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 107 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 108 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 109 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 110 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 111 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 112 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 113 | | |
| 114 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 115 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 116 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 117 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 118 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 119 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 120 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal }, |
| 121 | | {1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal },{1, illegal } |
| 122 | | }; |
| 123 | | |
| 124 | | static void cop440_op33(cop400_state *cop400, UINT8 opcode) |
| 125 | | { |
| 126 | | UINT8 opcode33 = ROM(PC++); |
| 127 | | |
| 128 | | (*(COP440_OPCODE_33_MAP[opcode33].function))(cop400, opcode33); |
| 129 | | } |
| 130 | | |
| 131 | | static const s_opcode COP440_OPCODE_MAP[256]= |
| 132 | | { |
| 133 | | {1, clra },{1, skmbz0 },{1, xor },{1, skmbz2 },{1, xis },{1, ld },{1, x },{1, xds }, |
| 134 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 135 | | {1, casc },{1, skmbz1 },{1, xabr },{1, skmbz3 },{1, xis },{1, ld },{1, x },{1, xds }, |
| 136 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 137 | | {1, skc },{1, ske },{1, sc },{1, cop440_op23 },{1, xis },{1, ld },{1, x },{1, xds }, |
| 138 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 139 | | {1, asc },{1, add },{1, rc },{1, cop440_op33 },{1, xis },{1, ld },{1, x },{1, xds }, |
| 140 | | {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, |
| 141 | | |
| 142 | | {1, comp },{1, skt },{1, rmb2 },{1, rmb3 },{1, nop },{1, rmb1 },{1, smb2 },{1, smb1 }, |
| 143 | | {1, cop420_ret },{1, retsk },{1, adt },{1, smb3 },{1, rmb0 },{1, smb0 },{1, cba },{1, xas }, |
| 144 | | {1, cab },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc }, |
| 145 | | {1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc },{1, aisc }, |
| 146 | | {2, jmp },{2, jmp },{2, jmp },{2, jmp },{0, illegal },{0, illegal },{0, illegal },{0, illegal }, |
| 147 | | {2, jsr },{2, jsr },{2, jsr },{2, jsr },{0, illegal },{0, illegal },{0, illegal },{0, illegal }, |
| 148 | | {1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii }, |
| 149 | | {1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii },{1, stii }, |
| 150 | | |
| 151 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 152 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 153 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 154 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 155 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 156 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 157 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 158 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{2, lqid }, |
| 159 | | |
| 160 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 161 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 162 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 163 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 164 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 165 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 166 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp }, |
| 167 | | {1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{1, jp },{2, jid } |
| 168 | | }; |
| 169 | | |
| 170 | | /* Memory Maps */ |
| 171 | | |
| 172 | | static ADDRESS_MAP_START( cop424_internal_rom, ADDRESS_SPACE_PROGRAM, 8 ) |
| 173 | | AM_RANGE(0x000, 0x3ff) AM_ROM |
| 174 | | ADDRESS_MAP_END |
| 175 | | |
| 176 | | static ADDRESS_MAP_START( cop424_internal_ram, ADDRESS_SPACE_DATA, 8 ) |
| 177 | | AM_RANGE(0x00, 0x3f) AM_RAM |
| 178 | | ADDRESS_MAP_END |
| 179 | | |
| 180 | | static ADDRESS_MAP_START( cop444_internal_rom, ADDRESS_SPACE_PROGRAM, 8 ) |
| 181 | | AM_RANGE(0x000, 0x7ff) AM_ROM |
| 182 | | ADDRESS_MAP_END |
| 183 | | |
| 184 | | static ADDRESS_MAP_START( cop444_internal_ram, ADDRESS_SPACE_DATA, 8 ) |
| 185 | | AM_RANGE(0x00, 0x7f) AM_RAM |
| 186 | | ADDRESS_MAP_END |
| 187 | | |
| 188 | | /**************************************************************************** |
| 189 | | * Initialize emulation |
| 190 | | ****************************************************************************/ |
| 191 | | static CPU_INIT( cop444 ) |
| 192 | | { |
| 193 | | cop400_state *cop400 = device->token; |
| 194 | | int i; |
| 195 | | |
| 196 | | cop400->device = device; |
| 197 | | cop400->intf = (cop400_interface *) device->static_config; |
| 198 | | |
| 199 | | /* get address spaces */ |
| 200 | | |
| 201 | | cop400->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM); |
| 202 | | cop400->data = memory_find_address_space(device, ADDRESS_SPACE_DATA); |
| 203 | | cop400->io = memory_find_address_space(device, ADDRESS_SPACE_IO); |
| 204 | | |
| 205 | | /* set output pin masks */ |
| 206 | | |
| 207 | | cop400->g_mask = 0x0f; // G0-G3 available |
| 208 | | cop400->d_mask = 0x0f; // D0-D3 available |
| 209 | | cop400->in_mask = 0x0f; // IN0-IN3 available |
| 210 | | |
| 211 | | /* set clock divider */ |
| 212 | | |
| 213 | | device_set_info_int(device, CPUINFO_INT_CLOCK_DIVIDER, cop400->intf->cki); |
| 214 | | |
| 215 | | /* allocate serial timer */ |
| 216 | | |
| 217 | | cop400->serial_timer = timer_alloc(device->machine, cop400_serial_tick, cop400); |
| 218 | | timer_adjust_periodic(cop400->serial_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16)); |
| 219 | | |
| 220 | | /* allocate counter timer */ |
| 221 | | |
| 222 | | cop400->counter_timer = timer_alloc(device->machine, cop400_counter_tick, cop400); |
| 223 | | timer_adjust_periodic(cop400->counter_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16 / 4)); |
| 224 | | |
| 225 | | /* allocate IN latch timer */ |
| 226 | | |
| 227 | | cop400->inil_timer = timer_alloc(device->machine, cop400_inil_tick, cop400); |
| 228 | | timer_adjust_periodic(cop400->inil_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16)); |
| 229 | | |
| 230 | | /* allocate Microbus timer */ |
| 231 | | |
| 232 | | if (cop400->intf->microbus == COP400_MICROBUS_ENABLED) |
| 233 | | { |
| 234 | | cop400->microbus_timer = timer_alloc(device->machine, cop400_microbus_tick, cop400); |
| 235 | | timer_adjust_periodic(cop400->microbus_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16)); |
| 236 | | } |
| 237 | | |
| 238 | | /* initialize instruction length array */ |
| 239 | | |
| 240 | | for (i=0; i<256; i++) cop400->InstLen[i]=1; |
| 241 | | |
| 242 | | cop400->InstLen[0x60] = cop400->InstLen[0x61] = cop400->InstLen[0x62] = cop400->InstLen[0x63] = |
| 243 | | cop400->InstLen[0x68] = cop400->InstLen[0x69] = cop400->InstLen[0x6a] = cop400->InstLen[0x6b] = |
| 244 | | cop400->InstLen[0x33] = cop400->InstLen[0x23] = 2; |
| 245 | | |
| 246 | | /* initialize LBI opcode array */ |
| 247 | | |
| 248 | | for (i=0; i<256; i++) cop400->LBIops[i] = 0; |
| 249 | | for (i=0x08; i<0x10; i++) cop400->LBIops[i] = 1; |
| 250 | | for (i=0x18; i<0x20; i++) cop400->LBIops[i] = 1; |
| 251 | | for (i=0x28; i<0x30; i++) cop400->LBIops[i] = 1; |
| 252 | | for (i=0x38; i<0x40; i++) cop400->LBIops[i] = 1; |
| 253 | | |
| 254 | | for (i=0; i<256; i++) cop400->LBIops33[i] = 0; |
| 255 | | for (i=0x80; i<0xc0; i++) cop400->LBIops33[i] = 1; |
| 256 | | |
| 257 | | /* register for state saving */ |
| 258 | | |
| 259 | | state_save_register_device_item(device, 0, cop400->pc); |
| 260 | | state_save_register_device_item(device, 0, cop400->prevpc); |
| 261 | | state_save_register_device_item(device, 0, cop400->a); |
| 262 | | state_save_register_device_item(device, 0, cop400->b); |
| 263 | | state_save_register_device_item(device, 0, cop400->c); |
| 264 | | state_save_register_device_item(device, 0, cop400->en); |
| 265 | | state_save_register_device_item(device, 0, cop400->g); |
| 266 | | state_save_register_device_item(device, 0, cop400->q); |
| 267 | | state_save_register_device_item(device, 0, cop400->sa); |
| 268 | | state_save_register_device_item(device, 0, cop400->sb); |
| 269 | | state_save_register_device_item(device, 0, cop400->sc); |
| 270 | | state_save_register_device_item(device, 0, cop400->sio); |
| 271 | | state_save_register_device_item(device, 0, cop400->skl); |
| 272 | | state_save_register_device_item(device, 0, cop400->skip); |
| 273 | | state_save_register_device_item(device, 0, cop400->skip_lbi); |
| 274 | | state_save_register_device_item(device, 0, cop400->t); |
| 275 | | state_save_register_device_item(device, 0, cop400->skt_latch); |
| 276 | | state_save_register_device_item(device, 0, cop400->g_mask); |
| 277 | | state_save_register_device_item(device, 0, cop400->d_mask); |
| 278 | | state_save_register_device_item(device, 0, cop400->in_mask); |
| 279 | | state_save_register_device_item(device, 0, cop400->si); |
| 280 | | state_save_register_device_item(device, 0, cop400->last_skip); |
| 281 | | state_save_register_device_item_array(device, 0, cop400->in); |
| 282 | | state_save_register_device_item(device, 0, cop400->microbus_int); |
| 283 | | state_save_register_device_item(device, 0, cop400->halt); |
| 284 | | } |
| 285 | | |
| 286 | | static CPU_INIT( cop425 ) |
| 287 | | { |
| 288 | | cop400_state *cop400 = device->token; |
| 289 | | |
| 290 | | CPU_INIT_CALL(cop444); |
| 291 | | |
| 292 | | cop400->in_mask = 0; |
| 293 | | } |
| 294 | | |
| 295 | | static CPU_INIT( cop426 ) |
| 296 | | { |
| 297 | | cop400_state *cop400 = device->token; |
| 298 | | |
| 299 | | CPU_INIT_CALL(cop444); |
| 300 | | |
| 301 | | cop400->g_mask = 0x0e; // only G2, G3 available |
| 302 | | cop400->d_mask = 0x0e; // only D2, D3 available |
| 303 | | } |
| 304 | | |
| 305 | | static CPU_INIT( cop445 ) |
| 306 | | { |
| 307 | | cop400_state *cop400 = device->token; |
| 308 | | |
| 309 | | CPU_INIT_CALL(cop444); |
| 310 | | |
| 311 | | cop400->g_mask = 0x07; |
| 312 | | cop400->d_mask = 0x03; |
| 313 | | cop400->in_mask = 0; |
| 314 | | } |
| 315 | | |
| 316 | | /**************************************************************************** |
| 317 | | * Reset registers to their initial values |
| 318 | | ****************************************************************************/ |
| 319 | | static CPU_RESET( cop444 ) |
| 320 | | { |
| 321 | | cop400_state *cop400 = device->token; |
| 322 | | |
| 323 | | PC = 0; |
| 324 | | A = 0; |
| 325 | | B = 0; |
| 326 | | C = 0; |
| 327 | | OUT_D(0); |
| 328 | | EN = 0; |
| 329 | | WRITE_G(cop400, 0); |
| 330 | | SKL = 1; |
| 331 | | |
| 332 | | T = 0; |
| 333 | | cop400->skt_latch = 1; |
| 334 | | |
| 335 | | cop400->halt = 0; |
| 336 | | cop400->idle = 0; |
| 337 | | } |
| 338 | | |
| 339 | | /**************************************************************************** |
| 340 | | * Execute cycles CPU cycles. Return number of cycles really executed |
| 341 | | ****************************************************************************/ |
| 342 | | static CPU_EXECUTE( cop444 ) |
| 343 | | { |
| 344 | | cop400_state *cop400 = device->token; |
| 345 | | |
| 346 | | UINT8 opcode; |
| 347 | | |
| 348 | | cop400->icount = cycles; |
| 349 | | |
| 350 | | do |
| 351 | | { |
| 352 | | prevPC = PC; |
| 353 | | |
| 354 | | debugger_instruction_hook(device, PC); |
| 355 | | |
| 356 | | if (cop400->intf->cko == COP400_CKO_HALT_IO_PORT) |
| 357 | | { |
| 358 | | cop400->halt = IN_CKO(); |
| 359 | | } |
| 360 | | |
| 361 | | if (cop400->halt) |
| 362 | | { |
| 363 | | cop400->icount -= 1; |
| 364 | | continue; |
| 365 | | } |
| 366 | | |
| 367 | | opcode = ROM(PC); |
| 368 | | |
| 369 | | if (cop400->skip_lbi) |
| 370 | | { |
| 371 | | int is_lbi = 0; |
| 372 | | |
| 373 | | if (opcode == 0x33) |
| 374 | | { |
| 375 | | is_lbi = cop400->LBIops33[ROM(PC+1)]; |
| 376 | | } |
| 377 | | else |
| 378 | | { |
| 379 | | is_lbi = cop400->LBIops[opcode]; |
| 380 | | } |
| 381 | | |
| 382 | | if (is_lbi) |
| 383 | | { |
| 384 | | cop400->icount -= COP440_OPCODE_MAP[opcode].cycles; |
| 385 | | |
| 386 | | PC += cop400->InstLen[opcode]; |
| 387 | | } |
| 388 | | else |
| 389 | | { |
| 390 | | cop400->skip_lbi = 0; |
| 391 | | } |
| 392 | | } |
| 393 | | |
| 394 | | if (!cop400->skip_lbi) |
| 395 | | { |
| 396 | | int inst_cycles = COP440_OPCODE_MAP[opcode].cycles; |
| 397 | | |
| 398 | | PC++; |
| 399 | | |
| 400 | | (*(COP440_OPCODE_MAP[opcode].function))(cop400, opcode); |
| 401 | | cop400->icount -= inst_cycles; |
| 402 | | |
| 403 | | // check for interrupt |
| 404 | | |
| 405 | | if (BIT(EN, 1) && BIT(IL, 1)) |
| 406 | | { |
| 407 | | void *function = COP440_OPCODE_MAP[ROM(PC)].function; |
| 408 | | |
| 409 | | if ((function != jp) && (function != jmp) && (function != jsr)) |
| 410 | | { |
| 411 | | // store skip logic |
| 412 | | cop400->last_skip = cop400->skip; |
| 413 | | cop400->skip = 0; |
| 414 | | |
| 415 | | // push next PC |
| 416 | | PUSH(PC); |
| 417 | | |
| 418 | | // jump to interrupt service routine |
| 419 | | PC = 0x0ff; |
| 420 | | |
| 421 | | // disable interrupt |
| 422 | | EN &= ~0x02; |
| 423 | | } |
| 424 | | |
| 425 | | IL &= ~2; |
| 426 | | } |
| 427 | | |
| 428 | | // skip next instruction? |
| 429 | | |
| 430 | | if (cop400->skip) |
| 431 | | { |
| 432 | | void *function = COP440_OPCODE_MAP[ROM(PC)].function; |
| 433 | | |
| 434 | | opcode = ROM(PC); |
| 435 | | |
| 436 | | if ((function == lqid) || (function == jid)) |
| 437 | | { |
| 438 | | cop400->icount -= 1; |
| 439 | | } |
| 440 | | else |
| 441 | | { |
| 442 | | cop400->icount -= COP440_OPCODE_MAP[opcode].cycles; |
| 443 | | } |
| 444 | | PC += cop400->InstLen[opcode]; |
| 445 | | |
| 446 | | cop400->skip = 0; |
| 447 | | } |
| 448 | | } |
| 449 | | } while (cop400->icount > 0); |
| 450 | | |
| 451 | | return cycles - cop400->icount; |
| 452 | | } |
| 453 | | |
| 454 | | /************************************************************************** |
| 455 | | * Validity check |
| 456 | | **************************************************************************/ |
| 457 | | static CPU_VALIDITY_CHECK( cop444 ) |
| 458 | | { |
| 459 | | int error = FALSE; |
| 460 | | const cop400_interface *intf = (const cop400_interface *) config; |
| 461 | | |
| 462 | | if ((intf == NULL) || (intf->cki <= 0)) |
| 463 | | { |
| 464 | | mame_printf_error("%s: %s has an invalid CPU configuration\n", driver->source_file, driver->name); |
| 465 | | error = TRUE; |
| 466 | | } |
| 467 | | |
| 468 | | return error; |
| 469 | | } |
| 470 | | |
| 471 | | /************************************************************************** |
| 472 | | * Generic set_info |
| 473 | | **************************************************************************/ |
| 474 | | |
| 475 | | static CPU_SET_INFO( cop444 ) |
| 476 | | { |
| 477 | | cop400_state *cop400 = device->token; |
| 478 | | |
| 479 | | switch (state) |
| 480 | | { |
| 481 | | /* --- the following bits of info are set as 64-bit signed integers --- */ |
| 482 | | case CPUINFO_INT_PC: |
| 483 | | case CPUINFO_INT_REGISTER + COP400_PC: PC = info->i; break; |
| 484 | | |
| 485 | | case CPUINFO_INT_REGISTER + COP400_A: A = info->i; break; |
| 486 | | case CPUINFO_INT_REGISTER + COP400_B: B = info->i; break; |
| 487 | | case CPUINFO_INT_REGISTER + COP400_C: C = info->i; break; |
| 488 | | case CPUINFO_INT_REGISTER + COP400_EN: EN = info->i; break; |
| 489 | | case CPUINFO_INT_REGISTER + COP400_G: G = info->i; break; |
| 490 | | case CPUINFO_INT_REGISTER + COP400_Q: Q = info->i; break; |
| 491 | | case CPUINFO_INT_REGISTER + COP400_SA: SA = info->i; break; |
| 492 | | case CPUINFO_INT_REGISTER + COP400_SB: SB = info->i; break; |
| 493 | | case CPUINFO_INT_REGISTER + COP400_SC: SC = info->i; break; |
| 494 | | case CPUINFO_INT_REGISTER + COP400_SIO: SIO = info->i; break; |
| 495 | | case CPUINFO_INT_REGISTER + COP400_SKL: SKL = info->i; break; |
| 496 | | case CPUINFO_INT_REGISTER + COP400_T: T = info->i; break; |
| 497 | | } |
| 498 | | } |
| 499 | | |
| 500 | | /************************************************************************** |
| 501 | | * Generic get_info |
| 502 | | **************************************************************************/ |
| 503 | | |
| 504 | | CPU_GET_INFO( cop444 ) |
| 505 | | { |
| 506 | | cop400_state *cop400 = (device != NULL) ? device->token : NULL; |
| 507 | | |
| 508 | | switch (state) |
| 509 | | { |
| 510 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 511 | | case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(cop400_state); break; |
| 512 | | case CPUINFO_INT_INPUT_LINES: info->i = 0; break; |
| 513 | | case CPUINFO_INT_DEFAULT_IRQ_VECTOR: info->i = 0; break; |
| 514 | | case CPUINFO_INT_ENDIANNESS: info->i = ENDIANNESS_LITTLE; break; |
| 515 | | case CPUINFO_INT_CLOCK_MULTIPLIER: info->i = 1; break; |
| 516 | | case CPUINFO_INT_CLOCK_DIVIDER: info->i = 16; break; |
| 517 | | case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 1; break; |
| 518 | | case CPUINFO_INT_MAX_INSTRUCTION_BYTES: info->i = 2; break; |
| 519 | | case CPUINFO_INT_MIN_CYCLES: info->i = 1; break; |
| 520 | | case CPUINFO_INT_MAX_CYCLES: info->i = 2; break; |
| 521 | | |
| 522 | | case CPUINFO_INT_DATABUS_WIDTH_PROGRAM: info->i = 8; break; |
| 523 | | case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM: info->i = 10; break; |
| 524 | | case CPUINFO_INT_ADDRBUS_SHIFT_PROGRAM: info->i = 0; break; |
| 525 | | case CPUINFO_INT_DATABUS_WIDTH_DATA: info->i = 8; break; |
| 526 | | case CPUINFO_INT_ADDRBUS_WIDTH_DATA: info->i = 7; break; |
| 527 | | case CPUINFO_INT_ADDRBUS_SHIFT_DATA: info->i = 0; break; |
| 528 | | case CPUINFO_INT_DATABUS_WIDTH_IO: info->i = 8; break; |
| 529 | | case CPUINFO_INT_ADDRBUS_WIDTH_IO: info->i = 9; break; |
| 530 | | case CPUINFO_INT_ADDRBUS_SHIFT_IO: info->i = 0; break; |
| 531 | | |
| 532 | | case CPUINFO_INT_INPUT_STATE + 0: info->i = 0; break; |
| 533 | | |
| 534 | | case CPUINFO_INT_PREVIOUSPC: info->i = prevPC; break; |
| 535 | | |
| 536 | | case CPUINFO_INT_PC: |
| 537 | | case CPUINFO_INT_REGISTER + COP400_PC: info->i = PC; break; |
| 538 | | case CPUINFO_INT_REGISTER + COP400_A: info->i = A; break; |
| 539 | | case CPUINFO_INT_REGISTER + COP400_B: info->i = B; break; |
| 540 | | case CPUINFO_INT_REGISTER + COP400_C: info->i = C; break; |
| 541 | | case CPUINFO_INT_REGISTER + COP400_EN: info->i = EN; break; |
| 542 | | case CPUINFO_INT_REGISTER + COP400_G: info->i = G; break; |
| 543 | | case CPUINFO_INT_REGISTER + COP400_Q: info->i = Q; break; |
| 544 | | case CPUINFO_INT_REGISTER + COP400_SA: info->i = SA; break; |
| 545 | | case CPUINFO_INT_REGISTER + COP400_SB: info->i = SB; break; |
| 546 | | case CPUINFO_INT_REGISTER + COP400_SC: info->i = SC; break; |
| 547 | | case CPUINFO_INT_REGISTER + COP400_SIO: info->i = SIO; break; |
| 548 | | case CPUINFO_INT_REGISTER + COP400_SKL: info->i = SKL; break; |
| 549 | | |
| 550 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 551 | | case CPUINFO_FCT_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(cop444); break; |
| 552 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop444); break; |
| 553 | | case CPUINFO_FCT_RESET: info->reset = CPU_RESET_NAME(cop444); break; |
| 554 | | case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(cop444); break; |
| 555 | | case CPUINFO_FCT_BURN: info->burn = NULL; break; |
| 556 | | case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(cop444); break; |
| 557 | | case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cop400->icount; break; |
| 558 | | case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop444); break; |
| 559 | | |
| 560 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM: |
| 561 | | info->internal_map8 = ADDRESS_MAP_NAME(cop444_internal_rom); break; |
| 562 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA: |
| 563 | | info->internal_map8 = ADDRESS_MAP_NAME(cop444_internal_ram); break; |
| 564 | | |
| 565 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 566 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP444"); break; |
| 567 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 568 | | case CPUINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break; |
| 569 | | case CPUINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break; |
| 570 | | case CPUINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright MAME Team"); break; |
| 571 | | |
| 572 | | case CPUINFO_STR_FLAGS: |
| 573 | | sprintf(info->s, " "); |
| 574 | | break; |
| 575 | | |
| 576 | | case CPUINFO_STR_REGISTER + COP400_PC: sprintf(info->s, "PC:%04X", PC); break; |
| 577 | | case CPUINFO_STR_REGISTER + COP400_A: sprintf(info->s, "A:%01X", A ); break; |
| 578 | | case CPUINFO_STR_REGISTER + COP400_B: sprintf(info->s, "B:%02X", B ); break; |
| 579 | | case CPUINFO_STR_REGISTER + COP400_C: sprintf(info->s, "C:%01X", C); break; |
| 580 | | case CPUINFO_STR_REGISTER + COP400_EN: sprintf(info->s, "EN:%01X", EN); break; |
| 581 | | case CPUINFO_STR_REGISTER + COP400_G: sprintf(info->s, "G:%01X", G); break; |
| 582 | | case CPUINFO_STR_REGISTER + COP400_Q: sprintf(info->s, "Q:%02X", Q); break; |
| 583 | | case CPUINFO_STR_REGISTER + COP400_SA: sprintf(info->s, "SA:%04X", SA); break; |
| 584 | | case CPUINFO_STR_REGISTER + COP400_SB: sprintf(info->s, "SB:%04X", SB); break; |
| 585 | | case CPUINFO_STR_REGISTER + COP400_SC: sprintf(info->s, "SC:%04X", SC); break; |
| 586 | | case CPUINFO_STR_REGISTER + COP400_SIO: sprintf(info->s, "SIO:%01X", SIO); break; |
| 587 | | case CPUINFO_STR_REGISTER + COP400_SKL: sprintf(info->s, "SKL:%01X", SKL); break; |
| 588 | | } |
| 589 | | } |
| 590 | | |
| 591 | | CPU_GET_INFO( cop445 ) |
| 592 | | { |
| 593 | | // COP445 is a 24-pin package version of the COP444, lacking the IN ports |
| 594 | | |
| 595 | | switch (state) |
| 596 | | { |
| 597 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 598 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop445); break; |
| 599 | | |
| 600 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 601 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP445"); break; |
| 602 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 603 | | |
| 604 | | default: CPU_GET_INFO_CALL(cop444); break; |
| 605 | | } |
| 606 | | } |
| 607 | | |
| 608 | | CPU_GET_INFO( cop424 ) |
| 609 | | { |
| 610 | | // COP424 is functionally equivalent to COP444, with only 1K ROM and 64x4 bytes RAM |
| 611 | | |
| 612 | | switch (state) |
| 613 | | { |
| 614 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 615 | | case CPUINFO_INT_ADDRBUS_WIDTH_DATA: info->i = 6; break; |
| 616 | | |
| 617 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 618 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM: |
| 619 | | info->internal_map8 = ADDRESS_MAP_NAME(cop424_internal_rom); break; |
| 620 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA: |
| 621 | | info->internal_map8 = ADDRESS_MAP_NAME(cop424_internal_ram); break; |
| 622 | | |
| 623 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 624 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP424"); break; |
| 625 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 626 | | |
| 627 | | default: CPU_GET_INFO_CALL(cop444); break; |
| 628 | | } |
| 629 | | } |
| 630 | | |
| 631 | | CPU_GET_INFO( cop425 ) |
| 632 | | { |
| 633 | | // COP425 is a 24-pin package version of the COP424, lacking the IN ports |
| 634 | | |
| 635 | | switch (state) |
| 636 | | { |
| 637 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 638 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop425); break; |
| 639 | | |
| 640 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 641 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP425"); break; |
| 642 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 643 | | |
| 644 | | default: CPU_GET_INFO_CALL(cop424); break; |
| 645 | | } |
| 646 | | } |
| 647 | | |
| 648 | | CPU_GET_INFO( cop426 ) |
| 649 | | { |
| 650 | | // COP426 is a 20-pin package version of the COP424, with only L0-L7, G2-G3, D2-D3 ports |
| 651 | | |
| 652 | | switch (state) |
| 653 | | { |
| 654 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 655 | | case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop426); break; |
| 656 | | |
| 657 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 658 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP426"); break; |
| 659 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 660 | | |
| 661 | | default: CPU_GET_INFO_CALL(cop424); break; |
| 662 | | } |
| 663 | | } |
| 664 | | |
| 665 | | CPU_GET_INFO( cop404 ) |
| 666 | | { |
| 667 | | // COP404 is a ROMless version of the COP444, which can emulate a COP410 or a COP424 |
| 668 | | |
| 669 | | switch (state) |
| 670 | | { |
| 671 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 672 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM: |
| 673 | | info->internal_map8 = NULL; break; |
| 674 | | |
| 675 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 676 | | case CPUINFO_STR_NAME: strcpy(info->s, "COP404"); break; |
| 677 | | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "National Semiconductor COPS"); break; |
| 678 | | |
| 679 | | default: CPU_GET_INFO_CALL(cop444); break; |
| 680 | | } |
| 681 | | } |