src/mess/drivers/pasopia.c
| r11751 | r11752 | |
| 1 | | /************************************************************************************************** |
| 2 | | |
| 3 | | Toshiba Pasopia 7 (c) 1983 Toshiba |
| 4 | | |
| 5 | | preliminary driver by Angelo Salese |
| 6 | | |
| 7 | | TODO: |
| 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 | | - cassette device; |
| 11 | | |
| 12 | | ***************************************************************************************************/ |
| 13 | | |
| 14 | | #include "emu.h" |
| 15 | | #include "cpu/z80/z80.h" |
| 16 | | #include "machine/z80ctc.h" |
| 17 | | #include "machine/i8255.h" |
| 18 | | #include "machine/z80pio.h" |
| 19 | | #include "machine/upd765.h" |
| 20 | | #include "sound/sn76496.h" |
| 21 | | #include "video/mc6845.h" |
| 22 | | |
| 23 | | |
| 24 | | class pasopia_state : public driver_device |
| 25 | | { |
| 26 | | public: |
| 27 | | pasopia_state(const machine_config &mconfig, device_type type, const char *tag) |
| 28 | | : driver_device(mconfig, type, tag) { } |
| 29 | | |
| 30 | | UINT8 m_vram_sel; |
| 31 | | UINT8 m_mio_sel; |
| 32 | | UINT8 *m_p7_pal; |
| 33 | | UINT8 m_bank_reg; |
| 34 | | UINT16 m_cursor_addr; |
| 35 | | UINT8 m_cursor_blink; |
| 36 | | UINT8 m_cursor_raster; |
| 37 | | UINT8 m_plane_reg; |
| 38 | | UINT8 m_attr_data; |
| 39 | | UINT8 m_attr_wrap; |
| 40 | | UINT8 m_attr_latch; |
| 41 | | UINT8 m_pal_sel; |
| 42 | | UINT8 m_x_width; |
| 43 | | UINT8 m_gfx_mode; |
| 44 | | UINT8 m_nmi_mask; |
| 45 | | UINT8 m_nmi_enable_reg; |
| 46 | | UINT8 m_nmi_trap; |
| 47 | | UINT8 m_nmi_reset; |
| 48 | | UINT16 m_pac2_index[2]; |
| 49 | | UINT32 m_kanji_index; |
| 50 | | UINT8 m_pac2_bank_select; |
| 51 | | int m_addr_latch; |
| 52 | | }; |
| 53 | | |
| 54 | | |
| 55 | | |
| 56 | | |
| 57 | | #define VDP_CLOCK XTAL_3_579545MHz/4 |
| 58 | | |
| 59 | | static VIDEO_START( paso7 ) |
| 60 | | { |
| 61 | | pasopia_state *state = machine.driver_data<pasopia_state>(); |
| 62 | | state->m_p7_pal = auto_alloc_array(machine, UINT8, 0x10); |
| 63 | | } |
| 64 | | |
| 65 | | #define keyb_press(_val_,_charset_) \ |
| 66 | | if(machine.input().code_pressed(_val_)) \ |
| 67 | | { \ |
| 68 | | ram_space->write_byte(0xfda4,0x01); \ |
| 69 | | ram_space->write_byte(0xfce1,_charset_); \ |
| 70 | | } \ |
| 71 | | |
| 72 | | #define keyb_shift_press(_val_,_charset_) \ |
| 73 | | if(machine.input().code_pressed(_val_) && machine.input().code_pressed(KEYCODE_LSHIFT)) \ |
| 74 | | { \ |
| 75 | | ram_space->write_byte(0xfda4,0x01); \ |
| 76 | | ram_space->write_byte(0xfce1,_charset_); \ |
| 77 | | } \ |
| 78 | | |
| 79 | | /* cheap kludge to use the keyboard without going nuts with the debugger ... */ |
| 80 | | static void fake_keyboard_data(running_machine &machine) |
| 81 | | { |
| 82 | | address_space *ram_space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 83 | | |
| 84 | | ram_space->write_byte(0xfda4,0x00); //clear flag |
| 85 | | |
| 86 | | keyb_press(KEYCODE_Z, 'z'); |
| 87 | | keyb_press(KEYCODE_X, 'x'); |
| 88 | | keyb_press(KEYCODE_C, 'c'); |
| 89 | | keyb_press(KEYCODE_V, 'v'); |
| 90 | | keyb_press(KEYCODE_B, 'b'); |
| 91 | | keyb_press(KEYCODE_N, 'n'); |
| 92 | | keyb_press(KEYCODE_M, 'm'); |
| 93 | | |
| 94 | | keyb_press(KEYCODE_A, 'a'); |
| 95 | | keyb_press(KEYCODE_S, 's'); |
| 96 | | keyb_press(KEYCODE_D, 'd'); |
| 97 | | keyb_press(KEYCODE_F, 'f'); |
| 98 | | keyb_press(KEYCODE_G, 'g'); |
| 99 | | keyb_press(KEYCODE_H, 'h'); |
| 100 | | keyb_press(KEYCODE_J, 'j'); |
| 101 | | keyb_press(KEYCODE_K, 'k'); |
| 102 | | keyb_press(KEYCODE_L, 'l'); |
| 103 | | |
| 104 | | keyb_press(KEYCODE_Q, 'q'); |
| 105 | | keyb_press(KEYCODE_W, 'w'); |
| 106 | | keyb_press(KEYCODE_E, 'e'); |
| 107 | | keyb_press(KEYCODE_R, 'r'); |
| 108 | | keyb_press(KEYCODE_T, 't'); |
| 109 | | keyb_press(KEYCODE_Y, 'y'); |
| 110 | | keyb_press(KEYCODE_U, 'u'); |
| 111 | | keyb_press(KEYCODE_I, 'i'); |
| 112 | | keyb_press(KEYCODE_O, 'o'); |
| 113 | | keyb_press(KEYCODE_P, 'p'); |
| 114 | | |
| 115 | | keyb_press(KEYCODE_0, '0'); |
| 116 | | keyb_press(KEYCODE_1, '1'); |
| 117 | | keyb_press(KEYCODE_2, '2'); |
| 118 | | keyb_press(KEYCODE_3, '3'); |
| 119 | | keyb_press(KEYCODE_4, '4'); |
| 120 | | keyb_press(KEYCODE_5, '5'); |
| 121 | | keyb_press(KEYCODE_6, '6'); |
| 122 | | keyb_press(KEYCODE_7, '7'); |
| 123 | | keyb_press(KEYCODE_8, '8'); |
| 124 | | keyb_press(KEYCODE_9, '9'); |
| 125 | | |
| 126 | | keyb_shift_press(KEYCODE_0, '='); |
| 127 | | keyb_shift_press(KEYCODE_1, '!'); |
| 128 | | keyb_shift_press(KEYCODE_2, '"'); |
| 129 | | keyb_shift_press(KEYCODE_3, '?'); |
| 130 | | keyb_shift_press(KEYCODE_4, '$'); |
| 131 | | keyb_shift_press(KEYCODE_5, '%'); |
| 132 | | keyb_shift_press(KEYCODE_6, '&'); |
| 133 | | keyb_shift_press(KEYCODE_7, '/'); |
| 134 | | keyb_shift_press(KEYCODE_8, '('); |
| 135 | | keyb_shift_press(KEYCODE_9, ')'); |
| 136 | | |
| 137 | | keyb_press(KEYCODE_ENTER, 0x0d); |
| 138 | | keyb_press(KEYCODE_SPACE, ' '); |
| 139 | | keyb_press(KEYCODE_STOP, '.'); |
| 140 | | keyb_shift_press(KEYCODE_STOP, ':'); |
| 141 | | keyb_press(KEYCODE_BACKSPACE, 0x08); |
| 142 | | keyb_press(KEYCODE_0_PAD, '@'); //@ |
| 143 | | keyb_press(KEYCODE_COMMA, ','); |
| 144 | | keyb_shift_press(KEYCODE_COMMA, ';'); |
| 145 | | keyb_press(KEYCODE_MINUS_PAD, '-'); |
| 146 | | keyb_press(KEYCODE_PLUS_PAD, '+'); |
| 147 | | keyb_press(KEYCODE_ASTERISK, '*'); |
| 148 | | } |
| 149 | | |
| 150 | | static void draw_cg4_screen(running_machine &machine, bitmap_t *bitmap,const rectangle *cliprect,int width) |
| 151 | | { |
| 152 | | UINT8 *vram = machine.region("vram")->base(); |
| 153 | | int x,y,xi,yi; |
| 154 | | int count; |
| 155 | | |
| 156 | | for(yi=0;yi<8;yi++) |
| 157 | | { |
| 158 | | count = yi; |
| 159 | | for(y=0;y<200;y+=8) |
| 160 | | { |
| 161 | | for(x=0;x<8*width;x+=8) |
| 162 | | { |
| 163 | | for(xi=0;xi<8;xi++) |
| 164 | | { |
| 165 | | int pen_b,pen_r,pen_g,color; |
| 166 | | |
| 167 | | pen_b = (vram[count+0x0000]>>(7-xi)) & 1; |
| 168 | | pen_r = (vram[count+0x4000]>>(7-xi)) & 1; |
| 169 | | pen_g = 0;//(p7_vram[count+0x8000]>>(7-xi)) & 1; |
| 170 | | |
| 171 | | color = pen_g<<2 | pen_r<<1 | pen_b<<0; |
| 172 | | |
| 173 | | *BITMAP_ADDR16(bitmap, y+yi, x+xi) = machine.pens[color+0x20]; |
| 174 | | } |
| 175 | | count+=8; |
| 176 | | } |
| 177 | | } |
| 178 | | } |
| 179 | | } |
| 180 | | |
| 181 | | static void draw_tv_screen(running_machine &machine, bitmap_t *bitmap,const rectangle *cliprect,int width) |
| 182 | | { |
| 183 | | pasopia_state *state = machine.driver_data<pasopia_state>(); |
| 184 | | UINT8 *vram = machine.region("vram")->base(); |
| 185 | | int x,y/*,xi,yi*/; |
| 186 | | int count; |
| 187 | | |
| 188 | | count = 0x0000; |
| 189 | | |
| 190 | | for(y=0;y<25;y++) |
| 191 | | { |
| 192 | | for(x=0;x<width;x++) |
| 193 | | { |
| 194 | | int tile = vram[count+0x8000]; |
| 195 | | int attr = vram[count+0xc000]; |
| 196 | | int color = attr & 7; |
| 197 | | |
| 198 | | drawgfx_transpen(bitmap,cliprect,machine.gfx[0],tile,color & 7,0,0,x*8,y*8,0); |
| 199 | | |
| 200 | | // draw cursor |
| 201 | | if(state->m_cursor_addr*8 == count) |
| 202 | | { |
| 203 | | int xc,yc,cursor_on; |
| 204 | | |
| 205 | | cursor_on = 0; |
| 206 | | switch(state->m_cursor_raster & 0x60) |
| 207 | | { |
| 208 | | case 0x00: cursor_on = 1; break; //always on |
| 209 | | case 0x20: cursor_on = 0; break; //always off |
| 210 | | case 0x40: if(machine.primary_screen->frame_number() & 0x10) { cursor_on = 1; } break; //fast blink |
| 211 | | case 0x60: if(machine.primary_screen->frame_number() & 0x20) { cursor_on = 1; } break; //slow blink |
| 212 | | } |
| 213 | | |
| 214 | | if(cursor_on) |
| 215 | | { |
| 216 | | for(yc=0;yc<(8-(state->m_cursor_raster & 7));yc++) |
| 217 | | { |
| 218 | | for(xc=0;xc<8;xc++) |
| 219 | | { |
| 220 | | *BITMAP_ADDR16(bitmap, y*8-yc+7, x*8+xc) = machine.pens[0x27]; |
| 221 | | } |
| 222 | | } |
| 223 | | } |
| 224 | | } |
| 225 | | count+=8; |
| 226 | | } |
| 227 | | } |
| 228 | | } |
| 229 | | |
| 230 | | static void draw_mixed_screen(running_machine &machine, bitmap_t *bitmap,const rectangle *cliprect,int width) |
| 231 | | { |
| 232 | | pasopia_state *state = machine.driver_data<pasopia_state>(); |
| 233 | | UINT8 *vram = machine.region("vram")->base(); |
| 234 | | UINT8 *gfx_data = machine.region("font")->base(); |
| 235 | | int x,y,xi,yi; |
| 236 | | int count; |
| 237 | | |
| 238 | | count = 0x0000; |
| 239 | | |
| 240 | | for(y=0;y<25;y++) |
| 241 | | { |
| 242 | | for(x=0;x<width;x++) |
| 243 | | { |
| 244 | | int tile = vram[count+0x8000]; |
| 245 | | |
| 246 | | for(yi=0;yi<8;yi++) |
| 247 | | { |
| 248 | | int attr = vram[count+0xc000+yi]; |
| 249 | | |
| 250 | | if(attr & 0x80) |
| 251 | | { |
| 252 | | for(xi=0;xi<8;xi++) |
| 253 | | { |
| 254 | | int pen,pen_b,pen_r,pen_g; |
| 255 | | |
| 256 | | pen_b = (vram[count+yi+0x0000]>>(7-xi)) & 1; |
| 257 | | pen_r = (vram[count+yi+0x4000]>>(7-xi)) & 1; |
| 258 | | pen_g = (vram[count+yi+0x8000]>>(7-xi)) & 1; |
| 259 | | |
| 260 | | pen = pen_g<<2 | pen_r<<1 | pen_b<<0; |
| 261 | | |
| 262 | | *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = machine.pens[pen+0x20]; |
| 263 | | } |
| 264 | | } |
| 265 | | else |
| 266 | | { |
| 267 | | int color = attr & 7; |
| 268 | | |
| 269 | | for(xi=0;xi<8;xi++) |
| 270 | | { |
| 271 | | int pen; |
| 272 | | pen = ((gfx_data[tile*8+yi]>>(7-xi)) & 1) ? color : 0; |
| 273 | | |
| 274 | | *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = machine.pens[pen+0x20]; |
| 275 | | } |
| 276 | | //drawgfx_transpen(bitmap,cliprect,machine.gfx[0],tile,color & 7,0,0,x*8,y*8,0); |
| 277 | | } |
| 278 | | } |
| 279 | | |
| 280 | | // draw cursor |
| 281 | | if(state->m_cursor_addr*8 == count) |
| 282 | | { |
| 283 | | int xc,yc,cursor_on; |
| 284 | | |
| 285 | | cursor_on = 0; |
| 286 | | switch(state->m_cursor_raster & 0x60) |
| 287 | | { |
| 288 | | case 0x00: cursor_on = 1; break; //always on |
| 289 | | case 0x20: cursor_on = 0; break; //always off |
| 290 | | case 0x40: if(machine.primary_screen->frame_number() & 0x10) { cursor_on = 1; } break; //fast blink |
| 291 | | case 0x60: if(machine.primary_screen->frame_number() & 0x20) { cursor_on = 1; } break; //slow blink |
| 292 | | } |
| 293 | | |
| 294 | | if(cursor_on) |
| 295 | | { |
| 296 | | for(yc=0;yc<(8-(state->m_cursor_raster & 7));yc++) |
| 297 | | { |
| 298 | | for(xc=0;xc<8;xc++) |
| 299 | | { |
| 300 | | *BITMAP_ADDR16(bitmap, y*8-yc+7, x*8+xc) = machine.pens[0x27]; |
| 301 | | } |
| 302 | | } |
| 303 | | } |
| 304 | | } |
| 305 | | |
| 306 | | count+=8; |
| 307 | | } |
| 308 | | } |
| 309 | | } |
| 310 | | |
| 311 | | static SCREEN_UPDATE( paso7 ) |
| 312 | | { |
| 313 | | pasopia_state *state = screen->machine().driver_data<pasopia_state>(); |
| 314 | | int width; |
| 315 | | |
| 316 | | bitmap_fill(bitmap, cliprect, screen->machine().pens[0]); |
| 317 | | |
| 318 | | fake_keyboard_data(screen->machine()); |
| 319 | | |
| 320 | | width = state->m_x_width ? 80 : 40; |
| 321 | | |
| 322 | | if(state->m_gfx_mode) |
| 323 | | draw_mixed_screen(screen->machine(),bitmap,cliprect,width); |
| 324 | | else |
| 325 | | { |
| 326 | | draw_cg4_screen(screen->machine(),bitmap,cliprect,width); |
| 327 | | draw_tv_screen(screen->machine(),bitmap,cliprect,width); |
| 328 | | } |
| 329 | | |
| 330 | | return 0; |
| 331 | | } |
| 332 | | |
| 333 | | static READ8_HANDLER( vram_r ) |
| 334 | | { |
| 335 | | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 336 | | UINT8 *vram = space->machine().region("vram")->base(); |
| 337 | | UINT8 res; |
| 338 | | |
| 339 | | if(state->m_vram_sel == 0) |
| 340 | | { |
| 341 | | UINT8 *work_ram = space->machine().region("maincpu")->base(); |
| 342 | | |
| 343 | | return work_ram[offset+0x8000]; |
| 344 | | } |
| 345 | | |
| 346 | | if(state->m_pal_sel && (state->m_plane_reg & 0x70) == 0x00) |
| 347 | | return state->m_p7_pal[offset & 0xf]; |
| 348 | | |
| 349 | | res = 0xff; |
| 350 | | |
| 351 | | if((state->m_plane_reg & 0x11) == 0x11) |
| 352 | | res &= vram[offset | 0x0000]; |
| 353 | | if((state->m_plane_reg & 0x22) == 0x22) |
| 354 | | res &= vram[offset | 0x4000]; |
| 355 | | if((state->m_plane_reg & 0x44) == 0x44) |
| 356 | | { |
| 357 | | res &= vram[offset | 0x8000]; |
| 358 | | state->m_attr_latch = vram[offset | 0xc000] & 0x87; |
| 359 | | } |
| 360 | | |
| 361 | | return res; |
| 362 | | } |
| 363 | | |
| 364 | | static WRITE8_HANDLER( vram_w ) |
| 365 | | { |
| 366 | | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 367 | | UINT8 *vram = space->machine().region("vram")->base(); |
| 368 | | |
| 369 | | if(state->m_vram_sel) |
| 370 | | { |
| 371 | | if(state->m_pal_sel && (state->m_plane_reg & 0x70) == 0x00) |
| 372 | | { |
| 373 | | state->m_p7_pal[offset & 0xf] = data & 0xf; |
| 374 | | return; |
| 375 | | } |
| 376 | | |
| 377 | | if(state->m_plane_reg & 0x10) |
| 378 | | vram[(offset & 0x3fff) | 0x0000] = (state->m_plane_reg & 1) ? data : 0xff; |
| 379 | | if(state->m_plane_reg & 0x20) |
| 380 | | vram[(offset & 0x3fff) | 0x4000] = (state->m_plane_reg & 2) ? data : 0xff; |
| 381 | | if(state->m_plane_reg & 0x40) |
| 382 | | { |
| 383 | | vram[(offset & 0x3fff) | 0x8000] = (state->m_plane_reg & 4) ? data : 0xff; |
| 384 | | state->m_attr_latch = state->m_attr_wrap ? state->m_attr_latch : state->m_attr_data; |
| 385 | | vram[(offset & 0x3fff) | 0xc000] = state->m_attr_latch; |
| 386 | | } |
| 387 | | } |
| 388 | | else |
| 389 | | { |
| 390 | | UINT8 *work_ram = space->machine().region("maincpu")->base(); |
| 391 | | |
| 392 | | work_ram[offset+0x8000] = data; |
| 393 | | } |
| 394 | | } |
| 395 | | |
| 396 | | static WRITE8_HANDLER( pasopia7_memory_ctrl_w ) |
| 397 | | { |
| 398 | | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 399 | | UINT8 *work_ram = space->machine().region("maincpu")->base(); |
| 400 | | UINT8 *basic = space->machine().region("basic")->base(); |
| 401 | | |
| 402 | | switch(data & 3) |
| 403 | | { |
| 404 | | case 0: |
| 405 | | case 3: //select Basic ROM |
| 406 | | memory_set_bankptr(space->machine(), "bank1", basic + 0x00000); |
| 407 | | memory_set_bankptr(space->machine(), "bank2", basic + 0x04000); |
| 408 | | break; |
| 409 | | case 1: //select Basic ROM + BIOS ROM |
| 410 | | memory_set_bankptr(space->machine(), "bank1", basic + 0x00000); |
| 411 | | memory_set_bankptr(space->machine(), "bank2", work_ram + 0x10000); |
| 412 | | break; |
| 413 | | case 2: //select Work RAM |
| 414 | | memory_set_bankptr(space->machine(), "bank1", work_ram + 0x00000); |
| 415 | | memory_set_bankptr(space->machine(), "bank2", work_ram + 0x04000); |
| 416 | | break; |
| 417 | | } |
| 418 | | |
| 419 | | state->m_bank_reg = data & 3; |
| 420 | | state->m_vram_sel = data & 4; |
| 421 | | state->m_mio_sel = data & 8; |
| 422 | | |
| 423 | | // bank4 is always RAM |
| 424 | | |
| 425 | | // printf("%02x\n",state->m_vram_sel); |
| 426 | | } |
| 427 | | |
| 428 | | #if 0 |
| 429 | | static READ8_HANDLER( fdc_r ) |
| 430 | | { |
| 431 | | return space->machine().rand(); |
| 432 | | } |
| 433 | | #endif |
| 434 | | |
| 435 | | |
| 436 | | static WRITE8_HANDLER( pac2_w ) |
| 437 | | { |
| 438 | | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 439 | | /* |
| 440 | | select register: |
| 441 | | 4 = ram1; |
| 442 | | 3 = ram2; |
| 443 | | 2 = kanji ROM; |
| 444 | | 1 = joy; |
| 445 | | anything else is nop |
| 446 | | */ |
| 447 | | |
| 448 | | if(state->m_pac2_bank_select == 3 || state->m_pac2_bank_select == 4) |
| 449 | | { |
| 450 | | switch(offset) |
| 451 | | { |
| 452 | | case 0: state->m_pac2_index[(state->m_pac2_bank_select-3) & 1] = (state->m_pac2_index[(state->m_pac2_bank_select-3) & 1] & 0x7f00) | (data & 0xff); break; |
| 453 | | case 1: state->m_pac2_index[(state->m_pac2_bank_select-3) & 1] = (state->m_pac2_index[(state->m_pac2_bank_select-3) & 1] & 0xff) | ((data & 0x7f) << 8); break; |
| 454 | | case 2: // PAC2 RAM write |
| 455 | | { |
| 456 | | UINT8 *pac2_ram; |
| 457 | | |
| 458 | | pac2_ram = space->machine().region(((state->m_pac2_bank_select-3) & 1) ? "rampac2" : "rampac1")->base(); |
| 459 | | |
| 460 | | pac2_ram[state->m_pac2_index[(state->m_pac2_bank_select-3) & 1]] = data; |
| 461 | | } |
| 462 | | } |
| 463 | | } |
| 464 | | else if(state->m_pac2_bank_select == 2) // kanji ROM |
| 465 | | { |
| 466 | | switch(offset) |
| 467 | | { |
| 468 | | case 0: state->m_kanji_index = (state->m_kanji_index & 0x1ff00) | ((data & 0xff) << 0); break; |
| 469 | | case 1: state->m_kanji_index = (state->m_kanji_index & 0x100ff) | ((data & 0xff) << 8); break; |
| 470 | | case 2: state->m_kanji_index = (state->m_kanji_index & 0x0ffff) | ((data & 0x01) << 16); break; |
| 471 | | } |
| 472 | | } |
| 473 | | |
| 474 | | if(offset == 3) |
| 475 | | { |
| 476 | | if(data & 0x80) |
| 477 | | { |
| 478 | | // ... |
| 479 | | } |
| 480 | | else |
| 481 | | state->m_pac2_bank_select = data & 7; |
| 482 | | } |
| 483 | | } |
| 484 | | |
| 485 | | static READ8_HANDLER( pac2_r ) |
| 486 | | { |
| 487 | | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 488 | | if(offset == 2) |
| 489 | | { |
| 490 | | if(state->m_pac2_bank_select == 3 || state->m_pac2_bank_select == 4) |
| 491 | | { |
| 492 | | UINT8 *pac2_ram; |
| 493 | | |
| 494 | | pac2_ram = space->machine().region(((state->m_pac2_bank_select-3) & 1) ? "rampac2" : "rampac1")->base(); |
| 495 | | |
| 496 | | return pac2_ram[state->m_pac2_index[(state->m_pac2_bank_select-3) & 1]]; |
| 497 | | } |
| 498 | | else if(state->m_pac2_bank_select == 2) |
| 499 | | { |
| 500 | | UINT8 *kanji_rom = space->machine().region("kanji")->base(); |
| 501 | | |
| 502 | | return kanji_rom[state->m_kanji_index]; |
| 503 | | } |
| 504 | | else |
| 505 | | { |
| 506 | | printf("%02x\n",state->m_pac2_bank_select); |
| 507 | | } |
| 508 | | } |
| 509 | | |
| 510 | | return 0xff; |
| 511 | | } |
| 512 | | |
| 513 | | /* writes always occurs to the RAM banks, even if the ROMs are selected. */ |
| 514 | | static WRITE8_HANDLER( ram_bank_w ) |
| 515 | | { |
| 516 | | UINT8 *work_ram = space->machine().region("maincpu")->base(); |
| 517 | | |
| 518 | | work_ram[offset] = data; |
| 519 | | } |
| 520 | | |
| 521 | | static WRITE8_HANDLER( pasopia7_6845_w ) |
| 522 | | { |
| 523 | | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 524 | | if(offset == 0) |
| 525 | | { |
| 526 | | state->m_addr_latch = data; |
| 527 | | space->machine().device<mc6845_device>("crtc")->address_w(*space, offset, data); |
| 528 | | } |
| 529 | | else |
| 530 | | { |
| 531 | | /* FIXME: this should be inside the MC6845 core! */ |
| 532 | | if(state->m_addr_latch == 0x0a) |
| 533 | | state->m_cursor_raster = data; |
| 534 | | if(state->m_addr_latch == 0x0e) |
| 535 | | state->m_cursor_addr = ((data<<8) & 0x3f00) | (state->m_cursor_addr & 0xff); |
| 536 | | else if(state->m_addr_latch == 0x0f) |
| 537 | | state->m_cursor_addr = (state->m_cursor_addr & 0x3f00) | (data & 0xff); |
| 538 | | |
| 539 | | space->machine().device<mc6845_device>("crtc")->register_w(*space, offset, data); |
| 540 | | |
| 541 | | /* double pump the pixel clock if we are in 640 x 200 mode */ |
| 542 | | space->machine().device<mc6845_device>("crtc")->set_clock( (state->m_x_width) ? VDP_CLOCK*2 : VDP_CLOCK); |
| 543 | | } |
| 544 | | } |
| 545 | | |
| 546 | | static void pasopia_nmi_trap(running_machine &machine) |
| 547 | | { |
| 548 | | pasopia_state *state = machine.driver_data<pasopia_state>(); |
| 549 | | if(state->m_nmi_enable_reg) |
| 550 | | { |
| 551 | | state->m_nmi_trap |= 2; |
| 552 | | |
| 553 | | if(state->m_nmi_mask == 0) |
| 554 | | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE); |
| 555 | | } |
| 556 | | } |
| 557 | | |
| 558 | | static READ8_HANDLER( pasopia7_fdc_r ) |
| 559 | | { |
| 560 | | switch(offset) |
| 561 | | { |
| 562 | | case 4: return upd765_status_r(space->machine().device("upd765"),0); |
| 563 | | case 5: return upd765_data_r(space->machine().device("upd765"),0); |
| 564 | | //case 6: bit 7 interrupt bit |
| 565 | | } |
| 566 | | |
| 567 | | return 0xff; |
| 568 | | } |
| 569 | | |
| 570 | | static WRITE8_HANDLER( pasopia7_fdc_w ) |
| 571 | | { |
| 572 | | switch(offset) |
| 573 | | { |
| 574 | | case 0: upd765_tc_w(space->machine().device("upd765"), 0); break; |
| 575 | | case 2: upd765_tc_w(space->machine().device("upd765"), 1); break; |
| 576 | | case 5: return upd765_data_w(space->machine().device("upd765"),0,data); |
| 577 | | case 6: |
| 578 | | upd765_reset_w(space->machine().device("upd765"),data & 0x80); |
| 579 | | floppy_mon_w(floppy_get_device(space->machine(), 0), (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); |
| 580 | | floppy_drive_set_ready_state(floppy_get_device(space->machine(), 0), (data & 0x40), 0); |
| 581 | | break; |
| 582 | | |
| 583 | | } |
| 584 | | } |
| 585 | | |
| 586 | | |
| 587 | | static READ8_HANDLER( pasopia7_io_r ) |
| 588 | | { |
| 589 | | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 590 | | UINT16 io_port; |
| 591 | | i8255_device *ppi0 = space->machine().device<i8255_device>("ppi8255_0"); |
| 592 | | i8255_device *ppi1 = space->machine().device<i8255_device>("ppi8255_1"); |
| 593 | | i8255_device *ppi2 = space->machine().device<i8255_device>("ppi8255_2"); |
| 594 | | |
| 595 | | if(state->m_mio_sel) |
| 596 | | { |
| 597 | | address_space *ram_space = space->machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 598 | | |
| 599 | | state->m_mio_sel = 0; |
| 600 | | //printf("%08x\n",offset); |
| 601 | | //return 0x0d; // hack: this is used for reading the keyboard data, we can fake it a little ... (modify fda4) |
| 602 | | return ram_space->read_byte(offset); |
| 603 | | } |
| 604 | | |
| 605 | | io_port = offset & 0xff; //trim down to 8-bit bus |
| 606 | | |
| 607 | | if(io_port >= 0x30 && io_port <= 0x33) |
| 608 | | printf("[%02x]\n",offset & 3); |
| 609 | | |
| 610 | | if(io_port >= 0x08 && io_port <= 0x0b) { return ppi0->read(*space, (io_port-0x08) & 3); } |
| 611 | | else if(io_port >= 0x0c && io_port <= 0x0f) { return ppi1->read(*space, (io_port-0x0c) & 3); } |
| 612 | | // else if(io_port == 0x10 || io_port == 0x11) { M6845 read } |
| 613 | | else if(io_port >= 0x18 && io_port <= 0x1b) { return pac2_r(space, (io_port-0x18) & 3); } |
| 614 | | else if(io_port >= 0x20 && io_port <= 0x23) |
| 615 | | { |
| 616 | | pasopia_nmi_trap(space->machine()); |
| 617 | | return ppi2->read(*space, (io_port-0x20) & 3); |
| 618 | | } |
| 619 | | else if(io_port >= 0x28 && io_port <= 0x2b) { return z80ctc_r(space->machine().device("ctc"), (io_port-0x28) & 3); } |
| 620 | | else if(io_port == 0x30) { return z80pio_d_r(space->machine().device("z80pio_0"), (io_port-0x30) & 1); } |
| 621 | | else if(io_port == 0x31) { return z80pio_c_r(space->machine().device("z80pio_0"), (io_port-0x31) & 1); } |
| 622 | | // else if(io_port == 0x3a) { SN1 } |
| 623 | | // else if(io_port == 0x3b) { SN2 } |
| 624 | | // else if(io_port == 0x3c) { bankswitch } |
| 625 | | else if(io_port >= 0xe0 && io_port <= 0xe6) { return pasopia7_fdc_r(space,offset & 7); } |
| 626 | | else |
| 627 | | { |
| 628 | | logerror("(PC=%06x) Read i/o address %02x\n",cpu_get_pc(&space->device()),io_port); |
| 629 | | } |
| 630 | | |
| 631 | | return 0xff; |
| 632 | | } |
| 633 | | |
| 634 | | static WRITE8_HANDLER( pasopia7_io_w ) |
| 635 | | { |
| 636 | | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 637 | | i8255_device *ppi0 = space->machine().device<i8255_device>("ppi8255_0"); |
| 638 | | i8255_device *ppi1 = space->machine().device<i8255_device>("ppi8255_1"); |
| 639 | | i8255_device *ppi2 = space->machine().device<i8255_device>("ppi8255_2"); |
| 640 | | UINT16 io_port; |
| 641 | | |
| 642 | | if(state->m_mio_sel) |
| 643 | | { |
| 644 | | address_space *ram_space = space->machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 645 | | state->m_mio_sel = 0; |
| 646 | | ram_space->write_byte(offset, data); |
| 647 | | return; |
| 648 | | } |
| 649 | | |
| 650 | | io_port = offset & 0xff; //trim down to 8-bit bus |
| 651 | | |
| 652 | | if(io_port >= 0x30 && io_port <= 0x33) |
| 653 | | printf("[%02x] <- %02x\n",offset & 3,data); |
| 654 | | |
| 655 | | if(io_port >= 0x08 && io_port <= 0x0b) { ppi0->write(*space, (io_port-0x08) & 3, data); } |
| 656 | | else if(io_port >= 0x0c && io_port <= 0x0f) { ppi1->write(*space, (io_port-0x0c) & 3, data); } |
| 657 | | else if(io_port >= 0x10 && io_port <= 0x11) { pasopia7_6845_w(space, io_port-0x10, data); } |
| 658 | | else if(io_port >= 0x18 && io_port <= 0x1b) { pac2_w(space, (io_port-0x18) & 3, data); } |
| 659 | | else if(io_port >= 0x20 && io_port <= 0x23) |
| 660 | | { |
| 661 | | ppi2->write(*space, (io_port-0x20) & 3, data); |
| 662 | | pasopia_nmi_trap(space->machine()); |
| 663 | | } |
| 664 | | else if(io_port >= 0x28 && io_port <= 0x2b) { z80ctc_w(space->machine().device("ctc"), (io_port-0x28) & 3,data); } |
| 665 | | else if(io_port >= 0x30 && io_port <= 0x31) { z80pio_d_w(space->machine().device("z80pio_0"), (io_port-0x30) & 1, data); } |
| 666 | | else if(io_port >= 0x32 && io_port <= 0x33) { z80pio_c_w(space->machine().device("z80pio_0"), (io_port-0x32) & 1, data); } |
| 667 | | else if(io_port == 0x3a) { sn76496_w(space->machine().device("sn1"), 0, data); } |
| 668 | | else if(io_port == 0x3b) { sn76496_w(space->machine().device("sn2"), 0, data); } |
| 669 | | else if(io_port == 0x3c) { pasopia7_memory_ctrl_w(space,0, data); } |
| 670 | | else if(io_port >= 0xe0 && io_port <= 0xe6) { pasopia7_fdc_w(space,offset & 7,data); } |
| 671 | | else |
| 672 | | { |
| 673 | | logerror("(PC=%06x) Write i/o address %02x = %02x\n",cpu_get_pc(&space->device()),offset,data); |
| 674 | | } |
| 675 | | } |
| 676 | | |
| 677 | | static ADDRESS_MAP_START(paso7_mem, AS_PROGRAM, 8) |
| 678 | | ADDRESS_MAP_UNMAP_HIGH |
| 679 | | AM_RANGE( 0x0000, 0x7fff ) AM_WRITE( ram_bank_w ) |
| 680 | | AM_RANGE( 0x0000, 0x3fff ) AM_ROMBANK("bank1") |
| 681 | | AM_RANGE( 0x4000, 0x7fff ) AM_ROMBANK("bank2") |
| 682 | | AM_RANGE( 0x8000, 0xbfff ) AM_READWRITE(vram_r, vram_w ) |
| 683 | | AM_RANGE( 0xc000, 0xffff ) AM_RAMBANK("bank4") |
| 684 | | ADDRESS_MAP_END |
| 685 | | |
| 686 | | static ADDRESS_MAP_START( paso7_io , AS_IO, 8) |
| 687 | | ADDRESS_MAP_UNMAP_HIGH |
| 688 | | AM_RANGE( 0x0000, 0xffff) AM_READWRITE( pasopia7_io_r, pasopia7_io_w ) |
| 689 | | ADDRESS_MAP_END |
| 690 | | |
| 691 | | /* Input ports */ |
| 692 | | static INPUT_PORTS_START( paso7 ) |
| 693 | | PORT_START("DSW") |
| 694 | | PORT_DIPNAME( 0x01, 0x01, "System type" ) |
| 695 | | PORT_DIPSETTING( 0x01, DEF_STR( Normal ) ) |
| 696 | | PORT_DIPSETTING( 0x00, "LCD" ) |
| 697 | | INPUT_PORTS_END |
| 698 | | |
| 699 | | static const gfx_layout p7_chars_8x8 = |
| 700 | | { |
| 701 | | 8,8, |
| 702 | | RGN_FRAC(1,1), |
| 703 | | 1, |
| 704 | | { 0 }, |
| 705 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 706 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 707 | | 8*8 |
| 708 | | }; |
| 709 | | |
| 710 | | static const gfx_layout p7_chars_16x16 = |
| 711 | | { |
| 712 | | 16,16, |
| 713 | | RGN_FRAC(1,1), |
| 714 | | 1, |
| 715 | | { 0 }, |
| 716 | | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, |
| 717 | | { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, |
| 718 | | 16*16 |
| 719 | | }; |
| 720 | | |
| 721 | | static GFXDECODE_START( pasopia7 ) |
| 722 | | GFXDECODE_ENTRY( "font", 0x00000, p7_chars_8x8, 0, 0x10 ) |
| 723 | | GFXDECODE_ENTRY( "kanji", 0x00000, p7_chars_16x16, 0, 0x10 ) |
| 724 | | GFXDECODE_END |
| 725 | | |
| 726 | | static const mc6845_interface mc6845_intf = |
| 727 | | { |
| 728 | | "screen", /* screen we are acting on */ |
| 729 | | 8, /* number of pixels per video memory address */ |
| 730 | | NULL, /* before pixel update callback */ |
| 731 | | NULL, /* row update callback */ |
| 732 | | NULL, /* after pixel update callback */ |
| 733 | | DEVCB_NULL, /* callback for display state changes */ |
| 734 | | DEVCB_NULL, /* callback for cursor state changes */ |
| 735 | | DEVCB_NULL, /* HSYNC callback */ |
| 736 | | DEVCB_NULL, /* VSYNC callback */ |
| 737 | | NULL /* update address callback */ |
| 738 | | }; |
| 739 | | |
| 740 | | static Z80CTC_INTERFACE( ctc_intf ) |
| 741 | | { |
| 742 | | 0, // timer disables |
| 743 | | DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_IRQ0), // interrupt handler |
| 744 | | DEVCB_LINE(z80ctc_trg1_w), // ZC/TO0 callback |
| 745 | | DEVCB_LINE(z80ctc_trg2_w), // ZC/TO1 callback, beep interface |
| 746 | | DEVCB_LINE(z80ctc_trg3_w) // ZC/TO2 callback |
| 747 | | }; |
| 748 | | |
| 749 | | static READ8_DEVICE_HANDLER( test_r ) |
| 750 | | { |
| 751 | | return device->machine().rand(); |
| 752 | | } |
| 753 | | |
| 754 | | static WRITE_LINE_DEVICE_HANDLER( testa_w ) |
| 755 | | { |
| 756 | | printf("A %02x\n",state); |
| 757 | | } |
| 758 | | |
| 759 | | static WRITE_LINE_DEVICE_HANDLER( testb_w ) |
| 760 | | { |
| 761 | | printf("B %02x\n",state); |
| 762 | | } |
| 763 | | |
| 764 | | static Z80PIO_INTERFACE( z80pio_intf ) |
| 765 | | { |
| 766 | | DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_IRQ0), //doesn't work? |
| 767 | | DEVCB_HANDLER(test_r), |
| 768 | | DEVCB_NULL, |
| 769 | | DEVCB_LINE(testa_w), |
| 770 | | DEVCB_HANDLER(test_r), |
| 771 | | DEVCB_NULL, |
| 772 | | DEVCB_LINE(testb_w) |
| 773 | | }; |
| 774 | | |
| 775 | | static const z80_daisy_config p7_daisy[] = |
| 776 | | { |
| 777 | | { "ctc" }, |
| 778 | | { "z80pio_0" }, |
| 779 | | // { "upd765" }, /* TODO */ |
| 780 | | { NULL } |
| 781 | | }; |
| 782 | | |
| 783 | | static READ8_DEVICE_HANDLER( crtc_portb_r ) |
| 784 | | { |
| 785 | | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 786 | | // --x- ---- vsync bit |
| 787 | | // ---x ---- lcd dip-sw |
| 788 | | // ---- x--- disp bit |
| 789 | | UINT8 lcd_bit = input_port_read(device->machine(), "DSW") & 1; |
| 790 | | UINT8 vdisp = (device->machine().primary_screen->vpos() < (lcd_bit ? 200 : 28)) ? 0x08 : 0x00; //TODO: check LCD vpos trigger |
| 791 | | UINT8 vsync = vdisp ? 0x00 : 0x20; |
| 792 | | |
| 793 | | return 0x40 | (state->m_attr_latch & 0x87) | vsync | vdisp | (lcd_bit << 4); |
| 794 | | } |
| 795 | | |
| 796 | | static WRITE8_DEVICE_HANDLER( screen_mode_w ) |
| 797 | | { |
| 798 | | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 799 | | if(data & 0x5f) |
| 800 | | printf("GFX MODE %02x\n",data); |
| 801 | | |
| 802 | | state->m_x_width = data & 0x20; |
| 803 | | state->m_gfx_mode = data & 0x80; |
| 804 | | |
| 805 | | // printf("%02x\n",state->m_gfx_mode); |
| 806 | | } |
| 807 | | |
| 808 | | static WRITE8_DEVICE_HANDLER( plane_reg_w ) |
| 809 | | { |
| 810 | | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 811 | | //if(data & 0x11) |
| 812 | | //printf("PLANE %02x\n",data); |
| 813 | | state->m_plane_reg = data; |
| 814 | | } |
| 815 | | |
| 816 | | static WRITE8_DEVICE_HANDLER( video_attr_w ) |
| 817 | | { |
| 818 | | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 819 | | //printf("VIDEO ATTR %02x | TEXT_PAGE %02x\n",data & 0xf,data & 0x70); |
| 820 | | state->m_attr_data = (data & 0x7) | ((data & 0x8)<<4); |
| 821 | | } |
| 822 | | |
| 823 | | //#include "debugger.h" |
| 824 | | |
| 825 | | static WRITE8_DEVICE_HANDLER( video_misc_w ) |
| 826 | | { |
| 827 | | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 828 | | /* |
| 829 | | --x- ---- blinking |
| 830 | | ---x ---- attribute wrap |
| 831 | | ---- x--- pal disable |
| 832 | | ---- xx-- palette selector (both bits enables this, odd hook-up) |
| 833 | | */ |
| 834 | | // if(data & 2) |
| 835 | | // { |
| 836 | | // printf("VIDEO MISC %02x\n",data); |
| 837 | | // debugger_break(device->machine()); |
| 838 | | // } |
| 839 | | state->m_cursor_blink = data & 0x20; |
| 840 | | state->m_attr_wrap = data & 0x10; |
| 841 | | // state->m_pal_sel = data & 0x02; |
| 842 | | } |
| 843 | | |
| 844 | | static WRITE8_DEVICE_HANDLER( nmi_mask_w ) |
| 845 | | { |
| 846 | | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 847 | | /* |
| 848 | | --x- ---- (related to the data rec) |
| 849 | | ---x ---- data rec out |
| 850 | | ---- --x- sound off |
| 851 | | ---- ---x reset NMI & trap |
| 852 | | */ |
| 853 | | // printf("SYSTEM MISC %02x\n",data); |
| 854 | | |
| 855 | | if(data & 1) |
| 856 | | { |
| 857 | | state->m_nmi_reset &= ~4; |
| 858 | | state->m_nmi_trap &= ~2; |
| 859 | | //cputag_set_input_line(device->machine(), "maincpu", INPUT_LINE_NMI, CLEAR_LINE); //guess |
| 860 | | } |
| 861 | | |
| 862 | | } |
| 863 | | |
| 864 | | /* TODO: investigate on these. */ |
| 865 | | static READ8_DEVICE_HANDLER( unk_r ) |
| 866 | | { |
| 867 | | return 0xff;//device->machine().rand(); |
| 868 | | } |
| 869 | | |
| 870 | | static READ8_DEVICE_HANDLER( nmi_reg_r ) |
| 871 | | { |
| 872 | | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 873 | | //printf("C\n"); |
| 874 | | return 0xfc | state->m_bank_reg;//device->machine().rand(); |
| 875 | | } |
| 876 | | |
| 877 | | static WRITE8_DEVICE_HANDLER( nmi_reg_w ) |
| 878 | | { |
| 879 | | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 880 | | /* |
| 881 | | x--- ---- NMI mask |
| 882 | | -x-- ---- NMI enable trap on PPI8255 2 r/w |
| 883 | | */ |
| 884 | | state->m_nmi_mask = data & 0x80; |
| 885 | | state->m_nmi_enable_reg = data & 0x40; |
| 886 | | } |
| 887 | | |
| 888 | | static READ8_DEVICE_HANDLER( nmi_porta_r ) |
| 889 | | { |
| 890 | | return 0xff; |
| 891 | | } |
| 892 | | |
| 893 | | static READ8_DEVICE_HANDLER( nmi_portb_r ) |
| 894 | | { |
| 895 | | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 896 | | return 0xf9 | state->m_nmi_trap | state->m_nmi_reset; |
| 897 | | } |
| 898 | | |
| 899 | | static I8255_INTERFACE( ppi8255_intf_0 ) |
| 900 | | { |
| 901 | | DEVCB_HANDLER(unk_r), /* Port A read */ |
| 902 | | DEVCB_HANDLER(screen_mode_w), /* Port A write */ |
| 903 | | DEVCB_HANDLER(crtc_portb_r), /* Port B read */ |
| 904 | | DEVCB_NULL, /* Port B write */ |
| 905 | | DEVCB_NULL, /* Port C read */ |
| 906 | | DEVCB_NULL /* Port C write */ |
| 907 | | }; |
| 908 | | |
| 909 | | static I8255_INTERFACE( ppi8255_intf_1 ) |
| 910 | | { |
| 911 | | DEVCB_NULL, /* Port A read */ |
| 912 | | DEVCB_HANDLER(plane_reg_w), /* Port A write */ |
| 913 | | DEVCB_NULL, /* Port B read */ |
| 914 | | DEVCB_HANDLER(video_attr_w), /* Port B write */ |
| 915 | | DEVCB_NULL, /* Port C read */ |
| 916 | | DEVCB_HANDLER(video_misc_w) /* Port C write */ |
| 917 | | }; |
| 918 | | |
| 919 | | static I8255_INTERFACE( ppi8255_intf_2 ) |
| 920 | | { |
| 921 | | DEVCB_HANDLER(nmi_porta_r), /* Port A read */ |
| 922 | | DEVCB_HANDLER(nmi_mask_w), /* Port A write */ |
| 923 | | DEVCB_HANDLER(nmi_portb_r), /* Port B read */ |
| 924 | | DEVCB_NULL, /* Port B write */ |
| 925 | | DEVCB_HANDLER(nmi_reg_r), /* Port C read */ |
| 926 | | DEVCB_HANDLER(nmi_reg_w) /* Port C write */ |
| 927 | | }; |
| 928 | | |
| 929 | | static MACHINE_RESET( paso7 ) |
| 930 | | { |
| 931 | | pasopia_state *state = machine.driver_data<pasopia_state>(); |
| 932 | | UINT8 *bios = machine.region("maincpu")->base(); |
| 933 | | |
| 934 | | memory_set_bankptr(machine, "bank1", bios + 0x10000); |
| 935 | | memory_set_bankptr(machine, "bank2", bios + 0x10000); |
| 936 | | // memory_set_bankptr(machine, "bank3", bios + 0x10000); |
| 937 | | // memory_set_bankptr(machine, "bank4", bios + 0x10000); |
| 938 | | |
| 939 | | state->m_nmi_reset |= 4; |
| 940 | | } |
| 941 | | |
| 942 | | static PALETTE_INIT( pasopia7 ) |
| 943 | | { |
| 944 | | int i; |
| 945 | | |
| 946 | | for (i = 0x000; i < 0x020; i++) |
| 947 | | { |
| 948 | | UINT8 r,g,b; |
| 949 | | |
| 950 | | if(((i & 0x11) == 0x01) || ((i & 0x11) == 0x10)) |
| 951 | | { |
| 952 | | r = ((i >> 2) & 1) ? 0xff : 0x00; |
| 953 | | g = ((i >> 3) & 1) ? 0xff : 0x00; |
| 954 | | b = ((i >> 1) & 1) ? 0xff : 0x00; |
| 955 | | } |
| 956 | | else { r = g = b = 0x00; } |
| 957 | | |
| 958 | | palette_set_color_rgb(machine, i, r,g,b); |
| 959 | | } |
| 960 | | for( i = 0x000; i < 8; i++) |
| 961 | | palette_set_color_rgb(machine, i+0x020, pal1bit(i >> 1), pal1bit(i >> 2), pal1bit(i >> 0)); |
| 962 | | } |
| 963 | | |
| 964 | | static const struct upd765_interface pasopia7_upd765_interface = |
| 965 | | { |
| 966 | | DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_IRQ0), |
| 967 | | DEVCB_NULL, //DRQ, TODO |
| 968 | | NULL, |
| 969 | | UPD765_RDY_PIN_CONNECTED, |
| 970 | | {FLOPPY_0, FLOPPY_1, NULL, NULL} |
| 971 | | }; |
| 972 | | |
| 973 | | static const floppy_config pasopia7_floppy_config = |
| 974 | | { |
| 975 | | DEVCB_NULL, |
| 976 | | DEVCB_NULL, |
| 977 | | DEVCB_NULL, |
| 978 | | DEVCB_NULL, |
| 979 | | DEVCB_NULL, |
| 980 | | FLOPPY_STANDARD_5_25_DSHD, |
| 981 | | FLOPPY_OPTIONS_NAME(default), |
| 982 | | NULL |
| 983 | | }; |
| 984 | | |
| 985 | | static MACHINE_CONFIG_START( paso7, pasopia_state ) |
| 986 | | /* basic machine hardware */ |
| 987 | | MCFG_CPU_ADD("maincpu",Z80, XTAL_4MHz) |
| 988 | | MCFG_CPU_PROGRAM_MAP(paso7_mem) |
| 989 | | MCFG_CPU_IO_MAP(paso7_io) |
| 990 | | // MCFG_CPU_VBLANK_INT("screen", irq0_line_hold) |
| 991 | | MCFG_CPU_CONFIG(p7_daisy) |
| 992 | | |
| 993 | | MCFG_Z80CTC_ADD( "ctc", XTAL_4MHz, ctc_intf ) |
| 994 | | |
| 995 | | MCFG_MACHINE_RESET(paso7) |
| 996 | | |
| 997 | | MCFG_I8255_ADD( "ppi8255_0", ppi8255_intf_0 ) |
| 998 | | MCFG_I8255_ADD( "ppi8255_1", ppi8255_intf_1 ) |
| 999 | | MCFG_I8255_ADD( "ppi8255_2", ppi8255_intf_2 ) |
| 1000 | | MCFG_Z80PIO_ADD( "z80pio_0", XTAL_4MHz, z80pio_intf ) |
| 1001 | | |
| 1002 | | MCFG_UPD765A_ADD("upd765", pasopia7_upd765_interface) |
| 1003 | | MCFG_FLOPPY_2_DRIVES_ADD(pasopia7_floppy_config) |
| 1004 | | |
| 1005 | | /* video hardware */ |
| 1006 | | MCFG_SCREEN_ADD("screen", RASTER) |
| 1007 | | MCFG_SCREEN_REFRESH_RATE(60) |
| 1008 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 1009 | | MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 1010 | | MCFG_SCREEN_SIZE(640, 480) |
| 1011 | | MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 200-1) |
| 1012 | | MCFG_SCREEN_UPDATE(paso7) |
| 1013 | | |
| 1014 | | MCFG_MC6845_ADD("crtc", H46505, VDP_CLOCK, mc6845_intf) /* unknown clock, hand tuned to get ~60 fps */ |
| 1015 | | MCFG_PALETTE_LENGTH(0x28) |
| 1016 | | MCFG_PALETTE_INIT(pasopia7) |
| 1017 | | |
| 1018 | | MCFG_GFXDECODE( pasopia7 ) |
| 1019 | | |
| 1020 | | MCFG_VIDEO_START(paso7) |
| 1021 | | |
| 1022 | | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 1023 | | |
| 1024 | | MCFG_SOUND_ADD("sn1", SN76489A, 1996800) // unknown clock / divider |
| 1025 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 1026 | | |
| 1027 | | MCFG_SOUND_ADD("sn2", SN76489A, 1996800) // unknown clock / divider |
| 1028 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 1029 | | MACHINE_CONFIG_END |
| 1030 | | |
| 1031 | | /* ROM definition */ |
| 1032 | | ROM_START( pasopia7 ) |
| 1033 | | ROM_REGION( 0x14000, "maincpu", ROMREGION_ERASEFF ) |
| 1034 | | ROM_LOAD( "bios.rom", 0x10000, 0x4000, CRC(b8111407) SHA1(ac93ae62db4c67de815f45de98c79cfa1313857d)) |
| 1035 | | |
| 1036 | | ROM_REGION( 0x8000, "basic", ROMREGION_ERASEFF ) |
| 1037 | | ROM_LOAD( "basic.rom", 0x0000, 0x8000, CRC(8a58fab6) SHA1(5e1a91dfb293bca5cf145b0a0c63217f04003ed1)) |
| 1038 | | |
| 1039 | | ROM_REGION( 0x800, "font", ROMREGION_ERASEFF ) |
| 1040 | | ROM_LOAD( "font.rom", 0x0000, 0x0800, CRC(a91c45a9) SHA1(a472adf791b9bac3dfa6437662e1a9e94a88b412)) |
| 1041 | | |
| 1042 | | ROM_REGION( 0x20000, "kanji", ROMREGION_ERASEFF ) |
| 1043 | | ROM_LOAD( "kanji.rom", 0x0000, 0x20000, CRC(6109e308) SHA1(5c21cf1f241ef1fa0b41009ea41e81771729785f)) |
| 1044 | | |
| 1045 | | ROM_REGION( 0x8000, "rampac1", ROMREGION_ERASEFF ) |
| 1046 | | // ROM_LOAD( "rampac1.bin", 0x0000, 0x8000, CRC(0e4f09bd) SHA1(4088906d57e4f6085a75b249a6139a0e2eb531a1) ) |
| 1047 | | |
| 1048 | | ROM_REGION( 0x8000, "rampac2", ROMREGION_ERASEFF ) |
| 1049 | | // ROM_LOAD( "rampac2.bin", 0x0000, 0x8000, CRC(0e4f09bd) SHA1(4088906d57e4f6085a75b249a6139a0e2eb531a1) ) |
| 1050 | | |
| 1051 | | ROM_REGION( 0x10000, "vram", ROMREGION_ERASE00 ) |
| 1052 | | ROM_END |
| 1053 | | |
| 1054 | | static DRIVER_INIT( paso7 ) |
| 1055 | | { |
| 1056 | | } |
| 1057 | | |
| 1058 | | /* Driver */ |
| 1059 | | |
| 1060 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 1061 | | COMP( 1983, pasopia7, 0, 0, paso7, paso7, paso7, "Toshiba", "PASOPIA 7", GAME_NOT_WORKING ) |
src/mess/drivers/pasopia7.c
| r0 | r11752 | |
| 1 | /************************************************************************************************** |
| 2 | |
| 3 | Toshiba Pasopia 7 (c) 1983 Toshiba |
| 4 | |
| 5 | preliminary driver by Angelo Salese |
| 6 | |
| 7 | TODO: |
| 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 | - cassette device; |
| 11 | |
| 12 | ***************************************************************************************************/ |
| 13 | |
| 14 | #include "emu.h" |
| 15 | #include "cpu/z80/z80.h" |
| 16 | #include "machine/z80ctc.h" |
| 17 | #include "machine/i8255.h" |
| 18 | #include "machine/z80pio.h" |
| 19 | #include "machine/upd765.h" |
| 20 | #include "sound/sn76496.h" |
| 21 | #include "video/mc6845.h" |
| 22 | |
| 23 | |
| 24 | class pasopia_state : public driver_device |
| 25 | { |
| 26 | public: |
| 27 | pasopia_state(const machine_config &mconfig, device_type type, const char *tag) |
| 28 | : driver_device(mconfig, type, tag) { } |
| 29 | |
| 30 | UINT8 m_vram_sel; |
| 31 | UINT8 m_mio_sel; |
| 32 | UINT8 *m_p7_pal; |
| 33 | UINT8 m_bank_reg; |
| 34 | UINT16 m_cursor_addr; |
| 35 | UINT8 m_cursor_blink; |
| 36 | UINT8 m_cursor_raster; |
| 37 | UINT8 m_plane_reg; |
| 38 | UINT8 m_attr_data; |
| 39 | UINT8 m_attr_wrap; |
| 40 | UINT8 m_attr_latch; |
| 41 | UINT8 m_pal_sel; |
| 42 | UINT8 m_x_width; |
| 43 | UINT8 m_gfx_mode; |
| 44 | UINT8 m_nmi_mask; |
| 45 | UINT8 m_nmi_enable_reg; |
| 46 | UINT8 m_nmi_trap; |
| 47 | UINT8 m_nmi_reset; |
| 48 | UINT16 m_pac2_index[2]; |
| 49 | UINT32 m_kanji_index; |
| 50 | UINT8 m_pac2_bank_select; |
| 51 | int m_addr_latch; |
| 52 | }; |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | #define VDP_CLOCK XTAL_3_579545MHz/4 |
| 58 | |
| 59 | static VIDEO_START( paso7 ) |
| 60 | { |
| 61 | pasopia_state *state = machine.driver_data<pasopia_state>(); |
| 62 | state->m_p7_pal = auto_alloc_array(machine, UINT8, 0x10); |
| 63 | } |
| 64 | |
| 65 | #define keyb_press(_val_,_charset_) \ |
| 66 | if(machine.input().code_pressed(_val_)) \ |
| 67 | { \ |
| 68 | ram_space->write_byte(0xfda4,0x01); \ |
| 69 | ram_space->write_byte(0xfce1,_charset_); \ |
| 70 | } \ |
| 71 | |
| 72 | #define keyb_shift_press(_val_,_charset_) \ |
| 73 | if(machine.input().code_pressed(_val_) && machine.input().code_pressed(KEYCODE_LSHIFT)) \ |
| 74 | { \ |
| 75 | ram_space->write_byte(0xfda4,0x01); \ |
| 76 | ram_space->write_byte(0xfce1,_charset_); \ |
| 77 | } \ |
| 78 | |
| 79 | /* cheap kludge to use the keyboard without going nuts with the debugger ... */ |
| 80 | static void fake_keyboard_data(running_machine &machine) |
| 81 | { |
| 82 | address_space *ram_space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 83 | |
| 84 | ram_space->write_byte(0xfda4,0x00); //clear flag |
| 85 | |
| 86 | keyb_press(KEYCODE_Z, 'z'); |
| 87 | keyb_press(KEYCODE_X, 'x'); |
| 88 | keyb_press(KEYCODE_C, 'c'); |
| 89 | keyb_press(KEYCODE_V, 'v'); |
| 90 | keyb_press(KEYCODE_B, 'b'); |
| 91 | keyb_press(KEYCODE_N, 'n'); |
| 92 | keyb_press(KEYCODE_M, 'm'); |
| 93 | |
| 94 | keyb_press(KEYCODE_A, 'a'); |
| 95 | keyb_press(KEYCODE_S, 's'); |
| 96 | keyb_press(KEYCODE_D, 'd'); |
| 97 | keyb_press(KEYCODE_F, 'f'); |
| 98 | keyb_press(KEYCODE_G, 'g'); |
| 99 | keyb_press(KEYCODE_H, 'h'); |
| 100 | keyb_press(KEYCODE_J, 'j'); |
| 101 | keyb_press(KEYCODE_K, 'k'); |
| 102 | keyb_press(KEYCODE_L, 'l'); |
| 103 | |
| 104 | keyb_press(KEYCODE_Q, 'q'); |
| 105 | keyb_press(KEYCODE_W, 'w'); |
| 106 | keyb_press(KEYCODE_E, 'e'); |
| 107 | keyb_press(KEYCODE_R, 'r'); |
| 108 | keyb_press(KEYCODE_T, 't'); |
| 109 | keyb_press(KEYCODE_Y, 'y'); |
| 110 | keyb_press(KEYCODE_U, 'u'); |
| 111 | keyb_press(KEYCODE_I, 'i'); |
| 112 | keyb_press(KEYCODE_O, 'o'); |
| 113 | keyb_press(KEYCODE_P, 'p'); |
| 114 | |
| 115 | keyb_press(KEYCODE_0, '0'); |
| 116 | keyb_press(KEYCODE_1, '1'); |
| 117 | keyb_press(KEYCODE_2, '2'); |
| 118 | keyb_press(KEYCODE_3, '3'); |
| 119 | keyb_press(KEYCODE_4, '4'); |
| 120 | keyb_press(KEYCODE_5, '5'); |
| 121 | keyb_press(KEYCODE_6, '6'); |
| 122 | keyb_press(KEYCODE_7, '7'); |
| 123 | keyb_press(KEYCODE_8, '8'); |
| 124 | keyb_press(KEYCODE_9, '9'); |
| 125 | |
| 126 | keyb_shift_press(KEYCODE_0, '='); |
| 127 | keyb_shift_press(KEYCODE_1, '!'); |
| 128 | keyb_shift_press(KEYCODE_2, '"'); |
| 129 | keyb_shift_press(KEYCODE_3, '?'); |
| 130 | keyb_shift_press(KEYCODE_4, '$'); |
| 131 | keyb_shift_press(KEYCODE_5, '%'); |
| 132 | keyb_shift_press(KEYCODE_6, '&'); |
| 133 | keyb_shift_press(KEYCODE_7, '/'); |
| 134 | keyb_shift_press(KEYCODE_8, '('); |
| 135 | keyb_shift_press(KEYCODE_9, ')'); |
| 136 | |
| 137 | keyb_press(KEYCODE_ENTER, 0x0d); |
| 138 | keyb_press(KEYCODE_SPACE, ' '); |
| 139 | keyb_press(KEYCODE_STOP, '.'); |
| 140 | keyb_shift_press(KEYCODE_STOP, ':'); |
| 141 | keyb_press(KEYCODE_BACKSPACE, 0x08); |
| 142 | keyb_press(KEYCODE_0_PAD, '@'); //@ |
| 143 | keyb_press(KEYCODE_COMMA, ','); |
| 144 | keyb_shift_press(KEYCODE_COMMA, ';'); |
| 145 | keyb_press(KEYCODE_MINUS_PAD, '-'); |
| 146 | keyb_press(KEYCODE_PLUS_PAD, '+'); |
| 147 | keyb_press(KEYCODE_ASTERISK, '*'); |
| 148 | } |
| 149 | |
| 150 | static void draw_cg4_screen(running_machine &machine, bitmap_t *bitmap,const rectangle *cliprect,int width) |
| 151 | { |
| 152 | UINT8 *vram = machine.region("vram")->base(); |
| 153 | int x,y,xi,yi; |
| 154 | int count; |
| 155 | |
| 156 | for(yi=0;yi<8;yi++) |
| 157 | { |
| 158 | count = yi; |
| 159 | for(y=0;y<200;y+=8) |
| 160 | { |
| 161 | for(x=0;x<8*width;x+=8) |
| 162 | { |
| 163 | for(xi=0;xi<8;xi++) |
| 164 | { |
| 165 | int pen_b,pen_r,pen_g,color; |
| 166 | |
| 167 | pen_b = (vram[count+0x0000]>>(7-xi)) & 1; |
| 168 | pen_r = (vram[count+0x4000]>>(7-xi)) & 1; |
| 169 | pen_g = 0;//(p7_vram[count+0x8000]>>(7-xi)) & 1; |
| 170 | |
| 171 | color = pen_g<<2 | pen_r<<1 | pen_b<<0; |
| 172 | |
| 173 | *BITMAP_ADDR16(bitmap, y+yi, x+xi) = machine.pens[color+0x20]; |
| 174 | } |
| 175 | count+=8; |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | static void draw_tv_screen(running_machine &machine, bitmap_t *bitmap,const rectangle *cliprect,int width) |
| 182 | { |
| 183 | pasopia_state *state = machine.driver_data<pasopia_state>(); |
| 184 | UINT8 *vram = machine.region("vram")->base(); |
| 185 | int x,y/*,xi,yi*/; |
| 186 | int count; |
| 187 | |
| 188 | count = 0x0000; |
| 189 | |
| 190 | for(y=0;y<25;y++) |
| 191 | { |
| 192 | for(x=0;x<width;x++) |
| 193 | { |
| 194 | int tile = vram[count+0x8000]; |
| 195 | int attr = vram[count+0xc000]; |
| 196 | int color = attr & 7; |
| 197 | |
| 198 | drawgfx_transpen(bitmap,cliprect,machine.gfx[0],tile,color & 7,0,0,x*8,y*8,0); |
| 199 | |
| 200 | // draw cursor |
| 201 | if(state->m_cursor_addr*8 == count) |
| 202 | { |
| 203 | int xc,yc,cursor_on; |
| 204 | |
| 205 | cursor_on = 0; |
| 206 | switch(state->m_cursor_raster & 0x60) |
| 207 | { |
| 208 | case 0x00: cursor_on = 1; break; //always on |
| 209 | case 0x20: cursor_on = 0; break; //always off |
| 210 | case 0x40: if(machine.primary_screen->frame_number() & 0x10) { cursor_on = 1; } break; //fast blink |
| 211 | case 0x60: if(machine.primary_screen->frame_number() & 0x20) { cursor_on = 1; } break; //slow blink |
| 212 | } |
| 213 | |
| 214 | if(cursor_on) |
| 215 | { |
| 216 | for(yc=0;yc<(8-(state->m_cursor_raster & 7));yc++) |
| 217 | { |
| 218 | for(xc=0;xc<8;xc++) |
| 219 | { |
| 220 | *BITMAP_ADDR16(bitmap, y*8-yc+7, x*8+xc) = machine.pens[0x27]; |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | count+=8; |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | static void draw_mixed_screen(running_machine &machine, bitmap_t *bitmap,const rectangle *cliprect,int width) |
| 231 | { |
| 232 | pasopia_state *state = machine.driver_data<pasopia_state>(); |
| 233 | UINT8 *vram = machine.region("vram")->base(); |
| 234 | UINT8 *gfx_data = machine.region("font")->base(); |
| 235 | int x,y,xi,yi; |
| 236 | int count; |
| 237 | |
| 238 | count = 0x0000; |
| 239 | |
| 240 | for(y=0;y<25;y++) |
| 241 | { |
| 242 | for(x=0;x<width;x++) |
| 243 | { |
| 244 | int tile = vram[count+0x8000]; |
| 245 | |
| 246 | for(yi=0;yi<8;yi++) |
| 247 | { |
| 248 | int attr = vram[count+0xc000+yi]; |
| 249 | |
| 250 | if(attr & 0x80) |
| 251 | { |
| 252 | for(xi=0;xi<8;xi++) |
| 253 | { |
| 254 | int pen,pen_b,pen_r,pen_g; |
| 255 | |
| 256 | pen_b = (vram[count+yi+0x0000]>>(7-xi)) & 1; |
| 257 | pen_r = (vram[count+yi+0x4000]>>(7-xi)) & 1; |
| 258 | pen_g = (vram[count+yi+0x8000]>>(7-xi)) & 1; |
| 259 | |
| 260 | pen = pen_g<<2 | pen_r<<1 | pen_b<<0; |
| 261 | |
| 262 | *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = machine.pens[pen+0x20]; |
| 263 | } |
| 264 | } |
| 265 | else |
| 266 | { |
| 267 | int color = attr & 7; |
| 268 | |
| 269 | for(xi=0;xi<8;xi++) |
| 270 | { |
| 271 | int pen; |
| 272 | pen = ((gfx_data[tile*8+yi]>>(7-xi)) & 1) ? color : 0; |
| 273 | |
| 274 | *BITMAP_ADDR16(bitmap, y*8+yi, x*8+xi) = machine.pens[pen+0x20]; |
| 275 | } |
| 276 | //drawgfx_transpen(bitmap,cliprect,machine.gfx[0],tile,color & 7,0,0,x*8,y*8,0); |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | // draw cursor |
| 281 | if(state->m_cursor_addr*8 == count) |
| 282 | { |
| 283 | int xc,yc,cursor_on; |
| 284 | |
| 285 | cursor_on = 0; |
| 286 | switch(state->m_cursor_raster & 0x60) |
| 287 | { |
| 288 | case 0x00: cursor_on = 1; break; //always on |
| 289 | case 0x20: cursor_on = 0; break; //always off |
| 290 | case 0x40: if(machine.primary_screen->frame_number() & 0x10) { cursor_on = 1; } break; //fast blink |
| 291 | case 0x60: if(machine.primary_screen->frame_number() & 0x20) { cursor_on = 1; } break; //slow blink |
| 292 | } |
| 293 | |
| 294 | if(cursor_on) |
| 295 | { |
| 296 | for(yc=0;yc<(8-(state->m_cursor_raster & 7));yc++) |
| 297 | { |
| 298 | for(xc=0;xc<8;xc++) |
| 299 | { |
| 300 | *BITMAP_ADDR16(bitmap, y*8-yc+7, x*8+xc) = machine.pens[0x27]; |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | count+=8; |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | static SCREEN_UPDATE( paso7 ) |
| 312 | { |
| 313 | pasopia_state *state = screen->machine().driver_data<pasopia_state>(); |
| 314 | int width; |
| 315 | |
| 316 | bitmap_fill(bitmap, cliprect, screen->machine().pens[0]); |
| 317 | |
| 318 | fake_keyboard_data(screen->machine()); |
| 319 | |
| 320 | width = state->m_x_width ? 80 : 40; |
| 321 | |
| 322 | if(state->m_gfx_mode) |
| 323 | draw_mixed_screen(screen->machine(),bitmap,cliprect,width); |
| 324 | else |
| 325 | { |
| 326 | draw_cg4_screen(screen->machine(),bitmap,cliprect,width); |
| 327 | draw_tv_screen(screen->machine(),bitmap,cliprect,width); |
| 328 | } |
| 329 | |
| 330 | return 0; |
| 331 | } |
| 332 | |
| 333 | static READ8_HANDLER( vram_r ) |
| 334 | { |
| 335 | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 336 | UINT8 *vram = space->machine().region("vram")->base(); |
| 337 | UINT8 res; |
| 338 | |
| 339 | if(state->m_vram_sel == 0) |
| 340 | { |
| 341 | UINT8 *work_ram = space->machine().region("maincpu")->base(); |
| 342 | |
| 343 | return work_ram[offset+0x8000]; |
| 344 | } |
| 345 | |
| 346 | if(state->m_pal_sel && (state->m_plane_reg & 0x70) == 0x00) |
| 347 | return state->m_p7_pal[offset & 0xf]; |
| 348 | |
| 349 | res = 0xff; |
| 350 | |
| 351 | if((state->m_plane_reg & 0x11) == 0x11) |
| 352 | res &= vram[offset | 0x0000]; |
| 353 | if((state->m_plane_reg & 0x22) == 0x22) |
| 354 | res &= vram[offset | 0x4000]; |
| 355 | if((state->m_plane_reg & 0x44) == 0x44) |
| 356 | { |
| 357 | res &= vram[offset | 0x8000]; |
| 358 | state->m_attr_latch = vram[offset | 0xc000] & 0x87; |
| 359 | } |
| 360 | |
| 361 | return res; |
| 362 | } |
| 363 | |
| 364 | static WRITE8_HANDLER( vram_w ) |
| 365 | { |
| 366 | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 367 | UINT8 *vram = space->machine().region("vram")->base(); |
| 368 | |
| 369 | if(state->m_vram_sel) |
| 370 | { |
| 371 | if(state->m_pal_sel && (state->m_plane_reg & 0x70) == 0x00) |
| 372 | { |
| 373 | state->m_p7_pal[offset & 0xf] = data & 0xf; |
| 374 | return; |
| 375 | } |
| 376 | |
| 377 | if(state->m_plane_reg & 0x10) |
| 378 | vram[(offset & 0x3fff) | 0x0000] = (state->m_plane_reg & 1) ? data : 0xff; |
| 379 | if(state->m_plane_reg & 0x20) |
| 380 | vram[(offset & 0x3fff) | 0x4000] = (state->m_plane_reg & 2) ? data : 0xff; |
| 381 | if(state->m_plane_reg & 0x40) |
| 382 | { |
| 383 | vram[(offset & 0x3fff) | 0x8000] = (state->m_plane_reg & 4) ? data : 0xff; |
| 384 | state->m_attr_latch = state->m_attr_wrap ? state->m_attr_latch : state->m_attr_data; |
| 385 | vram[(offset & 0x3fff) | 0xc000] = state->m_attr_latch; |
| 386 | } |
| 387 | } |
| 388 | else |
| 389 | { |
| 390 | UINT8 *work_ram = space->machine().region("maincpu")->base(); |
| 391 | |
| 392 | work_ram[offset+0x8000] = data; |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | static WRITE8_HANDLER( pasopia7_memory_ctrl_w ) |
| 397 | { |
| 398 | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 399 | UINT8 *work_ram = space->machine().region("maincpu")->base(); |
| 400 | UINT8 *basic = space->machine().region("basic")->base(); |
| 401 | |
| 402 | switch(data & 3) |
| 403 | { |
| 404 | case 0: |
| 405 | case 3: //select Basic ROM |
| 406 | memory_set_bankptr(space->machine(), "bank1", basic + 0x00000); |
| 407 | memory_set_bankptr(space->machine(), "bank2", basic + 0x04000); |
| 408 | break; |
| 409 | case 1: //select Basic ROM + BIOS ROM |
| 410 | memory_set_bankptr(space->machine(), "bank1", basic + 0x00000); |
| 411 | memory_set_bankptr(space->machine(), "bank2", work_ram + 0x10000); |
| 412 | break; |
| 413 | case 2: //select Work RAM |
| 414 | memory_set_bankptr(space->machine(), "bank1", work_ram + 0x00000); |
| 415 | memory_set_bankptr(space->machine(), "bank2", work_ram + 0x04000); |
| 416 | break; |
| 417 | } |
| 418 | |
| 419 | state->m_bank_reg = data & 3; |
| 420 | state->m_vram_sel = data & 4; |
| 421 | state->m_mio_sel = data & 8; |
| 422 | |
| 423 | // bank4 is always RAM |
| 424 | |
| 425 | // printf("%02x\n",state->m_vram_sel); |
| 426 | } |
| 427 | |
| 428 | #if 0 |
| 429 | static READ8_HANDLER( fdc_r ) |
| 430 | { |
| 431 | return space->machine().rand(); |
| 432 | } |
| 433 | #endif |
| 434 | |
| 435 | |
| 436 | static WRITE8_HANDLER( pac2_w ) |
| 437 | { |
| 438 | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 439 | /* |
| 440 | select register: |
| 441 | 4 = ram1; |
| 442 | 3 = ram2; |
| 443 | 2 = kanji ROM; |
| 444 | 1 = joy; |
| 445 | anything else is nop |
| 446 | */ |
| 447 | |
| 448 | if(state->m_pac2_bank_select == 3 || state->m_pac2_bank_select == 4) |
| 449 | { |
| 450 | switch(offset) |
| 451 | { |
| 452 | case 0: state->m_pac2_index[(state->m_pac2_bank_select-3) & 1] = (state->m_pac2_index[(state->m_pac2_bank_select-3) & 1] & 0x7f00) | (data & 0xff); break; |
| 453 | case 1: state->m_pac2_index[(state->m_pac2_bank_select-3) & 1] = (state->m_pac2_index[(state->m_pac2_bank_select-3) & 1] & 0xff) | ((data & 0x7f) << 8); break; |
| 454 | case 2: // PAC2 RAM write |
| 455 | { |
| 456 | UINT8 *pac2_ram; |
| 457 | |
| 458 | pac2_ram = space->machine().region(((state->m_pac2_bank_select-3) & 1) ? "rampac2" : "rampac1")->base(); |
| 459 | |
| 460 | pac2_ram[state->m_pac2_index[(state->m_pac2_bank_select-3) & 1]] = data; |
| 461 | } |
| 462 | } |
| 463 | } |
| 464 | else if(state->m_pac2_bank_select == 2) // kanji ROM |
| 465 | { |
| 466 | switch(offset) |
| 467 | { |
| 468 | case 0: state->m_kanji_index = (state->m_kanji_index & 0x1ff00) | ((data & 0xff) << 0); break; |
| 469 | case 1: state->m_kanji_index = (state->m_kanji_index & 0x100ff) | ((data & 0xff) << 8); break; |
| 470 | case 2: state->m_kanji_index = (state->m_kanji_index & 0x0ffff) | ((data & 0x01) << 16); break; |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | if(offset == 3) |
| 475 | { |
| 476 | if(data & 0x80) |
| 477 | { |
| 478 | // ... |
| 479 | } |
| 480 | else |
| 481 | state->m_pac2_bank_select = data & 7; |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | static READ8_HANDLER( pac2_r ) |
| 486 | { |
| 487 | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 488 | if(offset == 2) |
| 489 | { |
| 490 | if(state->m_pac2_bank_select == 3 || state->m_pac2_bank_select == 4) |
| 491 | { |
| 492 | UINT8 *pac2_ram; |
| 493 | |
| 494 | pac2_ram = space->machine().region(((state->m_pac2_bank_select-3) & 1) ? "rampac2" : "rampac1")->base(); |
| 495 | |
| 496 | return pac2_ram[state->m_pac2_index[(state->m_pac2_bank_select-3) & 1]]; |
| 497 | } |
| 498 | else if(state->m_pac2_bank_select == 2) |
| 499 | { |
| 500 | UINT8 *kanji_rom = space->machine().region("kanji")->base(); |
| 501 | |
| 502 | return kanji_rom[state->m_kanji_index]; |
| 503 | } |
| 504 | else |
| 505 | { |
| 506 | printf("%02x\n",state->m_pac2_bank_select); |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | return 0xff; |
| 511 | } |
| 512 | |
| 513 | /* writes always occurs to the RAM banks, even if the ROMs are selected. */ |
| 514 | static WRITE8_HANDLER( ram_bank_w ) |
| 515 | { |
| 516 | UINT8 *work_ram = space->machine().region("maincpu")->base(); |
| 517 | |
| 518 | work_ram[offset] = data; |
| 519 | } |
| 520 | |
| 521 | static WRITE8_HANDLER( pasopia7_6845_w ) |
| 522 | { |
| 523 | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 524 | if(offset == 0) |
| 525 | { |
| 526 | state->m_addr_latch = data; |
| 527 | space->machine().device<mc6845_device>("crtc")->address_w(*space, offset, data); |
| 528 | } |
| 529 | else |
| 530 | { |
| 531 | /* FIXME: this should be inside the MC6845 core! */ |
| 532 | if(state->m_addr_latch == 0x0a) |
| 533 | state->m_cursor_raster = data; |
| 534 | if(state->m_addr_latch == 0x0e) |
| 535 | state->m_cursor_addr = ((data<<8) & 0x3f00) | (state->m_cursor_addr & 0xff); |
| 536 | else if(state->m_addr_latch == 0x0f) |
| 537 | state->m_cursor_addr = (state->m_cursor_addr & 0x3f00) | (data & 0xff); |
| 538 | |
| 539 | space->machine().device<mc6845_device>("crtc")->register_w(*space, offset, data); |
| 540 | |
| 541 | /* double pump the pixel clock if we are in 640 x 200 mode */ |
| 542 | space->machine().device<mc6845_device>("crtc")->set_clock( (state->m_x_width) ? VDP_CLOCK*2 : VDP_CLOCK); |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | static void pasopia_nmi_trap(running_machine &machine) |
| 547 | { |
| 548 | pasopia_state *state = machine.driver_data<pasopia_state>(); |
| 549 | if(state->m_nmi_enable_reg) |
| 550 | { |
| 551 | state->m_nmi_trap |= 2; |
| 552 | |
| 553 | if(state->m_nmi_mask == 0) |
| 554 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE); |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | static READ8_HANDLER( pasopia7_fdc_r ) |
| 559 | { |
| 560 | switch(offset) |
| 561 | { |
| 562 | case 4: return upd765_status_r(space->machine().device("upd765"),0); |
| 563 | case 5: return upd765_data_r(space->machine().device("upd765"),0); |
| 564 | //case 6: bit 7 interrupt bit |
| 565 | } |
| 566 | |
| 567 | return 0xff; |
| 568 | } |
| 569 | |
| 570 | static WRITE8_HANDLER( pasopia7_fdc_w ) |
| 571 | { |
| 572 | switch(offset) |
| 573 | { |
| 574 | case 0: upd765_tc_w(space->machine().device("upd765"), 0); break; |
| 575 | case 2: upd765_tc_w(space->machine().device("upd765"), 1); break; |
| 576 | case 5: return upd765_data_w(space->machine().device("upd765"),0,data); |
| 577 | case 6: |
| 578 | upd765_reset_w(space->machine().device("upd765"),data & 0x80); |
| 579 | floppy_mon_w(floppy_get_device(space->machine(), 0), (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); |
| 580 | floppy_drive_set_ready_state(floppy_get_device(space->machine(), 0), (data & 0x40), 0); |
| 581 | break; |
| 582 | |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | |
| 587 | static READ8_HANDLER( pasopia7_io_r ) |
| 588 | { |
| 589 | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 590 | UINT16 io_port; |
| 591 | i8255_device *ppi0 = space->machine().device<i8255_device>("ppi8255_0"); |
| 592 | i8255_device *ppi1 = space->machine().device<i8255_device>("ppi8255_1"); |
| 593 | i8255_device *ppi2 = space->machine().device<i8255_device>("ppi8255_2"); |
| 594 | |
| 595 | if(state->m_mio_sel) |
| 596 | { |
| 597 | address_space *ram_space = space->machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 598 | |
| 599 | state->m_mio_sel = 0; |
| 600 | //printf("%08x\n",offset); |
| 601 | //return 0x0d; // hack: this is used for reading the keyboard data, we can fake it a little ... (modify fda4) |
| 602 | return ram_space->read_byte(offset); |
| 603 | } |
| 604 | |
| 605 | io_port = offset & 0xff; //trim down to 8-bit bus |
| 606 | |
| 607 | if(io_port >= 0x30 && io_port <= 0x33) |
| 608 | printf("[%02x]\n",offset & 3); |
| 609 | |
| 610 | if(io_port >= 0x08 && io_port <= 0x0b) { return ppi0->read(*space, (io_port-0x08) & 3); } |
| 611 | else if(io_port >= 0x0c && io_port <= 0x0f) { return ppi1->read(*space, (io_port-0x0c) & 3); } |
| 612 | // else if(io_port == 0x10 || io_port == 0x11) { M6845 read } |
| 613 | else if(io_port >= 0x18 && io_port <= 0x1b) { return pac2_r(space, (io_port-0x18) & 3); } |
| 614 | else if(io_port >= 0x20 && io_port <= 0x23) |
| 615 | { |
| 616 | pasopia_nmi_trap(space->machine()); |
| 617 | return ppi2->read(*space, (io_port-0x20) & 3); |
| 618 | } |
| 619 | else if(io_port >= 0x28 && io_port <= 0x2b) { return z80ctc_r(space->machine().device("ctc"), (io_port-0x28) & 3); } |
| 620 | else if(io_port == 0x30) { return z80pio_d_r(space->machine().device("z80pio_0"), (io_port-0x30) & 1); } |
| 621 | else if(io_port == 0x31) { return z80pio_c_r(space->machine().device("z80pio_0"), (io_port-0x31) & 1); } |
| 622 | // else if(io_port == 0x3a) { SN1 } |
| 623 | // else if(io_port == 0x3b) { SN2 } |
| 624 | // else if(io_port == 0x3c) { bankswitch } |
| 625 | else if(io_port >= 0xe0 && io_port <= 0xe6) { return pasopia7_fdc_r(space,offset & 7); } |
| 626 | else |
| 627 | { |
| 628 | logerror("(PC=%06x) Read i/o address %02x\n",cpu_get_pc(&space->device()),io_port); |
| 629 | } |
| 630 | |
| 631 | return 0xff; |
| 632 | } |
| 633 | |
| 634 | static WRITE8_HANDLER( pasopia7_io_w ) |
| 635 | { |
| 636 | pasopia_state *state = space->machine().driver_data<pasopia_state>(); |
| 637 | i8255_device *ppi0 = space->machine().device<i8255_device>("ppi8255_0"); |
| 638 | i8255_device *ppi1 = space->machine().device<i8255_device>("ppi8255_1"); |
| 639 | i8255_device *ppi2 = space->machine().device<i8255_device>("ppi8255_2"); |
| 640 | UINT16 io_port; |
| 641 | |
| 642 | if(state->m_mio_sel) |
| 643 | { |
| 644 | address_space *ram_space = space->machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 645 | state->m_mio_sel = 0; |
| 646 | ram_space->write_byte(offset, data); |
| 647 | return; |
| 648 | } |
| 649 | |
| 650 | io_port = offset & 0xff; //trim down to 8-bit bus |
| 651 | |
| 652 | if(io_port >= 0x30 && io_port <= 0x33) |
| 653 | printf("[%02x] <- %02x\n",offset & 3,data); |
| 654 | |
| 655 | if(io_port >= 0x08 && io_port <= 0x0b) { ppi0->write(*space, (io_port-0x08) & 3, data); } |
| 656 | else if(io_port >= 0x0c && io_port <= 0x0f) { ppi1->write(*space, (io_port-0x0c) & 3, data); } |
| 657 | else if(io_port >= 0x10 && io_port <= 0x11) { pasopia7_6845_w(space, io_port-0x10, data); } |
| 658 | else if(io_port >= 0x18 && io_port <= 0x1b) { pac2_w(space, (io_port-0x18) & 3, data); } |
| 659 | else if(io_port >= 0x20 && io_port <= 0x23) |
| 660 | { |
| 661 | ppi2->write(*space, (io_port-0x20) & 3, data); |
| 662 | pasopia_nmi_trap(space->machine()); |
| 663 | } |
| 664 | else if(io_port >= 0x28 && io_port <= 0x2b) { z80ctc_w(space->machine().device("ctc"), (io_port-0x28) & 3,data); } |
| 665 | else if(io_port >= 0x30 && io_port <= 0x31) { z80pio_d_w(space->machine().device("z80pio_0"), (io_port-0x30) & 1, data); } |
| 666 | else if(io_port >= 0x32 && io_port <= 0x33) { z80pio_c_w(space->machine().device("z80pio_0"), (io_port-0x32) & 1, data); } |
| 667 | else if(io_port == 0x3a) { sn76496_w(space->machine().device("sn1"), 0, data); } |
| 668 | else if(io_port == 0x3b) { sn76496_w(space->machine().device("sn2"), 0, data); } |
| 669 | else if(io_port == 0x3c) { pasopia7_memory_ctrl_w(space,0, data); } |
| 670 | else if(io_port >= 0xe0 && io_port <= 0xe6) { pasopia7_fdc_w(space,offset & 7,data); } |
| 671 | else |
| 672 | { |
| 673 | logerror("(PC=%06x) Write i/o address %02x = %02x\n",cpu_get_pc(&space->device()),offset,data); |
| 674 | } |
| 675 | } |
| 676 | |
| 677 | static ADDRESS_MAP_START(paso7_mem, AS_PROGRAM, 8) |
| 678 | ADDRESS_MAP_UNMAP_HIGH |
| 679 | AM_RANGE( 0x0000, 0x7fff ) AM_WRITE( ram_bank_w ) |
| 680 | AM_RANGE( 0x0000, 0x3fff ) AM_ROMBANK("bank1") |
| 681 | AM_RANGE( 0x4000, 0x7fff ) AM_ROMBANK("bank2") |
| 682 | AM_RANGE( 0x8000, 0xbfff ) AM_READWRITE(vram_r, vram_w ) |
| 683 | AM_RANGE( 0xc000, 0xffff ) AM_RAMBANK("bank4") |
| 684 | ADDRESS_MAP_END |
| 685 | |
| 686 | static ADDRESS_MAP_START( paso7_io , AS_IO, 8) |
| 687 | ADDRESS_MAP_UNMAP_HIGH |
| 688 | AM_RANGE( 0x0000, 0xffff) AM_READWRITE( pasopia7_io_r, pasopia7_io_w ) |
| 689 | ADDRESS_MAP_END |
| 690 | |
| 691 | /* Input ports */ |
| 692 | static INPUT_PORTS_START( paso7 ) |
| 693 | PORT_START("DSW") |
| 694 | PORT_DIPNAME( 0x01, 0x01, "System type" ) |
| 695 | PORT_DIPSETTING( 0x01, DEF_STR( Normal ) ) |
| 696 | PORT_DIPSETTING( 0x00, "LCD" ) |
| 697 | INPUT_PORTS_END |
| 698 | |
| 699 | static const gfx_layout p7_chars_8x8 = |
| 700 | { |
| 701 | 8,8, |
| 702 | RGN_FRAC(1,1), |
| 703 | 1, |
| 704 | { 0 }, |
| 705 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 706 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 707 | 8*8 |
| 708 | }; |
| 709 | |
| 710 | static const gfx_layout p7_chars_16x16 = |
| 711 | { |
| 712 | 16,16, |
| 713 | RGN_FRAC(1,1), |
| 714 | 1, |
| 715 | { 0 }, |
| 716 | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, |
| 717 | { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, |
| 718 | 16*16 |
| 719 | }; |
| 720 | |
| 721 | static GFXDECODE_START( pasopia7 ) |
| 722 | GFXDECODE_ENTRY( "font", 0x00000, p7_chars_8x8, 0, 0x10 ) |
| 723 | GFXDECODE_ENTRY( "kanji", 0x00000, p7_chars_16x16, 0, 0x10 ) |
| 724 | GFXDECODE_END |
| 725 | |
| 726 | static const mc6845_interface mc6845_intf = |
| 727 | { |
| 728 | "screen", /* screen we are acting on */ |
| 729 | 8, /* number of pixels per video memory address */ |
| 730 | NULL, /* before pixel update callback */ |
| 731 | NULL, /* row update callback */ |
| 732 | NULL, /* after pixel update callback */ |
| 733 | DEVCB_NULL, /* callback for display state changes */ |
| 734 | DEVCB_NULL, /* callback for cursor state changes */ |
| 735 | DEVCB_NULL, /* HSYNC callback */ |
| 736 | DEVCB_NULL, /* VSYNC callback */ |
| 737 | NULL /* update address callback */ |
| 738 | }; |
| 739 | |
| 740 | static Z80CTC_INTERFACE( ctc_intf ) |
| 741 | { |
| 742 | 0, // timer disables |
| 743 | DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_IRQ0), // interrupt handler |
| 744 | DEVCB_LINE(z80ctc_trg1_w), // ZC/TO0 callback |
| 745 | DEVCB_LINE(z80ctc_trg2_w), // ZC/TO1 callback, beep interface |
| 746 | DEVCB_LINE(z80ctc_trg3_w) // ZC/TO2 callback |
| 747 | }; |
| 748 | |
| 749 | static READ8_DEVICE_HANDLER( test_r ) |
| 750 | { |
| 751 | return device->machine().rand(); |
| 752 | } |
| 753 | |
| 754 | static WRITE_LINE_DEVICE_HANDLER( testa_w ) |
| 755 | { |
| 756 | printf("A %02x\n",state); |
| 757 | } |
| 758 | |
| 759 | static WRITE_LINE_DEVICE_HANDLER( testb_w ) |
| 760 | { |
| 761 | printf("B %02x\n",state); |
| 762 | } |
| 763 | |
| 764 | static Z80PIO_INTERFACE( z80pio_intf ) |
| 765 | { |
| 766 | DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_IRQ0), //doesn't work? |
| 767 | DEVCB_HANDLER(test_r), |
| 768 | DEVCB_NULL, |
| 769 | DEVCB_LINE(testa_w), |
| 770 | DEVCB_HANDLER(test_r), |
| 771 | DEVCB_NULL, |
| 772 | DEVCB_LINE(testb_w) |
| 773 | }; |
| 774 | |
| 775 | static const z80_daisy_config p7_daisy[] = |
| 776 | { |
| 777 | { "ctc" }, |
| 778 | { "z80pio_0" }, |
| 779 | // { "upd765" }, /* TODO */ |
| 780 | { NULL } |
| 781 | }; |
| 782 | |
| 783 | static READ8_DEVICE_HANDLER( crtc_portb_r ) |
| 784 | { |
| 785 | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 786 | // --x- ---- vsync bit |
| 787 | // ---x ---- lcd dip-sw |
| 788 | // ---- x--- disp bit |
| 789 | UINT8 lcd_bit = input_port_read(device->machine(), "DSW") & 1; |
| 790 | UINT8 vdisp = (device->machine().primary_screen->vpos() < (lcd_bit ? 200 : 28)) ? 0x08 : 0x00; //TODO: check LCD vpos trigger |
| 791 | UINT8 vsync = vdisp ? 0x00 : 0x20; |
| 792 | |
| 793 | return 0x40 | (state->m_attr_latch & 0x87) | vsync | vdisp | (lcd_bit << 4); |
| 794 | } |
| 795 | |
| 796 | static WRITE8_DEVICE_HANDLER( screen_mode_w ) |
| 797 | { |
| 798 | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 799 | if(data & 0x5f) |
| 800 | printf("GFX MODE %02x\n",data); |
| 801 | |
| 802 | state->m_x_width = data & 0x20; |
| 803 | state->m_gfx_mode = data & 0x80; |
| 804 | |
| 805 | // printf("%02x\n",state->m_gfx_mode); |
| 806 | } |
| 807 | |
| 808 | static WRITE8_DEVICE_HANDLER( plane_reg_w ) |
| 809 | { |
| 810 | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 811 | //if(data & 0x11) |
| 812 | //printf("PLANE %02x\n",data); |
| 813 | state->m_plane_reg = data; |
| 814 | } |
| 815 | |
| 816 | static WRITE8_DEVICE_HANDLER( video_attr_w ) |
| 817 | { |
| 818 | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 819 | //printf("VIDEO ATTR %02x | TEXT_PAGE %02x\n",data & 0xf,data & 0x70); |
| 820 | state->m_attr_data = (data & 0x7) | ((data & 0x8)<<4); |
| 821 | } |
| 822 | |
| 823 | //#include "debugger.h" |
| 824 | |
| 825 | static WRITE8_DEVICE_HANDLER( video_misc_w ) |
| 826 | { |
| 827 | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 828 | /* |
| 829 | --x- ---- blinking |
| 830 | ---x ---- attribute wrap |
| 831 | ---- x--- pal disable |
| 832 | ---- xx-- palette selector (both bits enables this, odd hook-up) |
| 833 | */ |
| 834 | // if(data & 2) |
| 835 | // { |
| 836 | // printf("VIDEO MISC %02x\n",data); |
| 837 | // debugger_break(device->machine()); |
| 838 | // } |
| 839 | state->m_cursor_blink = data & 0x20; |
| 840 | state->m_attr_wrap = data & 0x10; |
| 841 | // state->m_pal_sel = data & 0x02; |
| 842 | } |
| 843 | |
| 844 | static WRITE8_DEVICE_HANDLER( nmi_mask_w ) |
| 845 | { |
| 846 | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 847 | /* |
| 848 | --x- ---- (related to the data rec) |
| 849 | ---x ---- data rec out |
| 850 | ---- --x- sound off |
| 851 | ---- ---x reset NMI & trap |
| 852 | */ |
| 853 | // printf("SYSTEM MISC %02x\n",data); |
| 854 | |
| 855 | if(data & 1) |
| 856 | { |
| 857 | state->m_nmi_reset &= ~4; |
| 858 | state->m_nmi_trap &= ~2; |
| 859 | //cputag_set_input_line(device->machine(), "maincpu", INPUT_LINE_NMI, CLEAR_LINE); //guess |
| 860 | } |
| 861 | |
| 862 | } |
| 863 | |
| 864 | /* TODO: investigate on these. */ |
| 865 | static READ8_DEVICE_HANDLER( unk_r ) |
| 866 | { |
| 867 | return 0xff;//device->machine().rand(); |
| 868 | } |
| 869 | |
| 870 | static READ8_DEVICE_HANDLER( nmi_reg_r ) |
| 871 | { |
| 872 | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 873 | //printf("C\n"); |
| 874 | return 0xfc | state->m_bank_reg;//device->machine().rand(); |
| 875 | } |
| 876 | |
| 877 | static WRITE8_DEVICE_HANDLER( nmi_reg_w ) |
| 878 | { |
| 879 | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 880 | /* |
| 881 | x--- ---- NMI mask |
| 882 | -x-- ---- NMI enable trap on PPI8255 2 r/w |
| 883 | */ |
| 884 | state->m_nmi_mask = data & 0x80; |
| 885 | state->m_nmi_enable_reg = data & 0x40; |
| 886 | } |
| 887 | |
| 888 | static READ8_DEVICE_HANDLER( nmi_porta_r ) |
| 889 | { |
| 890 | return 0xff; |
| 891 | } |
| 892 | |
| 893 | static READ8_DEVICE_HANDLER( nmi_portb_r ) |
| 894 | { |
| 895 | pasopia_state *state = device->machine().driver_data<pasopia_state>(); |
| 896 | return 0xf9 | state->m_nmi_trap | state->m_nmi_reset; |
| 897 | } |
| 898 | |
| 899 | static I8255_INTERFACE( ppi8255_intf_0 ) |
| 900 | { |
| 901 | DEVCB_HANDLER(unk_r), /* Port A read */ |
| 902 | DEVCB_HANDLER(screen_mode_w), /* Port A write */ |
| 903 | DEVCB_HANDLER(crtc_portb_r), /* Port B read */ |
| 904 | DEVCB_NULL, /* Port B write */ |
| 905 | DEVCB_NULL, /* Port C read */ |
| 906 | DEVCB_NULL /* Port C write */ |
| 907 | }; |
| 908 | |
| 909 | static I8255_INTERFACE( ppi8255_intf_1 ) |
| 910 | { |
| 911 | DEVCB_NULL, /* Port A read */ |
| 912 | DEVCB_HANDLER(plane_reg_w), /* Port A write */ |
| 913 | DEVCB_NULL, /* Port B read */ |
| 914 | DEVCB_HANDLER(video_attr_w), /* Port B write */ |
| 915 | DEVCB_NULL, /* Port C read */ |
| 916 | DEVCB_HANDLER(video_misc_w) /* Port C write */ |
| 917 | }; |
| 918 | |
| 919 | static I8255_INTERFACE( ppi8255_intf_2 ) |
| 920 | { |
| 921 | DEVCB_HANDLER(nmi_porta_r), /* Port A read */ |
| 922 | DEVCB_HANDLER(nmi_mask_w), /* Port A write */ |
| 923 | DEVCB_HANDLER(nmi_portb_r), /* Port B read */ |
| 924 | DEVCB_NULL, /* Port B write */ |
| 925 | DEVCB_HANDLER(nmi_reg_r), /* Port C read */ |
| 926 | DEVCB_HANDLER(nmi_reg_w) /* Port C write */ |
| 927 | }; |
| 928 | |
| 929 | static MACHINE_RESET( paso7 ) |
| 930 | { |
| 931 | pasopia_state *state = machine.driver_data<pasopia_state>(); |
| 932 | UINT8 *bios = machine.region("maincpu")->base(); |
| 933 | |
| 934 | memory_set_bankptr(machine, "bank1", bios + 0x10000); |
| 935 | memory_set_bankptr(machine, "bank2", bios + 0x10000); |
| 936 | // memory_set_bankptr(machine, "bank3", bios + 0x10000); |
| 937 | // memory_set_bankptr(machine, "bank4", bios + 0x10000); |
| 938 | |
| 939 | state->m_nmi_reset |= 4; |
| 940 | } |
| 941 | |
| 942 | static PALETTE_INIT( pasopia7 ) |
| 943 | { |
| 944 | int i; |
| 945 | |
| 946 | for (i = 0x000; i < 0x020; i++) |
| 947 | { |
| 948 | UINT8 r,g,b; |
| 949 | |
| 950 | if(((i & 0x11) == 0x01) || ((i & 0x11) == 0x10)) |
| 951 | { |
| 952 | r = ((i >> 2) & 1) ? 0xff : 0x00; |
| 953 | g = ((i >> 3) & 1) ? 0xff : 0x00; |
| 954 | b = ((i >> 1) & 1) ? 0xff : 0x00; |
| 955 | } |
| 956 | else { r = g = b = 0x00; } |
| 957 | |
| 958 | palette_set_color_rgb(machine, i, r,g,b); |
| 959 | } |
| 960 | for( i = 0x000; i < 8; i++) |
| 961 | palette_set_color_rgb(machine, i+0x020, pal1bit(i >> 1), pal1bit(i >> 2), pal1bit(i >> 0)); |
| 962 | } |
| 963 | |
| 964 | static const struct upd765_interface pasopia7_upd765_interface = |
| 965 | { |
| 966 | DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_IRQ0), |
| 967 | DEVCB_NULL, //DRQ, TODO |
| 968 | NULL, |
| 969 | UPD765_RDY_PIN_CONNECTED, |
| 970 | {FLOPPY_0, FLOPPY_1, NULL, NULL} |
| 971 | }; |
| 972 | |
| 973 | static const floppy_config pasopia7_floppy_config = |
| 974 | { |
| 975 | DEVCB_NULL, |
| 976 | DEVCB_NULL, |
| 977 | DEVCB_NULL, |
| 978 | DEVCB_NULL, |
| 979 | DEVCB_NULL, |
| 980 | FLOPPY_STANDARD_5_25_DSHD, |
| 981 | FLOPPY_OPTIONS_NAME(default), |
| 982 | NULL |
| 983 | }; |
| 984 | |
| 985 | static MACHINE_CONFIG_START( paso7, pasopia_state ) |
| 986 | /* basic machine hardware */ |
| 987 | MCFG_CPU_ADD("maincpu",Z80, XTAL_4MHz) |
| 988 | MCFG_CPU_PROGRAM_MAP(paso7_mem) |
| 989 | MCFG_CPU_IO_MAP(paso7_io) |
| 990 | // MCFG_CPU_VBLANK_INT("screen", irq0_line_hold) |
| 991 | MCFG_CPU_CONFIG(p7_daisy) |
| 992 | |
| 993 | MCFG_Z80CTC_ADD( "ctc", XTAL_4MHz, ctc_intf ) |
| 994 | |
| 995 | MCFG_MACHINE_RESET(paso7) |
| 996 | |
| 997 | MCFG_I8255_ADD( "ppi8255_0", ppi8255_intf_0 ) |
| 998 | MCFG_I8255_ADD( "ppi8255_1", ppi8255_intf_1 ) |
| 999 | MCFG_I8255_ADD( "ppi8255_2", ppi8255_intf_2 ) |
| 1000 | MCFG_Z80PIO_ADD( "z80pio_0", XTAL_4MHz, z80pio_intf ) |
| 1001 | |
| 1002 | MCFG_UPD765A_ADD("upd765", pasopia7_upd765_interface) |
| 1003 | MCFG_FLOPPY_2_DRIVES_ADD(pasopia7_floppy_config) |
| 1004 | |
| 1005 | /* video hardware */ |
| 1006 | MCFG_SCREEN_ADD("screen", RASTER) |
| 1007 | MCFG_SCREEN_REFRESH_RATE(60) |
| 1008 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 1009 | MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 1010 | MCFG_SCREEN_SIZE(640, 480) |
| 1011 | MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 200-1) |
| 1012 | MCFG_SCREEN_UPDATE(paso7) |
| 1013 | |
| 1014 | MCFG_MC6845_ADD("crtc", H46505, VDP_CLOCK, mc6845_intf) /* unknown clock, hand tuned to get ~60 fps */ |
| 1015 | MCFG_PALETTE_LENGTH(0x28) |
| 1016 | MCFG_PALETTE_INIT(pasopia7) |
| 1017 | |
| 1018 | MCFG_GFXDECODE( pasopia7 ) |
| 1019 | |
| 1020 | MCFG_VIDEO_START(paso7) |
| 1021 | |
| 1022 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 1023 | |
| 1024 | MCFG_SOUND_ADD("sn1", SN76489A, 1996800) // unknown clock / divider |
| 1025 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 1026 | |
| 1027 | MCFG_SOUND_ADD("sn2", SN76489A, 1996800) // unknown clock / divider |
| 1028 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 1029 | MACHINE_CONFIG_END |
| 1030 | |
| 1031 | /* ROM definition */ |
| 1032 | ROM_START( pasopia7 ) |
| 1033 | ROM_REGION( 0x14000, "maincpu", ROMREGION_ERASEFF ) |
| 1034 | ROM_LOAD( "bios.rom", 0x10000, 0x4000, CRC(b8111407) SHA1(ac93ae62db4c67de815f45de98c79cfa1313857d)) |
| 1035 | |
| 1036 | ROM_REGION( 0x8000, "basic", ROMREGION_ERASEFF ) |
| 1037 | ROM_LOAD( "basic.rom", 0x0000, 0x8000, CRC(8a58fab6) SHA1(5e1a91dfb293bca5cf145b0a0c63217f04003ed1)) |
| 1038 | |
| 1039 | ROM_REGION( 0x800, "font", ROMREGION_ERASEFF ) |
| 1040 | ROM_LOAD( "font.rom", 0x0000, 0x0800, CRC(a91c45a9) SHA1(a472adf791b9bac3dfa6437662e1a9e94a88b412)) |
| 1041 | |
| 1042 | ROM_REGION( 0x20000, "kanji", ROMREGION_ERASEFF ) |
| 1043 | ROM_LOAD( "kanji.rom", 0x0000, 0x20000, CRC(6109e308) SHA1(5c21cf1f241ef1fa0b41009ea41e81771729785f)) |
| 1044 | |
| 1045 | ROM_REGION( 0x8000, "rampac1", ROMREGION_ERASEFF ) |
| 1046 | // ROM_LOAD( "rampac1.bin", 0x0000, 0x8000, CRC(0e4f09bd) SHA1(4088906d57e4f6085a75b249a6139a0e2eb531a1) ) |
| 1047 | |
| 1048 | ROM_REGION( 0x8000, "rampac2", ROMREGION_ERASEFF ) |
| 1049 | // ROM_LOAD( "rampac2.bin", 0x0000, 0x8000, CRC(0e4f09bd) SHA1(4088906d57e4f6085a75b249a6139a0e2eb531a1) ) |
| 1050 | |
| 1051 | ROM_REGION( 0x10000, "vram", ROMREGION_ERASE00 ) |
| 1052 | ROM_END |
| 1053 | |
| 1054 | static DRIVER_INIT( paso7 ) |
| 1055 | { |
| 1056 | } |
| 1057 | |
| 1058 | /* Driver */ |
| 1059 | |
| 1060 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 1061 | COMP( 1983, pasopia7, 0, 0, paso7, paso7, paso7, "Toshiba", "PASOPIA 7", GAME_NOT_WORKING ) |