trunk/src/mame/drivers/lethal.c
| r241894 | r241895 | |
| 109 | 109 | ---------------- --- -------- --------- ----------------------- |
| 110 | 110 | 000xxxxxxxxxxxxx R xxxxxxxx PROM program ROM (banked) |
| 111 | 111 | 001xxxxxxxxxxxxx R/W xxxxxxxx WRAM work RAM |
| 112 | | 010000--00xxxxxx W xxxxxxxx VREG 056832 control |
| 113 | | 010000--01--xxxx W xxxxxxxx VSCG 056832 control |
| 112 | 010000--00xxxxxx W xxxxxxxx VREG 054156 control |
| 113 | 010000--01--xxxx W xxxxxxxx VSCG 054157 control |
| 114 | 114 | 010000--1000---- R/W -------- AFR watchdog reset |
| 115 | 115 | 010000--1001---- W SDON sound enable? |
| 116 | 116 | 010000--1010 CCLR ? |
| r241894 | r241895 | |
| 121 | 121 | 010000--11-000-- W --x----- CRDB / |
| 122 | 122 | 010000--11-001-- W -----xxx EEP EEPROM DI, CS, CLK |
| 123 | 123 | 010000--11-001-- W ----x--- MUT sound mute? |
| 124 | | 010000--11-001-- W ---x---- CBNK bank switch 4800-7FFF region between palette and 053245/056832 |
| 124 | 010000--11-001-- W ---x---- CBNK bank switch 4400-7FFF region between palette and 053245/054156 |
| 125 | 125 | 010000--11-001-- W --x----- n.c. |
| 126 | 126 | 010000--11-001-- W xx------ SHD0/1 shadow control |
| 127 | 127 | 010000--11-010-- W -----xxx PCU1/XBA palette bank (tilemap A) |
| r241894 | r241895 | |
| 138 | 138 | 010000--11-11011 R -------x NCPU ? |
| 139 | 139 | 010000--11-111-- W --xxxxxx BREG ROM bank select |
| 140 | 140 | 010010--00------ n.c. |
| 141 | | 010010--01---xxx R/W xxxxxxxx OREG 053244 |
| 141 | 010010--01---xxx R/W xxxxxxxx OREG 053244/053245 control |
| 142 | 142 | 010010--10-xxxxx R/W xxxxxxxx HIP 054000 |
| 143 | 143 | 010010--11 R/W xxxxxxxx PAR sound communication |
| 144 | | 010100xxxxxxxxxx R/W xxxxxxxx OBJ 053245 |
| 145 | | 011xxxxxxxxxxxxx R/W xxxxxxxx VRAM 056832 |
| 144 | 010100xxxxxxxxxx R/W xxxxxxxx OBJ 053245 sprite RAM |
| 145 | 011xxxxxxxxxxxxx R/W xxxxxxxx VRAM 054156 video RAM |
| 146 | 146 | 1xxxxxxxxxxxxxxx R xxxxxxxx PROM program ROM |
| 147 | 147 | |
| 148 | 148 | |
| r241894 | r241895 | |
| 231 | 231 | |
| 232 | 232 | note: |
| 233 | 233 | |
| 234 | | lethal enforcers has 2 sprite rendering chips working in parallel mixing |
| 235 | | data together to give 6bpp.. we cheat by using a custom function in |
| 236 | | konamiic.c and a fixed 6bpp decode. |
| 234 | Lethal Enforcers has two sprite rendering chips working in parallel with their |
| 235 | output mixed to give 6bpp, and two tilemap rendering chips working in parallel |
| 236 | to give 8bpp. We currently cheat, using just one of each device but using |
| 237 | alternate gfx layouts. Emulating it accurately will require separating the |
| 238 | "front end" chips (053245, 054156) from the "back end" chips (053244, 054157) |
| 239 | as only the latter are doubled. |
| 237 | 240 | |
| 238 | 241 | mirror not set up correctly |
| 239 | 242 | |
| r241894 | r241895 | |
| 265 | 268 | /* bit 1 is cs (active low) */ |
| 266 | 269 | /* bit 2 is clock (active high) */ |
| 267 | 270 | /* bit 3 is "MUT" on the schematics (audio mute?) */ |
| 268 | | /* bit 4 bankswitches the 4800-7fff region: 0 = registers, 1 = RAM ("CBNK" on schematics) */ |
| 271 | /* bit 4 bankswitches the 4400-7fff region: 0 = registers, 1 = palette RAM ("CBNK" on schematics) */ |
| 269 | 272 | /* bit 6 is "SHD0" (some kind of shadow control) */ |
| 270 | 273 | /* bit 7 is "SHD1" (ditto) */ |
| 271 | 274 | |
| 272 | 275 | m_cur_control2 = data; |
| 273 | 276 | |
| 274 | | m_bank4800->set_bank((m_cur_control2 >> 4) & 1); |
| 277 | m_bank4000->set_bank(BIT(m_cur_control2, 4)); |
| 275 | 278 | |
| 276 | 279 | ioport("EEPROMOUT")->write(m_cur_control2, 0xff); |
| 277 | 280 | } |
| r241894 | r241895 | |
| 302 | 305 | membank("bank1")->set_entry(data); |
| 303 | 306 | } |
| 304 | 307 | |
| 305 | | // use one more palette entry for the BG color |
| 306 | | WRITE8_MEMBER(lethal_state::le_bgcolor_w) |
| 307 | | { |
| 308 | | m_palette->write(space, 0x3800 + offset, data); |
| 309 | | } |
| 310 | | |
| 311 | 308 | READ8_MEMBER(lethal_state::guns_r) |
| 312 | 309 | { |
| 313 | 310 | switch (offset) |
| r241894 | r241895 | |
| 356 | 353 | AM_RANGE(0x40d9, 0x40d9) AM_READ_PORT("INPUTS") |
| 357 | 354 | AM_RANGE(0x40db, 0x40db) AM_READ(gunsaux_r) // top X bit of guns |
| 358 | 355 | AM_RANGE(0x40dc, 0x40dc) AM_WRITE(le_bankswitch_w) |
| 359 | | AM_RANGE(0x47fe, 0x47ff) AM_WRITE(le_bgcolor_w) // BG color |
| 360 | | AM_RANGE(0x4800, 0x7fff) AM_DEVICE("bank4800", address_map_bank_device, amap8) |
| 356 | AM_RANGE(0x4000, 0x43ff) AM_UNMAP // first 0x400 bytes of palette RAM are inaccessible |
| 357 | AM_RANGE(0x4000, 0x7fff) AM_DEVICE("bank4000", address_map_bank_device, amap8) |
| 361 | 358 | AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION("maincpu", 0x38000) |
| 362 | 359 | ADDRESS_MAP_END |
| 363 | 360 | |
| 364 | | static ADDRESS_MAP_START( bank4800_map, AS_PROGRAM, 8, lethal_state ) |
| 365 | | AM_RANGE(0x0040, 0x004f) AM_DEVREADWRITE("k053244", k05324x_device, k053244_r, k053244_w) |
| 366 | | AM_RANGE(0x0080, 0x009f) AM_DEVREADWRITE("k054000", k054000_device, read, write) |
| 367 | | AM_RANGE(0x00c6, 0x00c6) AM_WRITE(sound_cmd_w) |
| 368 | | AM_RANGE(0x00c7, 0x00c7) AM_WRITE(sound_irq_w) |
| 369 | | AM_RANGE(0x00ca, 0x00ca) AM_READ(sound_status_r) |
| 370 | | AM_RANGE(0x0800, 0x17ff) AM_MASK(0x07ff) AM_DEVREADWRITE("k053244", k05324x_device, k053245_r, k053245_w) |
| 371 | | AM_RANGE(0x1800, 0x1fff) AM_DEVREADWRITE("k056832", k056832_device, ram_code_lo_r, ram_code_lo_w) |
| 372 | | AM_RANGE(0x2000, 0x27ff) AM_DEVREADWRITE("k056832", k056832_device, ram_code_hi_r, ram_code_hi_w) |
| 373 | | AM_RANGE(0x2800, 0x2fff) AM_DEVREADWRITE("k056832", k056832_device, ram_attr_lo_r, ram_attr_lo_w) |
| 374 | | AM_RANGE(0x3000, 0x37ff) AM_DEVREADWRITE("k056832", k056832_device, ram_attr_hi_r, ram_attr_hi_w) |
| 375 | | AM_RANGE(0x3800, 0x7001) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") // 2 extra bytes for the BG color |
| 361 | static ADDRESS_MAP_START( bank4000_map, AS_PROGRAM, 8, lethal_state ) |
| 362 | // VRD = 0 or 1, CBNK = 0 |
| 363 | AM_RANGE(0x0840, 0x084f) AM_MIRROR(0x8000) AM_DEVREADWRITE("k053244", k05324x_device, k053244_r, k053244_w) |
| 364 | AM_RANGE(0x0880, 0x089f) AM_MIRROR(0x8000) AM_DEVREADWRITE("k054000", k054000_device, read, write) |
| 365 | AM_RANGE(0x08c6, 0x08c6) AM_MIRROR(0x8000) AM_WRITE(sound_cmd_w) |
| 366 | AM_RANGE(0x08c7, 0x08c7) AM_MIRROR(0x8000) AM_WRITE(sound_irq_w) |
| 367 | AM_RANGE(0x08ca, 0x08ca) AM_MIRROR(0x8000) AM_READ(sound_status_r) |
| 368 | AM_RANGE(0x1000, 0x17ff) AM_MIRROR(0x8000) AM_DEVREADWRITE("k053244", k05324x_device, k053245_r, k053245_w) |
| 369 | |
| 370 | // VRD = 0, CBNK = 0 |
| 371 | AM_RANGE(0x2000, 0x27ff) AM_DEVREADWRITE("k056832", k056832_device, ram_code_lo_r, ram_code_lo_w) |
| 372 | AM_RANGE(0x2800, 0x2fff) AM_DEVREADWRITE("k056832", k056832_device, ram_code_hi_r, ram_code_hi_w) |
| 373 | AM_RANGE(0x3000, 0x37ff) AM_DEVREADWRITE("k056832", k056832_device, ram_attr_lo_r, ram_attr_lo_w) |
| 374 | AM_RANGE(0x3800, 0x3fff) AM_DEVREADWRITE("k056832", k056832_device, ram_attr_hi_r, ram_attr_hi_w) |
| 375 | |
| 376 | // VRD = 1, CBNK = 0 or 1 |
| 377 | AM_RANGE(0xa000, 0xbfff) AM_MIRROR(0x4000) AM_UNMAP // AM_DEVREAD("k056832", k056832_device, rom_byte_r) |
| 378 | |
| 379 | // CBNK = 1; partially overlaid when VRD = 1 |
| 380 | AM_RANGE(0x4000, 0x7fff) AM_MIRROR(0x8000) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") |
| 376 | 381 | ADDRESS_MAP_END |
| 377 | 382 | |
| 378 | 383 | static ADDRESS_MAP_START( le_sound, AS_PROGRAM, 8, lethal_state ) |
| r241894 | r241895 | |
| 467 | 472 | membank("bank1")->set_entry(0); |
| 468 | 473 | |
| 469 | 474 | save_item(NAME(m_cur_control2)); |
| 475 | save_item(NAME(m_layer_colorbase)); |
| 470 | 476 | save_item(NAME(m_sprite_colorbase)); |
| 471 | | save_item(NAME(m_layer_colorbase)); |
| 477 | save_item(NAME(m_back_colorbase)); |
| 472 | 478 | } |
| 473 | 479 | |
| 474 | 480 | void lethal_state::machine_reset() |
| r241894 | r241895 | |
| 477 | 483 | m_layer_colorbase[i] = 0; |
| 478 | 484 | |
| 479 | 485 | m_sprite_colorbase = 0; |
| 486 | m_back_colorbase = 0; |
| 480 | 487 | m_cur_control2 = 0; |
| 481 | | m_bank4800->set_bank(0); |
| 488 | m_bank4000->set_bank(0); |
| 482 | 489 | } |
| 483 | 490 | |
| 484 | 491 | static MACHINE_CONFIG_START( lethalen, lethal_state ) |
| r241894 | r241895 | |
| 491 | 498 | MCFG_CPU_ADD("soundcpu", Z80, MAIN_CLOCK/4) /* verified on pcb */ |
| 492 | 499 | MCFG_CPU_PROGRAM_MAP(le_sound) |
| 493 | 500 | |
| 494 | | MCFG_DEVICE_ADD("bank4800", ADDRESS_MAP_BANK, 0) |
| 495 | | MCFG_DEVICE_PROGRAM_MAP(bank4800_map) |
| 501 | MCFG_DEVICE_ADD("bank4000", ADDRESS_MAP_BANK, 0) |
| 502 | MCFG_DEVICE_PROGRAM_MAP(bank4000_map) |
| 496 | 503 | MCFG_ADDRESS_MAP_BANK_ENDIANNESS(ENDIANNESS_BIG) |
| 497 | 504 | MCFG_ADDRESS_MAP_BANK_DATABUS_WIDTH(8) |
| 498 | | MCFG_ADDRESS_MAP_BANK_ADDRBUS_WIDTH(15) |
| 499 | | MCFG_ADDRESS_MAP_BANK_STRIDE(0x3800) |
| 505 | MCFG_ADDRESS_MAP_BANK_ADDRBUS_WIDTH(16) |
| 506 | MCFG_ADDRESS_MAP_BANK_STRIDE(0x4000) |
| 500 | 507 | |
| 501 | 508 | MCFG_EEPROM_SERIAL_ER5911_8BIT_ADD("eeprom") |
| 502 | 509 | |
| r241894 | r241895 | |
| 511 | 518 | MCFG_SCREEN_UPDATE_DRIVER(lethal_state, screen_update_lethalen) |
| 512 | 519 | MCFG_SCREEN_PALETTE("palette") |
| 513 | 520 | |
| 514 | | MCFG_PALETTE_ADD("palette", 7168+1) |
| 521 | MCFG_PALETTE_ADD("palette", 8192) |
| 515 | 522 | MCFG_PALETTE_ENABLE_SHADOWS() |
| 516 | 523 | MCFG_PALETTE_FORMAT(xBBBBBGGGGGRRRRR) |
| 517 | 524 | |
trunk/src/mame/video/lethal.c
| r241894 | r241895 | |
| 14 | 14 | { |
| 15 | 15 | int pri = (*color & 0xfff0); |
| 16 | 16 | *color = *color & 0x000f; |
| 17 | | *color += 0x400 / 64; // colourbase? |
| 17 | *color += m_sprite_colorbase; |
| 18 | 18 | |
| 19 | 19 | /* this isn't ideal.. shouldn't need to hardcode it? not 100% sure about it anyway*/ |
| 20 | 20 | if (pri == 0x10) |
| r241894 | r241895 | |
| 65 | 65 | m_k056832->set_layer_offs(2, 192, 0); |
| 66 | 66 | m_k056832->set_layer_offs(3, 194, 0); |
| 67 | 67 | } |
| 68 | | |
| 69 | | m_layer_colorbase[0] = 0x00; |
| 70 | | m_layer_colorbase[1] = 0x40; |
| 71 | | m_layer_colorbase[2] = 0x80; |
| 72 | | m_layer_colorbase[3] = 0xc0; |
| 73 | 68 | } |
| 74 | 69 | |
| 75 | 70 | WRITE8_MEMBER(lethal_state::lethalen_palette_control) |
| r241894 | r241895 | |
| 77 | 72 | switch (offset) |
| 78 | 73 | { |
| 79 | 74 | case 0: // 40c8 - PCU1 from schematics |
| 80 | | m_layer_colorbase[0] = ((data & 0x7) - 1) * 0x40; |
| 81 | | m_layer_colorbase[1] = (((data >> 4) & 0x7) - 1) * 0x40; |
| 75 | m_layer_colorbase[0] = (data & 0x7) * 1024 / 16; |
| 76 | m_layer_colorbase[1] = ((data >> 4) & 0x7) * 1024 / 16; |
| 82 | 77 | m_k056832->mark_plane_dirty( 0); |
| 83 | 78 | m_k056832->mark_plane_dirty( 1); |
| 84 | 79 | break; |
| 85 | 80 | |
| 86 | 81 | case 4: // 40cc - PCU2 from schematics |
| 87 | | m_layer_colorbase[2] = ((data & 0x7) - 1) * 0x40; |
| 88 | | m_layer_colorbase[3] = (((data >> 4) & 0x7) - 1) * 0x40; |
| 82 | m_layer_colorbase[2] = (data & 0x7) * 1024 / 16; |
| 83 | m_layer_colorbase[3] = ((data >> 4) & 0x7) * 1024 / 16; |
| 89 | 84 | m_k056832->mark_plane_dirty( 2); |
| 90 | 85 | m_k056832->mark_plane_dirty( 3); |
| 91 | 86 | break; |
| 92 | 87 | |
| 93 | 88 | case 8: // 40d0 - PCU3 from schematics |
| 94 | | m_sprite_colorbase = ((data & 0x7) - 1) * 0x40; |
| 89 | m_sprite_colorbase = (data & 0x7) * 1024 / 64; |
| 90 | m_back_colorbase = ((data >> 4) & 0x7) * 1024 + 1023; |
| 95 | 91 | break; |
| 96 | 92 | } |
| 97 | 93 | } |
| 98 | 94 | |
| 99 | 95 | UINT32 lethal_state::screen_update_lethalen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 100 | 96 | { |
| 101 | | bitmap.fill(7168, cliprect); |
| 97 | bitmap.fill(m_back_colorbase, cliprect); |
| 102 | 98 | screen.priority().fill(0, cliprect); |
| 103 | 99 | |
| 104 | 100 | m_k056832->tilemap_draw(screen, bitmap, cliprect, 3, K056832_DRAW_FLAG_MIRROR, 1); |