Previous 199869 Revisions Next

r39877 Wednesday 22nd July, 2015 at 18:55:17 UTC by Osso
ttchamp.c: added save state support (nw)
[src/mame/drivers]ttchamp.c

trunk/src/mame/drivers/ttchamp.c
r248388r248389
3131 _|   74LS244  74LS14N 74HC74  16MHz |D70116C-10 | |
3232|__________________________________________________|
3333
34The PCB is Spanish and manufacured by Gamart.
34The PCB is Spanish and manufactured by Gamart.
3535
3636
3737Table tennis Championships by Gamart 1995
r248388r248389
4646ttennis2/3 main program
4747ttennis1 adpcm data
4848ttennis4/5 graphics
49*there is a pic16c84 that i cannot dump because my programmer doesn't support it.
49*there is a pic16c84 that I cannot dump because my programmer doesn't support it.
5050
5151Dumped by tirino73
5252
r248388r248389
5959- A bunch of spurious RAM writes to ROM area (genuine bug? left-overs?)
6060
6161Notes
62I think the PIC is used to interface with battry backed RAM instead of an EEPROM,
62I think the PIC is used to interface with battery backed RAM instead of an EEPROM,
6363we currently simulate this as the PIC is read protected.
6464
6565
r248388r248389
7171#include "sound/okim6295.h"
7272#include "machine/nvram.h"
7373
74
7475class ttchamp_state : public driver_device
7576{
7677public:
r248388r248389
7980      m_maincpu(*this, "maincpu"),
8081      m_palette(*this, "palette")  { }
8182
82   UINT16* m_peno_mainram;
83
83   required_device<cpu_device> m_maincpu;
84   required_device<palette_device> m_palette;
85   
8486   UINT16 m_paloff;
85   DECLARE_WRITE16_MEMBER(paloff_w);
86   DECLARE_WRITE16_MEMBER(pcup_prgbank_w);
87   DECLARE_WRITE16_MEMBER(paldat_w);
88
89   DECLARE_WRITE16_MEMBER(port10_w);
90
91   DECLARE_WRITE16_MEMBER(port20_w);
92   DECLARE_WRITE16_MEMBER(port62_w);
93
94   DECLARE_READ16_MEMBER(port1e_r);
95
96   DECLARE_READ16_MEMBER(ttchamp_pic_r);
97   DECLARE_WRITE16_MEMBER(ttchamp_pic_w);
98
9987   UINT16 m_port10;
10088   UINT8 m_rombank;
101
102   DECLARE_DRIVER_INIT(ttchamp);
103
104   DECLARE_READ16_MEMBER(ttchamp_blit_start_r);
105
106   DECLARE_READ16_MEMBER(ttchamp_mem_r);
107   DECLARE_WRITE16_MEMBER(ttchamp_mem_w);
108
10989   UINT16 m_videoram0[0x10000 / 2];
11090   UINT16 m_videoram2[0x10000 / 2];
11191
112
11392   enum picmode
11493   {
11594      PIC_IDLE = 0,
r248388r248389
11897      PIC_SET_WRITELATCH = 3,
11998      PIC_SET_READLATCH = 4
12099
121   } picmodex;
100   };
122101
102   picmode m_picmodex;
123103
124104   int m_pic_readaddr;
125105   int m_pic_writeaddr;
r248388r248389
133113   int m_spritesinit;
134114   int m_spriteswidth;
135115   int m_spritesaddr;
136
137   virtual void machine_start();
138116   UINT16* m_rom16;
139117   UINT8* m_rom8;
140118
119   DECLARE_WRITE16_MEMBER(paloff_w);
120   DECLARE_WRITE16_MEMBER(pcup_prgbank_w);
121   DECLARE_WRITE16_MEMBER(paldat_w);
122
123   DECLARE_WRITE16_MEMBER(port10_w);
124
125   DECLARE_WRITE16_MEMBER(port20_w);
126   DECLARE_WRITE16_MEMBER(port62_w);
127
128   DECLARE_READ16_MEMBER(port1e_r);
129
130   DECLARE_READ16_MEMBER(pic_r);
131   DECLARE_WRITE16_MEMBER(pic_w);
132
133   DECLARE_READ16_MEMBER(blit_start_r);
134
135   DECLARE_READ16_MEMBER(mem_r);
136   DECLARE_WRITE16_MEMBER(mem_w);
137
138   virtual void machine_start();
141139   virtual void video_start();
142   UINT32 screen_update_ttchamp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
143   INTERRUPT_GEN_MEMBER(ttchamp_irq);
144   required_device<cpu_device> m_maincpu;
145   required_device<palette_device> m_palette;
140
141   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
142
143   INTERRUPT_GEN_MEMBER(irq);
146144};
147145
146ALLOW_SAVE_TYPE(ttchamp_state::picmode);
147
148
148149void ttchamp_state::machine_start()
149150{
150151   m_rom16 = (UINT16*)memregion("maincpu")->base();
151152   m_rom8 = memregion("maincpu")->base();
152153
153   picmodex = PIC_IDLE;
154   m_picmodex = PIC_IDLE;
154155
155156   m_bakram = auto_alloc_array(machine(), UINT8, 0x100);
156157   machine().device<nvram_device>("backram")->set_base(m_bakram, 0x100);
158   
159   save_item(NAME(m_paloff));
160   save_item(NAME(m_port10));
161   save_item(NAME(m_rombank));
162   save_item(NAME(m_videoram0));
163   save_item(NAME(m_videoram2));
164   save_item(NAME(m_picmodex));
165   save_item(NAME(m_pic_readaddr));
166   save_item(NAME(m_pic_writeaddr));
167   save_item(NAME(m_pic_latched));
168   save_item(NAME(m_pic_writelatched));
169   save_item(NAME(m_mainram));
170   save_item(NAME(m_spritesinit));
171   save_item(NAME(m_spriteswidth));
172   save_item(NAME(m_spritesaddr));
157173
158174}
159175
r248388r248389
161177{
162178}
163179
164UINT32 ttchamp_state::screen_update_ttchamp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
180UINT32 ttchamp_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
165181{
166182   logerror("update\n");
167183   int y,x,count;
r248388r248389
261277   m_palette->set_pen_color(m_paloff & 0x3ff,pal5bit(data>>0),pal5bit(data>>5),pal5bit(data>>10));
262278}
263279
264READ16_MEMBER(ttchamp_state::ttchamp_pic_r)
280READ16_MEMBER(ttchamp_state::pic_r)
265281{
266282//  printf("%06x: read from PIC (%04x)\n", space.device().safe_pc(),mem_mask);
267   if (picmodex == PIC_SET_READLATCH)
283   if (m_picmodex == PIC_SET_READLATCH)
268284   {
269285//      printf("read data %02x from %02x\n", m_pic_latched, m_pic_readaddr);
270      picmodex = PIC_IDLE;
286      m_picmodex = PIC_IDLE;
271287
272288      return m_pic_latched << 8;
273289
r248388r248389
276292
277293}
278294
279WRITE16_MEMBER(ttchamp_state::ttchamp_pic_w)
295WRITE16_MEMBER(ttchamp_state::pic_w)
280296{
281//  printf("%06x: write to PIC %04x (%04x) (%d)\n", space.device().safe_pc(),data,mem_mask, picmodex);
282   if (picmodex == PIC_IDLE)
297//  printf("%06x: write to PIC %04x (%04x) (%d)\n", space.device().safe_pc(),data,mem_mask, m_picmodex);
298   if (m_picmodex == PIC_IDLE)
283299   {
284300      if (data == 0x11)
285301      {
286         picmodex = PIC_SET_READADDRESS;
302         m_picmodex = PIC_SET_READADDRESS;
287303//          printf("state = SET_READADDRESS\n");
288304      }
289305      else if (data == 0x12)
290306      {
291         picmodex = PIC_SET_WRITELATCH;
307         m_picmodex = PIC_SET_WRITELATCH;
292308//          printf("latch write data.. \n" );
293309      }
294310      else if (data == 0x20)
295311      {
296         picmodex = PIC_SET_WRITEADDRESS;
312         m_picmodex = PIC_SET_WRITEADDRESS;
297313//          printf("state = PIC_SET_WRITEADDRESS\n");
298314      }
299315      else if (data == 0x21) // write latched data
300316      {
301         picmodex = PIC_IDLE;
317         m_picmodex = PIC_IDLE;
302318         m_bakram[m_pic_writeaddr] = m_pic_writelatched;
303319   //      printf("wrote %02x to %02x\n", m_pic_writelatched, m_pic_writeaddr);
304320      }
r248388r248389
309325         m_pic_latched = m_bakram[m_pic_readaddr>>1];
310326
311327//          printf("latch read data %02x from %02x\n",m_pic_latched, m_pic_readaddr );
312         picmodex = PIC_SET_READLATCH; // waiting to read...
328         m_picmodex = PIC_SET_READLATCH; // waiting to read...
313329      }
314330      else
315331      {
316332//          printf("unknown\n");
317333      }
318334   }
319   else if (picmodex == PIC_SET_READADDRESS)
335   else if (m_picmodex == PIC_SET_READADDRESS)
320336   {
321337      m_pic_readaddr = data;
322      picmodex = PIC_IDLE;
338      m_picmodex = PIC_IDLE;
323339   }
324   else if (picmodex == PIC_SET_WRITEADDRESS)
340   else if (m_picmodex == PIC_SET_WRITEADDRESS)
325341   {
326342      m_pic_writeaddr = data;
327      picmodex = PIC_IDLE;
343      m_picmodex = PIC_IDLE;
328344   }
329   else if (picmodex == PIC_SET_WRITELATCH)
345   else if (m_picmodex == PIC_SET_WRITELATCH)
330346   {
331347      m_pic_writelatched = data;
332      picmodex = PIC_IDLE;
348      m_picmodex = PIC_IDLE;
333349   }
334350
335351}
336352
337353
338READ16_MEMBER(ttchamp_state::ttchamp_mem_r)
354READ16_MEMBER(ttchamp_state::mem_r)
339355{
340356   // bits 0xf0 are used too, so this is likely wrong.
341357
r248388r248389
367383   }
368384}
369385
370WRITE16_MEMBER(ttchamp_state::ttchamp_mem_w)
386WRITE16_MEMBER(ttchamp_state::mem_w)
371387{
372388   // this is very strange, we use the offset (address bits) not data bits to set values..
373389   // I get the impression this might actually overlay the entire address range, including RAM and regular VRAM?
r248388r248389
484500
485501
486502static ADDRESS_MAP_START( ttchamp_map, AS_PROGRAM, 16, ttchamp_state )
487   AM_RANGE(0x00000, 0xfffff) AM_READWRITE(ttchamp_mem_r, ttchamp_mem_w)
503   AM_RANGE(0x00000, 0xfffff) AM_READWRITE(mem_r, mem_w)
488504ADDRESS_MAP_END
489505
490506/* Re-use same parameters as before (one-shot) */
r248388r248389
494510   return 0xff;
495511}
496512
497READ16_MEMBER(ttchamp_state::ttchamp_blit_start_r)
513READ16_MEMBER(ttchamp_state::blit_start_r)
498514{
499515   m_spritesinit = 1;
500516   return 0xff;
r248388r248389
533549
534550   AM_RANGE(0x0006, 0x0007) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff)
535551
536   AM_RANGE(0x0018, 0x0019) AM_READ(ttchamp_blit_start_r) // read before using bus write offset as blit parameters
552   AM_RANGE(0x0018, 0x0019) AM_READ(blit_start_r) // read before using bus write offset as blit parameters
537553   AM_RANGE(0x001e, 0x001f) AM_READ(port1e_r) // read before some blit operations (but not all)
538554
539555   AM_RANGE(0x0008, 0x0009) AM_WRITE(paldat_w)
r248388r248389
543559
544560   AM_RANGE(0x0020, 0x0021) AM_WRITE(port20_w)
545561
546   AM_RANGE(0x0034, 0x0035) AM_READWRITE(ttchamp_pic_r, ttchamp_pic_w)
562   AM_RANGE(0x0034, 0x0035) AM_READWRITE(pic_r, pic_w)
547563
548564   AM_RANGE(0x0062, 0x0063) AM_WRITE(port62_w)
549565
r248388r248389
616632INPUT_PORTS_END
617633
618634
619INTERRUPT_GEN_MEMBER(ttchamp_state::ttchamp_irq)/* right? */
635INTERRUPT_GEN_MEMBER(ttchamp_state::irq)/* right? */
620636{
621637   device.execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
622638}
r248388r248389
626642   MCFG_CPU_ADD("maincpu", V30, 8000000)
627643   MCFG_CPU_PROGRAM_MAP(ttchamp_map)
628644   MCFG_CPU_IO_MAP(ttchamp_io)
629   MCFG_CPU_VBLANK_INT_DRIVER("screen", ttchamp_state,  ttchamp_irq)
645   MCFG_CPU_VBLANK_INT_DRIVER("screen", ttchamp_state,  irq)
630646
631647   /* video hardware */
632648   MCFG_SCREEN_ADD("screen", RASTER)
r248388r248389
634650   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
635651   MCFG_SCREEN_SIZE(1024,1024)
636652   MCFG_SCREEN_VISIBLE_AREA(0, 320-1, 0, 200-1)
637   MCFG_SCREEN_UPDATE_DRIVER(ttchamp_state, screen_update_ttchamp)
653   MCFG_SCREEN_UPDATE_DRIVER(ttchamp_state, screen_update)
638654   MCFG_SCREEN_PALETTE("palette")
639655
640656   MCFG_PALETTE_ADD("palette", 0x400)
r248388r248389
676692   ROM_LOAD( "27c020.1", 0x000000, 0x040000,  CRC(e2c4fe95) SHA1(da349035cc348db220a1e12b4c2a6021e2168425) )
677693ROM_END
678694
679DRIVER_INIT_MEMBER(ttchamp_state,ttchamp)
680{
681}
682695
683696// only the graphics differ between the two sets, code section is the same
684GAME( 1995, ttchamp, 0,        ttchamp, ttchamp, ttchamp_state, ttchamp, ROT0,  "Gamart",                               "Table Tennis Champions", 0 ) // this has various advertising boards, including 'Electronic Devices' and 'Deniam'
685GAME( 1995, ttchampa,ttchamp,  ttchamp, ttchamp, ttchamp_state, ttchamp, ROT0,  "Gamart (Palencia Elektronik license)", "Table Tennis Champions (Palencia Elektronik license)", 0 ) // this only has Palencia Elektronik advertising boards
697GAME( 1995, ttchamp, 0,        ttchamp, ttchamp, driver_device, 0, ROT0,  "Gamart",                               "Table Tennis Champions", GAME_SUPPORTS_SAVE ) // this has various advertising boards, including 'Electronic Devices' and 'Deniam'
698GAME( 1995, ttchampa,ttchamp,  ttchamp, ttchamp, driver_device, 0, ROT0,  "Gamart (Palencia Elektronik license)", "Table Tennis Champions (Palencia Elektronik license)", GAME_SUPPORTS_SAVE ) // this only has Palencia Elektronik advertising boards


Previous 199869 Revisions Next


© 1997-2024 The MAME Team