Previous 199869 Revisions Next

r32069 Thursday 11th September, 2014 at 23:45:38 UTC by hap
small cleanup
[src/mame/drivers]skyfox.c
[src/mame/includes]skyfox.h
[src/mame/video]skyfox.c

trunk/src/mame/includes/skyfox.h
r32068r32069
99public:
1010   skyfox_state(const machine_config &mconfig, device_type type, const char *tag)
1111      : driver_device(mconfig, type, tag),
12      m_spriteram(*this, "spriteram"),
1312      m_maincpu(*this, "maincpu"),
13      m_audiocpu(*this, "audiocpu"),
1414      m_gfxdecode(*this, "gfxdecode"),
1515      m_screen(*this, "screen"),
16      m_palette(*this, "palette") { }
16      m_palette(*this, "palette"),
17      m_spriteram(*this, "spriteram")
18   { }
1719
18   /* memory pointers */
19   required_shared_ptr<UINT8> m_spriteram;
20
21   /* video-related */
22   UINT8      m_vreg[8];
23   int        m_bg_pos;
24   int        m_bg_ctrl;
25
26   /* misc */
27   int        m_palette_selected;
28
29   /* devices */
20   /* devices/memory pointers */
3021   required_device<cpu_device> m_maincpu;
22   required_device<cpu_device> m_audiocpu;
3123   required_device<gfxdecode_device> m_gfxdecode;
3224   required_device<screen_device> m_screen;
3325   required_device<palette_device> m_palette;
26   required_shared_ptr<UINT8> m_spriteram;
3427
35   DECLARE_READ8_MEMBER(skyfox_vregs_r);
28   int m_bg_pos;
29   int m_bg_ctrl;
30
3631   DECLARE_WRITE8_MEMBER(skyfox_vregs_w);
3732   DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
3833   DECLARE_DRIVER_INIT(skyfox);
trunk/src/mame/video/skyfox.c
r32068r32069
4141
4242/***************************************************************************
4343
44                            Memory Handlers
45
46***************************************************************************/
47
48#ifdef UNUSED_FUNCTION
49READ8_MEMBER(skyfox_state::skyfox_vregs_r)// for debug
50{
51   return m_vreg[offset];
52}
53#endif
54
55WRITE8_MEMBER(skyfox_state::skyfox_vregs_w)
56{
57   m_vreg[offset] = data;
58
59   switch (offset)
60   {
61      case 0: m_bg_ctrl = data;   break;
62      case 1: soundlatch_byte_w(space, 0, data);  break;
63      case 2: break;
64      case 3: break;
65      case 4: break;
66      case 5: break;
67      case 6: break;
68      case 7: break;
69   }
70}
71
72
73
74/***************************************************************************
75
7644  Convert the color PROMs into a more useable format.
7745
7846  There are three 256x4 palette PROMs (one per gun).
r32068r32069
8957PALETTE_INIT_MEMBER(skyfox_state, skyfox)
9058{
9159   const UINT8 *color_prom = memregion("proms")->base();
92   int i;
9360
94   for (i = 0; i < 256; i++)
61   for (int i = 0; i < 256; i++)
9562   {
9663      int bit0, bit1, bit2, bit3, r, g, b;
9764
r32068r32069
11784      palette.set_pen_color(i, rgb_t(r, g, b));
11885   }
11986
120   /* Grey scale for the background??? */
121   for (i = 0; i < 256; i++)
87   /* Grey scale for the background??? is wrong */
88   for (int i = 0; i < 256; i++)
12289   {
12390      palette.set_pen_color(i + 256, rgb_t(i, i, i));
12491   }
r32068r32069
159126
160127void skyfox_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect )
161128{
162   int offs;
163
129   gfx_element *gfx = m_gfxdecode->gfx(0);
164130   int width = m_screen->width();
165131   int height = m_screen->height();
166132
167133   /* The 32x32 tiles in the 80-ff range are bankswitched */
168   int shift =(m_bg_ctrl & 0x80) ? (4 - 1) : 4;
134   int shift = (m_bg_ctrl & 0x80) ? (4 - 1) : 4;
169135
170   for (offs = 0; offs < m_spriteram.bytes(); offs += 4)
136   for (int offs = 0; offs < m_spriteram.bytes(); offs += 4)
171137   {
172138      int xstart, ystart, xend, yend;
173139      int xinc, yinc, dx, dy;
174140      int low_code, high_code, n;
175141
176      int y = m_spriteram[offs + 0];
177      int x = m_spriteram[offs + 1];
178      int code = m_spriteram[offs + 2] + m_spriteram[offs + 3] * 256;
142      int code = m_spriteram[offs + 3] << 8 | m_spriteram[offs + 2];
179143      int flipx = code & 0x2;
180144      int flipy = code & 0x4;
145      int y = m_spriteram[offs + 0];
146      int x = m_spriteram[offs + 1] << 1 | (code & 1);
181147
182      x = x * 2 + (code & 1); // add the least significant bit
183
184148      high_code = ((code >> 4) & 0x7f0) + ((code & 0x8000) >> shift);
185149
186      switch( code & 0x88 )
150      switch (code & 0x88)
187151      {
188         case 0x88:  n = 4; low_code = 0;                                        break;
189         case 0x08:  n = 2; low_code = ((code & 0x20) ? 8 : 0) + ((code & 0x10) ? 2 : 0);    break;
190         default:    n = 1; low_code = (code >> 4) & 0xf;
152         case 0x88:  n = 4; low_code = 0; break;
153         case 0x08:  n = 2; low_code = (code & 0x20) >> 2 | (code & 0x10) >> 3; break;
154         default:    n = 1; low_code = (code >> 4) & 0xf; break;
191155      }
192156
193#define DRAW_SPRITE(DX,DY,CODE) \
194      m_gfxdecode->gfx(0)->transpen(bitmap,\
195            cliprect, \
196            (CODE), \
197            0, \
198            flipx,flipy, \
199            x + (DX),y + (DY), 0xff);
200      if (m_bg_ctrl & 1)   // flipscreen
157      if (m_bg_ctrl & 1) // flipscreen
201158      {
202159         x = width  - x - (n - 1) * 8;
203160         y = height - y - (n - 1) * 8;
r32068r32069
217174      for (dy = ystart; dy != yend; dy += yinc)
218175      {
219176         for (dx = xstart; dx != xend; dx += xinc)
220            DRAW_SPRITE(dx * 8, dy * 8, code++);
177         {
178            gfx->transpen(bitmap, cliprect, code, 0, flipx, flipy, dx*8 + x, dy*8 + y, 0xff);
179            code++;
180         }
221181
222         if (n == 2) code += 2;
182         if (n == 2)
183            code += 2;
223184      }
224185   }
225186}
226187
227188
228189
229
230
231190/***************************************************************************
232191
233192                            Background Rendering
r32068r32069
236195
237196void skyfox_state::draw_background(bitmap_ind16 &bitmap, const rectangle &cliprect)
238197{
239   UINT8 *RAM = memregion("gfx2")->base();
240   int x, y, i;
198   UINT8 *rom = memregion("gfx2")->base();
241199
242200   /* The foreground stars (sprites) move at twice this speed when
243      the bg scroll rate [e.g. (skyfox_bg_reg >> 1) & 7] is 4 */
201      the bg scroll rate [e.g. (m_bg_ctrl >> 1) & 7] is 4 */
244202   int pos = (m_bg_pos >> 4) & (512 * 2 - 1);
245203
246   for (i = 0 ; i < 0x1000; i++)
204   for (int i = 0; i < 0x1000; i++)
247205   {
248      int pen, offs, j;
206      int offs = (i * 2 + ((m_bg_ctrl >> 4) & 0x3) * 0x2000) % 0x8000;
249207
250      offs    = (i * 2 + ((m_bg_ctrl >> 4) & 0x3) * 0x2000) % 0x8000;
208      int pen = rom[offs];
209      int x = rom[offs + 1] * 2 + (i & 1) + pos + ((i & 8) ? 512 : 0);
210      int y = ((i / 8) / 2) * 8 + (i % 8);
251211
252      pen = RAM[offs];
253      x = RAM[offs + 1] * 2 + (i & 1) + pos + ((i & 8) ? 512 : 0);
254      y = ((i / 8) / 2) * 8 + (i % 8);
255
256      if (m_bg_ctrl & 1)   // flipscreen
212      if (m_bg_ctrl & 1) // flipscreen
257213      {
258214         x = 512 * 2 - (x % (512 * 2));
259215         y = 256     - (y % 256);
260216      }
261217
262      for (j = 0 ; j <= ((pen & 0x80) ? 0 : 3); j++)
263         bitmap.pix16(
264                     (((j / 2) & 1) + y) % 256,
265                     ((j & 1)     + x) % 512) = 256 + (pen & 0x7f);
218      for (int j = 0; j <= ((pen & 0x80) ? 0 : 3); j++)
219         bitmap.pix16((((j / 2) & 1) + y) % 256, ((j & 1) + x) % 512) = 256 + (pen & 0x7f);
266220   }
267221}
268222
269223
270224/***************************************************************************
271225
272
273226                                Screen Drawing
274227
275
276228***************************************************************************/
277229
278
279230UINT32 skyfox_state::screen_update_skyfox(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
280231{
281232   bitmap.fill(255, cliprect); // the bg is black
trunk/src/mame/drivers/skyfox.c
r32068r32069
1616Verified Dip locations and recommended settings with manual
1717
1818***************************************************************************/
19
1920#include "emu.h"
2021#include "cpu/z80/z80.h"
2122#include "sound/2203intf.h"
r32068r32069
2425
2526/***************************************************************************
2627
27
2828                                Main CPU
2929
30
3130***************************************************************************/
3231
32WRITE8_MEMBER(skyfox_state::skyfox_vregs_w)
33{
34   switch (offset)
35   {
36      case 0:
37         m_bg_ctrl = data;
38         break;
3339
34/***************************************************************************
35                                Sky Fox
36***************************************************************************/
40      case 1:
41         soundlatch_byte_w(space, 0, data);
42         break;
3743
44      default:
45         break;
46   }
47}
48
3849static ADDRESS_MAP_START( skyfox_map, AS_PROGRAM, 8, skyfox_state )
39   AM_RANGE(0x0000, 0xbfff) AM_ROM                         // ROM
40   AM_RANGE(0xc000, 0xcfff) AM_RAM                         // RAM
41   AM_RANGE(0xd000, 0xd3ff) AM_RAM AM_SHARE("spriteram")   // Sprites
42   AM_RANGE(0xd400, 0xdfff) AM_RAM                         // RAM?
43   AM_RANGE(0xe000, 0xe000) AM_READ_PORT("INPUTS")         // Input Ports
44   AM_RANGE(0xe001, 0xe001) AM_READ_PORT("DSW0")           //
45   AM_RANGE(0xe002, 0xe002) AM_READ_PORT("DSW1")           //
46   AM_RANGE(0xe008, 0xe00f) AM_WRITE(skyfox_vregs_w)       // Video Regs
47   AM_RANGE(0xf001, 0xf001) AM_READ_PORT("DSW2")           //
48//  AM_RANGE(0xff00, 0xff07) AM_READ(skyfox_vregs_r)        // fake to read the vregs
50   AM_RANGE(0x0000, 0xbfff) AM_ROM
51   AM_RANGE(0xc000, 0xcfff) AM_RAM
52   AM_RANGE(0xd000, 0xd3ff) AM_RAM AM_SHARE("spriteram")
53   AM_RANGE(0xd400, 0xdfff) AM_RAM // ?
54   AM_RANGE(0xe000, 0xe000) AM_READ_PORT("INPUTS")
55   AM_RANGE(0xe001, 0xe001) AM_READ_PORT("DSW0")
56   AM_RANGE(0xe002, 0xe002) AM_READ_PORT("DSW1")
57   AM_RANGE(0xe008, 0xe00f) AM_WRITE(skyfox_vregs_w)
58   AM_RANGE(0xf001, 0xf001) AM_READ_PORT("DSW2")
4959ADDRESS_MAP_END
5060
5161
5262/***************************************************************************
5363
54
5564                                Sound CPU
5665
57
5866***************************************************************************/
5967
60
61/***************************************************************************
62                                Sky Fox
63***************************************************************************/
64
65
6668static ADDRESS_MAP_START( skyfox_sound_map, AS_PROGRAM, 8, skyfox_state )
67   AM_RANGE(0x0000, 0x7fff) AM_ROM                             // ROM
68   AM_RANGE(0x8000, 0x87ff) AM_RAM                             // RAM
69//  AM_RANGE(0x9000, 0x9001) AM_WRITENOP                        // ??
70   AM_RANGE(0xa000, 0xa001) AM_DEVREADWRITE("ym1", ym2203_device, read, write) // YM2203 #1
71//  AM_RANGE(0xb000, 0xb001) AM_WRITENOP                        // ??
72   AM_RANGE(0xc000, 0xc001) AM_DEVREADWRITE("ym2", ym2203_device, read, write) // YM2203 #2
73   AM_RANGE(0xb000, 0xb000) AM_READ(soundlatch_byte_r)             // From Main CPU
69   AM_RANGE(0x0000, 0x7fff) AM_ROM
70   AM_RANGE(0x8000, 0x87ff) AM_RAM
71//  AM_RANGE(0x9000, 0x9001) AM_WRITENOP // ??
72   AM_RANGE(0xa000, 0xa001) AM_DEVREADWRITE("ym1", ym2203_device, read, write)
73//  AM_RANGE(0xb000, 0xb001) AM_WRITENOP // ??
74   AM_RANGE(0xc000, 0xc001) AM_DEVREADWRITE("ym2", ym2203_device, read, write)
75   AM_RANGE(0xb000, 0xb000) AM_READ(soundlatch_byte_r)
7476ADDRESS_MAP_END
7577
7678
7779/***************************************************************************
7880
79
8081                                Input Ports
8182
82
8383***************************************************************************/
8484
8585INPUT_CHANGED_MEMBER(skyfox_state::coin_inserted)
r32068r32069
147147   PORT_DIPSETTING(    0x02, "3" )
148148   PORT_DIPSETTING(    0x03, "4" )
149149   PORT_DIPSETTING(    0x04, "5" )
150//  PORT_DIPSETTING(    0x05, "5" )
151//  PORT_DIPSETTING(    0x06, "5" )
150   PORT_DIPSETTING(    0x05, "5" ) // dupe
151   PORT_DIPSETTING(    0x06, "5" ) // dupe
152152   PORT_DIPSETTING(    0x07, "Infinite (Cheat)")
153153   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
154154   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
r32068r32069
166166
167167/***************************************************************************
168168
169
170169                                Graphics Layouts
171170
172
173171***************************************************************************/
174172
175173/* 8x8x8 tiles (note that the tiles in the ROMs are 32x32x8, but
r32068r32069
187185   8*8*8
188186};
189187
190/***************************************************************************
191                                Sky Fox
192***************************************************************************/
193
194188static GFXDECODE_START( skyfox )
195   GFXDECODE_ENTRY( "gfx1", 0, layout_8x8x8,   0, 1 ) // [0] Sprites
189   GFXDECODE_ENTRY( "gfx1", 0, layout_8x8x8, 0, 1 ) // [0] Sprites
196190GFXDECODE_END
197191
198192
199193/***************************************************************************
200194
201
202195                                Machine Drivers
203196
204
205197***************************************************************************/
206198
207
208/***************************************************************************
209                                Sky Fox
210***************************************************************************/
211
212199/* Scroll the background on every vblank (guess). */
213200
214201INTERRUPT_GEN_MEMBER(skyfox_state::skyfox_interrupt)
r32068r32069
234221   /* basic machine hardware */
235222   MCFG_CPU_ADD("maincpu", Z80, XTAL_8MHz/2) /* Verified at 4MHz */
236223   MCFG_CPU_PROGRAM_MAP(skyfox_map)
237   MCFG_CPU_VBLANK_INT_DRIVER("screen", skyfox_state, skyfox_interrupt)       /* NMI caused by coin insertion */
224   MCFG_CPU_VBLANK_INT_DRIVER("screen", skyfox_state, skyfox_interrupt)
238225
239226   MCFG_CPU_ADD("audiocpu", Z80, XTAL_14_31818MHz/8) /* Verified at 1.789772MHz */
240227   MCFG_CPU_PROGRAM_MAP(skyfox_sound_map)
241228
242
243229   /* video hardware */
244230   MCFG_SCREEN_ADD("screen", RASTER)
245231   MCFG_SCREEN_REFRESH_RATE(62.65)
246   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)   // we're using PORT_VBLANK
232   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
247233   MCFG_SCREEN_SIZE(512, 256)
248   MCFG_SCREEN_VISIBLE_AREA(0+0x60, 320-1+0x60, 0+16, 256-1-16)    // from $30*2 to $CC*2+8
234   MCFG_SCREEN_VISIBLE_AREA(0+0x60, 320-1+0x60, 0+16, 256-1-16) // from $30*2 to $CC*2+8
249235   MCFG_SCREEN_UPDATE_DRIVER(skyfox_state, screen_update_skyfox)
250236   MCFG_SCREEN_PALETTE("palette")
251237
252238   MCFG_GFXDECODE_ADD("gfxdecode", "palette", skyfox)
253   MCFG_PALETTE_ADD("palette", 256+256)    /* 256 static colors (+256 for the background??) */
239   MCFG_PALETTE_ADD("palette", 256+256) /* 256 static colors (+256 for the background??) */
254240   MCFG_PALETTE_INIT_OWNER(skyfox_state, skyfox)
255241
256242   /* sound hardware */
r32068r32069
265251
266252
267253
268
269
270
271254/***************************************************************************
272255
273
274256                                ROMs Loading
275257
258****************************************************************************
276259
277***************************************************************************/
278
279
280
281/***************************************************************************
282
283260                                    Sky Fox
284261
285262
r32068r32069
287264c044-5  :   Score (BCD)
288265c048-9  :   Power (BCD)
289266
290***************************************************************************/
267****************************************************************************
291268
292/***************************************************************************
293
294269                                Exerizer [Bootleg]
295270
296271malcor
r32068r32069
417392ROM_END
418393
419394
420
421
422395/* Untangle the graphics: cut each 32x32x8 tile in 16 8x8x8 tiles */
423396DRIVER_INIT_MEMBER(skyfox_state,skyfox)
424397{
425   UINT8 *RAM = memregion("gfx1")->base();
426   UINT8 *end = RAM + memregion("gfx1")->bytes();
398   UINT8 *rom = memregion("gfx1")->base();
399   UINT8 *end = rom + memregion("gfx1")->bytes();
427400   UINT8 buf[32 * 32];
428401
429   while (RAM < end)
402   while (rom < end)
430403   {
431      int i;
432      for (i = 0; i < (32 * 32); i++)
433         buf[i] = RAM[(i % 8) + ((i / 8) % 8) * 32 + ((i / 64) % 4) * 8 + (i / 256) * 256];
404      for (int i = 0; i < (32 * 32); i++)
405         buf[i] = rom[(i % 8) + ((i / 8) % 8) * 32 + ((i / 64) % 4) * 8 + (i / 256) * 256];
434406
435      memcpy(RAM, buf, 32 * 32);
436      RAM += 32 * 32;
407      memcpy(rom, buf, 32 * 32);
408      rom += 32 * 32;
437409   }
438410}
439411
440412
441
442GAME( 1987, skyfox,    0,      skyfox, skyfox, skyfox_state, skyfox, ROT90, "Jaleco (Nichibutsu USA license)", "Sky Fox" , GAME_SUPPORTS_SAVE )
413GAME( 1987, skyfox,    0,      skyfox, skyfox, skyfox_state, skyfox, ROT90, "Jaleco (Nichibutsu USA license)", "Sky Fox", GAME_SUPPORTS_SAVE )
443414GAME( 1987, exerizer,  skyfox, skyfox, skyfox, skyfox_state, skyfox, ROT90, "Jaleco", "Exerizer (Japan)", GAME_SUPPORTS_SAVE )
444GAME( 1987, exerizerb, skyfox, skyfox, skyfox, skyfox_state, skyfox, ROT90, "bootleg", "Exerizer (Japan) (bootleg)", GAME_SUPPORTS_SAVE )
415GAME( 1987, exerizerb, skyfox, skyfox, skyfox, skyfox_state, skyfox, ROT90, "bootleg", "Exerizer (bootleg)", GAME_SUPPORTS_SAVE )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team