src/mess/drivers/pasopia.c
| r8536 | r8537 | |
| 1 | | /*************************************************************************** |
| 1 | /************************************************************************************************** |
| 2 | 2 | |
| 3 | 3 | Toshiba Pasopia 7 (c) 1983 Toshiba |
| 4 | 4 | |
| r8536 | r8537 | |
| 6 | 6 | |
| 7 | 7 | TODO: |
| 8 | 8 | - floppy support (but floppy images are unobtainable at current time) |
| 9 | - Z80PIO keyboard irq doesn't work at all, kludged keyboard inputs to work for now |
| 10 | - advanced BASIC commands (width 80, circle, line ...) makes the emulation to go to la-la-land |
| 11 | - some text garbage pops up in place, first example is when you type "10 for a=0 to n" |
| 9 | 12 | |
| 10 | | ****************************************************************************/ |
| 13 | ***************************************************************************************************/ |
| 11 | 14 | |
| 12 | 15 | #include "emu.h" |
| 13 | 16 | #include "cpu/z80/z80.h" |
| r8536 | r8537 | |
| 18 | 21 | #include "video/mc6845.h" |
| 19 | 22 | |
| 20 | 23 | static UINT8 vram_sel,mio_sel; |
| 21 | | static UINT8 *p7_vram; |
| 24 | static UINT8 *p7_vram,*p7_pal; |
| 22 | 25 | static UINT8 bank_reg; |
| 23 | 26 | static UINT16 cursor_addr; |
| 24 | 27 | static UINT8 cursor_blink; |
| 25 | | static UINT8 plane_reg,attr_data,attr_wrap,attr_latch; |
| 28 | static UINT8 plane_reg,attr_data,attr_wrap,attr_latch,pal_sel,x_width; |
| 26 | 29 | |
| 27 | 30 | static VIDEO_START( paso7 ) |
| 28 | 31 | { |
| 29 | 32 | p7_vram = auto_alloc_array(machine, UINT8, 0x10000); |
| 33 | p7_pal = auto_alloc_array(machine, UINT8, 0x10); |
| 30 | 34 | } |
| 31 | 35 | |
| 32 | 36 | #define keyb_press(_val_,_charset_) \ |
| r8536 | r8537 | |
| 106 | 110 | keyb_press(KEYCODE_STOP, '.'); |
| 107 | 111 | keyb_shift_press(KEYCODE_STOP, ':'); |
| 108 | 112 | keyb_press(KEYCODE_BACKSPACE, 0x08); |
| 113 | keyb_press(KEYCODE_0_PAD, '@'); //@ |
| 114 | keyb_press(KEYCODE_COMMA, ','); |
| 115 | keyb_shift_press(KEYCODE_COMMA, ';'); |
| 116 | keyb_press(KEYCODE_MINUS_PAD, '-'); |
| 109 | 117 | |
| 110 | 118 | } |
| 111 | 119 | |
| 112 | 120 | static VIDEO_UPDATE( paso7 ) |
| 113 | 121 | { |
| 114 | | int x,y; |
| 122 | int x,y,xi; |
| 115 | 123 | int count; |
| 124 | int width; |
| 116 | 125 | |
| 126 | fake_keyboard_data(screen->machine); |
| 127 | |
| 128 | width = x_width ? 80 : 40; |
| 129 | |
| 117 | 130 | count = 0x0000; |
| 118 | 131 | |
| 119 | | fake_keyboard_data(screen->machine); |
| 132 | for(y=0;y<200;y++) |
| 133 | { |
| 134 | for(x=0;x<320;x+=8) |
| 135 | { |
| 136 | for(xi=0;xi<8;xi++) |
| 137 | { |
| 138 | int pen_b,pen_r,pen_g,color; |
| 120 | 139 | |
| 140 | pen_b = (p7_vram[count+0x0000]>>(7-xi)) & 1; |
| 141 | pen_r = (p7_vram[count+0x4000]>>(7-xi)) & 1; |
| 142 | pen_g = 0;//(p7_vram[count+0x8000]>>(7-xi)) & 1; |
| 143 | |
| 144 | color = pen_g<<2 | pen_r<<1 | pen_b<<0; |
| 145 | |
| 146 | *BITMAP_ADDR16(bitmap, y, x+xi) = screen->machine->pens[color+0x20]; |
| 147 | } |
| 148 | count++; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | count = 0x0000; |
| 153 | |
| 121 | 154 | for(y=0;y<25;y++) |
| 122 | 155 | { |
| 123 | | for(x=0;x<40;x++) |
| 156 | for(x=0;x<width;x++) |
| 124 | 157 | { |
| 125 | 158 | int tile = p7_vram[count+0x8000]; |
| 126 | 159 | int color = p7_vram[count+0xc000]; |
| 127 | 160 | |
| 128 | | drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],tile,color,0,0,x*8,y*8); |
| 161 | drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],tile,color,0,0,x*8,y*8,0); |
| 129 | 162 | |
| 130 | 163 | if(((cursor_addr*8) == count) && !cursor_blink) // draw cursor |
| 131 | | drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],0x5f,7,0,0,x*8,y*8); |
| 164 | drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],0x5f,7,0,0,x*8,y*8,0); |
| 132 | 165 | |
| 133 | 166 | count+=8; |
| 134 | 167 | } |
| r8536 | r8537 | |
| 139 | 172 | |
| 140 | 173 | static READ8_HANDLER( vram_r ) |
| 141 | 174 | { |
| 175 | static UINT8 res; |
| 176 | |
| 142 | 177 | //if(!vram_sel) |
| 143 | 178 | // return 0xff; |
| 144 | 179 | |
| 145 | | attr_latch = p7_vram[offset | 0xc000]; |
| 146 | | i8255a_w(devtag_get_device(space->machine, "ppi8255_0"), 1, (attr_latch << 4) | (attr_latch & 0x7)); |
| 180 | if(pal_sel && (plane_reg & 0x70) == 0x00) |
| 181 | return p7_pal[offset & 0xf]; |
| 147 | 182 | |
| 148 | | return p7_vram[offset | 0x8000]; //TODO |
| 183 | res = 0xff; |
| 184 | |
| 185 | if((plane_reg & 0x11) == 0x11) |
| 186 | res &= p7_vram[offset | 0x0000]; |
| 187 | if((plane_reg & 0x22) == 0x22) |
| 188 | res &= p7_vram[offset | 0x4000]; |
| 189 | if((plane_reg & 0x44) == 0x44) |
| 190 | { |
| 191 | res &= p7_vram[offset | 0x8000]; |
| 192 | attr_latch = p7_vram[offset | 0xc000]; |
| 193 | i8255a_w(devtag_get_device(space->machine, "ppi8255_0"), 1, (attr_latch << 4) | (attr_latch & 0x7)); |
| 194 | } |
| 195 | |
| 196 | return res; |
| 149 | 197 | } |
| 150 | 198 | |
| 151 | 199 | static WRITE8_HANDLER( vram_w ) |
| 152 | 200 | { |
| 153 | 201 | //if(vram_sel) |
| 154 | 202 | { |
| 155 | | if((plane_reg & 0x44) == 0x44) |
| 203 | if(pal_sel && (plane_reg & 0x70) == 0x00) |
| 156 | 204 | { |
| 157 | | p7_vram[offset | 0x8000] = data; |
| 205 | p7_pal[offset & 0xf] = data & 0xf; |
| 206 | return; |
| 207 | } |
| 208 | |
| 209 | if(plane_reg & 0x10) |
| 210 | p7_vram[offset | 0x0000] = (plane_reg & 1) ? data : 0xff; |
| 211 | if(plane_reg & 0x20) |
| 212 | p7_vram[offset | 0x4000] = (plane_reg & 2) ? data : 0xff; |
| 213 | if(plane_reg & 0x40) |
| 214 | { |
| 215 | p7_vram[offset | 0x8000] = (plane_reg & 4) ? data : 0xff; |
| 158 | 216 | attr_latch = attr_wrap ? attr_latch : attr_data; |
| 159 | 217 | p7_vram[offset | 0xc000] = attr_latch; |
| 160 | 218 | i8255a_w(devtag_get_device(space->machine, "ppi8255_0"), 1, (attr_latch << 4) | (attr_latch & 0x7)); |
| r8536 | r8537 | |
| 240 | 298 | UINT8 *pac2_ram = memory_region(space->machine, "rampac1"); |
| 241 | 299 | |
| 242 | 300 | if(offset == 2) |
| 301 | { |
| 243 | 302 | if(pac2_bank_select == 4) |
| 303 | { |
| 244 | 304 | return pac2_ram[pac2_index[4]]; |
| 305 | } |
| 306 | else |
| 307 | { |
| 308 | printf("%02x\n",pac2_bank_select); |
| 309 | } |
| 310 | } |
| 245 | 311 | |
| 246 | 312 | return 0xff; |
| 247 | 313 | } |
| r8536 | r8537 | |
| 441 | 507 | |
| 442 | 508 | static WRITE8_DEVICE_HANDLER( screen_mode_w ) |
| 443 | 509 | { |
| 444 | | printf("GFX MODE %02x\n",data); |
| 510 | if(data & 0xdf) |
| 511 | printf("GFX MODE %02x\n",data); |
| 512 | x_width = data & 0x20; |
| 445 | 513 | } |
| 446 | 514 | |
| 447 | 515 | static WRITE8_DEVICE_HANDLER( plane_reg_w ) |
| 448 | 516 | { |
| 449 | | printf("PLANE %02x\n",data); |
| 517 | //if(data & 0x11) |
| 518 | //printf("PLANE %02x\n",data); |
| 450 | 519 | plane_reg = data; |
| 451 | 520 | } |
| 452 | 521 | |
| 453 | 522 | static WRITE8_DEVICE_HANDLER( video_attr_w ) |
| 454 | 523 | { |
| 455 | | printf("VIDEO ATTR %02x | TEXT_PAGE %02x\n",data & 0xf,data & 0x70); |
| 524 | //printf("VIDEO ATTR %02x | TEXT_PAGE %02x\n",data & 0xf,data & 0x70); |
| 456 | 525 | attr_data = data & 0xf; |
| 457 | 526 | } |
| 458 | 527 | |
| 528 | //#include "debugger.h" |
| 529 | |
| 459 | 530 | static WRITE8_DEVICE_HANDLER( video_misc_w ) |
| 460 | 531 | { |
| 461 | 532 | /* |
| r8536 | r8537 | |
| 464 | 535 | ---- x--- pal disable |
| 465 | 536 | ---- xx-- palette selector (both bits enables this, odd hook-up) |
| 466 | 537 | */ |
| 467 | | // printf("VIDEO MISC REG %02x\n",data); |
| 538 | // if(data & 2) |
| 539 | // { |
| 540 | // printf("VIDEO MISC %02x\n",data); |
| 541 | // debugger_break(device->machine); |
| 542 | // } |
| 468 | 543 | cursor_blink = data & 0x20; |
| 469 | 544 | attr_wrap = data & 0x10; |
| 470 | | |
| 545 | // pal_sel = data & 0x02; |
| 471 | 546 | } |
| 472 | 547 | |
| 473 | 548 | static WRITE8_DEVICE_HANDLER( nmi_mask_w ) |
| r8536 | r8537 | |
| 478 | 553 | ---- --x- sound off |
| 479 | 554 | ---- ---x reset NMI (writes to port B = clears bits 1 & 2) (???) |
| 480 | 555 | */ |
| 481 | | printf("SYSTEM MISC %02x\n",data); |
| 556 | // printf("SYSTEM MISC %02x\n",data); |
| 482 | 557 | |
| 483 | | if(data & 1) |
| 484 | | i8255a_w(devtag_get_device(device->machine, "ppi8255_2"), 1, 0); |
| 558 | // if(data & 1) |
| 559 | // i8255a_w(devtag_get_device(device->machine, "ppi8255_2"), 1, 0); |
| 485 | 560 | |
| 486 | 561 | } |
| 487 | 562 | |
| r8536 | r8537 | |
| 571 | 646 | |
| 572 | 647 | palette_set_color_rgb(machine, i, r,g,b); |
| 573 | 648 | } |
| 649 | for( i = 0x000; i < 8; i++) |
| 650 | palette_set_color_rgb(machine, i+0x020, pal1bit(i >> 1), pal1bit(i >> 2), pal1bit(i >> 0)); |
| 574 | 651 | } |
| 575 | 652 | |
| 576 | 653 | static MACHINE_DRIVER_START( paso7 ) |
| r8536 | r8537 | |
| 598 | 675 | MDRV_SCREEN_SIZE(640, 480) |
| 599 | 676 | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) |
| 600 | 677 | MDRV_MC6845_ADD("crtc", H46505, XTAL_3_579545MHz/4, mc6845_intf) /* unknown clock, hand tuned to get ~60 fps */ |
| 601 | | MDRV_PALETTE_LENGTH(0x20) |
| 678 | MDRV_PALETTE_LENGTH(0x28) |
| 602 | 679 | MDRV_PALETTE_INIT(pasopia7) |
| 603 | 680 | |
| 604 | 681 | MDRV_GFXDECODE( pasopia7 ) |