trunk/src/mame/drivers/ttchamp.c
| r245209 | r245210 | |
| 53 | 53 | |
| 54 | 54 | - works in a very similar way to 'Spider' (twins.c) |
| 55 | 55 | including the blitter (seems to be doubled up hardware tho, twice as many layers?) |
| 56 | | - PIC is not for sound, what is is for? |
| 57 | | - eeprom? (I don't see one, maybe PIC is used for settings?) |
| 58 | 56 | - Convert this to a blitter device, and share it with twins.c |
| 59 | 57 | - A bunch of spurious RAM writes to ROM area (genuine bug? left-overs?) |
| 60 | 58 | |
| 59 | Notes |
| 60 | I think the PIC is used to interface with battry backed RAM instead of an EEPROM, |
| 61 | we currently attempt to simulate this as the PIC is read protected. |
| 61 | 62 | |
| 63 | |
| 64 | |
| 62 | 65 | */ |
| 63 | 66 | |
| 64 | 67 | #include "emu.h" |
| 65 | 68 | #include "cpu/nec/nec.h" |
| 66 | 69 | #include "sound/okim6295.h" |
| 70 | #include "machine/nvram.h" |
| 67 | 71 | |
| 68 | 72 | class ttchamp_state : public driver_device |
| 69 | 73 | { |
| r245209 | r245210 | |
| 87 | 91 | |
| 88 | 92 | DECLARE_READ16_MEMBER(port1e_r); |
| 89 | 93 | |
| 94 | DECLARE_READ16_MEMBER(ttchamp_pic_r); |
| 95 | DECLARE_WRITE16_MEMBER(ttchamp_pic_w); |
| 90 | 96 | |
| 91 | 97 | UINT16 m_port10; |
| 92 | 98 | UINT8 m_rombank; |
| r245209 | r245210 | |
| 99 | 105 | DECLARE_WRITE16_MEMBER(ttchamp_mem_w); |
| 100 | 106 | |
| 101 | 107 | UINT16 m_videoram0[0x10000 / 2]; |
| 102 | | // UINT16 m_videoram1[0x10000 / 2]; |
| 103 | 108 | UINT16 m_videoram2[0x10000 / 2]; |
| 104 | 109 | |
| 105 | 110 | |
| 111 | enum picmode |
| 112 | { |
| 113 | PIC_IDLE = 0, |
| 114 | PIC_SET_READADDRESS = 1, |
| 115 | PIC_SET_WRITEADDRESS = 2, |
| 116 | PIC_SET_WRITELATCH = 3, |
| 117 | PIC_SET_READLATCH = 4, |
| 106 | 118 | |
| 119 | } picmodex; |
| 120 | |
| 121 | |
| 122 | int m_pic_readaddr; |
| 123 | int m_pic_writeaddr; |
| 124 | int m_pic_latched; |
| 125 | int m_pic_writelatched; |
| 126 | |
| 127 | UINT8* m_bakram; |
| 128 | |
| 107 | 129 | UINT16 m_mainram[0x10000 / 2]; |
| 108 | 130 | |
| 109 | 131 | int m_spritesinit; |
| r245209 | r245210 | |
| 125 | 147 | { |
| 126 | 148 | m_rom16 = (UINT16*)memregion("maincpu")->base(); |
| 127 | 149 | m_rom8 = memregion("maincpu")->base(); |
| 150 | |
| 151 | picmodex = PIC_IDLE; |
| 152 | |
| 153 | m_bakram = auto_alloc_array(machine(), UINT8, 0x100); |
| 154 | machine().device<nvram_device>("backram")->set_base(m_bakram, 0x100); |
| 155 | |
| 128 | 156 | } |
| 129 | 157 | |
| 130 | 158 | void ttchamp_state::video_start() |
| r245209 | r245210 | |
| 231 | 259 | m_palette->set_pen_color(m_paloff & 0x3ff,pal5bit(data>>0),pal5bit(data>>5),pal5bit(data>>10)); |
| 232 | 260 | } |
| 233 | 261 | |
| 262 | READ16_MEMBER(ttchamp_state::ttchamp_pic_r) |
| 263 | { |
| 264 | // printf("%06x: read from PIC (%04x)\n", space.device().safe_pc(),mem_mask); |
| 265 | if (picmodex == PIC_SET_READLATCH) |
| 266 | { |
| 267 | printf("read data %02x from %02x\n", m_pic_latched, m_pic_readaddr); |
| 268 | picmodex = PIC_IDLE; |
| 269 | return m_pic_latched; |
| 234 | 270 | |
| 271 | } |
| 272 | return 0x00; |
| 273 | |
| 274 | } |
| 275 | |
| 276 | WRITE16_MEMBER(ttchamp_state::ttchamp_pic_w) |
| 277 | { |
| 278 | // printf("%06x: write to PIC %04x (%04x) (%d)\n", space.device().safe_pc(),data,mem_mask, picmodex); |
| 279 | if (picmodex == PIC_IDLE) |
| 280 | { |
| 281 | if (data == 0x11) |
| 282 | { |
| 283 | picmodex = PIC_SET_READADDRESS; |
| 284 | // printf("state = SET_READADDRESS\n"); |
| 285 | } |
| 286 | else if (data == 0x12) |
| 287 | { |
| 288 | picmodex = PIC_SET_WRITELATCH; |
| 289 | // printf("latch write data.. \n" ); |
| 290 | } |
| 291 | else if (data == 0x20) |
| 292 | { |
| 293 | picmodex = PIC_SET_WRITEADDRESS; |
| 294 | // printf("state = PIC_SET_WRITEADDRESS\n"); |
| 295 | } |
| 296 | else if (data == 0x21) // write latched data |
| 297 | { |
| 298 | picmodex = PIC_IDLE; |
| 299 | m_bakram[m_pic_writeaddr] = m_pic_writelatched; |
| 300 | printf("wrote %02x to %02x\n", m_pic_writelatched, m_pic_writeaddr); |
| 301 | } |
| 302 | else if (data == 0x22) // next data to latch |
| 303 | { |
| 304 | m_pic_latched = m_bakram[m_pic_readaddr]; |
| 305 | // printf("latch read data %02x from %02x\n",m_pic_latched, m_pic_readaddr ); |
| 306 | picmodex = PIC_SET_READLATCH; // waiting to read... |
| 307 | } |
| 308 | else |
| 309 | { |
| 310 | // printf("unknown\n"); |
| 311 | } |
| 312 | } |
| 313 | else if (picmodex == PIC_SET_READADDRESS) |
| 314 | { |
| 315 | m_pic_readaddr = data; |
| 316 | picmodex = PIC_IDLE; |
| 317 | } |
| 318 | else if (picmodex == PIC_SET_WRITEADDRESS) |
| 319 | { |
| 320 | m_pic_writeaddr = data; |
| 321 | picmodex = PIC_IDLE; |
| 322 | } |
| 323 | else if (picmodex == PIC_SET_WRITELATCH) |
| 324 | { |
| 325 | m_pic_writelatched = data; |
| 326 | picmodex = PIC_IDLE; |
| 327 | } |
| 328 | |
| 329 | } |
| 330 | |
| 331 | |
| 235 | 332 | READ16_MEMBER(ttchamp_state::ttchamp_mem_r) |
| 236 | 333 | { |
| 237 | 334 | // bits 0xf0 are used too, so this is likely wrong. |
| r245209 | r245210 | |
| 440 | 537 | |
| 441 | 538 | AM_RANGE(0x0020, 0x0021) AM_WRITE(port20_w) |
| 442 | 539 | |
| 443 | | // AM_RANGE(0x0034, 0x0035) AM_READ(peno_rand) AM_WRITENOP // eeprom (PIC?) / settings? |
| 540 | AM_RANGE(0x0034, 0x0035) AM_READWRITE(ttchamp_pic_r, ttchamp_pic_w) |
| 444 | 541 | |
| 445 | 542 | AM_RANGE(0x0062, 0x0063) AM_WRITE(port62_w) |
| 446 | 543 | |
| r245209 | r245210 | |
| 535 | 632 | MCFG_SCREEN_PALETTE("palette") |
| 536 | 633 | |
| 537 | 634 | MCFG_PALETTE_ADD("palette", 0x400) |
| 635 | |
| 636 | MCFG_NVRAM_ADD_0FILL("backram") |
| 538 | 637 | |
| 539 | 638 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 540 | 639 | |