Skip to content

Commit

Permalink
Converted Williams SC1/SC2 blitter to a device. (#13030)
Browse files Browse the repository at this point in the history
* -williams: Converted SC1/SC2 blitter to a device. [Ryan Holtz]

* Flipped some always-present optional finders to required.
  • Loading branch information
MooglyGuy authored Nov 30, 2024
1 parent e1a3143 commit 9197eb1
Show file tree
Hide file tree
Showing 8 changed files with 422 additions and 313 deletions.
2 changes: 2 additions & 0 deletions scripts/target/mame/tiny.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ files{
MAME_DIR .. "src/mame/shared/s11c_bg.h",
MAME_DIR .. "src/mame/shared/williamssound.cpp",
MAME_DIR .. "src/mame/shared/williamssound.h",
MAME_DIR .. "src/mame/midway/williamsblitter.cpp",
MAME_DIR .. "src/mame/midway/williamsblitter.h",
MAME_DIR .. "src/mame/midway/williams.cpp",
MAME_DIR .. "src/mame/midway/williams.h",
MAME_DIR .. "src/mame/midway/williams_m.cpp",
Expand Down
78 changes: 25 additions & 53 deletions src/mame/midway/williams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,7 @@
****************************************************************************
Blitter (Stargate and Defender do not have blitter)
---------------------------------------------------
CA00 start_blitter Each bits has a function
1000 0000 Do not process half the byte 4-7
0100 0000 Do not process half the byte 0-3
0010 0000 Shift the shape one pixel right (to display a shape on an odd pixel)
0001 0000 Remap, if shape != 0 then pixel = mask
0000 1000 Source 1 = take source 0 = take Mask only
0000 0100 ?
0000 0010 Transparent
0000 0001
CA01 blitter_mask Not really a mask, more a remap color, see Blitter
CA02 blitter_source hi
CA03 blitter_source lo
CA04 blitter_dest hi
CA05 blitter_dest lo
CA06 blitter_w_h H Do a XOR with 4 to have the real value (Except Splat)
CA07 blitter_w_h W Do a XOR with 4 to have the real value (Except Splat)
CA00-CA07 blitter (Stargate and Defender do not have blitter)
CB00 6 bits of the video counters bits 2-7
Expand Down Expand Up @@ -553,17 +535,21 @@ void williams_state::main_map(address_map &map)
map(0xc804, 0xc807).mirror(0x00f0).rw(m_pia[0], FUNC(pia6821_device::read), FUNC(pia6821_device::write));
map(0xc80c, 0xc80f).mirror(0x00f0).rw(m_pia[1], FUNC(pia6821_device::read), FUNC(pia6821_device::write));
map(0xc900, 0xc9ff).w(FUNC(williams_state::vram_select_w));
map(0xca00, 0xca07).mirror(0x00f8).w(FUNC(williams_state::blitter_w));
map(0xcb00, 0xcbff).r(FUNC(williams_state::video_counter_r));
map(0xcbff, 0xcbff).w(FUNC(williams_state::watchdog_reset_w));
map(0xcc00, 0xcfff).ram().w(FUNC(williams_state::cmos_4bit_w)).share("nvram");
map(0xd000, 0xffff).rom();
}

void williams_state::main_map_blitter(address_map &map)
{
main_map(map);
map(0xca00, 0xca07).mirror(0x00f8).m(m_blitter, FUNC(williams_blitter_device::map));
}

void williams_state::sinistar_main_map(address_map &map)
{
main_map(map);
main_map_blitter(map);

map(0xc900, 0xc9ff).w(FUNC(williams_state::sinistar_vram_select_w));

Expand All @@ -574,7 +560,7 @@ void williams_state::sinistar_main_map(address_map &map)

void williams_state::bubbles_main_map(address_map &map)
{
main_map(map);
main_map_blitter(map);

// bubbles has additional CMOS for a full 8 bits
map(0xcc00, 0xcfff).ram().share("nvram");
Expand All @@ -583,7 +569,7 @@ void williams_state::bubbles_main_map(address_map &map)

void williams_state::spdball_main_map(address_map &map)
{
main_map(map);
main_map_blitter(map);

// install extra input handlers
map(0xc800, 0xc800).portr("AN0");
Expand All @@ -598,7 +584,7 @@ void williams_state::spdball_main_map(address_map &map)

void williams_state::alienar_main_map(address_map &map)
{
main_map(map);
main_map_blitter(map);

map(0xcbff, 0xcbff).nopw();
}
Expand All @@ -621,10 +607,10 @@ void blaster_state::blaster_main_map(address_map &map)
map(0xc804, 0xc807).mirror(0x00f0).rw(m_pia[0], FUNC(pia6821_device::read), FUNC(pia6821_device::write));
map(0xc80c, 0xc80f).mirror(0x00f0).rw(m_pia[1], FUNC(pia6821_device::read), FUNC(pia6821_device::write));
map(0xc900, 0xc93f).w(FUNC(blaster_state::blaster_vram_select_w));
map(0xc940, 0xc97f).w(FUNC(blaster_state::remap_select_w));
map(0xc940, 0xc97f).w(m_blitter, FUNC(williams_blitter_device::remap_select_w));
map(0xc980, 0xc9bf).w(FUNC(blaster_state::bank_select_w));
map(0xc9c0, 0xc9ff).w(FUNC(blaster_state::video_control_w));
map(0xca00, 0xca07).mirror(0x00f8).w(FUNC(blaster_state::blitter_w));
map(0xca00, 0xca07).mirror(0x00f8).m(m_blitter, FUNC(williams_blitter_device::map));
map(0xcb00, 0xcbff).r(FUNC(blaster_state::video_counter_r));
map(0xcbff, 0xcbff).w(FUNC(blaster_state::watchdog_reset_w));
map(0xcc00, 0xcfff).ram().w(FUNC(blaster_state::cmos_4bit_w)).share("nvram");
Expand All @@ -648,7 +634,7 @@ void williams2_state::common_map(address_map &map)
m_palette_view[0](0x8000, 0x87ff).ram().w(FUNC(williams2_state::paletteram_w)).share(m_paletteram);
map(0xc000, 0xc7ff).ram().w(FUNC(williams2_state::tileram_w)).share(m_tileram);
map(0xc800, 0xc87f).w(FUNC(williams2_state::bank_select_w));
map(0xc880, 0xc887).mirror(0x0078).w(FUNC(williams2_state::blitter_w));
map(0xc880, 0xc887).mirror(0x0078).m(m_blitter, FUNC(williams_blitter_device::map));
map(0xc900, 0xc97f).w(FUNC(williams2_state::watchdog_reset_w));
map(0xc980, 0xc983).mirror(0x0070).rw(m_pia[1], FUNC(pia6821_device::read), FUNC(pia6821_device::write));
map(0xc984, 0xc987).mirror(0x0070).rw(m_pia[0], FUNC(pia6821_device::read), FUNC(pia6821_device::write));
Expand All @@ -658,7 +644,7 @@ void williams2_state::common_map(address_map &map)
map(0xcb40, 0xcb5f).w(FUNC(williams2_state::xscroll_low_w));
map(0xcb60, 0xcb7f).w(FUNC(williams2_state::xscroll_high_w));
map(0xcb80, 0xcb9f).w(FUNC(williams2_state::video_control_w));
map(0xcba0, 0xcbbf).w(FUNC(williams2_state::blit_window_enable_w));
map(0xcba0, 0xcbbf).w(m_blitter, FUNC(williams_blitter_device::window_enable_w));
map(0xcbe0, 0xcbef).r(FUNC(williams2_state::video_counter_r));
map(0xcc00, 0xcfff).ram().w(FUNC(williams2_state::cmos_4bit_w)).share("nvram");
}
Expand Down Expand Up @@ -1596,31 +1582,17 @@ void williams_state::williams_base(machine_config &config)
m_pia[2]->irqb_handler().set("soundirq", FUNC(input_merger_any_high_device::in_w<1>));
}

void williams_state::williams_b0(machine_config &config)
{
williams_base(config);
m_blitter_config = WILLIAMS_BLITTER_NONE;
m_blitter_clip_address = 0x0000;
}

void williams_state::williams_b1(machine_config &config)
{
williams_base(config);
m_blitter_config = WILLIAMS_BLITTER_SC1;
m_blitter_clip_address = 0xc000;
}

void williams_state::williams_b2(machine_config &config)
{
williams_base(config);
m_blitter_config = WILLIAMS_BLITTER_SC2;
m_blitter_clip_address = 0xc000;
WILLIAMS_BLITTER_SC1(config, m_blitter, 0xc000, m_maincpu, m_videoram);
m_maincpu->set_addrmap(AS_PROGRAM, &williams_state::main_map_blitter);
}


void defender_state::defender(machine_config &config)
{
williams_b0(config);
williams_base(config);

m_maincpu->set_addrmap(AS_PROGRAM, &defender_state::defender_main_map);
m_soundcpu->set_addrmap(AS_PROGRAM, &defender_state::defender_sound_map);
Expand Down Expand Up @@ -1681,7 +1653,8 @@ void williams_state::joust(machine_config &config)

void williams_state::splat(machine_config &config)
{
williams_b2(config);
williams_base(config);
WILLIAMS_BLITTER_SC2(config, m_blitter, 0xc000, m_maincpu, m_videoram);
williams_muxed(config);
}

Expand All @@ -1704,8 +1677,8 @@ void williams_state::bubbles(machine_config &config)
void williams_state::sinistar_upright(machine_config &config)
{
// Sinistar: blitter window clip
williams_b1(config);
m_blitter_clip_address = 0x7400;
williams_base(config);
WILLIAMS_BLITTER_SC1(config, m_blitter, 0x7400, m_maincpu, m_videoram);

m_maincpu->set_addrmap(AS_PROGRAM, &williams_state::sinistar_main_map);

Expand Down Expand Up @@ -1786,8 +1759,8 @@ void williams_state::lottofun(machine_config &config)

void blaster_state::blastkit(machine_config &config)
{
williams_b2(config);
m_blitter_clip_address = 0x9700;
williams_base(config);
WILLIAMS_BLITTER_SC2(config, m_blitter, 0x9700, m_maincpu, m_videoram, "proms");

m_maincpu->set_addrmap(AS_PROGRAM, &blaster_state::blaster_main_map);

Expand Down Expand Up @@ -1899,8 +1872,7 @@ void williams2_state::williams2_base(machine_config &config)
m_pia[2]->irqa_handler().set("soundirq", FUNC(input_merger_any_high_device::in_w<0>));
m_pia[2]->irqb_handler().set("soundirq", FUNC(input_merger_any_high_device::in_w<1>));

m_blitter_config = WILLIAMS_BLITTER_SC2;
m_blitter_clip_address = 0x9000;
WILLIAMS_BLITTER_SC2(config, m_blitter, 0x9000, m_maincpu, m_videoram);
}


Expand Down Expand Up @@ -3953,7 +3925,7 @@ GAME( 1982, jin, 0, jin, jin, defender_state, e


// Standard Williams hardware
GAME( 1981, stargate, 0, williams_b0, stargate, williams_state, empty_init, ROT0, "Williams / Vid Kidz", "Stargate", MACHINE_SUPPORTS_SAVE )
GAME( 1981, stargate, 0, williams_base, stargate, williams_state, empty_init, ROT0, "Williams / Vid Kidz", "Stargate", MACHINE_SUPPORTS_SAVE )

GAME( 1982, conquest, 0, williams_b1, conquest, conquest_state, empty_init, ROT270, "Williams / Vid Kidz", "Conquest (prototype)", MACHINE_IS_INCOMPLETE | MACHINE_SUPPORTS_SAVE )

Expand Down
48 changes: 7 additions & 41 deletions src/mame/midway/williams.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "s11c_bg.h"
#include "williamssound.h"
#include "williamsblitter.h"

#include "cpu/m6800/m6800.h"
#include "cpu/m6809/m6809.h"
Expand Down Expand Up @@ -39,6 +40,7 @@ class williams_state : public driver_device
m_screen(*this, "screen"),
m_palette(*this, "palette"),
m_paletteram(*this, "paletteram"),
m_blitter(*this, "blitter"),
m_pia(*this, "pia_%u", 0U),
m_nvram(*this, "nvram"),
m_videoram(*this, "videoram"),
Expand All @@ -47,9 +49,8 @@ class williams_state : public driver_device
m_49way_y(*this, "49WAYY")
{ }

void williams_b0(machine_config &config);
void williams_base(machine_config &config);
void williams_b1(machine_config &config);
void williams_b2(machine_config &config);

void joust(machine_config &config);
void bubbles(machine_config &config);
Expand All @@ -71,33 +72,13 @@ class williams_state : public driver_device
void palette_init(palette_device &palette) const;

protected:
// blitter type
enum
{
WILLIAMS_BLITTER_NONE = 0, // no blitter
WILLIAMS_BLITTER_SC1 = 1, // Special Chip 1 blitter
WILLIAMS_BLITTER_SC2 = 2 // Special Chip 2 "bugfixed" blitter
};

// controlbyte (0xCA00) bit definitions
enum
{
WMS_BLITTER_CONTROLBYTE_NO_EVEN = 0x80,
WMS_BLITTER_CONTROLBYTE_NO_ODD = 0x40,
WMS_BLITTER_CONTROLBYTE_SHIFT = 0x20,
WMS_BLITTER_CONTROLBYTE_SOLID = 0x10,
WMS_BLITTER_CONTROLBYTE_FOREGROUND_ONLY = 0x08,
WMS_BLITTER_CONTROLBYTE_SLOW = 0x04, // 2us blits instead of 1us
WMS_BLITTER_CONTROLBYTE_DST_STRIDE_256 = 0x02,
WMS_BLITTER_CONTROLBYTE_SRC_STRIDE_256 = 0x01
};

required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_soundcpu;
required_device<watchdog_timer_device> m_watchdog;
required_device<screen_device> m_screen;
optional_device<palette_device> m_palette;
optional_shared_ptr<uint8_t> m_paletteram;
required_device<palette_device> m_palette;
required_shared_ptr<uint8_t> m_paletteram;
optional_device<williams_blitter_device> m_blitter;
optional_device_array<pia6821_device, 4> m_pia;

required_shared_ptr<uint8_t> m_nvram;
Expand All @@ -108,16 +89,8 @@ class williams_state : public driver_device
optional_ioport m_49way_x;
optional_ioport m_49way_y;

uint8_t m_blitter_config;
uint16_t m_blitter_clip_address;
uint8_t m_blitter_window_enable;
uint8_t m_cocktail;
std::unique_ptr<rgb_t[]> m_palette_lookup;
uint8_t m_blitterram[8];
uint8_t m_blitter_xor;
uint8_t m_blitter_remap_index;
const uint8_t *m_blitter_remap;
std::unique_ptr<uint8_t[]> m_blitter_remap_lookup;

virtual void machine_reset() override ATTR_COLD;
virtual void video_start() override ATTR_COLD;
Expand All @@ -126,23 +99,17 @@ class williams_state : public driver_device
void vram_select_w(u8 data);
void sinistar_vram_select_w(u8 data);
void cmos_4bit_w(offs_t offset, u8 data);
void blitter_w(address_space &space, offs_t offset, u8 data);

template <unsigned A, unsigned... B>
TIMER_CALLBACK_MEMBER(deferred_snd_cmd_w);
virtual void snd_cmd_w(u8 data);
void playball_snd_cmd_w(u8 data);
void cockpit_snd_cmd_w(u8 data);

void state_save_register();
void blitter_init(int blitter_config, const uint8_t *remap_prom);
inline void blit_pixel(address_space &space, int dstaddr, int srcdata, int controlbyte);
int blitter_core(address_space &space, int sstart, int dstart, int w, int h, int data);

void williams_base(machine_config &config);
void williams_muxed(machine_config &config);

void main_map(address_map &map) ATTR_COLD;
void main_map_blitter(address_map &map) ATTR_COLD;
void bubbles_main_map(address_map &map) ATTR_COLD;
void sinistar_main_map(address_map &map) ATTR_COLD;
void spdball_main_map(address_map &map) ATTR_COLD;
Expand Down Expand Up @@ -237,7 +204,6 @@ class blaster_state : public williams_state

void blaster_vram_select_w(u8 data);
void bank_select_w(u8 data);
void remap_select_w(u8 data);
void video_control_w(u8 data);
TIMER_CALLBACK_MEMBER(deferred_snd_cmd_w);
void blaster_snd_cmd_w(u8 data);
Expand Down
4 changes: 2 additions & 2 deletions src/mame/midway/williams_m.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void williams_state::sinistar_vram_select_w(u8 data)
vram_select_w(data);

// window enable from bit 2 (clips to 0x7400)
m_blitter_window_enable = BIT(data, 2);
m_blitter->window_enable_w(BIT(data, 2));
}


Expand Down Expand Up @@ -421,7 +421,7 @@ void blaster_state::blaster_vram_select_w(u8 data)
m_cocktail = BIT(data, 1);

// window enable from bit 2 (clips to 0x9700)
m_blitter_window_enable = BIT(data, 2);
m_blitter->window_enable_w(BIT(data, 2));
}


Expand Down
Loading

0 comments on commit 9197eb1

Please sign in to comment.