Previous 199869 Revisions Next

r36187 Monday 2nd March, 2015 at 17:34:16 UTC by Osso
sandscrp.c: added save state support (nw)
[src/mame/drivers]sandscrp.c

trunk/src/mame/drivers/sandscrp.c
r244698r244699
102102   UINT8 m_vblank_irq;
103103   UINT8 m_latch1_full;
104104   UINT8 m_latch2_full;
105   DECLARE_READ16_MEMBER(sandscrp_irq_cause_r);
106   DECLARE_WRITE16_MEMBER(sandscrp_irq_cause_w);
107   DECLARE_WRITE16_MEMBER(sandscrp_coin_counter_w);
108   DECLARE_READ16_MEMBER(sandscrp_latchstatus_word_r);
109   DECLARE_WRITE16_MEMBER(sandscrp_latchstatus_word_w);
110   DECLARE_READ16_MEMBER(sandscrp_soundlatch_word_r);
111   DECLARE_WRITE16_MEMBER(sandscrp_soundlatch_word_w);
112   DECLARE_WRITE8_MEMBER(sandscrp_bankswitch_w);
113   DECLARE_READ8_MEMBER(sandscrp_latchstatus_r);
114   DECLARE_READ8_MEMBER(sandscrp_soundlatch_r);
115   DECLARE_WRITE8_MEMBER(sandscrp_soundlatch_w);
116   virtual void machine_reset();
117   UINT32 screen_update_sandscrp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
118   void screen_eof_sandscrp(screen_device &screen, bool state);
119   INTERRUPT_GEN_MEMBER(sandscrp_interrupt);
105   
106   DECLARE_READ16_MEMBER(irq_cause_r);
107   DECLARE_WRITE16_MEMBER(irq_cause_w);
108   DECLARE_WRITE16_MEMBER(coincounter_w);
109   DECLARE_READ16_MEMBER(latchstatus_word_r);
110   DECLARE_WRITE16_MEMBER(latchstatus_word_w);
111   DECLARE_READ16_MEMBER(soundlatch_word_r);
112   DECLARE_WRITE16_MEMBER(soundlatch_word_w);
113   DECLARE_WRITE8_MEMBER(bankswitch_w);
114   DECLARE_READ8_MEMBER(latchstatus_r);
115   DECLARE_READ8_MEMBER(soundlatch_r);
116   DECLARE_WRITE8_MEMBER(soundlatch_w);
117   
118   virtual void machine_start();
119   
120   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
121   void screen_eof(screen_device &screen, bool state);
122   
123   INTERRUPT_GEN_MEMBER(interrupt);
120124   void update_irq_state();
121   DECLARE_WRITE_LINE_MEMBER(irqhandler);
122   DECLARE_DRIVER_INIT(sandscp);
123125};
124126
125127
126128
127UINT32 sandscrp_state::screen_update_sandscrp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
129UINT32 sandscrp_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
128130{
129131   bitmap.fill(0, cliprect);
130132
131   int i;
132
133133   screen.priority().fill(0, cliprect);
134134
135135   m_view2_0->kaneko16_prepare(bitmap, cliprect);
136136
137   for ( i = 0; i < 8; i++ )
137   for ( int i = 0; i < 8; i++ )
138138   {
139139      m_view2_0->render_tilemap_chip(screen,bitmap,cliprect,i);
140140   }
r244698r244699
147147
148148
149149
150void sandscrp_state::machine_reset()
150void sandscrp_state::machine_start()
151151{
152   membank("bank1")->configure_entries(0, 8, memregion("audiocpu")->base(), 0x4000);
153   
154   save_item(NAME(m_sprite_irq));
155   save_item(NAME(m_unknown_irq));
156   save_item(NAME(m_vblank_irq));
157   save_item(NAME(m_latch1_full));
158   save_item(NAME(m_latch2_full));
152159}
153160
154/* Sand Scorpion */
155161
156
157
158162/* Update the IRQ state based on all possible causes */
159163void sandscrp_state::update_irq_state()
160164{
r244698r244699
167171
168172
169173/* Called once/frame to generate the VBLANK interrupt */
170INTERRUPT_GEN_MEMBER(sandscrp_state::sandscrp_interrupt)
174INTERRUPT_GEN_MEMBER(sandscrp_state::interrupt)
171175{
172176   m_vblank_irq = 1;
173177   update_irq_state();
174178}
175179
176180
177void sandscrp_state::screen_eof_sandscrp(screen_device &screen, bool state)
181void sandscrp_state::screen_eof(screen_device &screen, bool state)
178182{
179183   // rising edge
180184   if (state)
r244698r244699
186190}
187191
188192/* Reads the cause of the interrupt */
189READ16_MEMBER(sandscrp_state::sandscrp_irq_cause_r)
193READ16_MEMBER(sandscrp_state::irq_cause_r)
190194{
191195   return  ( m_sprite_irq  ?  0x08  : 0 ) |
192196         ( m_unknown_irq ?  0x10  : 0 ) |
r244698r244699
195199
196200
197201/* Clear the cause of the interrupt */
198WRITE16_MEMBER(sandscrp_state::sandscrp_irq_cause_w)
202WRITE16_MEMBER(sandscrp_state::irq_cause_w)
199203{
200204   if (ACCESSING_BITS_0_7)
201205   {
r244698r244699
216220                                Sand Scorpion
217221***************************************************************************/
218222
219WRITE16_MEMBER(sandscrp_state::sandscrp_coin_counter_w)
223WRITE16_MEMBER(sandscrp_state::coincounter_w)
220224{
221225   if (ACCESSING_BITS_0_7)
222226   {
r244698r244699
226230}
227231
228232
229READ16_MEMBER(sandscrp_state::sandscrp_latchstatus_word_r)
233READ16_MEMBER(sandscrp_state::latchstatus_word_r)
230234{
231235   return  (m_latch1_full ? 0x80 : 0) |
232236         (m_latch2_full ? 0x40 : 0) ;
233237}
234238
235WRITE16_MEMBER(sandscrp_state::sandscrp_latchstatus_word_w)
239WRITE16_MEMBER(sandscrp_state::latchstatus_word_w)
236240{
237241   if (ACCESSING_BITS_0_7)
238242   {
r244698r244699
241245   }
242246}
243247
244READ16_MEMBER(sandscrp_state::sandscrp_soundlatch_word_r)
248READ16_MEMBER(sandscrp_state::soundlatch_word_r)
245249{
246250   m_latch2_full = 0;
247251   return soundlatch2_byte_r(space,0);
248252}
249253
250WRITE16_MEMBER(sandscrp_state::sandscrp_soundlatch_word_w)
254WRITE16_MEMBER(sandscrp_state::soundlatch_word_w)
251255{
252256   if (ACCESSING_BITS_0_7)
253257   {
r244698r244699
260264
261265static ADDRESS_MAP_START( sandscrp, AS_PROGRAM, 16, sandscrp_state )
262266   AM_RANGE(0x000000, 0x07ffff) AM_ROM     // ROM
263   AM_RANGE(0x100000, 0x100001) AM_WRITE(sandscrp_irq_cause_w) // IRQ Ack
267   AM_RANGE(0x100000, 0x100001) AM_WRITE(irq_cause_w) // IRQ Ack
264268
265269   AM_RANGE(0x700000, 0x70ffff) AM_RAM     // RAM
266270   AM_RANGE(0x200000, 0x20001f) AM_DEVREADWRITE("calc1_mcu", kaneko_hit_device, kaneko_hit_r,kaneko_hit_w)
r244698r244699
268272   AM_RANGE(0x400000, 0x403fff) AM_DEVREADWRITE("view2_0", kaneko_view2_tilemap_device,  kaneko_tmap_vram_r, kaneko_tmap_vram_w )
269273   AM_RANGE(0x500000, 0x501fff) AM_DEVREADWRITE("pandora", kaneko_pandora_device, spriteram_LSB_r, spriteram_LSB_w ) // sprites
270274   AM_RANGE(0x600000, 0x600fff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")    // Palette
271   AM_RANGE(0xa00000, 0xa00001) AM_WRITE(sandscrp_coin_counter_w)  // Coin Counters (Lockout unused)
275   AM_RANGE(0xa00000, 0xa00001) AM_WRITE(coincounter_w)  // Coin Counters (Lockout unused)
272276   AM_RANGE(0xb00000, 0xb00001) AM_READ_PORT("P1")
273277   AM_RANGE(0xb00002, 0xb00003) AM_READ_PORT("P2")
274278   AM_RANGE(0xb00004, 0xb00005) AM_READ_PORT("SYSTEM")
275279   AM_RANGE(0xb00006, 0xb00007) AM_READ_PORT("UNK")
276280   AM_RANGE(0xec0000, 0xec0001) AM_READ(watchdog_reset16_r)    //
277   AM_RANGE(0x800000, 0x800001) AM_READ(sandscrp_irq_cause_r)  // IRQ Cause
278   AM_RANGE(0xe00000, 0xe00001) AM_READWRITE(sandscrp_soundlatch_word_r, sandscrp_soundlatch_word_w)   // From/To Sound CPU
279   AM_RANGE(0xe40000, 0xe40001) AM_READWRITE(sandscrp_latchstatus_word_r, sandscrp_latchstatus_word_w) //
281   AM_RANGE(0x800000, 0x800001) AM_READ(irq_cause_r)  // IRQ Cause
282   AM_RANGE(0xe00000, 0xe00001) AM_READWRITE(soundlatch_word_r, soundlatch_word_w)   // From/To Sound CPU
283   AM_RANGE(0xe40000, 0xe40001) AM_READWRITE(latchstatus_word_r, latchstatus_word_w) //
280284ADDRESS_MAP_END
281285
282286
r244698r244699
285289                                Sand Scorpion
286290***************************************************************************/
287291
288WRITE8_MEMBER(sandscrp_state::sandscrp_bankswitch_w)
292WRITE8_MEMBER(sandscrp_state::bankswitch_w)
289293{
290294   membank("bank1")->set_entry(data & 7);
291295}
292296
293READ8_MEMBER(sandscrp_state::sandscrp_latchstatus_r)
297READ8_MEMBER(sandscrp_state::latchstatus_r)
294298{
295299   return  (m_latch2_full ? 0x80 : 0) |    // swapped!?
296300         (m_latch1_full ? 0x40 : 0) ;
297301}
298302
299READ8_MEMBER(sandscrp_state::sandscrp_soundlatch_r)
303READ8_MEMBER(sandscrp_state::soundlatch_r)
300304{
301305   m_latch1_full = 0;
302306   return soundlatch_byte_r(space,0);
303307}
304308
305WRITE8_MEMBER(sandscrp_state::sandscrp_soundlatch_w)
309WRITE8_MEMBER(sandscrp_state::soundlatch_w)
306310{
307311   m_latch2_full = 1;
308312   soundlatch2_byte_w(space,0,data);
r244698r244699
316320
317321static ADDRESS_MAP_START( sandscrp_soundport, AS_IO, 8, sandscrp_state )
318322   ADDRESS_MAP_GLOBAL_MASK(0xff)
319   AM_RANGE(0x00, 0x00) AM_WRITE(sandscrp_bankswitch_w)    // ROM Bank
323   AM_RANGE(0x00, 0x00) AM_WRITE(bankswitch_w)    // ROM Bank
320324   AM_RANGE(0x02, 0x03) AM_DEVREADWRITE("ymsnd", ym2203_device, read, write)        // PORTA/B read
321325   AM_RANGE(0x04, 0x04) AM_DEVWRITE("oki", okim6295_device, write)     // OKIM6295
322   AM_RANGE(0x06, 0x06) AM_WRITE(sandscrp_soundlatch_w)    //
323   AM_RANGE(0x07, 0x07) AM_READ(sandscrp_soundlatch_r)     //
324   AM_RANGE(0x08, 0x08) AM_READ(sandscrp_latchstatus_r)    //
326   AM_RANGE(0x06, 0x06) AM_WRITE(soundlatch_w)    //
327   AM_RANGE(0x07, 0x07) AM_READ(soundlatch_r)     //
328   AM_RANGE(0x08, 0x08) AM_READ(latchstatus_r)    //
325329ADDRESS_MAP_END
326330
327331
r244698r244699
455459                                Sand Scorpion
456460***************************************************************************/
457461
458/* YM3014B + YM2203C */
459462
460WRITE_LINE_MEMBER(sandscrp_state::irqhandler)
461{
462   m_audiocpu->set_input_line(0, state ? ASSERT_LINE : CLEAR_LINE);
463}
464
465463static MACHINE_CONFIG_START( sandscrp, sandscrp_state )
466464
467465   /* basic machine hardware */
468466   MCFG_CPU_ADD("maincpu", M68000,12000000)    /* TMP68HC000N-12 */
469467   MCFG_CPU_PROGRAM_MAP(sandscrp)
470   MCFG_CPU_VBLANK_INT_DRIVER("screen", sandscrp_state,  sandscrp_interrupt)
468   MCFG_CPU_VBLANK_INT_DRIVER("screen", sandscrp_state,  interrupt)
471469
472470   MCFG_CPU_ADD("audiocpu", Z80,4000000)   /* Z8400AB1, Reads the DSWs: it can't be disabled */
473471   MCFG_CPU_PROGRAM_MAP(sandscrp_soundmem)
r244698r244699
481479   MCFG_SCREEN_VBLANK_TIME( ATTOSECONDS_IN_USEC(2500) /* not accurate */ )
482480   MCFG_SCREEN_SIZE(256, 256)
483481   MCFG_SCREEN_VISIBLE_AREA(0, 256-1, 0+16, 256-16-1)
484   MCFG_SCREEN_UPDATE_DRIVER(sandscrp_state, screen_update_sandscrp)
485   MCFG_SCREEN_VBLANK_DRIVER(sandscrp_state, screen_eof_sandscrp)
482   MCFG_SCREEN_UPDATE_DRIVER(sandscrp_state, screen_update)
483   MCFG_SCREEN_VBLANK_DRIVER(sandscrp_state, screen_eof)
486484   MCFG_SCREEN_PALETTE("palette")
487485
488486   MCFG_GFXDECODE_ADD("gfxdecode", "palette", sandscrp)
r244698r244699
508506   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.25)
509507   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.25)
510508
509   /* YM3014B + YM2203C */
511510   MCFG_SOUND_ADD("ymsnd", YM2203, 4000000)
512   MCFG_YM2203_IRQ_HANDLER(WRITELINE(sandscrp_state, irqhandler))
511   MCFG_YM2203_IRQ_HANDLER(INPUTLINE("audiocpu", 0))
513512   MCFG_AY8910_PORT_A_READ_CB(IOPORT("DSW1"))
514513   MCFG_AY8910_PORT_B_READ_CB(IOPORT("DSW2"))
515514   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.25)
r244698r244699
517516MACHINE_CONFIG_END
518517
519518
520DRIVER_INIT_MEMBER(sandscrp_state, sandscp)
521{
522   UINT8 *ROM = memregion("audiocpu")->base();
523   membank("bank1")->configure_entries(0, 8, ROM, 0x4000);
524}
525
526519/***************************************************************************
527520
528521                                Sand Scorpion
r244698r244699
590583ROM_END
591584
592585
593GAME( 1992, sandscrp,  0,        sandscrp, sandscrp, sandscrp_state, sandscp,          ROT90, "Face",   "Sand Scorpion", 0 )
594GAME( 1992, sandscrpa, sandscrp, sandscrp, sandscrp, sandscrp_state, sandscp,          ROT90, "Face",   "Sand Scorpion (Earlier)", 0 )
595GAME( 1992, sandscrpb, sandscrp, sandscrp, sandscrp, sandscrp_state, sandscp,          ROT90, "Face",   "Sand Scorpion (Chinese Title Screen, Revised Hardware)", 0 )
586GAME( 1992, sandscrp,  0,        sandscrp, sandscrp, driver_device, 0,          ROT90, "Face",   "Sand Scorpion", GAME_SUPPORTS_SAVE )
587GAME( 1992, sandscrpa, sandscrp, sandscrp, sandscrp, driver_device, 0,          ROT90, "Face",   "Sand Scorpion (Earlier)", GAME_SUPPORTS_SAVE )
588GAME( 1992, sandscrpb, sandscrp, sandscrp, sandscrp, driver_device, 0,          ROT90, "Face",   "Sand Scorpion (Chinese Title Screen, Revised Hardware)", GAME_SUPPORTS_SAVE )


Previous 199869 Revisions Next


© 1997-2024 The MAME Team