From bc9126a58186e6e6005b61f2c9a6cd2a1ff23afe Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Tue, 13 Aug 2013 17:15:54 +0000 Subject: [PATCH] Modernized the s2636 video device. Will try to merge the audio and video devices in one file next. (nw) --- src/emu/video/s2636.c | 242 +++++++++++++++-------------------- src/emu/video/s2636.h | 48 ++++--- src/mame/drivers/cvs.c | 20 +-- src/mame/drivers/galaxia.c | 16 +-- src/mame/drivers/laserbat.c | 19 +-- src/mame/drivers/malzak.c | 15 +-- src/mame/drivers/quasar.c | 4 - src/mame/drivers/seabattl.c | 7 +- src/mame/includes/cvs.h | 12 +- src/mame/includes/laserbat.h | 12 +- src/mame/includes/malzak.h | 13 +- src/mame/video/cvs.c | 19 ++- src/mame/video/galaxia.c | 15 +-- src/mame/video/malzak.c | 5 +- src/mame/video/quasar.c | 7 +- 15 files changed, 197 insertions(+), 257 deletions(-) diff --git a/src/emu/video/s2636.c b/src/emu/video/s2636.c index 7ce15c4ead2..f4782149621 100644 --- a/src/emu/video/s2636.c +++ b/src/emu/video/s2636.c @@ -78,7 +78,68 @@ #include "emu.h" #include "video/s2636.h" #include "sound/s2636.h" -#include "devlegcy.h" + + + +/************************************* + * + * Device interface + * + *************************************/ + +const device_type S2636 = &device_creator; + +s2636_device::s2636_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, S2636, "Signetics 2636", tag, owner, clock, "s2636", __FILE__), + device_video_interface(mconfig, *this), + m_work_ram(NULL), + m_bitmap(NULL), + m_collision_bitmap(NULL) +{ +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void s2636_device::device_config_complete() +{ + // inherit a copy of the static data + const s2636_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + m_work_ram_size = 0; + m_y_offset = 0; + m_x_offset = 0; + m_sound_tag = ""; + } +} + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void s2636_device::device_start() +{ + int width = m_screen->width(); + int height = m_screen->height(); + + m_work_ram = auto_alloc_array_clear(machine(), UINT8, m_work_ram_size); + m_bitmap = auto_bitmap_ind16_alloc(machine(), width, height); + m_collision_bitmap = auto_bitmap_ind16_alloc(machine(), width, height); + + save_item(NAME(m_x_offset)); + save_item(NAME(m_y_offset)); + save_pointer(NAME(m_work_ram), m_work_ram_size); + save_item(NAME(*m_bitmap)); + save_item(NAME(*m_collision_bitmap)); +} /************************************* * @@ -91,43 +152,7 @@ static const int sprite_offsets[4] = { 0x00, 0x10, 0x20, 0x40 }; -/************************************* - * - * Internal S2636 data structure - * - *************************************/ -struct s2636_state -{ - UINT8 *work_ram; - int work_ram_size; - int y_offset; - int x_offset; - - bitmap_ind16 *bitmap; - bitmap_ind16 *collision_bitmap; -}; - -/************************************* - * - * Inline functions - * - *************************************/ - -INLINE s2636_state *get_safe_token( device_t *device ) -{ - assert(device != NULL); - assert(device->type() == S2636); - - return (s2636_state *)downcast(device)->token(); -} - -INLINE const s2636_interface *get_interface( device_t *device ) -{ - assert(device != NULL); - assert((device->type() == S2636)); - return (const s2636_interface *) device->static_config(); -} /************************************* @@ -187,32 +212,31 @@ static void draw_sprite( UINT8 *gfx, int color, int y, int x, int expand, int or * *************************************/ -static int check_collision( device_t *device, int spriteno1, int spriteno2, const rectangle &cliprect ) +int s2636_device::check_collision( int spriteno1, int spriteno2, const rectangle &cliprect ) { - s2636_state *s2636 = get_safe_token(device); int checksum = 0; - UINT8* attr1 = &s2636->work_ram[sprite_offsets[spriteno1]]; - UINT8* attr2 = &s2636->work_ram[sprite_offsets[spriteno2]]; + UINT8* attr1 = &m_work_ram[sprite_offsets[spriteno1]]; + UINT8* attr2 = &m_work_ram[sprite_offsets[spriteno2]]; /* TODO: does not check shadow sprites yet */ - s2636->collision_bitmap->fill(0, cliprect); + m_collision_bitmap->fill(0, cliprect); if ((attr1[0x0a] != 0xff) && (attr2[0x0a] != 0xff)) { int x, y; - int x1 = attr1[0x0a] + s2636->x_offset; - int y1 = attr1[0x0c] + s2636->y_offset; - int x2 = attr2[0x0a] + s2636->x_offset; - int y2 = attr2[0x0c] + s2636->y_offset; + int x1 = attr1[0x0a] + m_x_offset; + int y1 = attr1[0x0c] + m_y_offset; + int x2 = attr2[0x0a] + m_x_offset; + int y2 = attr2[0x0c] + m_y_offset; - int expand1 = (s2636->work_ram[0xc0] >> (spriteno1 << 1)) & 0x03; - int expand2 = (s2636->work_ram[0xc0] >> (spriteno2 << 1)) & 0x03; + int expand1 = (m_work_ram[0xc0] >> (spriteno1 << 1)) & 0x03; + int expand2 = (m_work_ram[0xc0] >> (spriteno2 << 1)) & 0x03; /* draw first sprite */ - draw_sprite(attr1, 1, y1, x1, expand1, FALSE, *s2636->collision_bitmap, cliprect); + draw_sprite(attr1, 1, y1, x1, expand1, FALSE, *m_collision_bitmap, cliprect); /* get fingerprint */ for (x = x1; x < x1 + SPRITE_WIDTH; x++) @@ -221,11 +245,11 @@ static int check_collision( device_t *device, int spriteno1, int spriteno2, cons if (!cliprect.contains(x, y)) continue; - checksum = checksum + s2636->collision_bitmap->pix16(y, x); + checksum = checksum + m_collision_bitmap->pix16(y, x); } /* black out second sprite */ - draw_sprite(attr2, 0, y2, x2, expand2, FALSE, *s2636->collision_bitmap, cliprect); + draw_sprite(attr2, 0, y2, x2, expand2, FALSE, *m_collision_bitmap, cliprect); /* remove fingerprint */ for (x = x1; x < x1 + SPRITE_WIDTH; x++) @@ -234,7 +258,7 @@ static int check_collision( device_t *device, int spriteno1, int spriteno2, cons if (!cliprect.contains(x, y)) continue; - checksum = checksum - s2636->collision_bitmap->pix16(y, x); + checksum = checksum - m_collision_bitmap->pix16(y, x); } } @@ -249,56 +273,55 @@ static int check_collision( device_t *device, int spriteno1, int spriteno2, cons * *************************************/ -bitmap_ind16 &s2636_update( device_t *device, const rectangle &cliprect ) +bitmap_ind16 &s2636_device::update( const rectangle &cliprect ) { - s2636_state *s2636 = get_safe_token(device); UINT8 collision = 0; int spriteno; - s2636->bitmap->fill(0, cliprect); + m_bitmap->fill(0, cliprect); for (spriteno = 0; spriteno < 4; spriteno++) { int color, expand, x, y; - UINT8* attr = &s2636->work_ram[sprite_offsets[spriteno]]; + UINT8* attr = &m_work_ram[sprite_offsets[spriteno]]; /* get out if sprite is turned off */ if (attr[0x0a] == 0xff) continue; - x = attr[0x0a] + s2636->x_offset; - y = attr[0x0c] + s2636->y_offset; + x = attr[0x0a] + m_x_offset; + y = attr[0x0c] + m_y_offset; - color = (s2636->work_ram[0xc1 + (spriteno >> 1)] >> ((spriteno & 1) ? 0 : 3)) & 0x07; - expand = (s2636->work_ram[0xc0] >> (spriteno << 1)) & 0x03; + color = (m_work_ram[0xc1 + (spriteno >> 1)] >> ((spriteno & 1) ? 0 : 3)) & 0x07; + expand = (m_work_ram[0xc0] >> (spriteno << 1)) & 0x03; - draw_sprite(attr, color, y, x, expand, TRUE, *s2636->bitmap, cliprect); + draw_sprite(attr, color, y, x, expand, TRUE, *m_bitmap, cliprect); /* bail if no shadow sprites */ if ((attr[0x0b] == 0xff) || (attr[0x0d] == 0xfe)) continue; - x = attr[0x0b] + s2636->x_offset; + x = attr[0x0b] + m_x_offset; while (y < 0xff) { y = y + SPRITE_HEIGHT + attr[0x0d]; - draw_sprite(attr, color, y, x, expand, TRUE, *s2636->bitmap, cliprect); + draw_sprite(attr, color, y, x, expand, TRUE, *m_bitmap, cliprect); } } /* collision detection */ - if (check_collision(device, 0, 1, cliprect)) collision |= 0x20; - if (check_collision(device, 0, 2, cliprect)) collision |= 0x10; - if (check_collision(device, 0, 3, cliprect)) collision |= 0x08; - if (check_collision(device, 1, 2, cliprect)) collision |= 0x04; - if (check_collision(device, 1, 3, cliprect)) collision |= 0x02; - if (check_collision(device, 2, 3, cliprect)) collision |= 0x01; + if (check_collision(0, 1, cliprect)) collision |= 0x20; + if (check_collision(0, 2, cliprect)) collision |= 0x10; + if (check_collision(0, 3, cliprect)) collision |= 0x08; + if (check_collision(1, 2, cliprect)) collision |= 0x04; + if (check_collision(1, 3, cliprect)) collision |= 0x02; + if (check_collision(2, 3, cliprect)) collision |= 0x01; - s2636->work_ram[0xcb] = collision; + m_work_ram[0xcb] = collision; - return *s2636->bitmap; + return *m_bitmap; } @@ -308,86 +331,25 @@ bitmap_ind16 &s2636_update( device_t *device, const rectangle &cliprect ) * *************************************/ -WRITE8_DEVICE_HANDLER( s2636_work_ram_w ) +WRITE8_MEMBER( s2636_device::work_ram_w ) { - s2636_state *s2636 = get_safe_token(device); - - assert(offset < s2636->work_ram_size); + assert(offset < m_work_ram_size); if ( offset == 0xc7 ) { - const s2636_interface *intf = get_interface(device); - if ( intf->sound && *intf->sound ) + if ( m_sound_tag && *m_sound_tag ) { - device->machine().device(intf->sound)->soundport_w(0, data); + machine().device(m_sound_tag)->soundport_w(0, data); } } - s2636->work_ram[offset] = data; + m_work_ram[offset] = data; } -READ8_DEVICE_HANDLER( s2636_work_ram_r ) +READ8_MEMBER( s2636_device::work_ram_r ) { - s2636_state *s2636 = get_safe_token(device); + assert(offset < m_work_ram_size); - assert(offset < s2636->work_ram_size); - - return s2636->work_ram[offset]; -} - -/************************************* - * - * Device interface - * - *************************************/ - -static DEVICE_START( s2636 ) -{ - s2636_state *s2636 = get_safe_token(device); - const s2636_interface *intf = get_interface(device); - screen_device *screen = downcast(device->machine().device(intf->screen)); - int width = screen->width(); - int height = screen->height(); - - s2636->work_ram_size = intf->work_ram_size; - s2636->x_offset = intf->x_offset; - s2636->y_offset = intf->y_offset; - - s2636->work_ram = auto_alloc_array_clear(device->machine(), UINT8, intf->work_ram_size); - s2636->bitmap = auto_bitmap_ind16_alloc(device->machine(), width, height); - s2636->collision_bitmap = auto_bitmap_ind16_alloc(device->machine(), width, height); - - device->save_item(NAME(s2636->x_offset)); - device->save_item(NAME(s2636->y_offset)); - device->save_pointer(NAME(s2636->work_ram), s2636->work_ram_size); - device->save_item(NAME(*s2636->bitmap)); - device->save_item(NAME(*s2636->collision_bitmap)); -} - -const device_type S2636 = &device_creator; - -s2636_device::s2636_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, S2636, "Signetics 2636", tag, owner, clock, "s2636", __FILE__) -{ - m_token = global_alloc_clear(s2636_state); -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void s2636_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void s2636_device::device_start() -{ - DEVICE_START_NAME( s2636 )(this); + return m_work_ram[offset]; } diff --git a/src/emu/video/s2636.h b/src/emu/video/s2636.h index 9cd7dde90f6..29d2385b6e1 100644 --- a/src/emu/video/s2636.h +++ b/src/emu/video/s2636.h @@ -20,11 +20,10 @@ struct s2636_interface { - const char *screen; - int work_ram_size; - int y_offset; - int x_offset; - const char *sound; + int m_work_ram_size; + int m_y_offset; + int m_x_offset; + const char *m_sound_tag; }; /************************************* @@ -33,21 +32,34 @@ struct s2636_interface * *************************************/ -class s2636_device : public device_t +class s2636_device : public device_t, + public device_video_interface, + public s2636_interface { public: s2636_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~s2636_device() { global_free(m_token); } + ~s2636_device() {} + + /* returns a BITMAP_FORMAT_IND16 bitmap the size of the screen + D0-D2 of each pixel is the pixel color + D3 indicates whether the S2636 drew this pixel - 0 = not drawn, 1 = drawn */ + + bitmap_ind16 &update( const rectangle &cliprect ); + DECLARE_WRITE8_MEMBER( work_ram_w ); + DECLARE_READ8_MEMBER( work_ram_r ); - // access to legacy token - void *token() const { assert(m_token != NULL); return m_token; } protected: // device-level overrides virtual void device_config_complete(); virtual void device_start(); + private: // internal state - void *m_token; + UINT8 *m_work_ram; + bitmap_ind16 *m_bitmap; + bitmap_ind16 *m_collision_bitmap; + + int check_collision( int spriteno1, int spriteno2, const rectangle &cliprect ); }; extern const device_type S2636; @@ -58,20 +70,4 @@ extern const device_type S2636; MCFG_DEVICE_CONFIG(_interface) -/************************************* - * - * Device I/O functions - * - *************************************/ - - -/* returns a BITMAP_FORMAT_IND16 bitmap the size of the screen - D0-D2 of each pixel is the pixel color - D3 indicates whether the S2636 drew this pixel - 0 = not drawn, 1 = drawn */ - -bitmap_ind16 &s2636_update( device_t *device, const rectangle &cliprect ); -DECLARE_WRITE8_DEVICE_HANDLER( s2636_work_ram_w ); -DECLARE_READ8_DEVICE_HANDLER( s2636_work_ram_r ); - - #endif /* __S2636_H__ */ diff --git a/src/mame/drivers/cvs.c b/src/mame/drivers/cvs.c index 123ac8ddee8..ed1271615b0 100644 --- a/src/mame/drivers/cvs.c +++ b/src/mame/drivers/cvs.c @@ -92,8 +92,6 @@ Todo & FIXME: #include "emu.h" #include "cpu/s2650/s2650.h" -#include "sound/dac.h" -#include "video/s2636.h" #include "includes/cvs.h" @@ -150,7 +148,7 @@ READ8_MEMBER(cvs_state::cvs_s2636_0_or_character_ram_r) if (*m_fo_state) return m_character_ram[(0 * 0x800) | 0x400 | m_character_ram_page_start | offset]; else - return s2636_work_ram_r(m_s2636_0, space, offset); + return m_s2636_0->work_ram_r(space, offset); } WRITE8_MEMBER(cvs_state::cvs_s2636_0_or_character_ram_w) @@ -162,7 +160,7 @@ WRITE8_MEMBER(cvs_state::cvs_s2636_0_or_character_ram_w) machine().gfx[1]->mark_dirty((offset / 8) % 256); } else - s2636_work_ram_w(m_s2636_0, space, offset, data); + m_s2636_0->work_ram_w(space, offset, data); } @@ -171,7 +169,7 @@ READ8_MEMBER(cvs_state::cvs_s2636_1_or_character_ram_r) if (*m_fo_state) return m_character_ram[(1 * 0x800) | 0x400 | m_character_ram_page_start | offset]; else - return s2636_work_ram_r(m_s2636_1, space, offset); + return m_s2636_1->work_ram_r(space, offset); } WRITE8_MEMBER(cvs_state::cvs_s2636_1_or_character_ram_w) @@ -183,7 +181,7 @@ WRITE8_MEMBER(cvs_state::cvs_s2636_1_or_character_ram_w) machine().gfx[1]->mark_dirty((offset / 8) % 256); } else - s2636_work_ram_w(m_s2636_1, space, offset, data); + m_s2636_1->work_ram_w(space, offset, data); } @@ -192,7 +190,7 @@ READ8_MEMBER(cvs_state::cvs_s2636_2_or_character_ram_r) if (*m_fo_state) return m_character_ram[(2 * 0x800) | 0x400 | m_character_ram_page_start | offset]; else - return s2636_work_ram_r(m_s2636_2, space, offset); + return m_s2636_2->work_ram_r(space, offset); } WRITE8_MEMBER(cvs_state::cvs_s2636_2_or_character_ram_w) @@ -204,7 +202,7 @@ WRITE8_MEMBER(cvs_state::cvs_s2636_2_or_character_ram_w) machine().gfx[1]->mark_dirty((offset / 8) % 256); } else - s2636_work_ram_w(m_s2636_2, space, offset, data); + m_s2636_2->work_ram_w(space, offset, data); } @@ -945,7 +943,6 @@ GFXDECODE_END static const s2636_interface s2636_0_config = { - "screen", 0x100, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET, NULL @@ -953,7 +950,6 @@ static const s2636_interface s2636_0_config = static const s2636_interface s2636_1_config = { - "screen", 0x100, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET, NULL @@ -961,7 +957,6 @@ static const s2636_interface s2636_1_config = static const s2636_interface s2636_2_config = { - "screen", 0x100, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET, NULL @@ -978,9 +973,6 @@ MACHINE_START_MEMBER(cvs_state,cvs) /* set devices */ m_speech = machine().device("speech"); - m_s2636_0 = machine().device("s2636_0"); - m_s2636_1 = machine().device("s2636_1"); - m_s2636_2 = machine().device("s2636_2"); /* register state save */ save_item(NAME(m_color_ram)); diff --git a/src/mame/drivers/galaxia.c b/src/mame/drivers/galaxia.c index caef850bf0f..92507e4513b 100644 --- a/src/mame/drivers/galaxia.c +++ b/src/mame/drivers/galaxia.c @@ -61,7 +61,6 @@ TODO: */ #include "emu.h" -#include "video/s2636.h" #include "sound/s2636.h" #include "cpu/s2650/s2650.h" #include "includes/galaxia.h" @@ -123,9 +122,9 @@ READ8_MEMBER(galaxia_state::galaxia_collision_clear) static ADDRESS_MAP_START( galaxia_mem_map, AS_PROGRAM, 8, galaxia_state ) AM_RANGE(0x0000, 0x13ff) AM_ROM AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("bullet_ram") - AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_0", s2636_work_ram_r, s2636_work_ram_w) - AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_1", s2636_work_ram_r, s2636_work_ram_w) - AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_2", s2636_work_ram_r, s2636_work_ram_w) + AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_device, work_ram_r, work_ram_w) + AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_device, work_ram_r, work_ram_w) + AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_2", s2636_device, work_ram_r, work_ram_w) AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READ(cvs_video_or_color_ram_r) AM_WRITE(galaxia_video_w) AM_SHARE("video_ram") AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM AM_RANGE(0x2000, 0x33ff) AM_ROM @@ -135,7 +134,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( astrowar_mem_map, AS_PROGRAM, 8, galaxia_state ) AM_RANGE(0x0000, 0x13ff) AM_ROM AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_RAM - AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_0", s2636_work_ram_r, s2636_work_ram_w) + AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_device, work_ram_r, work_ram_w) AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READ(cvs_video_or_color_ram_r) AM_WRITE(galaxia_video_w) AM_SHARE("video_ram") AM_RANGE(0x1c00, 0x1cff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("bullet_ram") AM_RANGE(0x2000, 0x33ff) AM_ROM @@ -277,14 +276,13 @@ GFXDECODE_END static const s2636_interface galaxia_s2636_config[3] = { - { "screen", 0x100, 3, -26, "s2636snd_0" }, - { "screen", 0x100, 3, -26, "s2636snd_1" }, - { "screen", 0x100, 3, -26, "s2636snd_2" } + { 0x100, 3, -26, "s2636snd_0" }, + { 0x100, 3, -26, "s2636snd_1" }, + { 0x100, 3, -26, "s2636snd_2" } }; static const s2636_interface astrowar_s2636_config = { - "screen", 0x100, 3, 0, "s2636snd_0" diff --git a/src/mame/drivers/laserbat.c b/src/mame/drivers/laserbat.c index f0cbb067f2f..8653e8f4977 100644 --- a/src/mame/drivers/laserbat.c +++ b/src/mame/drivers/laserbat.c @@ -22,7 +22,6 @@ TODO: #include "machine/6821pia.h" #include "sound/sn76477.h" #include "sound/tms3615.h" -#include "video/s2636.h" #include "includes/laserbat.h" @@ -165,9 +164,9 @@ static ADDRESS_MAP_START( laserbat_map, AS_PROGRAM, 8, laserbat_state ) AM_RANGE(0x7800, 0x7bff) AM_ROM AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_WRITENOP // always 0 (bullet ram in Quasar) - AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_1", s2636_work_ram_r, s2636_work_ram_w) - AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_2", s2636_work_ram_r, s2636_work_ram_w) - AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_3", s2636_work_ram_r, s2636_work_ram_w) + AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_device, work_ram_r, work_ram_w) + AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_2", s2636_device, work_ram_r, work_ram_w) + AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_3", s2636_device, work_ram_r, work_ram_w) AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_WRITE(laserbat_videoram_w) AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM ADDRESS_MAP_END @@ -498,9 +497,9 @@ UINT32 laserbat_state::screen_update_laserbat(screen_device &screen, bitmap_ind1 m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); /* update the S2636 chips */ - bitmap_ind16 &s2636_1_bitmap = s2636_update(m_s2636_1, cliprect); - bitmap_ind16 &s2636_2_bitmap = s2636_update(m_s2636_2, cliprect); - bitmap_ind16 &s2636_3_bitmap = s2636_update(m_s2636_3, cliprect); + bitmap_ind16 &s2636_1_bitmap = m_s2636_1->update(cliprect); + bitmap_ind16 &s2636_2_bitmap = m_s2636_2->update(cliprect); + bitmap_ind16 &s2636_3_bitmap = m_s2636_3->update(cliprect); /* copy the S2636 images into the main bitmap */ for (y = cliprect.min_y; y <= cliprect.max_y; y++) @@ -657,7 +656,6 @@ INTERRUPT_GEN_MEMBER(laserbat_state::zaccaria_cb1_toggle) static const s2636_interface s2636_1_config = { - "screen", 0x100, 0, -19, NULL @@ -665,7 +663,6 @@ static const s2636_interface s2636_1_config = static const s2636_interface s2636_2_config = { - "screen", 0x100, 0, -19, NULL @@ -673,7 +670,6 @@ static const s2636_interface s2636_2_config = static const s2636_interface s2636_3_config = { - "screen", 0x100, 0, -19, NULL @@ -681,9 +677,6 @@ static const s2636_interface s2636_3_config = void laserbat_state::machine_start() { - m_s2636_1 = machine().device("s2636_1"); - m_s2636_2 = machine().device("s2636_2"); - m_s2636_3 = machine().device("s2636_3"); m_pia = machine().device("pia"); m_sn = machine().device("snsnd"); m_tms1 = machine().device("tms1"); diff --git a/src/mame/drivers/malzak.c b/src/mame/drivers/malzak.c index 4cd0b53ab85..29dfa991d9d 100644 --- a/src/mame/drivers/malzak.c +++ b/src/mame/drivers/malzak.c @@ -66,7 +66,6 @@ #include "cpu/s2650/s2650.h" #include "sound/sn76477.h" #include "sound/s2636.h" -#include "video/s2636.h" #include "video/saa5050.h" #include "machine/nvram.h" #include "includes/malzak.h" @@ -74,7 +73,7 @@ READ8_MEMBER(malzak_state::fake_VRLE_r) { - return (s2636_work_ram_r(m_s2636_0, space, 0xcb) & 0x3f) + (m_screen->vblank() * 0x40); + return (m_s2636_0->work_ram_r(space, 0xcb) & 0x3f) + (m_screen->vblank() * 0x40); } READ8_MEMBER(malzak_state::s2636_portA_r) @@ -106,8 +105,8 @@ static ADDRESS_MAP_START( malzak_map, AS_PROGRAM, 8, malzak_state ) AM_RANGE(0x1200, 0x12ff) AM_MIRROR(0x6000) AM_RAM AM_RANGE(0x1300, 0x13ff) AM_MIRROR(0x6000) AM_RAM AM_RANGE(0x14cb, 0x14cb) AM_MIRROR(0x6000) AM_READ(fake_VRLE_r) - AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_0", s2636_work_ram_r, s2636_work_ram_w) - AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_1", s2636_work_ram_r, s2636_work_ram_w) + AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_device, work_ram_r, work_ram_w) + AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_device, work_ram_r, work_ram_w) AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_RAM_WRITE(malzak_playfield_w) AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_RAM AM_RANGE(0x1800, 0x1fff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("videoram") @@ -127,8 +126,8 @@ static ADDRESS_MAP_START( malzak2_map, AS_PROGRAM, 8, malzak_state ) AM_RANGE(0x1300, 0x13ff) AM_MIRROR(0x6000) AM_RAM AM_RANGE(0x14cb, 0x14cb) AM_MIRROR(0x6000) AM_READ(fake_VRLE_r) AM_RANGE(0x14cc, 0x14cc) AM_MIRROR(0x6000) AM_READ(s2636_portA_r) - AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_0", s2636_work_ram_r, s2636_work_ram_w) - AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE_LEGACY("s2636_1", s2636_work_ram_r, s2636_work_ram_w) + AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_0", s2636_device, work_ram_r, work_ram_w) + AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_device, work_ram_r, work_ram_w) AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_RAM_WRITE(malzak_playfield_w) AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("nvram") AM_RANGE(0x1800, 0x1fff) AM_MIRROR(0x6000) AM_RAM AM_SHARE("videoram") @@ -303,7 +302,6 @@ static const sn76477_interface sn76477_intf = static const s2636_interface malzac_s2636_0_config = { - "screen", 0x100, 0, -16, /* -8, -16 */ "s2636snd_0" @@ -311,7 +309,6 @@ static const s2636_interface malzac_s2636_0_config = static const s2636_interface malzac_s2636_1_config = { - "screen", 0x100, 0, -16, /* -9, -16 */ "s2636snd_1" @@ -332,8 +329,6 @@ void malzak_state::machine_start() { membank("bank1")->configure_entries(0, 2, memregion("user2")->base(), 0x400); - m_s2636_0 = machine().device("s2636_0"); - m_s2636_1 = machine().device("s2636_1"); m_saa5050 = machine().device("saa5050"); save_item(NAME(m_playfield_code)); diff --git a/src/mame/drivers/quasar.c b/src/mame/drivers/quasar.c index d10cd7ebe97..d390b3a020a 100644 --- a/src/mame/drivers/quasar.c +++ b/src/mame/drivers/quasar.c @@ -31,7 +31,6 @@ I8085 Sound Board #include "cpu/s2650/s2650.h" #include "cpu/mcs48/mcs48.h" #include "sound/dac.h" -#include "video/s2636.h" #include "includes/quasar.h" /************************************************************************ @@ -274,7 +273,6 @@ INTERRUPT_GEN_MEMBER(quasar_state::quasar_interrupt) static const s2636_interface s2636_0_config = { - "screen", 0x100, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET, NULL @@ -282,7 +280,6 @@ static const s2636_interface s2636_0_config = static const s2636_interface s2636_1_config = { - "screen", 0x100, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET, NULL @@ -290,7 +287,6 @@ static const s2636_interface s2636_1_config = static const s2636_interface s2636_2_config = { - "screen", 0x100, CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET, NULL diff --git a/src/mame/drivers/seabattl.c b/src/mame/drivers/seabattl.c index 53bc2d072b4..57e5975860c 100644 --- a/src/mame/drivers/seabattl.c +++ b/src/mame/drivers/seabattl.c @@ -52,6 +52,7 @@ public: m_digit3(*this, "sc_unity"), m_digit4(*this, "tm_half"), m_digit5(*this, "tm_unity"), + m_s2636(*this, "s2636"), m_waveenable(false), m_collision(0) { @@ -67,6 +68,7 @@ public: required_device m_digit3; required_device m_digit4; required_device m_digit5; + required_device m_s2636; tilemap_t *m_bg_tilemap; bitmap_ind16 m_collision_bg; @@ -181,7 +183,7 @@ UINT32 seabattl_state::screen_update_seabattl(screen_device &screen, bitmap_ind1 } } - bitmap_ind16 &s2636_0_bitmap = s2636_update(machine().device("s2636"), cliprect); + bitmap_ind16 &s2636_0_bitmap = m_s2636->update(cliprect); // collisions for (y = cliprect.min_y; y <= cliprect.max_y; y++) @@ -252,7 +254,7 @@ static ADDRESS_MAP_START( seabattl_map, AS_PROGRAM, 8, seabattl_state ) AM_RANGE(0x1e06, 0x1e06) AM_MIRROR(0x20f0) AM_READ_PORT("DIPS1") AM_WRITE(sound_w) AM_RANGE(0x1e07, 0x1e07) AM_MIRROR(0x20f0) AM_READ_PORT("DIPS0") AM_WRITE(sound2_w) AM_RANGE(0x1fcc, 0x1fcc) AM_MIRROR(0x2000) AM_READ_PORT("IN1") - AM_RANGE(0x1f00, 0x1fff) AM_MIRROR(0x2000) AM_DEVREADWRITE_LEGACY("s2636", s2636_work_ram_r, s2636_work_ram_w) + AM_RANGE(0x1f00, 0x1fff) AM_MIRROR(0x2000) AM_DEVREADWRITE("s2636", s2636_device, work_ram_r, work_ram_w) ADDRESS_MAP_END static ADDRESS_MAP_START( seabattl_io_map, AS_IO, 8, seabattl_state ) @@ -467,7 +469,6 @@ GFXDECODE_END static const s2636_interface s2636_config = { - "screen", 0x100, 3, -21, "s2636snd" diff --git a/src/mame/includes/cvs.h b/src/mame/includes/cvs.h index ba3bf764792..5af36972c79 100644 --- a/src/mame/includes/cvs.h +++ b/src/mame/includes/cvs.h @@ -6,6 +6,7 @@ #include "sound/dac.h" #include "sound/tms5110.h" +#include "video/s2636.h" #define CVS_S2636_Y_OFFSET (3) #define CVS_S2636_X_OFFSET (-26) @@ -31,7 +32,10 @@ public: m_audiocpu(*this, "audiocpu"), m_dac2(*this, "dac2"), m_dac3(*this, "dac3"), - m_tms5110(*this, "tms") + m_tms5110(*this, "tms"), + m_s2636_0(*this, "s2636_0"), + m_s2636_1(*this, "s2636_1"), + m_s2636_2(*this, "s2636_2") { } @@ -69,9 +73,9 @@ public: optional_device m_dac2; optional_device m_dac3; optional_device m_tms5110; - device_t *m_s2636_0; - device_t *m_s2636_1; - device_t *m_s2636_2; + optional_device m_s2636_0; + optional_device m_s2636_1; + optional_device m_s2636_2; /* memory */ UINT8 m_color_ram[0x400]; diff --git a/src/mame/includes/laserbat.h b/src/mame/includes/laserbat.h index 2eb174723df..bbca5a70d65 100644 --- a/src/mame/includes/laserbat.h +++ b/src/mame/includes/laserbat.h @@ -6,6 +6,7 @@ #include "machine/6821pia.h" #include "sound/ay8910.h" +#include "video/s2636.h" class laserbat_state : public driver_device { @@ -16,7 +17,10 @@ public: m_audiocpu(*this, "audiocpu"), m_fo_state(*this, "fo_state"), m_ay1(*this, "ay1"), - m_ay2(*this, "ay2") + m_ay2(*this, "ay2"), + m_s2636_1(*this, "s2636_1"), + m_s2636_2(*this, "s2636_2"), + m_s2636_3(*this, "s2636_3") { } @@ -25,6 +29,9 @@ public: required_shared_ptr m_fo_state; optional_device m_ay1; optional_device m_ay2; + required_device m_s2636_1; + required_device m_s2636_2; + required_device m_s2636_3; /* video-related */ tilemap_t *m_bg_tilemap; @@ -56,9 +63,6 @@ public: int m_bit14; /* device */ - device_t *m_s2636_1; - device_t *m_s2636_2; - device_t *m_s2636_3; pia6821_device *m_pia; device_t *m_sn; tms3615_device *m_tms1; diff --git a/src/mame/includes/malzak.h b/src/mame/includes/malzak.h index 076ae4f75a6..eef6d292fc0 100644 --- a/src/mame/includes/malzak.h +++ b/src/mame/includes/malzak.h @@ -4,6 +4,7 @@ *************************************************************************/ +#include "video/s2636.h" #include "video/saa5050.h" class malzak_state : public driver_device @@ -11,10 +12,15 @@ class malzak_state : public driver_device public: malzak_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_s2636_0(*this, "s2636_0"), + m_s2636_1(*this, "s2636_1"), m_trom(*this, "saa5050"), - m_videoram(*this, "videoram"), - m_maincpu(*this, "maincpu") { } + m_videoram(*this, "videoram") { } + required_device m_maincpu; + required_device m_s2636_0; + required_device m_s2636_1; required_device m_trom; required_shared_ptr m_videoram; @@ -27,8 +33,6 @@ public: int m_collision_counter; /* devices */ - device_t *m_s2636_0; - device_t *m_s2636_1; device_t *m_saa5050; DECLARE_READ8_MEMBER(fake_VRLE_r); DECLARE_READ8_MEMBER(s2636_portA_r); @@ -43,5 +47,4 @@ public: virtual void machine_reset(); virtual void palette_init(); UINT32 screen_update_malzak(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - required_device m_maincpu; }; diff --git a/src/mame/video/cvs.c b/src/mame/video/cvs.c index 1f2e1e8b76d..89a79b6a3a7 100644 --- a/src/mame/video/cvs.c +++ b/src/mame/video/cvs.c @@ -9,7 +9,6 @@ #include "emu.h" #include "cpu/s2650/s2650.h" #include "includes/cvs.h" -#include "video/s2636.h" #define SPRITE_PEN_BASE (0x820) @@ -192,9 +191,9 @@ UINT32 cvs_state::screen_update_cvs(screen_device &screen, bitmap_ind16 &bitmap, copyscrollbitmap(m_scrolled_collision_background, m_collision_background, 0, 0, 8, scroll, cliprect); /* update the S2636 chips */ - bitmap_ind16 &s2636_0_bitmap = s2636_update(m_s2636_0, cliprect); - bitmap_ind16 &s2636_1_bitmap = s2636_update(m_s2636_1, cliprect); - bitmap_ind16 &s2636_2_bitmap = s2636_update(m_s2636_2, cliprect); + bitmap_ind16 *s2636_0_bitmap = &m_s2636_0->update(cliprect); + bitmap_ind16 *s2636_1_bitmap = &m_s2636_1->update(cliprect); + bitmap_ind16 *s2636_2_bitmap = &m_s2636_2->update(cliprect); /* Bullet Hardware */ for (offs = 8; offs < 256; offs++ ) @@ -207,9 +206,9 @@ UINT32 cvs_state::screen_update_cvs(screen_device &screen, bitmap_ind16 &bitmap, int bx = 255 - 7 - m_bullet_ram[offs] - ct; /* Bullet/Object Collision */ - if ((s2636_0_bitmap.pix16(offs, bx) != 0) || - (s2636_1_bitmap.pix16(offs, bx) != 0) || - (s2636_2_bitmap.pix16(offs, bx) != 0)) + if ((s2636_0_bitmap->pix16(offs, bx) != 0) || + (s2636_1_bitmap->pix16(offs, bx) != 0) || + (s2636_2_bitmap->pix16(offs, bx) != 0)) m_collision_register |= 0x08; /* Bullet/Background Collision */ @@ -232,9 +231,9 @@ UINT32 cvs_state::screen_update_cvs(screen_device &screen, bitmap_ind16 &bitmap, for (x = cliprect.min_x; x <= cliprect.max_x; x++) { - int pixel0 = s2636_0_bitmap.pix16(y, x); - int pixel1 = s2636_1_bitmap.pix16(y, x); - int pixel2 = s2636_2_bitmap.pix16(y, x); + int pixel0 = s2636_0_bitmap->pix16(y, x); + int pixel1 = s2636_1_bitmap->pix16(y, x); + int pixel2 = s2636_2_bitmap->pix16(y, x); int pixel = pixel0 | pixel1 | pixel2; diff --git a/src/mame/video/galaxia.c b/src/mame/video/galaxia.c index f653294ee70..3717dd7a685 100644 --- a/src/mame/video/galaxia.c +++ b/src/mame/video/galaxia.c @@ -7,7 +7,6 @@ ***************************************************************************/ #include "emu.h" -#include "video/s2636.h" #include "includes/galaxia.h" #define SPRITE_PEN_BASE (0x10) @@ -111,9 +110,9 @@ UINT32 galaxia_state::screen_update_galaxia(screen_device &screen, bitmap_ind16 { int x, y; - bitmap_ind16 &s2636_0_bitmap = s2636_update(machine().device("s2636_0"), cliprect); - bitmap_ind16 &s2636_1_bitmap = s2636_update(machine().device("s2636_1"), cliprect); - bitmap_ind16 &s2636_2_bitmap = s2636_update(machine().device("s2636_2"), cliprect); + bitmap_ind16 *s2636_0_bitmap = &m_s2636_0->update(cliprect); + bitmap_ind16 *s2636_1_bitmap = &m_s2636_1->update(cliprect); + bitmap_ind16 *s2636_2_bitmap = &m_s2636_2->update(cliprect); bitmap.fill(0, cliprect); cvs_update_stars(bitmap, cliprect, STAR_PEN, 1); @@ -138,9 +137,9 @@ UINT32 galaxia_state::screen_update_galaxia(screen_device &screen, bitmap_ind16 } // copy the S2636 images into the main bitmap and check collision - int pixel0 = s2636_0_bitmap.pix16(y, x); - int pixel1 = s2636_1_bitmap.pix16(y, x); - int pixel2 = s2636_2_bitmap.pix16(y, x); + int pixel0 = s2636_0_bitmap->pix16(y, x); + int pixel1 = s2636_1_bitmap->pix16(y, x); + int pixel2 = s2636_2_bitmap->pix16(y, x); int pixel = pixel0 | pixel1 | pixel2; @@ -177,7 +176,7 @@ UINT32 galaxia_state::screen_update_astrowar(screen_device &screen, bitmap_ind16 // astrowar has only one S2636 int x, y; - bitmap_ind16 &s2636_0_bitmap = s2636_update(machine().device("s2636_0"), cliprect); + bitmap_ind16 &s2636_0_bitmap = m_s2636_0->update(cliprect); bitmap.fill(0, cliprect); cvs_update_stars(bitmap, cliprect, STAR_PEN, 1); diff --git a/src/mame/video/malzak.c b/src/mame/video/malzak.c index a5eba9ef2bc..90f8934ee0e 100644 --- a/src/mame/video/malzak.c +++ b/src/mame/video/malzak.c @@ -13,7 +13,6 @@ #include "emu.h" -#include "video/s2636.h" #include "video/saa5050.h" #include "includes/malzak.h" @@ -43,8 +42,8 @@ UINT32 malzak_state::screen_update_malzak(screen_device &screen, bitmap_rgb32 &b } /* update the S2636 chips */ - bitmap_ind16 &s2636_0_bitmap = s2636_update(m_s2636_0, cliprect); - bitmap_ind16 &s2636_1_bitmap = s2636_update(m_s2636_1, cliprect); + bitmap_ind16 &s2636_0_bitmap = m_s2636_0->update(cliprect); + bitmap_ind16 &s2636_1_bitmap = m_s2636_1->update(cliprect); /* copy the S2636 images into the main bitmap */ { diff --git a/src/mame/video/quasar.c b/src/mame/video/quasar.c index 1d62c4c34b1..77bbe9e40d0 100644 --- a/src/mame/video/quasar.c +++ b/src/mame/video/quasar.c @@ -15,7 +15,6 @@ ***************************************************************************/ #include "emu.h" -#include "video/s2636.h" #include "cpu/s2650/s2650.h" #include "includes/quasar.h" @@ -144,9 +143,9 @@ UINT32 quasar_state::screen_update_quasar(screen_device &screen, bitmap_ind16 &b } /* update the S2636 chips */ - bitmap_ind16 &s2636_0_bitmap = s2636_update(m_s2636_0, cliprect); - bitmap_ind16 &s2636_1_bitmap = s2636_update(m_s2636_1, cliprect); - bitmap_ind16 &s2636_2_bitmap = s2636_update(m_s2636_2, cliprect); + bitmap_ind16 &s2636_0_bitmap = m_s2636_0->update(cliprect); + bitmap_ind16 &s2636_1_bitmap = m_s2636_1->update(cliprect); + bitmap_ind16 &s2636_2_bitmap = m_s2636_2->update(cliprect); /* Bullet Hardware */ for (offs = 8; offs < 256; offs++ )