Previous 199869 Revisions Next

r24876 Tuesday 13th August, 2013 at 17:15:54 UTC by Osso
Modernized the s2636 video device. Will try to merge the audio and video devices in one file next. (nw)
[src/emu/video]s2636.c s2636.h
[src/mame/drivers]cvs.c galaxia.c laserbat.c malzak.c quasar.c seabattl.c
[src/mame/includes]cvs.h laserbat.h malzak.h
[src/mame/video]cvs.c galaxia.c malzak.c quasar.c

trunk/src/mame/includes/cvs.h
r24875r24876
66
77#include "sound/dac.h"
88#include "sound/tms5110.h"
9#include "video/s2636.h"
910
1011#define CVS_S2636_Y_OFFSET     (3)
1112#define CVS_S2636_X_OFFSET     (-26)
r24875r24876
3132         m_audiocpu(*this, "audiocpu"),
3233         m_dac2(*this, "dac2"),
3334         m_dac3(*this, "dac3"),
34         m_tms5110(*this, "tms")
35         m_tms5110(*this, "tms"),
36         m_s2636_0(*this, "s2636_0"),
37         m_s2636_1(*this, "s2636_1"),
38         m_s2636_2(*this, "s2636_2")
3539   {
3640   }
3741
r24875r24876
6973   optional_device<dac_device> m_dac2;
7074   optional_device<dac_device> m_dac3;
7175   optional_device<tms5110_device> m_tms5110;
72   device_t *m_s2636_0;
73   device_t *m_s2636_1;
74   device_t *m_s2636_2;
76   optional_device<s2636_device> m_s2636_0;
77   optional_device<s2636_device> m_s2636_1;
78   optional_device<s2636_device> m_s2636_2;
7579
7680   /* memory */
7781   UINT8      m_color_ram[0x400];
trunk/src/mame/includes/laserbat.h
r24875r24876
66
77#include "machine/6821pia.h"
88#include "sound/ay8910.h"
9#include "video/s2636.h"
910
1011class laserbat_state : public driver_device
1112{
r24875r24876
1617      m_audiocpu(*this, "audiocpu"),
1718      m_fo_state(*this, "fo_state"),
1819      m_ay1(*this, "ay1"),
19      m_ay2(*this, "ay2")
20      m_ay2(*this, "ay2"),
21      m_s2636_1(*this, "s2636_1"),
22      m_s2636_2(*this, "s2636_2"),
23      m_s2636_3(*this, "s2636_3")
2024   {
2125   }
2226
r24875r24876
2529   required_shared_ptr<UINT8> m_fo_state;
2630   optional_device<ay8910_device> m_ay1;
2731   optional_device<ay8910_device> m_ay2;
32   required_device<s2636_device> m_s2636_1;
33   required_device<s2636_device> m_s2636_2;
34   required_device<s2636_device> m_s2636_3;
2835
2936   /* video-related */
3037   tilemap_t    *m_bg_tilemap;
r24875r24876
5663   int        m_bit14;
5764
5865   /* device */
59   device_t *m_s2636_1;
60   device_t *m_s2636_2;
61   device_t *m_s2636_3;
6266   pia6821_device *m_pia;
6367   device_t *m_sn;
6468   tms3615_device *m_tms1;
trunk/src/mame/includes/malzak.h
r24875r24876
44
55*************************************************************************/
66
7#include "video/s2636.h"
78#include "video/saa5050.h"
89
910class malzak_state : public driver_device
r24875r24876
1112public:
1213   malzak_state(const machine_config &mconfig, device_type type, const char *tag)
1314      : driver_device(mconfig, type, tag),
15         m_maincpu(*this, "maincpu"),
16         m_s2636_0(*this, "s2636_0"),
17         m_s2636_1(*this, "s2636_1"),
1418         m_trom(*this, "saa5050"),
15         m_videoram(*this, "videoram"),
16      m_maincpu(*this, "maincpu") { }
19         m_videoram(*this, "videoram") { }
1720
21   required_device<cpu_device> m_maincpu;
22   required_device<s2636_device> m_s2636_0;
23   required_device<s2636_device> m_s2636_1;
1824   required_device<saa5050_device> m_trom;
1925   required_shared_ptr<UINT8> m_videoram;
2026
r24875r24876
2733   int m_collision_counter;
2834
2935   /* devices */
30   device_t *m_s2636_0;
31   device_t *m_s2636_1;
3236   device_t *m_saa5050;
3337   DECLARE_READ8_MEMBER(fake_VRLE_r);
3438   DECLARE_READ8_MEMBER(s2636_portA_r);
r24875r24876
4347   virtual void machine_reset();
4448   virtual void palette_init();
4549   UINT32 screen_update_malzak(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
46   required_device<cpu_device> m_maincpu;
4750};
trunk/src/mame/video/galaxia.c
r24875r24876
77***************************************************************************/
88
99#include "emu.h"
10#include "video/s2636.h"
1110#include "includes/galaxia.h"
1211
1312#define SPRITE_PEN_BASE     (0x10)
r24875r24876
111110{
112111   int x, y;
113112
114   bitmap_ind16 &s2636_0_bitmap = s2636_update(machine().device("s2636_0"), cliprect);
115   bitmap_ind16 &s2636_1_bitmap = s2636_update(machine().device("s2636_1"), cliprect);
116   bitmap_ind16 &s2636_2_bitmap = s2636_update(machine().device("s2636_2"), cliprect);
113   bitmap_ind16 *s2636_0_bitmap = &m_s2636_0->update(cliprect);
114   bitmap_ind16 *s2636_1_bitmap = &m_s2636_1->update(cliprect);
115   bitmap_ind16 *s2636_2_bitmap = &m_s2636_2->update(cliprect);
117116
118117   bitmap.fill(0, cliprect);
119118   cvs_update_stars(bitmap, cliprect, STAR_PEN, 1);
r24875r24876
138137         }
139138
140139         // copy the S2636 images into the main bitmap and check collision
141         int pixel0 = s2636_0_bitmap.pix16(y, x);
142         int pixel1 = s2636_1_bitmap.pix16(y, x);
143         int pixel2 = s2636_2_bitmap.pix16(y, x);
140         int pixel0 = s2636_0_bitmap->pix16(y, x);
141         int pixel1 = s2636_1_bitmap->pix16(y, x);
142         int pixel2 = s2636_2_bitmap->pix16(y, x);
144143
145144         int pixel = pixel0 | pixel1 | pixel2;
146145
r24875r24876
177176   // astrowar has only one S2636
178177   int x, y;
179178
180   bitmap_ind16 &s2636_0_bitmap = s2636_update(machine().device("s2636_0"), cliprect);
179   bitmap_ind16 &s2636_0_bitmap = m_s2636_0->update(cliprect);
181180
182181   bitmap.fill(0, cliprect);
183182   cvs_update_stars(bitmap, cliprect, STAR_PEN, 1);
trunk/src/mame/video/malzak.c
r24875r24876
1313
1414
1515#include "emu.h"
16#include "video/s2636.h"
1716#include "video/saa5050.h"
1817#include "includes/malzak.h"
1918
r24875r24876
4342      }
4443
4544   /* update the S2636 chips */
46   bitmap_ind16 &s2636_0_bitmap = s2636_update(m_s2636_0, cliprect);
47   bitmap_ind16 &s2636_1_bitmap = s2636_update(m_s2636_1, cliprect);
45   bitmap_ind16 &s2636_0_bitmap = m_s2636_0->update(cliprect);
46   bitmap_ind16 &s2636_1_bitmap = m_s2636_1->update(cliprect);
4847
4948   /* copy the S2636 images into the main bitmap */
5049   {
trunk/src/mame/video/cvs.c
r24875r24876
99#include "emu.h"
1010#include "cpu/s2650/s2650.h"
1111#include "includes/cvs.h"
12#include "video/s2636.h"
1312
1413
1514#define SPRITE_PEN_BASE     (0x820)
r24875r24876
192191   copyscrollbitmap(m_scrolled_collision_background, m_collision_background, 0, 0, 8, scroll, cliprect);
193192
194193   /* update the S2636 chips */
195   bitmap_ind16 &s2636_0_bitmap = s2636_update(m_s2636_0, cliprect);
196   bitmap_ind16 &s2636_1_bitmap = s2636_update(m_s2636_1, cliprect);
197   bitmap_ind16 &s2636_2_bitmap = s2636_update(m_s2636_2, cliprect);
194   bitmap_ind16 *s2636_0_bitmap = &m_s2636_0->update(cliprect);
195   bitmap_ind16 *s2636_1_bitmap = &m_s2636_1->update(cliprect);
196   bitmap_ind16 *s2636_2_bitmap = &m_s2636_2->update(cliprect);
198197
199198   /* Bullet Hardware */
200199   for (offs = 8; offs < 256; offs++ )
r24875r24876
207206            int bx = 255 - 7 - m_bullet_ram[offs] - ct;
208207
209208            /* Bullet/Object Collision */
210            if ((s2636_0_bitmap.pix16(offs, bx) != 0) ||
211               (s2636_1_bitmap.pix16(offs, bx) != 0) ||
212               (s2636_2_bitmap.pix16(offs, bx) != 0))
209            if ((s2636_0_bitmap->pix16(offs, bx) != 0) ||
210               (s2636_1_bitmap->pix16(offs, bx) != 0) ||
211               (s2636_2_bitmap->pix16(offs, bx) != 0))
213212               m_collision_register |= 0x08;
214213
215214            /* Bullet/Background Collision */
r24875r24876
232231
233232         for (x = cliprect.min_x; x <= cliprect.max_x; x++)
234233         {
235            int pixel0 = s2636_0_bitmap.pix16(y, x);
236            int pixel1 = s2636_1_bitmap.pix16(y, x);
237            int pixel2 = s2636_2_bitmap.pix16(y, x);
234            int pixel0 = s2636_0_bitmap->pix16(y, x);
235            int pixel1 = s2636_1_bitmap->pix16(y, x);
236            int pixel2 = s2636_2_bitmap->pix16(y, x);
238237
239238            int pixel = pixel0 | pixel1 | pixel2;
240239
trunk/src/mame/video/quasar.c
r24875r24876
1515***************************************************************************/
1616
1717#include "emu.h"
18#include "video/s2636.h"
1918#include "cpu/s2650/s2650.h"
2019#include "includes/quasar.h"
2120
r24875r24876
144143   }
145144
146145   /* update the S2636 chips */
147   bitmap_ind16 &s2636_0_bitmap = s2636_update(m_s2636_0, cliprect);
148   bitmap_ind16 &s2636_1_bitmap = s2636_update(m_s2636_1, cliprect);
149   bitmap_ind16 &s2636_2_bitmap = s2636_update(m_s2636_2, cliprect);
146   bitmap_ind16 &s2636_0_bitmap = m_s2636_0->update(cliprect);
147   bitmap_ind16 &s2636_1_bitmap = m_s2636_1->update(cliprect);
148   bitmap_ind16 &s2636_2_bitmap = m_s2636_2->update(cliprect);
150149
151150   /* Bullet Hardware */
152151   for (offs = 8; offs < 256; offs++ )
trunk/src/mame/drivers/galaxia.c
r24875r24876
6161*/
6262
6363#include "emu.h"
64#include "video/s2636.h"
6564#include "sound/s2636.h"
6665#include "cpu/s2650/s2650.h"
6766#include "includes/galaxia.h"
r24875r24876
123122static ADDRESS_MAP_START( galaxia_mem_map, AS_PROGRAM, 8, galaxia_state )
124123   AM_RANGE(0x0000, 0x13ff) AM_ROM
125124   AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("bullet_ram")
126   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_0", s2636_work_ram_r, s2636_work_ram_w)
127   AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_1", s2636_work_ram_r, s2636_work_ram_w)
128   AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_2", s2636_work_ram_r, s2636_work_ram_w)
125   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_device, work_ram_r, work_ram_w)
126   AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_device, work_ram_r, work_ram_w)
127   AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_2", s2636_device, work_ram_r, work_ram_w)
129128   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READ(cvs_video_or_color_ram_r) AM_WRITE(galaxia_video_w) AM_SHARE("video_ram")
130129   AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM
131130   AM_RANGE(0x2000, 0x33ff) AM_ROM
r24875r24876
135134static ADDRESS_MAP_START( astrowar_mem_map, AS_PROGRAM, 8, galaxia_state )
136135   AM_RANGE(0x0000, 0x13ff) AM_ROM
137136   AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_RAM
138   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_0", s2636_work_ram_r, s2636_work_ram_w)
137   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_device, work_ram_r, work_ram_w)
139138   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READ(cvs_video_or_color_ram_r) AM_WRITE(galaxia_video_w)  AM_SHARE("video_ram")
140139   AM_RANGE(0x1c00, 0x1cff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("bullet_ram")
141140   AM_RANGE(0x2000, 0x33ff) AM_ROM
r24875r24876
277276
278277static const s2636_interface galaxia_s2636_config[3] =
279278{
280   { "screen", 0x100, 3, -26, "s2636snd_0" },
281   { "screen", 0x100, 3, -26, "s2636snd_1" },
282   { "screen", 0x100, 3, -26, "s2636snd_2" }
279   { 0x100, 3, -26, "s2636snd_0" },
280   { 0x100, 3, -26, "s2636snd_1" },
281   { 0x100, 3, -26, "s2636snd_2" }
283282};
284283
285284static const s2636_interface astrowar_s2636_config =
286285{
287   "screen",
288286   0x100,
289287   3, 0,
290288   "s2636snd_0"
trunk/src/mame/drivers/malzak.c
r24875r24876
6666#include "cpu/s2650/s2650.h"
6767#include "sound/sn76477.h"
6868#include "sound/s2636.h"
69#include "video/s2636.h"
7069#include "video/saa5050.h"
7170#include "machine/nvram.h"
7271#include "includes/malzak.h"
r24875r24876
7473
7574READ8_MEMBER(malzak_state::fake_VRLE_r)
7675{
77   return (s2636_work_ram_r(m_s2636_0, space, 0xcb) & 0x3f) + (m_screen->vblank() * 0x40);
76   return (m_s2636_0->work_ram_r(space, 0xcb) & 0x3f) + (m_screen->vblank() * 0x40);
7877}
7978
8079READ8_MEMBER(malzak_state::s2636_portA_r)
r24875r24876
106105   AM_RANGE(0x1200, 0x12ff) AM_MIRROR(0x6000) AM_RAM
107106   AM_RANGE(0x1300, 0x13ff) AM_MIRROR(0x6000) AM_RAM
108107   AM_RANGE(0x14cb, 0x14cb) AM_MIRROR(0x6000) AM_READ(fake_VRLE_r)
109   AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_0", s2636_work_ram_r, s2636_work_ram_w)
110   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_1", s2636_work_ram_r, s2636_work_ram_w)
108   AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_device, work_ram_r, work_ram_w)
109   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_device, work_ram_r, work_ram_w)
111110   AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_RAM_WRITE(malzak_playfield_w)
112111   AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_RAM
113112   AM_RANGE(0x1800, 0x1fff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("videoram")
r24875r24876
127126   AM_RANGE(0x1300, 0x13ff) AM_MIRROR(0x6000) AM_RAM
128127   AM_RANGE(0x14cb, 0x14cb) AM_MIRROR(0x6000) AM_READ(fake_VRLE_r)
129128   AM_RANGE(0x14cc, 0x14cc) AM_MIRROR(0x6000) AM_READ(s2636_portA_r)
130   AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_0", s2636_work_ram_r, s2636_work_ram_w)
131   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_1", s2636_work_ram_r, s2636_work_ram_w)
129   AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_device, work_ram_r, work_ram_w)
130   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_device, work_ram_r, work_ram_w)
132131   AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_RAM_WRITE(malzak_playfield_w)
133132   AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("nvram")
134133   AM_RANGE(0x1800, 0x1fff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("videoram")
r24875r24876
303302
304303static const s2636_interface malzac_s2636_0_config =
305304{
306   "screen",
307305   0x100,
308306   0, -16, /* -8, -16 */
309307   "s2636snd_0"
r24875r24876
311309
312310static const s2636_interface malzac_s2636_1_config =
313311{
314   "screen",
315312   0x100,
316313   0, -16, /* -9, -16 */
317314   "s2636snd_1"
r24875r24876
332329{
333330   membank("bank1")->configure_entries(0, 2, memregion("user2")->base(), 0x400);
334331
335   m_s2636_0 = machine().device("s2636_0");
336   m_s2636_1 = machine().device("s2636_1");
337332   m_saa5050 = machine().device("saa5050");
338333
339334   save_item(NAME(m_playfield_code));
trunk/src/mame/drivers/laserbat.c
r24875r24876
2222#include "machine/6821pia.h"
2323#include "sound/sn76477.h"
2424#include "sound/tms3615.h"
25#include "video/s2636.h"
2625#include "includes/laserbat.h"
2726
2827
r24875r24876
165164   AM_RANGE(0x7800, 0x7bff) AM_ROM
166165
167166   AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_WRITENOP // always 0 (bullet ram in Quasar)
168   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_1", s2636_work_ram_r, s2636_work_ram_w)
169   AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_2", s2636_work_ram_r, s2636_work_ram_w)
170   AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_3", s2636_work_ram_r, s2636_work_ram_w)
167   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_device, work_ram_r, work_ram_w)
168   AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_2", s2636_device, work_ram_r, work_ram_w)
169   AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_3", s2636_device, work_ram_r, work_ram_w)
171170   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_WRITE(laserbat_videoram_w)
172171   AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM
173172ADDRESS_MAP_END
r24875r24876
498497   m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
499498
500499   /* update the S2636 chips */
501   bitmap_ind16 &s2636_1_bitmap = s2636_update(m_s2636_1, cliprect);
502   bitmap_ind16 &s2636_2_bitmap = s2636_update(m_s2636_2, cliprect);
503   bitmap_ind16 &s2636_3_bitmap = s2636_update(m_s2636_3, cliprect);
500   bitmap_ind16 &s2636_1_bitmap = m_s2636_1->update(cliprect);
501   bitmap_ind16 &s2636_2_bitmap = m_s2636_2->update(cliprect);
502   bitmap_ind16 &s2636_3_bitmap = m_s2636_3->update(cliprect);
504503
505504   /* copy the S2636 images into the main bitmap */
506505   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
r24875r24876
657656
658657static const s2636_interface s2636_1_config =
659658{
660   "screen",
661659   0x100,
662660   0, -19,
663661   NULL
r24875r24876
665663
666664static const s2636_interface s2636_2_config =
667665{
668   "screen",
669666   0x100,
670667   0, -19,
671668   NULL
r24875r24876
673670
674671static const s2636_interface s2636_3_config =
675672{
676   "screen",
677673   0x100,
678674   0, -19,
679675   NULL
r24875r24876
681677
682678void laserbat_state::machine_start()
683679{
684   m_s2636_1 = machine().device("s2636_1");
685   m_s2636_2 = machine().device("s2636_2");
686   m_s2636_3 = machine().device("s2636_3");
687680   m_pia = machine().device<pia6821_device>("pia");
688681   m_sn = machine().device("snsnd");
689682   m_tms1 = machine().device<tms3615_device>("tms1");
trunk/src/mame/drivers/cvs.c
r24875r24876
9292
9393#include "emu.h"
9494#include "cpu/s2650/s2650.h"
95#include "sound/dac.h"
96#include "video/s2636.h"
9795#include "includes/cvs.h"
9896
9997
r24875r24876
150148   if (*m_fo_state)
151149      return m_character_ram[(0 * 0x800) | 0x400 | m_character_ram_page_start | offset];
152150   else
153      return s2636_work_ram_r(m_s2636_0, space, offset);
151      return m_s2636_0->work_ram_r(space, offset);
154152}
155153
156154WRITE8_MEMBER(cvs_state::cvs_s2636_0_or_character_ram_w)
r24875r24876
162160      machine().gfx[1]->mark_dirty((offset / 8) % 256);
163161   }
164162   else
165      s2636_work_ram_w(m_s2636_0, space, offset, data);
163      m_s2636_0->work_ram_w(space, offset, data);
166164}
167165
168166
r24875r24876
171169   if (*m_fo_state)
172170      return m_character_ram[(1 * 0x800) | 0x400 | m_character_ram_page_start | offset];
173171   else
174      return s2636_work_ram_r(m_s2636_1, space, offset);
172      return m_s2636_1->work_ram_r(space, offset);
175173}
176174
177175WRITE8_MEMBER(cvs_state::cvs_s2636_1_or_character_ram_w)
r24875r24876
183181      machine().gfx[1]->mark_dirty((offset / 8) % 256);
184182   }
185183   else
186      s2636_work_ram_w(m_s2636_1, space, offset, data);
184      m_s2636_1->work_ram_w(space, offset, data);
187185}
188186
189187
r24875r24876
192190   if (*m_fo_state)
193191      return m_character_ram[(2 * 0x800) | 0x400 | m_character_ram_page_start | offset];
194192   else
195      return s2636_work_ram_r(m_s2636_2, space, offset);
193      return m_s2636_2->work_ram_r(space, offset);
196194}
197195
198196WRITE8_MEMBER(cvs_state::cvs_s2636_2_or_character_ram_w)
r24875r24876
204202      machine().gfx[1]->mark_dirty((offset / 8) % 256);
205203   }
206204   else
207      s2636_work_ram_w(m_s2636_2, space, offset, data);
205      m_s2636_2->work_ram_w(space, offset, data);
208206}
209207
210208
r24875r24876
945943
946944static const s2636_interface s2636_0_config =
947945{
948   "screen",
949946   0x100,
950947   CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET,
951948   NULL
r24875r24876
953950
954951static const s2636_interface s2636_1_config =
955952{
956   "screen",
957953   0x100,
958954   CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET,
959955   NULL
r24875r24876
961957
962958static const s2636_interface s2636_2_config =
963959{
964   "screen",
965960   0x100,
966961   CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET,
967962   NULL
r24875r24876
978973
979974   /* set devices */
980975   m_speech = machine().device("speech");
981   m_s2636_0 = machine().device("s2636_0");
982   m_s2636_1 = machine().device("s2636_1");
983   m_s2636_2 = machine().device("s2636_2");
984976
985977   /* register state save */
986978   save_item(NAME(m_color_ram));
trunk/src/mame/drivers/seabattl.c
r24875r24876
5252      m_digit3(*this, "sc_unity"),
5353      m_digit4(*this, "tm_half"),
5454      m_digit5(*this, "tm_unity"),
55      m_s2636(*this, "s2636"),
5556      m_waveenable(false),
5657      m_collision(0)
5758   {
r24875r24876
6768   required_device<dm9368_device> m_digit3;
6869   required_device<dm9368_device> m_digit4;
6970   required_device<dm9368_device> m_digit5;
71   required_device<s2636_device> m_s2636;
7072
7173   tilemap_t *m_bg_tilemap;
7274   bitmap_ind16 m_collision_bg;
r24875r24876
181183      }
182184   }
183185
184   bitmap_ind16 &s2636_0_bitmap = s2636_update(machine().device("s2636"), cliprect);
186   bitmap_ind16 &s2636_0_bitmap = m_s2636->update(cliprect);
185187
186188   // collisions
187189   for (y = cliprect.min_y; y <= cliprect.max_y; y++)
r24875r24876
252254   AM_RANGE(0x1e06, 0x1e06) AM_MIRROR(0x20f0) AM_READ_PORT("DIPS1") AM_WRITE(sound_w)
253255   AM_RANGE(0x1e07, 0x1e07) AM_MIRROR(0x20f0) AM_READ_PORT("DIPS0") AM_WRITE(sound2_w)
254256   AM_RANGE(0x1fcc, 0x1fcc) AM_MIRROR(0x2000) AM_READ_PORT("IN1")
255   AM_RANGE(0x1f00, 0x1fff) AM_MIRROR(0x2000) AM_DEVREADWRITE_LEGACY("s2636", s2636_work_ram_r, s2636_work_ram_w)
257   AM_RANGE(0x1f00, 0x1fff) AM_MIRROR(0x2000) AM_DEVREADWRITE("s2636", s2636_device, work_ram_r, work_ram_w)
256258ADDRESS_MAP_END
257259
258260static ADDRESS_MAP_START( seabattl_io_map, AS_IO, 8, seabattl_state )
r24875r24876
467469
468470static const s2636_interface s2636_config =
469471{
470   "screen",
471472   0x100,
472473   3, -21,
473474   "s2636snd"
trunk/src/mame/drivers/quasar.c
r24875r24876
3131#include "cpu/s2650/s2650.h"
3232#include "cpu/mcs48/mcs48.h"
3333#include "sound/dac.h"
34#include "video/s2636.h"
3534#include "includes/quasar.h"
3635
3736/************************************************************************
r24875r24876
274273
275274static const s2636_interface s2636_0_config =
276275{
277   "screen",
278276   0x100,
279277   CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET,
280278   NULL
r24875r24876
282280
283281static const s2636_interface s2636_1_config =
284282{
285   "screen",
286283   0x100,
287284   CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET,
288285   NULL
r24875r24876
290287
291288static const s2636_interface s2636_2_config =
292289{
293   "screen",
294290   0x100,
295291   CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET,
296292   NULL
trunk/src/emu/video/s2636.c
r24875r24876
7878#include "emu.h"
7979#include "video/s2636.h"
8080#include "sound/s2636.h"
81#include "devlegcy.h"
8281
82
83
8384/*************************************
8485 *
85 *  Constants
86 *  Device interface
8687 *
8788 *************************************/
8889
89#define SPRITE_WIDTH    (8)
90#define SPRITE_HEIGHT   (10)
90const device_type S2636 = &device_creator<s2636_device>;
9191
92static const int sprite_offsets[4] = { 0x00, 0x10, 0x20, 0x40 };
92s2636_device::s2636_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
93   : device_t(mconfig, S2636, "Signetics 2636", tag, owner, clock, "s2636", __FILE__),
94      device_video_interface(mconfig, *this),
95      m_work_ram(NULL),
96      m_bitmap(NULL),
97      m_collision_bitmap(NULL)
98{
99}
93100
94/*************************************
95 *
96 *  Internal S2636 data structure
97 *
98 *************************************/
101//-------------------------------------------------
102//  device_config_complete - perform any
103//  operations now that the configuration is
104//  complete
105//-------------------------------------------------
99106
100struct s2636_state
107void s2636_device::device_config_complete()
101108{
102   UINT8     *work_ram;
103   int       work_ram_size;
104   int       y_offset;
105   int       x_offset;
109   // inherit a copy of the static data
110   const s2636_interface *intf = reinterpret_cast<const s2636_interface *>(static_config());
111   if (intf != NULL)
112      *static_cast<s2636_interface *>(this) = *intf;
106113
107   bitmap_ind16 *bitmap;
108   bitmap_ind16 *collision_bitmap;
109};
114   // or initialize to defaults if none provided
115   else
116   {
117      m_work_ram_size = 0;
118      m_y_offset = 0;
119      m_x_offset = 0;
120      m_sound_tag = "";
121   }
122}
110123
124//-------------------------------------------------
125//  device_start - device-specific startup
126//-------------------------------------------------
127
128void s2636_device::device_start()
129{
130   int width = m_screen->width();
131   int height = m_screen->height();
132
133   m_work_ram = auto_alloc_array_clear(machine(), UINT8, m_work_ram_size);
134   m_bitmap = auto_bitmap_ind16_alloc(machine(), width, height);
135   m_collision_bitmap = auto_bitmap_ind16_alloc(machine(), width, height);
136
137   save_item(NAME(m_x_offset));
138   save_item(NAME(m_y_offset));
139   save_pointer(NAME(m_work_ram), m_work_ram_size);
140   save_item(NAME(*m_bitmap));
141   save_item(NAME(*m_collision_bitmap));
142}
143
111144/*************************************
112145 *
113 *  Inline functions
146 *  Constants
114147 *
115148 *************************************/
116149
117INLINE s2636_state *get_safe_token( device_t *device )
118{
119   assert(device != NULL);
120   assert(device->type() == S2636);
150#define SPRITE_WIDTH    (8)
151#define SPRITE_HEIGHT   (10)
121152
122   return (s2636_state *)downcast<s2636_device *>(device)->token();
123}
153static const int sprite_offsets[4] = { 0x00, 0x10, 0x20, 0x40 };
124154
125INLINE const s2636_interface *get_interface( device_t *device )
126{
127   assert(device != NULL);
128   assert((device->type() == S2636));
129   return (const s2636_interface *) device->static_config();
130}
131155
132156
157
133158/*************************************
134159 *
135160 *  Draw a sprite
r24875r24876
187212 *
188213 *************************************/
189214
190static int check_collision( device_t *device, int spriteno1, int spriteno2, const rectangle &cliprect )
215int s2636_device::check_collision( int spriteno1, int spriteno2, const rectangle &cliprect )
191216{
192   s2636_state *s2636 = get_safe_token(device);
193217   int checksum = 0;
194218
195   UINT8* attr1 = &s2636->work_ram[sprite_offsets[spriteno1]];
196   UINT8* attr2 = &s2636->work_ram[sprite_offsets[spriteno2]];
219   UINT8* attr1 = &m_work_ram[sprite_offsets[spriteno1]];
220   UINT8* attr2 = &m_work_ram[sprite_offsets[spriteno2]];
197221
198222   /* TODO: does not check shadow sprites yet */
199223
200   s2636->collision_bitmap->fill(0, cliprect);
224   m_collision_bitmap->fill(0, cliprect);
201225
202226   if ((attr1[0x0a] != 0xff) && (attr2[0x0a] != 0xff))
203227   {
204228      int x, y;
205229
206      int x1 = attr1[0x0a] + s2636->x_offset;
207      int y1 = attr1[0x0c] + s2636->y_offset;
208      int x2 = attr2[0x0a] + s2636->x_offset;
209      int y2 = attr2[0x0c] + s2636->y_offset;
230      int x1 = attr1[0x0a] + m_x_offset;
231      int y1 = attr1[0x0c] + m_y_offset;
232      int x2 = attr2[0x0a] + m_x_offset;
233      int y2 = attr2[0x0c] + m_y_offset;
210234
211      int expand1 = (s2636->work_ram[0xc0] >> (spriteno1 << 1)) & 0x03;
212      int expand2 = (s2636->work_ram[0xc0] >> (spriteno2 << 1)) & 0x03;
235      int expand1 = (m_work_ram[0xc0] >> (spriteno1 << 1)) & 0x03;
236      int expand2 = (m_work_ram[0xc0] >> (spriteno2 << 1)) & 0x03;
213237
214238      /* draw first sprite */
215      draw_sprite(attr1, 1, y1, x1, expand1, FALSE, *s2636->collision_bitmap, cliprect);
239      draw_sprite(attr1, 1, y1, x1, expand1, FALSE, *m_collision_bitmap, cliprect);
216240
217241      /* get fingerprint */
218242      for (x = x1; x < x1 + SPRITE_WIDTH; x++)
r24875r24876
221245            if (!cliprect.contains(x, y))
222246               continue;
223247
224            checksum = checksum + s2636->collision_bitmap->pix16(y, x);
248            checksum = checksum + m_collision_bitmap->pix16(y, x);
225249         }
226250
227251      /* black out second sprite */
228      draw_sprite(attr2, 0, y2, x2, expand2, FALSE, *s2636->collision_bitmap, cliprect);
252      draw_sprite(attr2, 0, y2, x2, expand2, FALSE, *m_collision_bitmap, cliprect);
229253
230254      /* remove fingerprint */
231255      for (x = x1; x < x1 + SPRITE_WIDTH; x++)
r24875r24876
234258            if (!cliprect.contains(x, y))
235259               continue;
236260
237            checksum = checksum - s2636->collision_bitmap->pix16(y, x);
261            checksum = checksum - m_collision_bitmap->pix16(y, x);
238262         }
239263   }
240264
r24875r24876
249273 *
250274 *************************************/
251275
252bitmap_ind16 &s2636_update( device_t *device, const rectangle &cliprect )
276bitmap_ind16 &s2636_device::update( const rectangle &cliprect )
253277{
254   s2636_state *s2636 = get_safe_token(device);
255278   UINT8 collision = 0;
256279   int spriteno;
257280
258   s2636->bitmap->fill(0, cliprect);
281   m_bitmap->fill(0, cliprect);
259282
260283   for (spriteno = 0; spriteno < 4; spriteno++)
261284   {
262285      int color, expand, x, y;
263      UINT8* attr = &s2636->work_ram[sprite_offsets[spriteno]];
286      UINT8* attr = &m_work_ram[sprite_offsets[spriteno]];
264287
265288      /* get out if sprite is turned off */
266289      if (attr[0x0a] == 0xff)
267290         continue;
268291
269      x = attr[0x0a] + s2636->x_offset;
270      y = attr[0x0c] + s2636->y_offset;
292      x = attr[0x0a] + m_x_offset;
293      y = attr[0x0c] + m_y_offset;
271294
272      color = (s2636->work_ram[0xc1 + (spriteno >> 1)] >> ((spriteno & 1) ? 0 : 3)) & 0x07;
273      expand = (s2636->work_ram[0xc0] >> (spriteno << 1)) & 0x03;
295      color = (m_work_ram[0xc1 + (spriteno >> 1)] >> ((spriteno & 1) ? 0 : 3)) & 0x07;
296      expand = (m_work_ram[0xc0] >> (spriteno << 1)) & 0x03;
274297
275      draw_sprite(attr, color, y, x, expand, TRUE, *s2636->bitmap, cliprect);
298      draw_sprite(attr, color, y, x, expand, TRUE, *m_bitmap, cliprect);
276299
277300      /* bail if no shadow sprites */
278301      if ((attr[0x0b] == 0xff) || (attr[0x0d] == 0xfe))
279302         continue;
280303
281      x = attr[0x0b] + s2636->x_offset;
304      x = attr[0x0b] + m_x_offset;
282305
283306      while (y < 0xff)
284307      {
285308         y = y + SPRITE_HEIGHT + attr[0x0d];
286309
287         draw_sprite(attr, color, y, x, expand, TRUE, *s2636->bitmap, cliprect);
310         draw_sprite(attr, color, y, x, expand, TRUE, *m_bitmap, cliprect);
288311      }
289312   }
290313
291314   /* collision detection */
292   if (check_collision(device, 0, 1, cliprect))  collision |= 0x20;
293   if (check_collision(device, 0, 2, cliprect))  collision |= 0x10;
294   if (check_collision(device, 0, 3, cliprect))  collision |= 0x08;
295   if (check_collision(device, 1, 2, cliprect))  collision |= 0x04;
296   if (check_collision(device, 1, 3, cliprect))  collision |= 0x02;
297   if (check_collision(device, 2, 3, cliprect))  collision |= 0x01;
315   if (check_collision(0, 1, cliprect))  collision |= 0x20;
316   if (check_collision(0, 2, cliprect))  collision |= 0x10;
317   if (check_collision(0, 3, cliprect))  collision |= 0x08;
318   if (check_collision(1, 2, cliprect))  collision |= 0x04;
319   if (check_collision(1, 3, cliprect))  collision |= 0x02;
320   if (check_collision(2, 3, cliprect))  collision |= 0x01;
298321
299   s2636->work_ram[0xcb] = collision;
322   m_work_ram[0xcb] = collision;
300323
301   return *s2636->bitmap;
324   return *m_bitmap;
302325}
303326
304327
r24875r24876
308331 *
309332 *************************************/
310333
311WRITE8_DEVICE_HANDLER( s2636_work_ram_w )
334WRITE8_MEMBER( s2636_device::work_ram_w )
312335{
313   s2636_state *s2636 = get_safe_token(device);
336   assert(offset < m_work_ram_size);
314337
315   assert(offset < s2636->work_ram_size);
316
317338   if ( offset == 0xc7 )
318339   {
319      const s2636_interface *intf = get_interface(device);
320      if ( intf->sound && *intf->sound )
340      if ( m_sound_tag && *m_sound_tag )
321341      {
322         device->machine().device<s2636_sound_device>(intf->sound)->soundport_w(0, data);
342         machine().device<s2636_sound_device>(m_sound_tag)->soundport_w(0, data);
323343      }
324344   }
325345
326   s2636->work_ram[offset] = data;
346   m_work_ram[offset] = data;
327347}
328348
329349
330READ8_DEVICE_HANDLER( s2636_work_ram_r )
350READ8_MEMBER( s2636_device::work_ram_r )
331351{
332   s2636_state *s2636 = get_safe_token(device);
352   assert(offset < m_work_ram_size);
333353
334   assert(offset < s2636->work_ram_size);
335
336   return s2636->work_ram[offset];
354   return m_work_ram[offset];
337355}
338
339/*************************************
340 *
341 *  Device interface
342 *
343 *************************************/
344
345static DEVICE_START( s2636 )
346{
347   s2636_state *s2636 = get_safe_token(device);
348   const s2636_interface *intf = get_interface(device);
349   screen_device *screen = downcast<screen_device *>(device->machine().device(intf->screen));
350   int width = screen->width();
351   int height = screen->height();
352
353   s2636->work_ram_size = intf->work_ram_size;
354   s2636->x_offset = intf->x_offset;
355   s2636->y_offset = intf->y_offset;
356
357   s2636->work_ram = auto_alloc_array_clear(device->machine(), UINT8, intf->work_ram_size);
358   s2636->bitmap = auto_bitmap_ind16_alloc(device->machine(), width, height);
359   s2636->collision_bitmap = auto_bitmap_ind16_alloc(device->machine(), width, height);
360
361   device->save_item(NAME(s2636->x_offset));
362   device->save_item(NAME(s2636->y_offset));
363   device->save_pointer(NAME(s2636->work_ram), s2636->work_ram_size);
364   device->save_item(NAME(*s2636->bitmap));
365   device->save_item(NAME(*s2636->collision_bitmap));
366}
367
368const device_type S2636 = &device_creator<s2636_device>;
369
370s2636_device::s2636_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
371   : device_t(mconfig, S2636, "Signetics 2636", tag, owner, clock, "s2636", __FILE__)
372{
373   m_token = global_alloc_clear(s2636_state);
374}
375
376//-------------------------------------------------
377//  device_config_complete - perform any
378//  operations now that the configuration is
379//  complete
380//-------------------------------------------------
381
382void s2636_device::device_config_complete()
383{
384}
385
386//-------------------------------------------------
387//  device_start - device-specific startup
388//-------------------------------------------------
389
390void s2636_device::device_start()
391{
392   DEVICE_START_NAME( s2636 )(this);
393}
trunk/src/emu/video/s2636.h
r24875r24876
2020
2121struct s2636_interface
2222{
23   const char *screen;
24   int        work_ram_size;
25   int        y_offset;
26   int        x_offset;
27   const char *sound;
23   int        m_work_ram_size;
24   int        m_y_offset;
25   int        m_x_offset;
26   const char *m_sound_tag;
2827};
2928
3029/*************************************
r24875r24876
3332 *
3433 *************************************/
3534
36class s2636_device : public device_t
35class s2636_device : public device_t,
36            public device_video_interface,
37            public s2636_interface
3738{
3839public:
3940   s2636_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
40   ~s2636_device() { global_free(m_token); }
41   ~s2636_device() {}
4142
42   // access to legacy token
43   void *token() const { assert(m_token != NULL); return m_token; }
43   /* returns a BITMAP_FORMAT_IND16 bitmap the size of the screen
44      D0-D2 of each pixel is the pixel color
45      D3 indicates whether the S2636 drew this pixel - 0 = not drawn, 1 = drawn */
46
47   bitmap_ind16 &update( const rectangle &cliprect );
48   DECLARE_WRITE8_MEMBER( work_ram_w );
49   DECLARE_READ8_MEMBER( work_ram_r );
50
4451protected:
4552   // device-level overrides
4653   virtual void device_config_complete();
4754   virtual void device_start();
55
4856private:
4957   // internal state
50   void *m_token;
58   UINT8     *m_work_ram;
59   bitmap_ind16 *m_bitmap;
60   bitmap_ind16 *m_collision_bitmap;
61   
62   int check_collision( int spriteno1, int spriteno2, const rectangle &cliprect );
5163};
5264
5365extern const device_type S2636;
r24875r24876
5870   MCFG_DEVICE_CONFIG(_interface)
5971
6072
61/*************************************
62 *
63 *  Device I/O functions
64 *
65 *************************************/
66
67
68/* returns a BITMAP_FORMAT_IND16 bitmap the size of the screen
69   D0-D2 of each pixel is the pixel color
70   D3 indicates whether the S2636 drew this pixel - 0 = not drawn, 1 = drawn */
71
72bitmap_ind16 &s2636_update( device_t *device, const rectangle &cliprect );
73DECLARE_WRITE8_DEVICE_HANDLER( s2636_work_ram_w );
74DECLARE_READ8_DEVICE_HANDLER( s2636_work_ram_r );
75
76
7773#endif /* __S2636_H__ */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team