Previous 199869 Revisions Next

r30660 Sunday 25th May, 2014 at 12:56:59 UTC by David Haywood
move some gcpinbal / aquarium code around for later refactoring (nw)
[src/mame]mame.mak
[src/mame/drivers]aquarium.c gcpinbal.c
[src/mame/includes]aquarium.h gcpinbal.h
[src/mame/video]aquarium.c excellent_spr.c* excellent_spr.h* gcpinbal.c

trunk/src/mame/drivers/aquarium.c
r30659r30660
105105   AM_RANGE(0xc00000, 0xc00fff) AM_RAM_WRITE(aquarium_mid_videoram_w) AM_SHARE("mid_videoram")
106106   AM_RANGE(0xc01000, 0xc01fff) AM_RAM_WRITE(aquarium_bak_videoram_w) AM_SHARE("bak_videoram")
107107   AM_RANGE(0xc02000, 0xc03fff) AM_RAM_WRITE(aquarium_txt_videoram_w) AM_SHARE("txt_videoram")
108   AM_RANGE(0xc80000, 0xc81fff) AM_RAM AM_SHARE("spriteram")
108   AM_RANGE(0xc80000, 0xc81fff) AM_DEVREADWRITE8("spritegen", excellent_spr_device, read, write, 0x00ff)
109109   AM_RANGE(0xd00000, 0xd00fff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")
110110   AM_RANGE(0xd80014, 0xd8001f) AM_WRITEONLY AM_SHARE("scroll")
111111   AM_RANGE(0xd80068, 0xd80069) AM_WRITENOP        /* probably not used */
r30659r30660
320320   MCFG_PALETTE_ADD("palette", 0x1000/2)
321321   MCFG_PALETTE_FORMAT(RRRRGGGGBBBBRGBx)
322322
323   MCFG_DEVICE_ADD("spritegen", EXCELLENT_SPRITE, 0)
324
323325   /* sound hardware */
324326   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
325327
trunk/src/mame/drivers/gcpinbal.c
r30659r30660
3232
3333  - Reset the game while pressing START1 to enter the "test mode"
3434
35
35 
3636***************************************************************************/
3737
3838#include "emu.h"
r30659r30660
235235static ADDRESS_MAP_START( gcpinbal_map, AS_PROGRAM, 16, gcpinbal_state )
236236   AM_RANGE(0x000000, 0x1fffff) AM_ROM
237237   AM_RANGE(0xc00000, 0xc03fff) AM_READWRITE(gcpinbal_tilemaps_word_r, gcpinbal_tilemaps_word_w) AM_SHARE("tilemapram")
238   AM_RANGE(0xc80000, 0xc80fff) AM_RAM AM_SHARE("spriteram")   /* sprite ram */
238   AM_RANGE(0xc80000, 0xc81fff) AM_DEVREADWRITE8("spritegen", excellent_spr_device, read, write, 0x00ff)
239239   AM_RANGE(0xd00000, 0xd00fff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")
240240   AM_RANGE(0xd80000, 0xd800ff) AM_READWRITE(ioc_r, ioc_w) AM_SHARE("ioc_ram")
241241   AM_RANGE(0xff0000, 0xffffff) AM_RAM /* RAM */
r30659r30660
442442   MCFG_PALETTE_ADD("palette", 4096)
443443   MCFG_PALETTE_FORMAT(RRRRGGGGBBBBRGBx)
444444
445   MCFG_DEVICE_ADD("spritegen", EXCELLENT_SPRITE, 0)
446
445447   /* sound hardware */
446448   MCFG_SPEAKER_STANDARD_MONO("mono")
447449
trunk/src/mame/includes/aquarium.h
r30659r30660
11#include "sound/okim6295.h"
2#include "video/excellent_spr.h"
23
3
44class aquarium_state : public driver_device
55{
66public:
r30659r30660
99      m_mid_videoram(*this, "mid_videoram"),
1010      m_bak_videoram(*this, "bak_videoram"),
1111      m_txt_videoram(*this, "txt_videoram"),
12      m_spriteram(*this, "spriteram"),
1312      m_scroll(*this, "scroll"),
1413      m_audiocpu(*this, "audiocpu"),
1514      m_maincpu(*this, "maincpu"),
1615      m_oki(*this, "oki"),
1716      m_gfxdecode(*this, "gfxdecode"),
18      m_palette(*this, "palette") { }
17      m_palette(*this, "palette"),
18      m_sprgen(*this, "spritegen"){ }
1919
2020   /* memory pointers */
2121   required_shared_ptr<UINT16> m_mid_videoram;
2222   required_shared_ptr<UINT16> m_bak_videoram;
2323   required_shared_ptr<UINT16> m_txt_videoram;
24   required_shared_ptr<UINT16> m_spriteram;
2524   required_shared_ptr<UINT16> m_scroll;
2625//  UINT16 *  m_paletteram;   // currently this uses generic palette handling
2726
r30659r30660
5857   required_device<okim6295_device> m_oki;
5958   required_device<gfxdecode_device> m_gfxdecode;
6059   required_device<palette_device> m_palette;
60   required_device<excellent_spr_device> m_sprgen;
61
6162};
trunk/src/mame/includes/gcpinbal.h
r30659r30660
11
22#include "sound/okim6295.h"
33#include "sound/msm5205.h"
4#include "video/excellent_spr.h"
45
56class gcpinbal_state : public driver_device
67{
r30659r30660
1718      m_oki(*this, "oki"),
1819      m_msm(*this, "msm"),
1920      m_tilemapram(*this, "tilemapram"),
20      m_spriteram(*this, "spriteram"),
2121      m_ioc_ram(*this, "ioc_ram"),
2222      m_gfxdecode(*this, "gfxdecode"),
23      m_palette(*this, "palette")
23      m_palette(*this, "palette"),
24      m_sprgen(*this, "spritegen")
2425   { }
2526
2627   /* devices */
r30659r30660
3031
3132   /* memory pointers */
3233   required_shared_ptr<UINT16> m_tilemapram;
33   required_shared_ptr<UINT16> m_spriteram;
3434   required_shared_ptr<UINT16> m_ioc_ram;
3535
3636   required_device<gfxdecode_device> m_gfxdecode;
r30659r30660
7474   void gcpinbal_core_vh_start(  );
7575   void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs );
7676   DECLARE_WRITE_LINE_MEMBER(gcp_adpcm_int);
77   required_device<excellent_spr_device> m_sprgen;
7778
7879protected:
7980   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
trunk/src/mame/mame.mak
r30659r30660
11031103   $(DRIVERS)/d9final.o \
11041104   $(DRIVERS)/dblcrown.o \
11051105   $(DRIVERS)/gcpinbal.o $(VIDEO)/gcpinbal.o \
1106   $(VIDEO)/excellent_spr.o \
11061107   $(DRIVERS)/lastbank.o \
11071108
11081109$(MAMEOBJ)/exidy.a: \
trunk/src/mame/video/excellent_spr.c
r0r30660
1/*
2   Excellent Systems Sprite chip
3
4  is this original hw or a clone of something?
5
6  possible chips:
7  ES 9207 & ES 9303 are near the sprite ROM (aquarium)
8  ES 9208 is near the tilemap ROM so probably not the sprite chip
9
10
11  todo: collapse to single draw function instead of one for each game
12
13*/
14
15
16#include "emu.h"
17#include "excellent_spr.h"
18
19
20const device_type EXCELLENT_SPRITE = &device_creator<excellent_spr_device>;
21
22excellent_spr_device::excellent_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
23   : device_t(mconfig, EXCELLENT_SPRITE, "Excllent 8-bit Sprite", tag, owner, clock, "excellent_spr", __FILE__),
24      device_video_interface(mconfig, *this)
25{
26}
27
28
29void excellent_spr_device::device_start()
30{
31   m_ram = auto_alloc_array_clear(this->machine(), UINT8, 0x1000);
32}
33
34
35READ8_MEMBER(excellent_spr_device::read)
36{
37   return m_ram[offset];
38}
39
40WRITE8_MEMBER(excellent_spr_device::write)
41{
42   m_ram[offset] = data;
43}
44
45void excellent_spr_device::device_reset()
46{
47}
48
49
50/****************************************************************
51                     SPRITE DRAW ROUTINE
52                (8-bit)
53
54    Word |     Bit(s)      | Use
55    -----+-----------------+-----------------
56      0  | xxxxxxxx| X lo
57      1  | xxxxxxxx| X hi
58      2  | xxxxxxxx| Y lo
59      3  | xxxxxxxx| Y hi
60      4  | x.......| Disable
61      4  | ...x....| Flip Y
62      4  | ....x...| 1 = Y chain, 0 = X chain
63      4  | .....xxx| Chain size
64      5  | ??xxxxxx| Tile (low)
65      6  | xxxxxxxx| Tile (high)
66      7  | ....xxxx| Color Bank
67
68****************************************************************/
69
70
71void excellent_spr_device::aquarium_draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int y_offs )
72{
73
74   int offs, chain_pos;
75   int x, y, curx, cury;
76   UINT8 col, flipx, flipy, chain;
77   UINT16 code;
78
79   for (offs = 0; offs < 0x1000; offs += 8)
80   {
81      code = ((m_ram[offs + 5]) & 0xff) + (((m_ram[offs + 6]) & 0xff) << 8);
82      code &= 0x3fff;
83
84      if (!(m_ram[offs + 4] &0x80))  /* active sprite ? */
85      {
86         x = ((m_ram[offs + 0]) &0xff) + (((m_ram[offs + 1]) & 0xff) << 8);
87         y = ((m_ram[offs + 2]) &0xff) + (((m_ram[offs + 3]) & 0xff) << 8);
88
89         /* Treat coords as signed */
90         if (x & 0x8000)  x -= 0x10000;
91         if (y & 0x8000)  y -= 0x10000;
92
93         col = ((m_ram[offs + 7]) & 0x0f);
94         chain = (m_ram[offs + 4]) & 0x07;
95         flipy = (m_ram[offs + 4]) & 0x10;
96         flipx = (m_ram[offs + 4]) & 0x20;
97
98         curx = x;
99         cury = y;
100
101         if (((m_ram[offs + 4]) & 0x08) && flipy)
102            cury += (chain * 16);
103
104         if (!(((m_ram[offs + 4]) & 0x08)) && flipx)
105            curx += (chain * 16);
106
107
108         for (chain_pos = chain; chain_pos >= 0; chain_pos--)
109         {
110            gfxdecode->gfx(0)->transpen(bitmap,cliprect,
111                  code,
112                  col,
113                  flipx, flipy,
114                  curx,cury,0);
115
116            /* wrap around y */
117            gfxdecode->gfx(0)->transpen(bitmap,cliprect,
118                  code,
119                  col,
120                  flipx, flipy,
121                  curx,cury + 256,0);
122
123            code++;
124
125            if ((m_ram[offs + 4]) &0x08)   /* Y chain */
126            {
127               if (flipy)
128                  cury -= 16;
129               else
130                  cury += 16;
131            }
132            else    /* X chain */
133            {
134               if (flipx)
135                  curx -= 16;
136               else
137                  curx += 16;
138            }
139         }
140      }
141   }
142
143#if 0
144   if (rotate)
145   {
146      char buf[80];
147      sprintf(buf, "sprite rotate offs %04x ?", rotate);
148      popmessage(buf);
149   }
150#endif
151}
152
153void excellent_spr_device::gcpinbal_draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int y_offs, int priority )
154{
155   UINT8 *spriteram = m_ram;
156   int offs, chain_pos;
157   int x, y, curx, cury;
158//   int priority = 0;
159   UINT8 col, flipx, flipy, chain;
160   UINT16 code;
161
162
163   for (offs = 0x1000 - 8; offs >= 0; offs -= 8)
164   {
165      code = ((spriteram[offs + 5]) & 0xff) + (((spriteram[offs + 6]) & 0xff) << 8);
166      code &= 0x3fff;
167
168      if (!(spriteram[offs + 4] &0x80))   /* active sprite ? */
169      {
170         x = ((spriteram[offs + 0]) & 0xff) + (((spriteram[offs + 1]) & 0xff) << 8);
171         y = ((spriteram[offs + 2]) & 0xff) + (((spriteram[offs + 3]) & 0xff) << 8);
172
173         /* Treat coords as signed */
174         if (x & 0x8000)  x -= 0x10000;
175         if (y & 0x8000)  y -= 0x10000;
176
177         col  = ((spriteram[offs + 7]) & 0x0f) | 0x60;
178         chain = (spriteram[offs + 4]) & 0x07;
179         flipy = (spriteram[offs + 4]) & 0x10;
180         flipx = 0;
181
182         curx = x;
183         cury = y;
184
185         if (((spriteram[offs + 4]) & 0x08) && flipy)
186            cury += (chain * 16);
187
188         for (chain_pos = chain; chain_pos >= 0; chain_pos--)
189         {
190            gfxdecode->gfx(0)->prio_transpen(bitmap,cliprect,
191                  code,
192                  col,
193                  flipx, flipy,
194                  curx,cury,
195                  screen.priority(),
196                  priority ? 0xfc : 0xf0,0);
197
198            code++;
199
200            if ((spriteram[offs + 4]) & 0x08)   /* Y chain */
201            {
202               if (flipy)  cury -= 16;
203               else cury += 16;
204            }
205            else    /* X chain */
206            {
207               curx += 16;
208            }
209         }
210      }
211   }
212#if 0
213   if (rotate)
214   {
215      char buf[80];
216      sprintf(buf, "sprite rotate offs %04x ?", rotate);
217      popmessage(buf);
218   }
219#endif
220}
221
Property changes on: trunk/src/mame/video/excellent_spr.c
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/mame/video/excellent_spr.h
r0r30660
1
2class excellent_spr_device : public device_t,
3                  public device_video_interface
4{
5public:
6   excellent_spr_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
7
8   void draw_sprites(screen_device &screen, gfxdecode_device *gfxdecode, const rectangle &cliprect);
9
10   DECLARE_READ8_MEMBER(read);
11   DECLARE_WRITE8_MEMBER(write);
12
13   void aquarium_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int y_offs);
14   void gcpinbal_draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, gfxdecode_device *gfxdecode, int y_offs, int priority);
15
16protected:
17   UINT8* m_ram;
18   
19   virtual void device_start();
20   virtual void device_reset();
21private:
22};
23
24extern const device_type EXCELLENT_SPRITE;
25
26
Property changes on: trunk/src/mame/video/excellent_spr.h
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/mame/video/aquarium.c
r30659r30660
33#include "emu.h"
44#include "includes/aquarium.h"
55
6/* gcpinbal.c modified */
7void aquarium_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs )
8{
9   int offs, chain_pos;
10   int x, y, curx, cury;
11   UINT8 col, flipx, flipy, chain;
12   UINT16 code;
136
14   for (offs = 0; offs < m_spriteram.bytes() / 2; offs += 8)
15   {
16      code = ((m_spriteram[offs + 5]) & 0xff) + (((m_spriteram[offs + 6]) & 0xff) << 8);
17      code &= 0x3fff;
18
19      if (!(m_spriteram[offs + 4] &0x80))  /* active sprite ? */
20      {
21         x = ((m_spriteram[offs + 0]) &0xff) + (((m_spriteram[offs + 1]) & 0xff) << 8);
22         y = ((m_spriteram[offs + 2]) &0xff) + (((m_spriteram[offs + 3]) & 0xff) << 8);
23
24         /* Treat coords as signed */
25         if (x & 0x8000)  x -= 0x10000;
26         if (y & 0x8000)  y -= 0x10000;
27
28         col = ((m_spriteram[offs + 7]) & 0x0f);
29         chain = (m_spriteram[offs + 4]) & 0x07;
30         flipy = (m_spriteram[offs + 4]) & 0x10;
31         flipx = (m_spriteram[offs + 4]) & 0x20;
32
33         curx = x;
34         cury = y;
35
36         if (((m_spriteram[offs + 4]) & 0x08) && flipy)
37            cury += (chain * 16);
38
39         if (!(((m_spriteram[offs + 4]) & 0x08)) && flipx)
40            curx += (chain * 16);
41
42
43         for (chain_pos = chain; chain_pos >= 0; chain_pos--)
44         {
45            m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,
46                  code,
47                  col,
48                  flipx, flipy,
49                  curx,cury,0);
50
51            /* wrap around y */
52            m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,
53                  code,
54                  col,
55                  flipx, flipy,
56                  curx,cury + 256,0);
57
58            code++;
59
60            if ((m_spriteram[offs + 4]) &0x08)   /* Y chain */
61            {
62               if (flipy)
63                  cury -= 16;
64               else
65                  cury += 16;
66            }
67            else    /* X chain */
68            {
69               if (flipx)
70                  curx -= 16;
71               else
72                  curx += 16;
73            }
74         }
75      }
76   }
77#if 0
78   if (rotate)
79   {
80      char buf[80];
81      sprintf(buf, "sprite rotate offs %04x ?", rotate);
82      popmessage(buf);
83   }
84#endif
85}
86
877/* TXT Layer */
888TILE_GET_INFO_MEMBER(aquarium_state::get_aquarium_txt_tile_info)
899{
r30659r30660
16282   m_bak_tilemap->draw(screen, bitmap, cliprect, 0, 0);
16383   m_mid_tilemap->draw(screen, bitmap, cliprect, 0, 0);
16484
165   draw_sprites(bitmap, cliprect, 16);
85   m_sprgen->aquarium_draw_sprites(bitmap, cliprect, m_gfxdecode, 16);
16686
16787   m_bak_tilemap->draw(screen, bitmap, cliprect, 1, 0);
16888   m_mid_tilemap->draw(screen, bitmap, cliprect, 1, 0);
trunk/src/mame/video/gcpinbal.c
r30659r30660
8787}
8888
8989
90#ifdef UNUSED_FUNCTION
9190
92READ16_MEMBER(gcpinbal_state::gcpinbal_ctrl_word_r)
93{
94   // ***** NOT HOOKED UP *****
95
96   return gcpinbal_piv_ctrlram[offset];
97}
98
99
100WRITE16_MEMBER(gcpinbal_state::gcpinbal_ctrl_word_w)
101{
102   // ***** NOT HOOKED UP *****
103
104   COMBINE_DATA(&gcpinbal_piv_ctrlram[offset]);
105   data = gcpinbal_piv_ctrlram[offset];
106
107   switch (offset)
108   {
109      case 0x00:
110         gcpinbal_scrollx[0] = -data;
111         break;
112
113      case 0x01:
114         gcpinbal_scrollx[1] = -data;
115         break;
116
117      case 0x02:
118         gcpinbal_scrollx[2] = -data;
119         break;
120
121      case 0x03:
122         gcpinbal_scrolly[0] = data;
123         break;
124
125      case 0x04:
126         gcpinbal_scrolly[1] = data;
127         break;
128
129      case 0x05:
130         gcpinbal_scrolly[2] = data;
131         break;
132
133      case 0x06:
134         gcpinbal_ctrl_reg = data;
135         break;
136   }
137}
138
139#endif
140
141
142/****************************************************************
143                     SPRITE DRAW ROUTINE
144
145    Word |     Bit(s)      | Use
146    -----+-----------------+-----------------
147      0  |........ xxxxxxxx| X lo
148      1  |........ xxxxxxxx| X hi
149      2  |........ xxxxxxxx| Y lo
150      3  |........ xxxxxxxx| Y hi
151      4  |........ x.......| Disable
152      4  |........ ...x....| Flip Y
153      4  |........ ....x...| 1 = Y chain, 0 = X chain
154      4  |........ .....xxx| Chain size
155      5  |........ ??xxxxxx| Tile (low)
156      6  |........ xxxxxxxx| Tile (high)
157      7  |........ ....xxxx| Color Bank
158
159    Modified table from Raine
160
161****************************************************************/
162
163void gcpinbal_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int y_offs )
164{
165   UINT16 *spriteram = m_spriteram;
166   int offs, chain_pos;
167   int x, y, curx, cury;
168   int priority = 0;
169   UINT8 col, flipx, flipy, chain;
170   UINT16 code;
171
172   /* According to Raine, word in ioc_ram determines sprite/tile priority... */
173   priority = (m_ioc_ram[0x68 / 2] & 0x8800) ? 0 : 1;
174
175   for (offs = m_spriteram.bytes() / 2 - 8; offs >= 0; offs -= 8)
176   {
177      code = ((spriteram[offs + 5]) & 0xff) + (((spriteram[offs + 6]) & 0xff) << 8);
178      code &= 0x3fff;
179
180      if (!(spriteram[offs + 4] &0x80))   /* active sprite ? */
181      {
182         x = ((spriteram[offs + 0]) & 0xff) + (((spriteram[offs + 1]) & 0xff) << 8);
183         y = ((spriteram[offs + 2]) & 0xff) + (((spriteram[offs + 3]) & 0xff) << 8);
184
185         /* Treat coords as signed */
186         if (x & 0x8000)  x -= 0x10000;
187         if (y & 0x8000)  y -= 0x10000;
188
189         col  = ((spriteram[offs + 7]) & 0x0f) | 0x60;
190         chain = (spriteram[offs + 4]) & 0x07;
191         flipy = (spriteram[offs + 4]) & 0x10;
192         flipx = 0;
193
194         curx = x;
195         cury = y;
196
197         if (((spriteram[offs + 4]) & 0x08) && flipy)
198            cury += (chain * 16);
199
200         for (chain_pos = chain; chain_pos >= 0; chain_pos--)
201         {
202            m_gfxdecode->gfx(0)->prio_transpen(bitmap,cliprect,
203                  code,
204                  col,
205                  flipx, flipy,
206                  curx,cury,
207                  screen.priority(),
208                  priority ? 0xfc : 0xf0,0);
209
210            code++;
211
212            if ((spriteram[offs + 4]) & 0x08)   /* Y chain */
213            {
214               if (flipy)  cury -= 16;
215               else cury += 16;
216            }
217            else    /* X chain */
218            {
219               curx += 16;
220            }
221         }
222      }
223   }
224#if 0
225   if (rotate)
226   {
227      char buf[80];
228      sprintf(buf, "sprite rotate offs %04x ?", rotate);
229      popmessage(buf);
230   }
231#endif
232}
233
234
235
236
23791/**************************************************************
23892                        SCREEN REFRESH
23993**************************************************************/
r30659r30660
304158#endif
305159   m_tilemap[layer[2]]->draw(screen, bitmap, cliprect, 0, 4);
306160
161   int sprpri = (m_ioc_ram[0x68 / 2] & 0x8800) ? 0 : 1;
162   m_sprgen->gcpinbal_draw_sprites(screen, bitmap, cliprect, m_gfxdecode, 16, sprpri);
307163
308   draw_sprites(screen, bitmap, cliprect, 16);
309
310164#if 0
311165   {
312166//      char buf[80];

Previous 199869 Revisions Next


© 1997-2024 The MAME Team