src/mess/drivers/x1.c
| r5506 | r5507 | |
| 10 | 10 | - Video part is bare minimum, chances are that's probably a tilemap/bitmap nightmare; |
| 11 | 11 | - Sort out / redump the gfx roms; |
| 12 | 12 | |
| 13 | per-game specific TODO: |
| 14 | - 177 / Dragon Buster: check why it does a tight loop (patching it makes the game go further) |
| 15 | - Dragon Buster: uses PCG + sets bitmap in a weird way; |
| 16 | - Shanghai: tests the ay8910 read regs, mouse/joystick perhaps? |
| 17 | - Gaia: Hits a FDC drive assert; |
| 18 | |
| 13 | 19 | ================================================================================================= |
| 14 | 20 | |
| 15 | 21 | X1 (CZ-800C) - November, 1982 |
| r5506 | r5507 | |
| 121 | 127 | #include "devices/basicdsk.h" |
| 122 | 128 | |
| 123 | 129 | static UINT8 hres_320,io_switch; |
| 124 | | static UINT8 *bitmapa_ram,*bitmapb_ram; |
| 130 | static UINT8 *gfx_bitmap_ram; |
| 125 | 131 | |
| 126 | 132 | static VIDEO_START( x1 ) |
| 127 | 133 | { |
| r5506 | r5507 | |
| 133 | 139 | |
| 134 | 140 | w = (hres_320 & 0x40) ? 1 : 2; |
| 135 | 141 | |
| 142 | bitmap_fill(bitmap, cliprect, 0); |
| 143 | |
| 144 | { |
| 145 | int count,xi,yi; |
| 146 | int pen_r,pen_g,pen_b,color; |
| 147 | |
| 148 | count = 0; |
| 149 | for(yi=0;yi<8;yi++) |
| 150 | { |
| 151 | for(y=0;y<200;y+=8) |
| 152 | { |
| 153 | for(x=0;x<640;x+=8) |
| 154 | { |
| 155 | for(xi=0;xi<8;xi++) |
| 156 | { |
| 157 | pen_r = (gfx_bitmap_ram[count+0x4000]>>(7-xi)) & 1; |
| 158 | pen_g = (gfx_bitmap_ram[count+0x8000]>>(7-xi)) & 1; |
| 159 | pen_b = (gfx_bitmap_ram[count+0x0000]>>(7-xi)) & 1; |
| 160 | |
| 161 | color = pen_r<<2 | pen_g<<1 | pen_b<<0; |
| 162 | |
| 163 | if((x+xi)<=video_screen_get_visible_area(screen)->max_x && ((y)+0)<video_screen_get_visible_area(screen)->max_y) |
| 164 | *BITMAP_ADDR16(bitmap, y+yi, x+xi) = screen->machine->pens[color+0x80]; |
| 165 | |
| 166 | } |
| 167 | count++; |
| 168 | } |
| 169 | } |
| 170 | count+=48; |
| 171 | } |
| 172 | } |
| 173 | |
| 136 | 174 | for (y=0;y<25;y++) |
| 137 | 175 | { |
| 138 | 176 | for (x=0;x<40*w;x++) |
| r5506 | r5507 | |
| 141 | 179 | int color = colorram[x+(y*40*w)] & 0x3f; |
| 142 | 180 | int width = (colorram[x+(y*40*w)] & 0x80)>>7; |
| 143 | 181 | |
| 144 | | drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[width],tile,color,0,0,(x/(width+1))*8*(width+1),y*8); |
| 182 | if(tile == 0) continue; //<- correct? |
| 183 | |
| 184 | if(color & 0x38) |
| 185 | drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[width],tile,color,0,0,(x/(width+1))*8*(width+1),y*8); |
| 186 | else |
| 187 | drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[width],tile,color,0,0,(x/(width+1))*8*(width+1),y*8,0); |
| 145 | 188 | } |
| 146 | 189 | } |
| 147 | 190 | |
| r5506 | r5507 | |
| 326 | 369 | NULL |
| 327 | 370 | }; |
| 328 | 371 | |
| 372 | /* for bitmap mode */ |
| 373 | static UINT8 x_b,x_g,x_r; |
| 374 | |
| 375 | static void set_current_palette(running_machine *machine) |
| 376 | { |
| 377 | UINT8 addr,r,g,b; |
| 378 | |
| 379 | for(addr=0;addr<8;addr++) |
| 380 | { |
| 381 | r = ((x_r)>>(7-addr)) & 1; |
| 382 | g = ((x_g)>>(7-addr)) & 1; |
| 383 | b = ((x_b)>>(7-addr)) & 1; |
| 384 | |
| 385 | palette_set_color_rgb(machine, addr+0x100, pal1bit(r), pal1bit(g), pal1bit(b)); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | static WRITE8_HANDLER( x1_pal_r_w ) { x_r = data; set_current_palette(space->machine); } |
| 390 | static WRITE8_HANDLER( x1_pal_g_w ) { x_g = data; set_current_palette(space->machine); } |
| 391 | static WRITE8_HANDLER( x1_pal_b_w ) { x_b = data; set_current_palette(space->machine); } |
| 392 | |
| 393 | |
| 329 | 394 | static ADDRESS_MAP_START( x1_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 330 | 395 | ADDRESS_MAP_UNMAP_HIGH |
| 331 | 396 | AM_RANGE(0x0000, 0x7fff) AM_ROMBANK(1) AM_WRITE(rom_data_w) |
| r5506 | r5507 | |
| 336 | 401 | ADDRESS_MAP_UNMAP_HIGH |
| 337 | 402 | // AM_RANGE(0x0700, 0x0701) AM_WRITENOP //YM-2151 reg/data |
| 338 | 403 | // AM_RANGE(0x0704, 0x0707) AM_NOP //ctc regs |
| 404 | // 0x0c00 rs232c port |
| 339 | 405 | AM_RANGE(0x0e00, 0x0e02) AM_WRITE(x1_rom_w) |
| 340 | 406 | AM_RANGE(0x0e03, 0x0e03) AM_READ(x1_rom_r) |
| 341 | 407 | // AM_RANGE(0x0e80, 0x0e82) AM_WRITENOP //kanji registers? |
| 342 | 408 | AM_RANGE(0x0ff8, 0x0fff) AM_READWRITE(x1_fdc_r,x1_fdc_w) //fdc registers |
| 343 | | // AM_RANGE(0x1000, 0x12ff) AM_RAM //paletteram |
| 409 | AM_RANGE(0x1000, 0x10ff) AM_WRITE(x1_pal_b_w) //paletteram |
| 410 | AM_RANGE(0x1100, 0x11ff) AM_WRITE(x1_pal_r_w) //paletteram |
| 411 | AM_RANGE(0x1200, 0x12ff) AM_WRITE(x1_pal_g_w) //paletteram |
| 344 | 412 | // AM_RANGE(0x1300, 0x13ff) AM_WRITENOP //ply port, mirrored |
| 345 | | // AM_RANGE(0x1400, 0x17ff) AM_RAM //pcg? |
| 413 | // AM_RANGE(0x1400, 0x17ff) AM_RAM //PCG = Programmable Character Generator |
| 346 | 414 | AM_RANGE(0x1800, 0x1800) AM_DEVWRITE("crtc", mc6845_address_w) |
| 347 | 415 | AM_RANGE(0x1801, 0x1801) AM_DEVWRITE("crtc", mc6845_register_w) |
| 348 | 416 | AM_RANGE(0x1900, 0x19ff) AM_READWRITE(sub_io_r,sub_io_w) //sub port comms, mirrored |
| 349 | 417 | AM_RANGE(0x1a00, 0x1a03) AM_MIRROR(0xfc) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w) //8255, mirrored |
| 418 | // AM_RANGE(0x1b00, 0x1bff) AM_DEVREADWRITE("ay", ay8910_r, ay8910_data_w) //PSG / ay-3-8910 data port |
| 350 | 419 | AM_RANGE(0x1b00, 0x1bff) AM_DEVWRITE("ay", ay8910_data_w) //PSG / ay-3-8910 data port |
| 351 | 420 | AM_RANGE(0x1c00, 0x1cff) AM_DEVWRITE("ay", ay8910_address_w) //PSG / ay-3-8910 reg port |
| 352 | 421 | AM_RANGE(0x1d00, 0x1dff) AM_WRITE(rom_bank_1_w) //ROM bankswitch = 1 |
| r5506 | r5507 | |
| 358 | 427 | // AM_RANGE(0x1fd0, 0x1fdf) AM_RAM //scrn? |
| 359 | 428 | AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE(&colorram)//txt mode RAM |
| 360 | 429 | AM_RANGE(0x3000, 0x3fff) AM_RAM AM_BASE(&videoram)//txt mode RAM |
| 361 | | AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&bitmapa_ram)//gfx mode bank 1 RAM |
| 362 | | AM_RANGE(0x6000, 0x7fff) AM_RAM AM_BASE(&bitmapb_ram)//gfx mode bank 2 RAM |
| 430 | AM_RANGE(0x4000, 0xffff) AM_RAM AM_BASE(&gfx_bitmap_ram)//gfx mode bank b/r/g RAM |
| 363 | 431 | ADDRESS_MAP_END |
| 364 | 432 | |
| 365 | 433 | static const gfx_layout x1_chars_8x8 = |
| r5506 | r5507 | |
| 418 | 486 | |
| 419 | 487 | //bitmap mode,TODO |
| 420 | 488 | for(i=0;i<8;i++) |
| 421 | | palette_set_color_rgb(machine, 0x200+i, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); |
| 489 | palette_set_color_rgb(machine, 0x80+i, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); |
| 422 | 490 | } |
| 423 | 491 | |
| 424 | 492 | static READ8_DEVICE_HANDLER( x1_porta_r ) |
| r5506 | r5507 | |
| 523 | 591 | PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) ) |
| 524 | 592 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) |
| 525 | 593 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 526 | | PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) |
| 527 | | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) |
| 528 | | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 594 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK ) |
| 529 | 595 | |
| 530 | 596 | PORT_START("IOSYS") |
| 531 | 597 | PORT_DIPNAME( 0x01, 0x01, "IOSYS" ) |
| r5506 | r5507 | |
| 559 | 625 | UINT8 *ROM = memory_region(machine, "maincpu"); |
| 560 | 626 | |
| 561 | 627 | memory_set_bankptr(machine, 1, &ROM[0x00000]); |
| 628 | |
| 629 | memset(gfx_bitmap_ram,0x00,0xc000); |
| 562 | 630 | } |
| 563 | 631 | |
| 564 | 632 | |