Previous 199869 Revisions Next

r36698 Friday 27th March, 2015 at 01:43:24 UTC by David Haywood
looking at ttchamp backupram (via PIC?) not yet working (nw)
[src/mame/drivers]ttchamp.c

trunk/src/mame/drivers/ttchamp.c
r245209r245210
5353
5454- works in a very similar way to 'Spider' (twins.c)
5555  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?)
5856- Convert this to a blitter device, and share it with twins.c
5957- A bunch of spurious RAM writes to ROM area (genuine bug? left-overs?)
6058
59Notes
60I think the PIC is used to interface with battry backed RAM instead of an EEPROM,
61we currently attempt to simulate this as the PIC is read protected.
6162
63
64
6265*/
6366
6467#include "emu.h"
6568#include "cpu/nec/nec.h"
6669#include "sound/okim6295.h"
70#include "machine/nvram.h"
6771
6872class ttchamp_state : public driver_device
6973{
r245209r245210
8791
8892   DECLARE_READ16_MEMBER(port1e_r);
8993
94   DECLARE_READ16_MEMBER(ttchamp_pic_r);
95   DECLARE_WRITE16_MEMBER(ttchamp_pic_w);
9096
9197   UINT16 m_port10;
9298   UINT8 m_rombank;
r245209r245210
99105   DECLARE_WRITE16_MEMBER(ttchamp_mem_w);
100106
101107   UINT16 m_videoram0[0x10000 / 2];
102//  UINT16 m_videoram1[0x10000 / 2];
103108   UINT16 m_videoram2[0x10000 / 2];
104109
105110
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,
106118
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
107129   UINT16 m_mainram[0x10000 / 2];
108130
109131   int m_spritesinit;
r245209r245210
125147{
126148   m_rom16 = (UINT16*)memregion("maincpu")->base();
127149   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
128156}
129157
130158void ttchamp_state::video_start()
r245209r245210
231259   m_palette->set_pen_color(m_paloff & 0x3ff,pal5bit(data>>0),pal5bit(data>>5),pal5bit(data>>10));
232260}
233261
262READ16_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;
234270
271   }
272   return 0x00;
273
274}
275
276WRITE16_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
235332READ16_MEMBER(ttchamp_state::ttchamp_mem_r)
236333{
237334   // bits 0xf0 are used too, so this is likely wrong.
r245209r245210
440537
441538   AM_RANGE(0x0020, 0x0021) AM_WRITE(port20_w)
442539
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)
444541
445542   AM_RANGE(0x0062, 0x0063) AM_WRITE(port62_w)
446543
r245209r245210
535632   MCFG_SCREEN_PALETTE("palette")
536633
537634   MCFG_PALETTE_ADD("palette", 0x400)
635   
636   MCFG_NVRAM_ADD_0FILL("backram")
538637
539638   MCFG_SPEAKER_STANDARD_MONO("mono")
540639


Previous 199869 Revisions Next


© 1997-2024 The MAME Team