Previous 199869 Revisions Next

r36842 Tuesday 31st March, 2015 at 18:29:55 UTC by Osso
mainsnk.c, mirax.c: added save state support (nw)
[src/mame/drivers]mainsnk.c mirax.c
[src/mame/includes]mainsnk.h
[src/mame/video]mainsnk.c

trunk/src/mame/drivers/mainsnk.c
r245353r245354
1111  The game uses 2 joysticks (with button on top) and 2 buttons per player.
1212  Left stick
1313  up: left straight punch to enemy's face
14  left: swey to left
14  left: sway to left
1515
1616  Right stick
1717  up: right straight punch to enemy's face
18  right: swey to right
18  right: sway to right
1919
2020  Left + Right stick combinations
2121  L down + R up: right straight punch to enemy's body
r245353r245354
112112#include "sound/ay8910.h"
113113#include "includes/mainsnk.h"
114114
115
116void mainsnk_state::machine_start()
117{
118   save_item(NAME(m_sound_cpu_busy));
119}
120
115121WRITE8_MEMBER(mainsnk_state::sound_command_w)
116122{
117123   m_sound_cpu_busy = 1;
r245353r245354
119125   m_audiocpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
120126}
121127
122READ8_MEMBER(mainsnk_state::sound_command_r)
123{
124   return soundlatch_byte_r(space, 0);
125}
126
127128READ8_MEMBER(mainsnk_state::sound_ack_r)
128129{
129130   m_sound_cpu_busy = 0;
130131   return 0xff;
131132}
132133
133CUSTOM_INPUT_MEMBER(mainsnk_state::mainsnk_sound_r)
134CUSTOM_INPUT_MEMBER(mainsnk_state::sound_r)
134135{
135136   return (m_sound_cpu_busy) ? 0x01 : 0x00;
136137}
r245353r245354
145146   AM_RANGE(0xc300, 0xc300) AM_READ_PORT("IN3")
146147   AM_RANGE(0xc400, 0xc400) AM_READ_PORT("DSW1")
147148   AM_RANGE(0xc500, 0xc500) AM_READ_PORT("DSW2")
148   AM_RANGE(0xc600, 0xc600) AM_WRITE(mainsnk_c600_w)
149   AM_RANGE(0xc600, 0xc600) AM_WRITE(c600_w)
149150   AM_RANGE(0xc700, 0xc700) AM_WRITE(sound_command_w)
150   AM_RANGE(0xd800, 0xdbff) AM_RAM_WRITE(mainsnk_bgram_w) AM_SHARE("bgram")
151   AM_RANGE(0xd800, 0xdbff) AM_RAM_WRITE(bgram_w) AM_SHARE("bgram")
151152   AM_RANGE(0xdc00, 0xe7ff) AM_RAM
152153   AM_RANGE(0xe800, 0xefff) AM_RAM AM_SHARE("spriteram")
153   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(mainsnk_fgram_w) AM_SHARE("fgram")    // + work RAM
154   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(fgram_w) AM_SHARE("fgram")    // + work RAM
154155ADDRESS_MAP_END
155156
156157static ADDRESS_MAP_START( sound_map, AS_PROGRAM, 8, mainsnk_state )
157158   AM_RANGE(0x0000, 0x7fff) AM_ROM
158159   AM_RANGE(0x8000, 0x87ff) AM_RAM
159   AM_RANGE(0xa000, 0xa000) AM_READ(sound_command_r)
160   AM_RANGE(0xa000, 0xa000) AM_READ(soundlatch_byte_r)
160161   AM_RANGE(0xc000, 0xc000) AM_READ(sound_ack_r)
161162   AM_RANGE(0xe000, 0xe001) AM_DEVWRITE("ay1", ay8910_device, address_data_w)
162163   AM_RANGE(0xe002, 0xe003) AM_WRITENOP    // ? always FFFF, snkwave leftover?
r245353r245354
177178   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SERVICE1 )
178179   PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_START1 )
179180   PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_START2 )
180   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, mainsnk_state,mainsnk_sound_r, NULL)  /* sound CPU status */
181   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, mainsnk_state, sound_r, NULL)  /* sound CPU status */
181182   PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN )
182183   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_SERVICE )
183184
r245353r245354
271272   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SERVICE1 )
272273   PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_START1 )
273274   PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_START2 )
274   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, mainsnk_state,mainsnk_sound_r, NULL)  /* sound CPU status */
275   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, mainsnk_state, sound_r, NULL)  /* sound CPU status */
275276   PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN )
276277   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_SERVICE )
277278
r245353r245354
399400   MCFG_SCREEN_REFRESH_RATE(60)
400401   MCFG_SCREEN_SIZE(36*8, 28*8)
401402   MCFG_SCREEN_VISIBLE_AREA(0*8, 36*8-1, 1*8, 28*8-1)
402   MCFG_SCREEN_UPDATE_DRIVER(mainsnk_state, screen_update_mainsnk)
403   MCFG_SCREEN_UPDATE_DRIVER(mainsnk_state, screen_update)
403404   MCFG_SCREEN_PALETTE("palette")
404405
405406   MCFG_GFXDECODE_ADD("gfxdecode", "palette", mainsnk)
r245353r245354
483484ROM_END
484485
485486
486GAME( 1984, mainsnk,   0,   mainsnk, mainsnk, driver_device, 0,   ROT0, "SNK", "Main Event (1984)", 0)
487GAME( 1985, canvas,    0,   mainsnk, canvas, driver_device,  0,   ROT0, "SNK", "Canvas Croquis", 0)
487GAME( 1984, mainsnk,   0,   mainsnk, mainsnk, driver_device, 0,   ROT0, "SNK", "Main Event (1984)", GAME_SUPPORTS_SAVE )
488GAME( 1985, canvas,    0,   mainsnk, canvas, driver_device,  0,   ROT0, "SNK", "Canvas Croquis", GAME_SUPPORTS_SAVE )
trunk/src/mame/drivers/mirax.c
r245353r245354
9393      * different stages names :
9494          . stages  1 to 10 : "LUXORI" instead of "MIRAX"
9595          . stages 71 to 80 : "DESCOM" instead of "DESBOM"
96        futhermore, for all stages, it's written "UNIT" instead of "CITY"
96        furthermore, for all stages, it's written "UNIT" instead of "CITY"
9797  - Same ingame bug as in 'mirax' when you reach level 100 (of course, it will display
9898    "LUXORI UNIT" instead of "MIRAX CITY" on "presentation" screen).
9999
r245353r245354
110110public:
111111   mirax_state(const machine_config &mconfig, device_type type, const char *tag)
112112      : driver_device(mconfig, type, tag),
113      m_videoram(*this, "videoram"),
114      m_spriteram(*this, "spriteram"),
115      m_colorram(*this, "colorram"),
116113      m_maincpu(*this, "maincpu"),
117114      m_audiocpu(*this, "audiocpu"),
118115      m_gfxdecode(*this, "gfxdecode"),
119      m_palette(*this, "palette")  { }
116      m_palette(*this, "palette"),
117      m_videoram(*this, "videoram"),
118      m_spriteram(*this, "spriteram"),
119      m_colorram(*this, "colorram")  { }
120120
121   required_device<cpu_device> m_maincpu;
122   required_device<cpu_device> m_audiocpu;
123   required_device<gfxdecode_device> m_gfxdecode;
124   required_device<palette_device> m_palette;
125
121126   required_shared_ptr<UINT8> m_videoram;
122127   required_shared_ptr<UINT8> m_spriteram;
123128   required_shared_ptr<UINT8> m_colorram;
129
124130   UINT8 m_nAyCtrl;
125131   UINT8 m_nmi_mask;
126132   UINT8 m_flipscreen_x;
127133   UINT8 m_flipscreen_y;
134
128135   DECLARE_WRITE8_MEMBER(audio_w);
129136   DECLARE_WRITE8_MEMBER(nmi_mask_w);
130   DECLARE_WRITE8_MEMBER(mirax_sound_cmd_w);
131   DECLARE_WRITE8_MEMBER(mirax_coin_counter0_w);
132   DECLARE_WRITE8_MEMBER(mirax_coin_counter1_w);
133   DECLARE_WRITE8_MEMBER(mirax_flip_screen_w);
137   DECLARE_WRITE8_MEMBER(sound_cmd_w);
138   DECLARE_WRITE8_MEMBER(coin_counter0_w);
139   DECLARE_WRITE8_MEMBER(coin_counter1_w);
140   DECLARE_WRITE8_MEMBER(flip_screen_w);
134141   DECLARE_WRITE8_MEMBER(ay1_sel);
135142   DECLARE_WRITE8_MEMBER(ay2_sel);
143
136144   DECLARE_DRIVER_INIT(mirax);
137145   DECLARE_PALETTE_INIT(mirax);
138   virtual void sound_start();
139   UINT32 screen_update_mirax(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
140   INTERRUPT_GEN_MEMBER(mirax_vblank_irq);
146   virtual void machine_start();
147
148   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
141149   void draw_tilemap(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT8 draw_flag);
142150   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
143   required_device<cpu_device> m_maincpu;
144   required_device<cpu_device> m_audiocpu;
145   required_device<gfxdecode_device> m_gfxdecode;
146   required_device<palette_device> m_palette;
151   
152   INTERRUPT_GEN_MEMBER(vblank_irq);
147153};
148154
149155
r245353r245354
207213
208214void mirax_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
209215{
210   UINT8 *spriteram = m_spriteram;
211   int count;
212
213   for(count=0;count<0x200;count+=4)
216   for(int count=0;count<0x200;count+=4)
214217   {
215218      int spr_offs,x,y,color,fx,fy;
216219
217      if(spriteram[count] == 0x00 || spriteram[count+3] == 0x00)
220      if(m_spriteram[count] == 0x00 || m_spriteram[count+3] == 0x00)
218221         continue;
219222
220      spr_offs = (spriteram[count+1] & 0x3f);
221      color = spriteram[count+2] & 0x7;
222      fx = (m_flipscreen_x) ^ ((spriteram[count+1] & 0x40) >> 6); //<- guess
223      fy = (m_flipscreen_y) ^ ((spriteram[count+1] & 0x80) >> 7);
223      spr_offs = (m_spriteram[count+1] & 0x3f);
224      color = m_spriteram[count+2] & 0x7;
225      fx = (m_flipscreen_x) ^ ((m_spriteram[count+1] & 0x40) >> 6); //<- guess
226      fy = (m_flipscreen_y) ^ ((m_spriteram[count+1] & 0x80) >> 7);
224227
225      spr_offs += (spriteram[count+2] & 0xe0)<<1;
226      spr_offs += (spriteram[count+2] & 0x10)<<5;
228      spr_offs += (m_spriteram[count+2] & 0xe0)<<1;
229      spr_offs += (m_spriteram[count+2] & 0x10)<<5;
227230
228      y = (m_flipscreen_y) ? spriteram[count] : 0x100 - spriteram[count] - 16;
229      x = (m_flipscreen_x) ? 240 - spriteram[count+3] : spriteram[count+3];
231      y = (m_flipscreen_y) ? m_spriteram[count] : 0x100 - m_spriteram[count] - 16;
232      x = (m_flipscreen_x) ? 240 - m_spriteram[count+3] : m_spriteram[count+3];
230233
231234      m_gfxdecode->gfx(1)->transpen(bitmap,cliprect,spr_offs,color,fx,fy,x,y,0);
232235   }
233236}
234237
235UINT32 mirax_state::screen_update_mirax(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
238UINT32 mirax_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
236239{
237240   draw_tilemap(bitmap,cliprect,1);
238241   draw_sprites(bitmap,cliprect);
r245353r245354
241244}
242245
243246
244void mirax_state::sound_start()
247void mirax_state::machine_start()
245248{
246249   m_nAyCtrl = 0x00;
250   
251   save_item(NAME(m_nAyCtrl));
252   save_item(NAME(m_nmi_mask));
253   save_item(NAME(m_flipscreen_x));
254   save_item(NAME(m_flipscreen_y));
247255}
248256
249257WRITE8_MEMBER(mirax_state::audio_w)
r245353r245354
272280      printf("Warning: %02x written at $f501\n",data);
273281}
274282
275WRITE8_MEMBER(mirax_state::mirax_sound_cmd_w)
283WRITE8_MEMBER(mirax_state::sound_cmd_w)
276284{
277285   soundlatch_byte_w(space, 0, data & 0xff);
278286   m_audiocpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE);
279287}
280288
281289
282WRITE8_MEMBER(mirax_state::mirax_coin_counter0_w)
290WRITE8_MEMBER(mirax_state::coin_counter0_w)
283291{
284292   coin_counter_w(machine(), 0, data & 1);
285293}
286294
287WRITE8_MEMBER(mirax_state::mirax_coin_counter1_w)
295WRITE8_MEMBER(mirax_state::coin_counter1_w)
288296{
289297   coin_counter_w(machine(), 1, data & 1);
290298}
291299
292300/* One address flips X, the other flips Y, but I can't tell which is which - Since the value is the same for the 2 addresses, it doesn't really matter */
293WRITE8_MEMBER(mirax_state::mirax_flip_screen_w)
301WRITE8_MEMBER(mirax_state::flip_screen_w)
294302{
295303   if (offset == 0)
296304      m_flipscreen_x = data & 0x01;
r245353r245354
310318   AM_RANGE(0xf200, 0xf200) AM_READ_PORT("DSW1")
311319   AM_RANGE(0xf300, 0xf300) AM_READNOP //watchdog? value is always read then discarded
312320   AM_RANGE(0xf400, 0xf400) AM_READ_PORT("DSW2")
313   AM_RANGE(0xf500, 0xf500) AM_WRITE(mirax_coin_counter0_w)
321   AM_RANGE(0xf500, 0xf500) AM_WRITE(coin_counter0_w)
314322   AM_RANGE(0xf501, 0xf501) AM_WRITE(nmi_mask_w)
315   AM_RANGE(0xf502, 0xf502) AM_WRITE(mirax_coin_counter1_w) // only used in 'miraxa' - see notes
316   AM_RANGE(0xf506, 0xf507) AM_WRITE(mirax_flip_screen_w)
317   AM_RANGE(0xf800, 0xf800) AM_WRITE(mirax_sound_cmd_w)
323   AM_RANGE(0xf502, 0xf502) AM_WRITE(coin_counter1_w) // only used in 'miraxa' - see notes
324   AM_RANGE(0xf506, 0xf507) AM_WRITE(flip_screen_w)
325   AM_RANGE(0xf800, 0xf800) AM_WRITE(sound_cmd_w)
318326//  AM_RANGE(0xf900, 0xf900) //sound cmd mirror? ack?
319327ADDRESS_MAP_END
320328
r245353r245354
455463GFXDECODE_END
456464
457465
458INTERRUPT_GEN_MEMBER(mirax_state::mirax_vblank_irq)
466INTERRUPT_GEN_MEMBER(mirax_state::vblank_irq)
459467{
460468   if(m_nmi_mask)
461469      device.execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
r245353r245354
464472static MACHINE_CONFIG_START( mirax, mirax_state )
465473   MCFG_CPU_ADD("maincpu", Z80, 12000000/4) // ceramic potted module, encrypted z80
466474   MCFG_CPU_PROGRAM_MAP(mirax_main_map)
467   MCFG_CPU_VBLANK_INT_DRIVER("screen", mirax_state, mirax_vblank_irq)
475   MCFG_CPU_VBLANK_INT_DRIVER("screen", mirax_state, vblank_irq)
468476
469477   MCFG_CPU_ADD("audiocpu", Z80, 12000000/4)
470478   MCFG_CPU_PROGRAM_MAP(mirax_sound_map)
r245353r245354
476484   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
477485   MCFG_SCREEN_SIZE(256, 256)
478486   MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
479   MCFG_SCREEN_UPDATE_DRIVER(mirax_state, screen_update_mirax)
487   MCFG_SCREEN_UPDATE_DRIVER(mirax_state, screen_update)
480488   MCFG_SCREEN_PALETTE("palette")
481489
482490   MCFG_PALETTE_ADD("palette", 0x40)
r245353r245354
572580   m_flipscreen_y = 0;
573581}
574582
575GAME( 1985, mirax,    0,        mirax,    mirax, mirax_state,    mirax,    ROT90, "Current Technologies", "Mirax (set 1)", 0 )
576GAME( 1985, miraxa,   mirax,    mirax,    miraxa, mirax_state,   mirax,    ROT90, "Current Technologies", "Mirax (set 2)", 0 )
583GAME( 1985, mirax,    0,        mirax,    mirax, mirax_state,    mirax,    ROT90, "Current Technologies", "Mirax (set 1)", GAME_SUPPORTS_SAVE )
584GAME( 1985, miraxa,   mirax,    mirax,    miraxa, mirax_state,   mirax,    ROT90, "Current Technologies", "Mirax (set 2)", GAME_SUPPORTS_SAVE )
trunk/src/mame/includes/mainsnk.h
r245353r245354
33public:
44   mainsnk_state(const machine_config &mconfig, device_type type, const char *tag)
55      : driver_device(mconfig, type, tag),
6      m_bgram(*this, "bgram"),
7      m_spriteram(*this, "spriteram"),
8      m_fgram(*this, "fgram"),
96      m_maincpu(*this, "maincpu"),
107      m_audiocpu(*this, "audiocpu"),
118      m_gfxdecode(*this, "gfxdecode"),
12      m_palette(*this, "palette") { }
9      m_palette(*this, "palette"),
10      m_bgram(*this, "bgram"),
11      m_spriteram(*this, "spriteram"),
12      m_fgram(*this, "fgram") { }
1313
14   tilemap_t *m_tx_tilemap;
15   tilemap_t *m_bg_tilemap;
14   required_device<cpu_device> m_maincpu;
15   required_device<cpu_device> m_audiocpu;
16   required_device<gfxdecode_device> m_gfxdecode;
17   required_device<palette_device> m_palette;
18
1619   required_shared_ptr<UINT8> m_bgram;
1720   required_shared_ptr<UINT8> m_spriteram;
1821   required_shared_ptr<UINT8> m_fgram;
1922
23   tilemap_t *m_tx_tilemap;
24   tilemap_t *m_bg_tilemap;
2025   int m_sound_cpu_busy;
2126   UINT32 m_bg_tile_offset;
27   
2228   DECLARE_WRITE8_MEMBER(sound_command_w);
23   DECLARE_READ8_MEMBER(sound_command_r);
2429   DECLARE_READ8_MEMBER(sound_ack_r);
25   DECLARE_WRITE8_MEMBER(mainsnk_c600_w);
26   DECLARE_WRITE8_MEMBER(mainsnk_fgram_w);
27   DECLARE_WRITE8_MEMBER(mainsnk_bgram_w);
28   DECLARE_CUSTOM_INPUT_MEMBER(mainsnk_sound_r);
30   DECLARE_WRITE8_MEMBER(c600_w);
31   DECLARE_WRITE8_MEMBER(fgram_w);
32   DECLARE_WRITE8_MEMBER(bgram_w);
33   
34   DECLARE_CUSTOM_INPUT_MEMBER(sound_r);
35   
2936   TILEMAP_MAPPER_MEMBER(marvins_tx_scan_cols);
3037   TILE_GET_INFO_MEMBER(get_tx_tile_info);
3138   TILE_GET_INFO_MEMBER(get_bg_tile_info);
39   
40   virtual void machine_start();
3241   virtual void video_start();
3342   DECLARE_PALETTE_INIT(mainsnk);
34   UINT32 screen_update_mainsnk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
43   
44   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3545   void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int scrollx, int scrolly );
36   required_device<cpu_device> m_maincpu;
37   required_device<cpu_device> m_audiocpu;
38   required_device<gfxdecode_device> m_gfxdecode;
39   required_device<palette_device> m_palette;
4046};
trunk/src/mame/video/mainsnk.c
r245353r245354
7676
7777   m_bg_tilemap->set_scrolldx(16, 16);
7878   m_bg_tilemap->set_scrolldy(8,  8);
79   
80   save_item(NAME(m_bg_tile_offset));
7981}
8082
8183
82WRITE8_MEMBER(mainsnk_state::mainsnk_c600_w)
84WRITE8_MEMBER(mainsnk_state::c600_w)
8385{
8486   int bank;
8587   int total_elements = m_gfxdecode->gfx(0)->elements();
r245353r245354
102104   }
103105}
104106
105WRITE8_MEMBER(mainsnk_state::mainsnk_fgram_w)
107WRITE8_MEMBER(mainsnk_state::fgram_w)
106108{
107109   m_fgram[offset] = data;
108110   m_tx_tilemap->mark_tile_dirty(offset);
109111}
110112
111WRITE8_MEMBER(mainsnk_state::mainsnk_bgram_w)
113WRITE8_MEMBER(mainsnk_state::bgram_w)
112114{
113115   m_bgram[offset] = data;
114116   m_bg_tilemap->mark_tile_dirty(offset);
r245353r245354
158160}
159161
160162
161UINT32 mainsnk_state::screen_update_mainsnk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
163UINT32 mainsnk_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
162164{
163165   m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
164166   draw_sprites(bitmap, cliprect, 0, 0);


Previous 199869 Revisions Next


© 1997-2024 The MAME Team