From 6b6e43fa1c702ce692df4a63dbff44cbf868c001 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 17 Mar 2014 13:43:18 +0000 Subject: [PATCH] avgdvg is now device (nw) --- src/mame/drivers/asteroid.c | 22 +- src/mame/drivers/bwidow.c | 20 +- src/mame/drivers/bzone.c | 14 +- src/mame/drivers/mhavoc.c | 18 +- src/mame/drivers/omegrace.c | 16 +- src/mame/drivers/quantum.c | 18 +- src/mame/drivers/starwars.c | 10 +- src/mame/drivers/tempest.c | 18 +- src/mame/drivers/tomcat.c | 10 +- src/mame/includes/asteroid.h | 5 +- src/mame/machine/asteroid.c | 4 +- src/mame/video/avgdvg.c | 1818 ++++++++++++++++------------------ src/mame/video/avgdvg.h | 281 +++++- 13 files changed, 1216 insertions(+), 1038 deletions(-) diff --git a/src/mame/drivers/asteroid.c b/src/mame/drivers/asteroid.c index bcd4628f632..d44eedd1b21 100644 --- a/src/mame/drivers/asteroid.c +++ b/src/mame/drivers/asteroid.c @@ -196,7 +196,6 @@ There is not a rev 03 known or dumped. An Asteroids rev 03 is not mentioned in a #include "includes/asteroid.h" #include "sound/discrete.h" #include "sound/pokey.h" -#include "drivlgcy.h" #include "astdelux.lh" @@ -249,7 +248,7 @@ static ADDRESS_MAP_START( asteroid_map, AS_PROGRAM, 8, asteroid_state ) AM_RANGE(0x2000, 0x2007) AM_READ(asteroid_IN0_r) /* IN0 */ AM_RANGE(0x2400, 0x2407) AM_READ(asteroid_IN1_r) /* IN1 */ AM_RANGE(0x2800, 0x2803) AM_READ(asteroid_DSW1_r) /* DSW1 */ - AM_RANGE(0x3000, 0x3000) AM_WRITE_LEGACY(avgdvg_go_w) + AM_RANGE(0x3000, 0x3000) AM_DEVWRITE("dvg", dvg_device, go_w) AM_RANGE(0x3200, 0x3200) AM_WRITE(asteroid_bank_switch_w) AM_RANGE(0x3400, 0x3400) AM_WRITE(watchdog_reset_w) AM_RANGE(0x3600, 0x3600) AM_WRITE(asteroid_explode_w) @@ -272,7 +271,7 @@ static ADDRESS_MAP_START( astdelux_map, AS_PROGRAM, 8, asteroid_state ) AM_RANGE(0x2800, 0x2803) AM_READ(asteroid_DSW1_r) /* DSW1 */ AM_RANGE(0x2c00, 0x2c0f) AM_DEVREADWRITE("pokey", pokey_device, read, write) AM_RANGE(0x2c40, 0x2c7f) AM_DEVREAD("earom", atari_vg_earom_device, read) - AM_RANGE(0x3000, 0x3000) AM_WRITE_LEGACY(avgdvg_go_w) + AM_RANGE(0x3000, 0x3000) AM_DEVWRITE("dvg", dvg_device, go_w) AM_RANGE(0x3200, 0x323f) AM_DEVWRITE("earom", atari_vg_earom_device, write) AM_RANGE(0x3400, 0x3400) AM_WRITE(watchdog_reset_w) AM_RANGE(0x3600, 0x3600) AM_WRITE(asteroid_explode_w) @@ -295,7 +294,7 @@ static ADDRESS_MAP_START( llander_map, AS_PROGRAM, 8, asteroid_state ) AM_RANGE(0x2400, 0x2407) AM_READ(asteroid_IN1_r) /* IN1 */ AM_RANGE(0x2800, 0x2803) AM_READ(asteroid_DSW1_r) /* DSW1 */ AM_RANGE(0x2c00, 0x2c00) AM_READ_PORT("THRUST") - AM_RANGE(0x3000, 0x3000) AM_WRITE_LEGACY(avgdvg_go_w) + AM_RANGE(0x3000, 0x3000) AM_DEVWRITE("dvg", dvg_device, go_w) AM_RANGE(0x3200, 0x3200) AM_WRITE(llander_led_w) AM_RANGE(0x3400, 0x3400) AM_WRITE(watchdog_reset_w) AM_RANGE(0x3c00, 0x3c00) AM_WRITE(llander_sounds_w) @@ -323,7 +322,7 @@ static INPUT_PORTS_START( asteroid ) PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* Bit 2 is the 3 KHz source and Bit 3 the VG_HALT bit */ PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, asteroid_state,clock_r, NULL) - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("dvg", dvg_device, done_r, NULL) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_CODE(KEYCODE_SPACE) PORT_CODE(JOYCODE_BUTTON3) /* hyperspace */ PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(JOYCODE_BUTTON1) /* fire */ PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE ) PORT_NAME("Diagnostic Step") PORT_CODE(KEYCODE_F1) @@ -377,7 +376,7 @@ static INPUT_PORTS_START( asteroidb ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* Bit 7 is VG_HALT */ - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("dvg", dvg_device, done_r, NULL) PORT_MODIFY("IN1") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 ) @@ -414,7 +413,7 @@ static INPUT_PORTS_START( asterock ) PORT_MODIFY("IN0") /* Bit 0 is VG_HALT and Bit 2 is the 3 KHz source */ - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("dvg", dvg_device, done_r, NULL) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, asteroid_state,clock_r, NULL) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_CODE(KEYCODE_SPACE) PORT_CODE(JOYCODE_BUTTON3) /* hyperspace */ @@ -457,7 +456,7 @@ static INPUT_PORTS_START( astdelux ) PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) /* According to schematics */ /* Bit 2 is the 3 KHz source and Bit 3 the VG_HALT bit */ PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, asteroid_state,clock_r, NULL) - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("dvg", dvg_device, done_r, NULL) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_CODE(KEYCODE_SPACE) PORT_CODE(JOYCODE_BUTTON3) /* hyperspace */ PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(JOYCODE_BUTTON1) /* fire */ PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE ) PORT_NAME("Diagnostic Step") PORT_CODE(KEYCODE_F1) @@ -539,7 +538,7 @@ INPUT_PORTS_END static INPUT_PORTS_START( llander ) PORT_START("IN0") /* Bit 0 is VG_HALT */ - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("dvg", dvg_device, done_r, NULL) PORT_SERVICE( 0x02, IP_ACTIVE_LOW ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_TILT ) /* Of the rest, Bit 6 is the 3KHz source. 3,4 and 5 are unknown */ @@ -645,8 +644,9 @@ static MACHINE_CONFIG_START( asteroid, asteroid_state ) MCFG_SCREEN_VISIBLE_AREA(522, 1566, 394, 1182) MCFG_SCREEN_UPDATE_DEVICE("vector", vector_device, screen_update) - MCFG_VIDEO_START(dvg) - + MCFG_DEVICE_ADD("dvg", DVG, 0) + MCFG_AVGDVG_VECTOR("vector") + /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mame/drivers/bwidow.c b/src/mame/drivers/bwidow.c index 285b48f255b..46e69f5f6cc 100644 --- a/src/mame/drivers/bwidow.c +++ b/src/mame/drivers/bwidow.c @@ -226,7 +226,6 @@ #include "includes/bwidow.h" -#include "drivlgcy.h" #define IN_LEFT (1 << 0) @@ -364,8 +363,8 @@ static ADDRESS_MAP_START( bwidow_map, AS_PROGRAM, 8, bwidow_state ) AM_RANGE(0x8000, 0x8000) AM_READ_PORT("IN3") AM_RANGE(0x8800, 0x8800) AM_READ_PORT("IN4") AM_RANGE(0x8800, 0x8800) AM_WRITE(bwidow_misc_w) /* coin counters, leds */ - AM_RANGE(0x8840, 0x8840) AM_WRITE_LEGACY(avgdvg_go_w) - AM_RANGE(0x8880, 0x8880) AM_WRITE_LEGACY(avgdvg_reset_w) + AM_RANGE(0x8840, 0x8840) AM_DEVWRITE("avg", avg_device, go_w) + AM_RANGE(0x8880, 0x8880) AM_DEVWRITE("avg", avg_device, reset_w) AM_RANGE(0x88c0, 0x88c0) AM_WRITE(irq_ack_w) /* interrupt acknowledge */ AM_RANGE(0x8900, 0x8900) AM_DEVWRITE("earom", atari_vg_earom_device, ctrl_w) AM_RANGE(0x8940, 0x897f) AM_DEVWRITE("earom", atari_vg_earom_device, write) @@ -381,9 +380,9 @@ static ADDRESS_MAP_START( spacduel_map, AS_PROGRAM, 8, bwidow_state ) AM_RANGE(0x0905, 0x0906) AM_WRITENOP /* ignore? */ AM_RANGE(0x0a00, 0x0a00) AM_DEVREAD("earom", atari_vg_earom_device, read) // AM_RANGE(0x0c00, 0x0c00) AM_WRITE(coin_counter_w) /* coin out */ - AM_RANGE(0x0c80, 0x0c80) AM_WRITE_LEGACY(avgdvg_go_w) + AM_RANGE(0x0c80, 0x0c80) AM_DEVWRITE("avg", avg_device, go_w) AM_RANGE(0x0d00, 0x0d00) AM_WRITENOP /* watchdog clear */ - AM_RANGE(0x0d80, 0x0d80) AM_WRITE_LEGACY(avgdvg_reset_w) + AM_RANGE(0x0d80, 0x0d80) AM_DEVWRITE("avg", avg_device, reset_w) AM_RANGE(0x0e00, 0x0e00) AM_WRITE(irq_ack_w) /* interrupt acknowledge */ AM_RANGE(0x0e80, 0x0e80) AM_DEVWRITE("earom", atari_vg_earom_device, ctrl_w) AM_RANGE(0x0f00, 0x0f3f) AM_DEVWRITE("earom", atari_vg_earom_device, write) @@ -411,7 +410,7 @@ static INPUT_PORTS_START( bwidow ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Diagnostic Step") PORT_CODE(KEYCODE_F1) /* bit 6 is the VG HALT bit. We set it to "low" */ /* per default (busy vector processor). */ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("avg", avg_device, done_r, NULL) /* bit 7 is tied to a 3kHz clock */ PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, bwidow_state,clock_r, NULL) @@ -490,7 +489,7 @@ static INPUT_PORTS_START( gravitar ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Diagnostic Step") PORT_CODE(KEYCODE_F1) /* bit 6 is the VG HALT bit. We set it to "low" */ /* per default (busy vector processor). */ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("avg", avg_device, done_r, NULL) /* bit 7 is tied to a 3kHz clock */ PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, bwidow_state,clock_r, NULL) @@ -564,7 +563,7 @@ static INPUT_PORTS_START( lunarbat ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* bit 6 is the VG HALT bit. We set it to "low" */ /* per default (busy vector processor). */ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("avg", avg_device, done_r, NULL) /* bit 7 is tied to a 3kHz clock */ PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, bwidow_state,clock_r, NULL) @@ -598,7 +597,7 @@ static INPUT_PORTS_START( spacduel ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Diagnostic Step") PORT_CODE(KEYCODE_F1) /* bit 6 is the VG HALT bit. We set it to "low" */ /* per default (busy vector processor). */ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("avg", avg_device, done_r, NULL) /* bit 7 is tied to a 3kHz clock */ PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, bwidow_state,clock_r, NULL) @@ -708,7 +707,8 @@ static MACHINE_CONFIG_START( bwidow, bwidow_state ) MCFG_SCREEN_VISIBLE_AREA(0, 480, 0, 440) MCFG_SCREEN_UPDATE_DEVICE("vector", vector_device, screen_update) - MCFG_VIDEO_START(avg) + MCFG_DEVICE_ADD("avg", AVG, 0) + MCFG_AVGDVG_VECTOR("vector") /* sound hardware */ MCFG_FRAGMENT_ADD(bwidow_audio) diff --git a/src/mame/drivers/bzone.c b/src/mame/drivers/bzone.c index 6e654e724d1..9270d8062df 100644 --- a/src/mame/drivers/bzone.c +++ b/src/mame/drivers/bzone.c @@ -211,7 +211,6 @@ #include "machine/atari_vg.h" #include "includes/bzone.h" #include "sound/pokey.h" -#include "drivlgcy.h" #include "bzone.lh" #include "redbaron.lh" @@ -302,9 +301,9 @@ static ADDRESS_MAP_START( bzone_map, AS_PROGRAM, 8, bzone_state ) AM_RANGE(0x0a00, 0x0a00) AM_READ_PORT("DSW0") AM_RANGE(0x0c00, 0x0c00) AM_READ_PORT("DSW1") AM_RANGE(0x1000, 0x1000) AM_WRITE(bzone_coin_counter_w) - AM_RANGE(0x1200, 0x1200) AM_WRITE_LEGACY(avgdvg_go_w) + AM_RANGE(0x1200, 0x1200) AM_DEVWRITE("avg", avg_bzone_device, go_w) AM_RANGE(0x1400, 0x1400) AM_WRITE(watchdog_reset_w) - AM_RANGE(0x1600, 0x1600) AM_WRITE_LEGACY(avgdvg_reset_w) + AM_RANGE(0x1600, 0x1600) AM_DEVWRITE("avg", avg_bzone_device, reset_w) AM_RANGE(0x1800, 0x1800) AM_DEVREAD("mathbox", mathbox_device, status_r) AM_RANGE(0x1810, 0x1810) AM_DEVREAD("mathbox", mathbox_device, lo_r) AM_RANGE(0x1818, 0x1818) AM_DEVREAD("mathbox", mathbox_device, hi_r) @@ -322,9 +321,9 @@ static ADDRESS_MAP_START( redbaron_map, AS_PROGRAM, 8, bzone_state ) AM_RANGE(0x0a00, 0x0a00) AM_READ_PORT("DSW0") AM_RANGE(0x0c00, 0x0c00) AM_READ_PORT("DSW1") AM_RANGE(0x1000, 0x1000) AM_WRITENOP /* coin out - Manual states this is "Coin Counter" */ - AM_RANGE(0x1200, 0x1200) AM_WRITE_LEGACY(avgdvg_go_w) + AM_RANGE(0x1200, 0x1200) AM_DEVWRITE("avg", avg_bzone_device, go_w) AM_RANGE(0x1400, 0x1400) AM_WRITE(watchdog_reset_w) - AM_RANGE(0x1600, 0x1600) AM_WRITE_LEGACY(avgdvg_reset_w) + AM_RANGE(0x1600, 0x1600) AM_DEVWRITE("avg", avg_bzone_device, reset_w) AM_RANGE(0x1800, 0x1800) AM_DEVREAD("mathbox", mathbox_device, status_r) AM_RANGE(0x1802, 0x1802) AM_READ_PORT("IN4") AM_RANGE(0x1804, 0x1804) AM_DEVREAD("mathbox", mathbox_device, lo_r) @@ -356,7 +355,7 @@ ADDRESS_MAP_END PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Diagnostic Step") PORT_CODE(KEYCODE_F1)\ /* bit 6 is the VG HALT bit. We set it to "low" */\ /* per default (busy vector processor). */\ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL)\ + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("avg", avg_bzone_device, done_r, NULL)\ /* bit 7 is tied to a 3kHz clock */\ PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, bzone_state,clock_r, NULL) @@ -562,7 +561,8 @@ static MACHINE_CONFIG_START( bzone_base, bzone_state ) MCFG_SCREEN_VISIBLE_AREA(0, 580, 0, 400) MCFG_SCREEN_UPDATE_DEVICE("vector", vector_device, screen_update) - MCFG_VIDEO_START(avg_bzone) + MCFG_DEVICE_ADD("avg", AVG_BZONE, 0) + MCFG_AVGDVG_VECTOR("vector") /* Drivers */ MCFG_MATHBOX_ADD("mathbox") diff --git a/src/mame/drivers/mhavoc.c b/src/mame/drivers/mhavoc.c index 7d4cca0e1ea..34014214838 100644 --- a/src/mame/drivers/mhavoc.c +++ b/src/mame/drivers/mhavoc.c @@ -192,7 +192,6 @@ #include "sound/pokey.h" #include "machine/nvram.h" #include "includes/mhavoc.h" -#include "drivlgcy.h" READ8_MEMBER(mhavoc_state::quad_pokeyn_r) @@ -265,9 +264,9 @@ static ADDRESS_MAP_START( alpha_map, AS_PROGRAM, 8, mhavoc_state ) AM_RANGE(0x1200, 0x1200) AM_READ_PORT("IN0") AM_WRITENOP /* Alpha Input Port 0 */ AM_RANGE(0x1400, 0x141f) AM_RAM AM_SHARE("colorram") /* ColorRAM */ AM_RANGE(0x1600, 0x1600) AM_WRITE(mhavoc_out_0_w) /* Control Signals */ - AM_RANGE(0x1640, 0x1640) AM_WRITE_LEGACY(avgdvg_go_w) /* Vector Generator GO */ + AM_RANGE(0x1640, 0x1640) AM_DEVWRITE("avg", avg_mhavoc_device, go_w) /* Vector Generator GO */ AM_RANGE(0x1680, 0x1680) AM_WRITE(watchdog_reset_w) /* Watchdog Clear */ - AM_RANGE(0x16c0, 0x16c0) AM_WRITE_LEGACY(avgdvg_reset_w) /* Vector Generator Reset */ + AM_RANGE(0x16c0, 0x16c0) AM_DEVWRITE("avg", avg_mhavoc_device, reset_w) /* Vector Generator Reset */ AM_RANGE(0x1700, 0x1700) AM_WRITE(mhavoc_alpha_irq_ack_w) /* IRQ ack */ AM_RANGE(0x1740, 0x1740) AM_WRITE(mhavoc_rom_banksel_w) /* Program ROM Page Select */ AM_RANGE(0x1780, 0x1780) AM_WRITE(mhavoc_ram_banksel_w) /* Program RAM Page Select */ @@ -320,9 +319,9 @@ static ADDRESS_MAP_START( alphaone_map, AS_PROGRAM, 8, mhavoc_state ) AM_RANGE(0x1060, 0x1060) AM_READ_PORT("IN1") /* Gamma Input Port */ AM_RANGE(0x1080, 0x1080) AM_READ_PORT("DIAL") /* Roller Controller Input*/ AM_RANGE(0x10a0, 0x10a0) AM_WRITE(alphaone_out_0_w) /* Control Signals */ - AM_RANGE(0x10a4, 0x10a4) AM_WRITE_LEGACY(avgdvg_go_w) /* Vector Generator GO */ + AM_RANGE(0x10a4, 0x10a4) AM_DEVWRITE("avg", avg_mhavoc_device, go_w) /* Vector Generator GO */ AM_RANGE(0x10a8, 0x10a8) AM_WRITE(watchdog_reset_w) /* Watchdog Clear */ - AM_RANGE(0x10ac, 0x10ac) AM_WRITE_LEGACY(avgdvg_reset_w) /* Vector Generator Reset */ + AM_RANGE(0x10ac, 0x10ac) AM_DEVWRITE("avg", avg_mhavoc_device, reset_w) /* Vector Generator Reset */ AM_RANGE(0x10b0, 0x10b0) AM_WRITE(mhavoc_alpha_irq_ack_w) /* IRQ ack */ AM_RANGE(0x10b4, 0x10b4) AM_WRITE(mhavoc_rom_banksel_w) AM_RANGE(0x10b8, 0x10b8) AM_WRITE(mhavoc_ram_banksel_w) @@ -361,7 +360,7 @@ static INPUT_PORTS_START( mhavoc ) /* Bit 2 = Gamma xmtd flag */ /* Bit 1 = 2.4kHz (divide 2.5MHz by 1024) */ /* Bit 0 = Vector generator halt flag */ - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("avg", avg_mhavoc_device, done_r, NULL) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, mhavoc_state,clock_r, NULL) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, mhavoc_state,gamma_xmtd_r, NULL) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, mhavoc_state,gamma_rcvd_r, NULL) @@ -460,7 +459,7 @@ INPUT_PORTS_END static INPUT_PORTS_START( alphaone ) PORT_START("IN0") /* alpha (player_1 = 0) */ - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("avg", avg_mhavoc_device, done_r, NULL) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, mhavoc_state,clock_r, NULL) PORT_BIT( 0x7c, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) @@ -517,8 +516,9 @@ static MACHINE_CONFIG_START( mhavoc, mhavoc_state ) MCFG_SCREEN_SIZE(400, 300) MCFG_SCREEN_VISIBLE_AREA(0, 300, 0, 260) MCFG_SCREEN_UPDATE_DEVICE("vector", vector_device, screen_update) - - MCFG_VIDEO_START(avg_mhavoc) + + MCFG_DEVICE_ADD("avg", AVG_MHAVOC, 0) + MCFG_AVGDVG_VECTOR("vector") /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mame/drivers/omegrace.c b/src/mame/drivers/omegrace.c index 6fb28cc1b0c..75a2dd82450 100644 --- a/src/mame/drivers/omegrace.c +++ b/src/mame/drivers/omegrace.c @@ -219,7 +219,6 @@ #include "video/avgdvg.h" #include "sound/ay8910.h" #include "machine/nvram.h" -#include "drivlgcy.h" #include "omegrace.lh" @@ -230,10 +229,12 @@ public: omegrace_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), - m_audiocpu(*this, "audiocpu") { } + m_audiocpu(*this, "audiocpu"), + m_dvg(*this, "dvg") { } required_device m_maincpu; required_device m_audiocpu; + required_device m_dvg; DECLARE_READ8_MEMBER(omegrace_vg_go_r); DECLARE_READ8_MEMBER(omegrace_spinner1_r); @@ -254,7 +255,7 @@ void omegrace_state::machine_reset() { address_space &space = m_maincpu->space(AS_PROGRAM); /* Omega Race expects the vector processor to be ready. */ - avgdvg_reset_w(space, 0, 0); +m_dvg->reset_w(space, 0, 0); } @@ -267,7 +268,7 @@ void omegrace_state::machine_reset() READ8_MEMBER(omegrace_state::omegrace_vg_go_r) { - avgdvg_go_w(space, 0, 0); + m_dvg->go_w(space, 0, 0); return 0; } @@ -359,7 +360,7 @@ static ADDRESS_MAP_START( port_map, AS_IO, 8, omegrace_state ) ADDRESS_MAP_GLOBAL_MASK(0xff) AM_RANGE(0x08, 0x08) AM_READ(omegrace_vg_go_r) AM_RANGE(0x09, 0x09) AM_READ(watchdog_reset_r) - AM_RANGE(0x0a, 0x0a) AM_WRITE_LEGACY(avgdvg_reset_w) + AM_RANGE(0x0a, 0x0a) AM_DEVWRITE("dvg", dvg_device, reset_w) AM_RANGE(0x0b, 0x0b) AM_READ_PORT("AVGDVG") /* vg_halt */ AM_RANGE(0x10, 0x10) AM_READ_PORT("DSW1") /* DIP SW C4 */ AM_RANGE(0x17, 0x17) AM_READ_PORT("DSW2") /* DIP SW C6 */ @@ -476,7 +477,7 @@ static INPUT_PORTS_START( omegrace ) PORT_BIT( 0x3f, 0x00, IPT_DIAL ) PORT_SENSITIVITY(12) PORT_KEYDELTA(10) PORT_COCKTAIL PORT_START("AVGDVG") /* port 0x0b */ - PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("dvg", dvg_device, done_r, NULL) INPUT_PORTS_END @@ -518,7 +519,8 @@ static MACHINE_CONFIG_START( omegrace, omegrace_state ) MCFG_SCREEN_VISIBLE_AREA(522, 1566, 522, 1566) MCFG_SCREEN_UPDATE_DEVICE("vector", vector_device, screen_update) - MCFG_VIDEO_START(dvg) + MCFG_DEVICE_ADD("dvg", DVG, 0) + MCFG_AVGDVG_VECTOR("vector") /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mame/drivers/quantum.c b/src/mame/drivers/quantum.c index d42df098822..3a57fe3aa60 100644 --- a/src/mame/drivers/quantum.c +++ b/src/mame/drivers/quantum.c @@ -50,7 +50,6 @@ #include "sound/pokey.h" #include "sound/discrete.h" #include "machine/nvram.h" -#include "drivlgcy.h" class quantum_state : public driver_device @@ -58,13 +57,15 @@ class quantum_state : public driver_device public: quantum_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu") { } + m_maincpu(*this, "maincpu"), + m_avg(*this, "avg") { } DECLARE_READ16_MEMBER(trackball_r); DECLARE_WRITE16_MEMBER(led_w); DECLARE_READ8_MEMBER(input_1_r); DECLARE_READ8_MEMBER(input_2_r); required_device m_maincpu; + required_device m_avg; }; @@ -118,8 +119,8 @@ WRITE16_MEMBER(quantum_state::led_w) set_led_status(machine(), 1, data & 0x20); /* bits 6 and 7 flip screen */ - avg_set_flip_x (data & 0x40); - avg_set_flip_y (data & 0x80); + m_avg->set_flip_x (data & 0x40); + m_avg->set_flip_y (data & 0x80); } } @@ -143,8 +144,8 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16, quantum_state ) AM_RANGE(0x950000, 0x95001f) AM_WRITEONLY AM_SHARE("colorram") AM_RANGE(0x958000, 0x958001) AM_WRITE(led_w) AM_RANGE(0x960000, 0x960001) AM_WRITENOP - AM_RANGE(0x968000, 0x968001) AM_WRITE_LEGACY(avgdvg_reset_word_w) - AM_RANGE(0x970000, 0x970001) AM_WRITE_LEGACY(avgdvg_go_word_w) + AM_RANGE(0x968000, 0x968001) AM_DEVWRITE("avg", avg_quantum_device, reset_word_w) + AM_RANGE(0x970000, 0x970001) AM_DEVWRITE("avg", avg_quantum_device, go_word_w) AM_RANGE(0x978000, 0x978001) AM_READNOP AM_WRITE(watchdog_reset16_w) ADDRESS_MAP_END @@ -158,7 +159,7 @@ ADDRESS_MAP_END static INPUT_PORTS_START( quantum ) PORT_START("SYSTEM") /* YHALT here MUST BE ALWAYS 0 */ - PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) /* vg YHALT */ + PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("avg", avg_quantum_device, done_r, NULL) /* vg YHALT */ PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_START2 ) @@ -307,7 +308,8 @@ static MACHINE_CONFIG_START( quantum, quantum_state ) MCFG_SCREEN_VISIBLE_AREA(0, 900, 0, 600) MCFG_SCREEN_UPDATE_DEVICE("vector", vector_device, screen_update) - MCFG_VIDEO_START(avg_quantum) + MCFG_DEVICE_ADD("avg", AVG_QUANTUM, 0) + MCFG_AVGDVG_VECTOR("vector") /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mame/drivers/starwars.c b/src/mame/drivers/starwars.c index 91b609a1231..aa07ce69236 100644 --- a/src/mame/drivers/starwars.c +++ b/src/mame/drivers/starwars.c @@ -31,7 +31,6 @@ #include "machine/x2212.h" #include "includes/starwars.h" #include "includes/slapstic.h" -#include "drivlgcy.h" #define MASTER_CLOCK (12096000) @@ -172,8 +171,8 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, starwars_state ) AM_RANGE(0x4400, 0x4400) AM_READWRITE(starwars_main_read_r, starwars_main_wr_w) AM_RANGE(0x4401, 0x4401) AM_READ(starwars_main_ready_flag_r) AM_RANGE(0x4500, 0x45ff) AM_DEVREADWRITE("x2212", x2212_device, read, write) - AM_RANGE(0x4600, 0x461f) AM_WRITE_LEGACY(avgdvg_go_w) - AM_RANGE(0x4620, 0x463f) AM_WRITE_LEGACY(avgdvg_reset_w) + AM_RANGE(0x4600, 0x461f) AM_DEVWRITE("avg", avg_starwars_device, go_w) + AM_RANGE(0x4620, 0x463f) AM_DEVWRITE("avg", avg_starwars_device, reset_w) AM_RANGE(0x4640, 0x465f) AM_WRITE(watchdog_reset_w) AM_RANGE(0x4660, 0x467f) AM_WRITE(irq_ack_w) AM_RANGE(0x4680, 0x469f) AM_READNOP AM_WRITE(starwars_out_w) @@ -239,7 +238,7 @@ static INPUT_PORTS_START( starwars ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) /* Bit 6 is VG_HALT */ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("avg", avg_starwars_device, done_r, NULL) /* Bit 7 is MATH_RUN - see machine/starwars.c */ PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, starwars_state,matrix_flag_r, NULL) @@ -348,7 +347,8 @@ static MACHINE_CONFIG_START( starwars, starwars_state ) MCFG_SCREEN_VISIBLE_AREA(0, 250, 0, 280) MCFG_SCREEN_UPDATE_DEVICE("vector", vector_device, screen_update) - MCFG_VIDEO_START(avg_starwars) + MCFG_DEVICE_ADD("avg", AVG_STARWARS, 0) + MCFG_AVGDVG_VECTOR("vector") /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mame/drivers/tempest.c b/src/mame/drivers/tempest.c index bf2b8b43425..14874caaf66 100644 --- a/src/mame/drivers/tempest.c +++ b/src/mame/drivers/tempest.c @@ -280,7 +280,6 @@ Note: Roms for Tempest Analog Vector-Generator PCB Assembly A037383-03 or A03738 #include "video/vector.h" #include "machine/atari_vg.h" #include "sound/pokey.h" -#include "drivlgcy.h" class tempest_state : public driver_device @@ -289,10 +288,12 @@ public: tempest_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), - m_mathbox(*this, "mathbox") { } + m_mathbox(*this, "mathbox"), + m_avg(*this, "avg") { } required_device m_maincpu; required_device m_mathbox; + required_device m_avg; UINT8 m_player_select; DECLARE_WRITE8_MEMBER(wdclr_w); @@ -391,8 +392,8 @@ WRITE8_MEMBER(tempest_state::tempest_coin_w) coin_counter_w(machine(), 0, (data & 0x01)); coin_counter_w(machine(), 1, (data & 0x02)); coin_counter_w(machine(), 2, (data & 0x04)); - avg_set_flip_x(data & 0x08); - avg_set_flip_y(data & 0x10); + m_avg->set_flip_x(data & 0x08); + m_avg->set_flip_y(data & 0x10); } @@ -412,9 +413,9 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, tempest_state ) AM_RANGE(0x2000, 0x2fff) AM_RAM AM_SHARE("vectorram") AM_REGION("maincpu", 0x2000) AM_RANGE(0x3000, 0x3fff) AM_ROM AM_RANGE(0x4000, 0x4000) AM_WRITE(tempest_coin_w) - AM_RANGE(0x4800, 0x4800) AM_WRITE_LEGACY(avgdvg_go_w) + AM_RANGE(0x4800, 0x4800) AM_DEVWRITE("avg", avg_tempest_device, go_w) AM_RANGE(0x5000, 0x5000) AM_WRITE(wdclr_w) - AM_RANGE(0x5800, 0x5800) AM_WRITE_LEGACY(avgdvg_reset_w) + AM_RANGE(0x5800, 0x5800) AM_DEVWRITE("avg", avg_tempest_device, reset_w) AM_RANGE(0x6000, 0x603f) AM_DEVWRITE("earom", atari_vg_earom_device, write) AM_RANGE(0x6040, 0x6040) AM_DEVREAD("mathbox", mathbox_device, status_r) AM_DEVWRITE("earom", atari_vg_earom_device, ctrl_w) AM_RANGE(0x6050, 0x6050) AM_DEVREAD("earom", atari_vg_earom_device, read) @@ -445,7 +446,7 @@ static INPUT_PORTS_START( tempest ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Diagnostic Step") PORT_CODE(KEYCODE_F1) /* bit 6 is the VG HALT bit. We set it to "low" */ /* per default (busy vector processor). */ - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("avg", avg_tempest_device, done_r, NULL) /* bit 7 is tied to a 3kHz (?) clock */ PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, tempest_state,clock_r, NULL) @@ -608,7 +609,8 @@ static MACHINE_CONFIG_START( tempest, tempest_state ) MCFG_SCREEN_VISIBLE_AREA(0, 580, 0, 570) MCFG_SCREEN_UPDATE_DEVICE("vector", vector_device, screen_update) - MCFG_VIDEO_START(avg_tempest) + MCFG_DEVICE_ADD("avg", AVG_TEMPEST, 0) + MCFG_AVGDVG_VECTOR("vector") /* Drivers */ MCFG_MATHBOX_ADD("mathbox") diff --git a/src/mame/drivers/tomcat.c b/src/mame/drivers/tomcat.c index 0f55b6af0fe..71973bae77d 100644 --- a/src/mame/drivers/tomcat.c +++ b/src/mame/drivers/tomcat.c @@ -34,7 +34,6 @@ #include "sound/pokey.h" #include "sound/tms5220.h" #include "sound/2151intf.h" -#include "drivlgcy.h" @@ -285,8 +284,8 @@ WRITE8_MEMBER(tomcat_state::tomcat_nvram_w) static ADDRESS_MAP_START( tomcat_map, AS_PROGRAM, 16, tomcat_state ) AM_RANGE(0x000000, 0x00ffff) AM_ROM AM_RANGE(0x402000, 0x402001) AM_READ(tomcat_adcread_r) AM_WRITE(tomcat_adcon_w) - AM_RANGE(0x404000, 0x404001) AM_READ(tomcat_inputs_r) AM_WRITE_LEGACY(avgdvg_go_word_w) - AM_RANGE(0x406000, 0x406001) AM_WRITE_LEGACY(avgdvg_reset_word_w) + AM_RANGE(0x404000, 0x404001) AM_READ(tomcat_inputs_r) AM_DEVWRITE("avg", avg_tomcat_device, go_word_w) + AM_RANGE(0x406000, 0x406001) AM_DEVWRITE("avg", avg_tomcat_device, reset_word_w) AM_RANGE(0x408000, 0x408001) AM_READWRITE(tomcat_inputs2_r, watchdog_reset16_w) AM_RANGE(0x40a000, 0x40a001) AM_READWRITE(tomcat_320bio_r, tomcat_irqclr_w) AM_RANGE(0x40e000, 0x40e001) AM_WRITE(tomcat_led1on_w) @@ -348,7 +347,7 @@ ADDRESS_MAP_END static INPUT_PORTS_START( tomcat ) PORT_START("IN0") /* INPUTS */ - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(avgdvg_done_r, NULL) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("avg", avg_tomcat_device, done_r, NULL) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) // SPARE PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON5 ) // DIAGNOSTIC PORT_SERVICE( 0x08, IP_ACTIVE_LOW ) @@ -433,7 +432,8 @@ static MACHINE_CONFIG_START( tomcat, tomcat_state ) MCFG_SCREEN_VISIBLE_AREA(0, 280, 0, 250) MCFG_SCREEN_UPDATE_DEVICE("vector", vector_device, screen_update) - MCFG_VIDEO_START(avg_tomcat) + MCFG_DEVICE_ADD("avg", AVG_TOMCAT, 0) + MCFG_AVGDVG_VECTOR("vector") MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") MCFG_POKEY_ADD("pokey1", XTAL_14_31818MHz / 8) diff --git a/src/mame/includes/asteroid.h b/src/mame/includes/asteroid.h index 66188c11a5f..63a70f268fc 100644 --- a/src/mame/includes/asteroid.h +++ b/src/mame/includes/asteroid.h @@ -5,6 +5,7 @@ *************************************************************************/ #include "sound/discrete.h" +#include "video/avgdvg.h" class asteroid_state : public driver_device { @@ -14,7 +15,8 @@ public: m_ram1(*this, "ram1"), m_ram2(*this, "ram2"), m_discrete(*this, "discrete") , - m_maincpu(*this, "maincpu") { } + m_maincpu(*this, "maincpu"), + m_dvg(*this, "dvg") { } optional_shared_ptr m_ram1; optional_shared_ptr m_ram2; @@ -44,6 +46,7 @@ public: DECLARE_WRITE8_MEMBER(llander_sounds_w); DECLARE_MACHINE_RESET(llander); required_device m_maincpu; + required_device m_dvg; }; /*----------- defined in audio/asteroid.c -----------*/ diff --git a/src/mame/machine/asteroid.c b/src/mame/machine/asteroid.c index b04697434dd..09c5946fed1 100644 --- a/src/mame/machine/asteroid.c +++ b/src/mame/machine/asteroid.c @@ -134,10 +134,10 @@ WRITE8_MEMBER(asteroid_state::astdelux_led_w) void asteroid_state::machine_reset() { asteroid_bank_switch_w(m_maincpu->space(AS_PROGRAM), 0, 0); - avgdvg_reset_w(m_maincpu->space(AS_PROGRAM), 0, 0); + m_dvg->reset_w(m_maincpu->space(AS_PROGRAM), 0, 0); } MACHINE_RESET_MEMBER(asteroid_state, llander) { - avgdvg_reset_w(m_maincpu->space(AS_PROGRAM), 0, 0); + m_dvg->reset_w(m_maincpu->space(AS_PROGRAM), 0, 0); } \ No newline at end of file diff --git a/src/mame/video/avgdvg.c b/src/mame/video/avgdvg.c index 0c400c66723..39d83938a8b 100644 --- a/src/mame/video/avgdvg.c +++ b/src/mame/video/avgdvg.c @@ -13,21 +13,6 @@ #include "emu.h" #include "avgdvg.h" -#include "video/vector.h" -#include "drivlgcy.h" - -/************************************* - * - * Global variables - * - *************************************/ - -static UINT8 *avgdvg_vectorram; -static size_t avgdvg_vectorram_size; - -static UINT8 *avgdvg_colorram; - - /************************************* * @@ -37,107 +22,15 @@ static UINT8 *avgdvg_colorram; #define MASTER_CLOCK (12096000) #define VGSLICE (10000) -#define MAXVECT (10000) - #define VGVECTOR 0 #define VGCLIP 1 -#define OP0 (vg->op & 1) -#define OP1 (vg->op & 2) -#define OP2 (vg->op & 4) -#define OP3 (vg->op & 8) +#define OP0 (m_op & 1) +#define OP1 (m_op & 2) +#define OP2 (m_op & 4) +#define OP3 (m_op & 8) -#define ST3 (vg->state_latch & 8) - - -/************************************* - * - * Typedefs - * - *************************************/ - -struct vgvector -{ - int x; int y; - rgb_t color; - int intensity; - int arg1; int arg2; - int status; -}; - -struct vgdata -{ - running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } - void set_machine(running_machine &machine) { m_machine = &machine; } - - UINT16 pc; - UINT8 sp; - UINT16 dvx; - UINT16 dvy; - UINT8 dvy12; - UINT16 timer; - UINT16 stack[4]; - UINT16 data; - - UINT8 state_latch; - UINT8 int_latch; - UINT8 scale; - UINT8 bin_scale; - UINT8 intensity; - UINT8 color; - UINT8 enspkl; - UINT8 spkl_shift; - UINT8 map; - - UINT16 hst; - UINT16 lst; - UINT16 izblank; - - UINT8 op; - UINT8 halt; - UINT8 sync_halt; - - UINT16 xdac_xor; - UINT16 ydac_xor; - - INT32 xpos; - INT32 ypos; - - INT32 clipx_min; - INT32 clipy_min; - INT32 clipx_max; - INT32 clipy_max; - -private: - running_machine *m_machine; -}; - -struct vgconf -{ - int (*handler[8])(vgdata *); - UINT8 (*state_addr)(vgdata *); - void (*update_databus)(vgdata *); - void (*vggo)(vgdata *); - void (*vgrst)(vgdata *); -}; - - -/************************************* - * - * Static variables - * - *************************************/ - -static int xmin, xmax, ymin, ymax; -static int xcenter, ycenter; -static emu_timer *vg_run_timer, *vg_halt_timer; - -static int flip_x, flip_y; - -static vgdata vgd, *vg; -static const vgconf *vgc; -static int nvect; -static vgvector vectbuf[MAXVECT]; +#define ST3 (m_state_latch & 8) /************************************* @@ -146,17 +39,17 @@ static vgvector vectbuf[MAXVECT]; * *************************************/ -void avg_set_flip_x(int flip) +void avgdvg_device::set_flip_x(int flip) { flip_x = flip; } -void avg_set_flip_y(int flip) +void avgdvg_device::set_flip_y(int flip) { flip_y = flip; } -static void avg_apply_flipping(int *x, int *y) +void avgdvg_device::apply_flipping(int *x, int *y) { if (flip_x) *x += (xcenter - *x) << 1; @@ -171,27 +64,27 @@ static void avg_apply_flipping(int *x, int *y) * *************************************/ -static void vg_flush (running_machine &machine) +void avgdvg_device::vg_flush() { int i = 0; while (vectbuf[i].status == VGCLIP) i++; - machine.device("vector")->add_point(vectbuf[i].x, vectbuf[i].y, vectbuf[i].color, 0); + m_vector->add_point(vectbuf[i].x, vectbuf[i].y, vectbuf[i].color, 0); for (i = 0; i < nvect; i++) { if (vectbuf[i].status == VGVECTOR) - machine.device("vector")->add_point(vectbuf[i].x, vectbuf[i].y, vectbuf[i].color, vectbuf[i].intensity); + m_vector->add_point(vectbuf[i].x, vectbuf[i].y, vectbuf[i].color, vectbuf[i].intensity); if (vectbuf[i].status == VGCLIP) - machine.device("vector")->add_clip(vectbuf[i].x, vectbuf[i].y, vectbuf[i].arg1, vectbuf[i].arg2); + m_vector->add_clip(vectbuf[i].x, vectbuf[i].y, vectbuf[i].arg1, vectbuf[i].arg2); } nvect=0; } -static void vg_add_point_buf(int x, int y, rgb_t color, int intensity) +void avgdvg_device::vg_add_point_buf(int x, int y, rgb_t color, int intensity) { if (nvect < MAXVECT) { @@ -204,7 +97,7 @@ static void vg_add_point_buf(int x, int y, rgb_t color, int intensity) } } -static void vg_add_clip (int xmin, int ymin, int xmax, int ymax) +void avgdvg_device::vg_add_clip (int xmin, int ymin, int xmax, int ymax) { if (nvect < MAXVECT) { @@ -224,52 +117,52 @@ static void vg_add_clip (int xmin, int ymin, int xmax, int ymax) * *************************************/ -static void dvg_data(vgdata *vg) +void dvg_device::update_databus() // dvg_data { /* * DVG uses low bit of state for address */ - vg->data = avgdvg_vectorram[(vg->pc << 1) | (vg->state_latch & 1)]; + m_data = avgdvg_vectorram[(m_pc << 1) | (m_state_latch & 1)]; } -static UINT8 dvg_state_addr(vgdata *vg) +UINT8 dvg_device::state_addr() // dvg_state_addr { UINT8 addr; - addr =((((vg->state_latch >> 4) ^ 1) & 1) << 7) | (vg->state_latch & 0xf); + addr =((((m_state_latch >> 4) ^ 1) & 1) << 7) | (m_state_latch & 0xf); if (OP3) - addr |= ((vg->op & 7) << 4); + addr |= ((m_op & 7) << 4); return addr; } -static int dvg_dmapush(vgdata *vg) +int dvg_device::handler_0() // dvg_dmapush { if (OP0 == 0) { - vg->sp = (vg->sp + 1) & 0xf; - vg->stack[vg->sp & 3] = vg->pc; + m_sp = (m_sp + 1) & 0xf; + m_stack[m_sp & 3] = m_pc; } return 0; } -static int dvg_dmald(vgdata *vg) +int dvg_device::handler_1() // dvg_dmald { if (OP0) { - vg->pc = vg->stack[vg->sp & 3]; - vg->sp = (vg->sp - 1) & 0xf; + m_pc = m_stack[m_sp & 3]; + m_sp = (m_sp - 1) & 0xf; } else { - vg->pc = vg->dvy; + m_pc = m_dvy; } return 0; } -static void dvg_draw_to(int x, int y, int intensity) +void dvg_device::dvg_draw_to(int x, int y, int intensity) { if (((x | y) & 0x400) == 0) vg_add_point_buf((xmin + x - 512) << 16, @@ -277,34 +170,34 @@ static void dvg_draw_to(int x, int y, int intensity) VECTOR_COLOR111(7), intensity << 4); } -static int dvg_gostrobe(vgdata *vg) +int dvg_device::handler_2() //dvg_gostrobe { int scale, fin, dx, dy, c, mx, my, countx, county, bit, cycles; - if (vg->op == 0xf) + if (m_op == 0xf) { - scale = (vg->scale + - (((vg->dvy & 0x800) >> 11) - | (((vg->dvx & 0x800) ^ 0x800) >> 10) - | ((vg->dvx & 0x800) >> 9))) & 0xf; + scale = (m_scale + + (((m_dvy & 0x800) >> 11) + | (((m_dvx & 0x800) ^ 0x800) >> 10) + | ((m_dvx & 0x800) >> 9))) & 0xf; - vg->dvy &= 0xf00; - vg->dvx &= 0xf00; + m_dvy &= 0xf00; + m_dvx &= 0xf00; } else { - scale = (vg->scale + vg->op) & 0xf; + scale = (m_scale + m_op) & 0xf; } fin = 0xfff - (((2 << scale) & 0x7ff) ^ 0xfff); /* Count up or down */ - dx = (vg->dvx & 0x400)? -1: +1; - dy = (vg->dvy & 0x400)? -1: +1; + dx = (m_dvx & 0x400)? -1: +1; + dy = (m_dvy & 0x400)? -1: +1; /* Scale factor for rate multipliers */ - mx = (vg->dvx << 2) & 0xfff; - my = (vg->dvy << 2) & 0xfff; + mx = (m_dvx << 2) & 0xfff; + my = (m_dvy << 2) & 0xfff; cycles = 8 * fin; c=0; @@ -352,102 +245,115 @@ static int dvg_gostrobe(vgdata *vg) if (countx) { /* Is y valid and x entering or leaving the valid range? */ - if (((vg->ypos & 0x400) == 0) - && ((vg->xpos ^ (vg->xpos + dx)) & 0x400)) + if (((m_ypos & 0x400) == 0) + && ((m_xpos ^ (m_xpos + dx)) & 0x400)) { - if ((vg->xpos + dx) & 0x400) + if ((m_xpos + dx) & 0x400) /* We are leaving the valid range */ - dvg_draw_to(vg->xpos, vg->ypos, vg->intensity); + dvg_draw_to(m_xpos, m_ypos, m_intensity); else /* We are entering the valid range */ - dvg_draw_to((vg->xpos + dx) & 0xfff, vg->ypos, 0); + dvg_draw_to((m_xpos + dx) & 0xfff, m_ypos, 0); } - vg->xpos = (vg->xpos + dx) & 0xfff; + m_xpos = (m_xpos + dx) & 0xfff; } if (county) { - if (((vg->xpos & 0x400) == 0) - && ((vg->ypos ^ (vg->ypos + dy)) & 0x400)) + if (((m_xpos & 0x400) == 0) + && ((m_ypos ^ (m_ypos + dy)) & 0x400)) { - if ((vg->xpos & 0x400) == 0) + if ((m_xpos & 0x400) == 0) { - if ((vg->ypos + dy) & 0x400) - dvg_draw_to(vg->xpos, vg->ypos, vg->intensity); + if ((m_ypos + dy) & 0x400) + dvg_draw_to(m_xpos, m_ypos, m_intensity); else - dvg_draw_to(vg->xpos, (vg->ypos + dy) & 0xfff, 0); + dvg_draw_to(m_xpos, (m_ypos + dy) & 0xfff, 0); } } - vg->ypos = (vg->ypos + dy) & 0xfff; + m_ypos = (m_ypos + dy) & 0xfff; } } - dvg_draw_to(vg->xpos, vg->ypos, vg->intensity); + dvg_draw_to(m_xpos, m_ypos, m_intensity); return cycles; } -static int dvg_haltstrobe(vgdata *vg) +int dvg_device::handler_3() // dvg_haltstrobe { - vg->halt = OP0; + m_halt = OP0; if (OP0 == 0) { - vg->xpos = vg->dvx & 0xfff; - vg->ypos = vg->dvy & 0xfff; - dvg_draw_to(vg->xpos, vg->ypos, 0); + m_xpos = m_dvx & 0xfff; + m_ypos = m_dvy & 0xfff; + dvg_draw_to(m_xpos, m_ypos, 0); } return 0; } -static int dvg_latch3(vgdata *vg) +int dvg_device::handler_7() // dvg_latch3 { - vg->dvx = (vg->dvx & 0xff) | ((vg->data & 0xf) << 8); - vg->intensity = vg->data >> 4; + m_dvx = (m_dvx & 0xff) | ((m_data & 0xf) << 8); + m_intensity = m_data >> 4; return 0; } -static int dvg_latch2(vgdata *vg) +int dvg_device::handler_6() // dvg_latch2 { - vg->dvx &= 0xf00; - if (vg->op != 0xf) - vg->dvx = (vg->dvx & 0xf00) | vg->data; + m_dvx &= 0xf00; + if (m_op != 0xf) + m_dvx = (m_dvx & 0xf00) | m_data; - if ((vg->op & 0xa) == 0xa) - vg->scale = vg->intensity; + if ((m_op & 0xa) == 0xa) + m_scale = m_intensity; - vg->pc++; + m_pc++; return 0; } -static int dvg_latch1(vgdata *vg) +int dvg_device::handler_5() // dvg_latch1 { - vg->dvy = (vg->dvy & 0xff) - | ((vg->data & 0xf) << 8); - vg->op = vg->data >> 4; + m_dvy = (m_dvy & 0xff) + | ((m_data & 0xf) << 8); + m_op = m_data >> 4; - if (vg->op == 0xf) + if (m_op == 0xf) { - vg->dvx &= 0xf00; - vg->dvy &= 0xf00; + m_dvx &= 0xf00; + m_dvy &= 0xf00; } return 0; } -static int dvg_latch0(vgdata *vg) +int dvg_device::handler_4() // dvg_latch0 { - vg->dvy &= 0xf00; - if (vg->op == 0xf) - dvg_latch3(vg); + m_dvy &= 0xf00; + if (m_op == 0xf) + handler_7(); //dvg_latch3 else - vg->dvy = (vg->dvy & 0xf00) | vg->data; + m_dvy = (m_dvy & 0xf00) | m_data; - vg->pc++; + m_pc++; return 0; } +void dvg_device::vggo() // dvg_vggo +{ + m_dvy = 0; + m_op = 0; +} + +void dvg_device::vgrst() // dvg_vgrst +{ + m_state_latch = 0; + m_dvy = 0; + m_op = 0; +} + /******************************************************************** * @@ -460,167 +366,82 @@ static int dvg_latch0(vgdata *vg) * *******************************************************************/ -static void avg_data(vgdata *vg) +UINT8 avg_device::state_addr() // avg_state_addr { - vg->data = avgdvg_vectorram[vg->pc ^ 1]; + return (((m_state_latch >> 4) ^ 1) << 7) + | (m_op << 4) + | (m_state_latch & 0xf); } -static void starwars_data(vgdata *vg) + +void avg_device::update_databus() // avg_data { - vg->data = avgdvg_vectorram[vg->pc]; + m_data = avgdvg_vectorram[m_pc ^ 1]; } -static void quantum_data(vgdata *vg) +void avg_device::vggo() // avg_vggo { - vg->data = ((UINT16 *)avgdvg_vectorram)[vg->pc >> 1]; + m_pc = 0; + m_sp = 0; } -static void mhavoc_data(vgdata *vg) -{ - UINT8 *bank; - if (vg->pc & 0x2000) - { - bank = &vg->machine().root_device().memregion("alpha")->base()[0x18000]; - vg->data = bank[(vg->map << 13) | ((vg->pc ^ 1) & 0x1fff)]; - } - else - { - vg->data = avgdvg_vectorram[vg->pc ^ 1]; - } +void avg_device::vgrst() // avg_vgrst +{ + m_state_latch = 0; + m_bin_scale = 0; + m_scale = 0; + m_color = 0; } -static UINT8 avg_state_addr(vgdata *vg) +int avg_device::handler_0() // avg_latch0 { - return (((vg->state_latch >> 4) ^ 1) << 7) - | (vg->op << 4) - | (vg->state_latch & 0xf); -} - -static int avg_latch0(vgdata *vg) -{ - vg->dvy = (vg->dvy & 0x1f00) | vg->data; - vg->pc++; + m_dvy = (m_dvy & 0x1f00) | m_data; + m_pc++; return 0; } -static int quantum_st2st3(vgdata *vg) +int avg_device::handler_1() // avg_latch1 { - /* Quantum doesn't decode latch0 or latch2 but ST2 and ST3 are fed - * into the address controller which increments the PC - */ - vg->pc++; - return 0; -} + m_dvy12 = (m_data >> 4) &1; + m_op = m_data >> 5; -static int avg_latch1(vgdata *vg) -{ - vg->dvy12 = (vg->data >> 4) &1; - vg->op = vg->data >> 5; - - vg->int_latch = 0; - vg->dvy = (vg->dvy12 << 12) - | ((vg->data & 0xf) << 8 ); - vg->dvx = 0; - vg->pc++; + m_int_latch = 0; + m_dvy = (m_dvy12 << 12) + | ((m_data & 0xf) << 8 ); + m_dvx = 0; + m_pc++; return 0; } -static int quantum_latch1(vgdata *vg) +int avg_device::handler_2() // avg_latch2 { - vg->dvy = vg->data & 0x1fff; - vg->dvy12 = (vg->data >> 12) & 1; - vg->op = vg->data >> 13; - - vg->int_latch = 0; - vg->dvx = 0; - vg->pc++; + m_dvx = (m_dvx & 0x1f00) | m_data; + m_pc++; return 0; } -static int bzone_latch1(vgdata *vg) +int avg_device::handler_3() // avg_latch3 { - /* - * Battle Zone has clipping hardware. We need to remember the - * position of the beam when the analog switches hst or lst get - * turned off. - */ - - if (vg->hst == 0) - { - vg->clipx_max = vg->xpos; - vg->clipy_min = vg->ypos; - } - - if (vg->lst == 0) - { - vg->clipx_min = vg->xpos; - vg->clipy_max = vg->ypos; - } - - if (vg->lst==0 || vg->hst==0) - { - vg_add_clip(vg->clipx_min, vg->clipy_min, vg->clipx_max, vg->clipy_max); - } - vg->lst = vg->hst = 1; - - return avg_latch1(vg); -} - -static int mhavoc_latch1(vgdata *vg) -{ - /* - * Major Havoc just has ymin clipping - */ - - if (vg->lst == 0) - { - vg_add_clip(0, vg->ypos, xmax << 16, ymax << 16); - } - vg->lst = 1; - - return avg_latch1(vg); -} - -static int avg_latch2(vgdata *vg) -{ - vg->dvx = (vg->dvx & 0x1f00) | vg->data; - vg->pc++; + m_int_latch = m_data >> 4; + m_dvx = ((m_int_latch & 1) << 12) + | ((m_data & 0xf) << 8 ) + | (m_dvx & 0xff); + m_pc++; return 0; } -static int avg_latch3(vgdata *vg) -{ - vg->int_latch = vg->data >> 4; - vg->dvx = ((vg->int_latch & 1) << 12) - | ((vg->data & 0xf) << 8 ) - | (vg->dvx & 0xff); - vg->pc++; - - return 0; -} - -static int quantum_latch3(vgdata *vg) -{ - vg->int_latch = vg->data >> 12; - vg->dvx = vg->data & 0xfff; - vg->pc++; - - return 0; -} - - -static int avg_strobe0(vgdata *vg) +int avg_device::handler_4() // avg_strobe0 { int i; if (OP0) { - vg->stack[vg->sp & 3] = vg->pc; + m_stack[m_sp & 3] = m_pc; } else { @@ -637,106 +458,64 @@ static int avg_strobe0(vgdata *vg) * low. We cut off after 16 shifts. */ i = 0; - while ((((vg->dvy ^ (vg->dvy << 1)) & 0x1000) == 0) - && (((vg->dvx ^ (vg->dvx << 1)) & 0x1000) == 0) + while ((((m_dvy ^ (m_dvy << 1)) & 0x1000) == 0) + && (((m_dvx ^ (m_dvx << 1)) & 0x1000) == 0) && (i++ < 16)) { - vg->dvy = (vg->dvy & 0x1000) | ((vg->dvy << 1) & 0x1fff); - vg->dvx = (vg->dvx & 0x1000) | ((vg->dvx << 1) & 0x1fff); - vg->timer >>= 1; - vg->timer |= 0x4000 | (OP1 << 6); + m_dvy = (m_dvy & 0x1000) | ((m_dvy << 1) & 0x1fff); + m_dvx = (m_dvx & 0x1000) | ((m_dvx << 1) & 0x1fff); + m_timer >>= 1; + m_timer |= 0x4000 | (OP1 << 6); } if (OP1) - vg->timer &= 0xff; + m_timer &= 0xff; } return 0; } -static int quantum_strobe0(vgdata *vg) -{ - int i; - if (OP0) - { - vg->stack[vg->sp & 3] = vg->pc; - } - else - { - /* - * Quantum normalizes to 12 bit - */ - i = 0; - while ((((vg->dvy ^ (vg->dvy << 1)) & 0x800) == 0) - && (((vg->dvx ^ (vg->dvx << 1)) & 0x800) == 0) - && (i++ < 16)) - { - vg->dvy = (vg->dvy << 1) & 0xfff; - vg->dvx = (vg->dvx << 1) & 0xfff; - vg->timer >>= 1; - vg->timer |= 0x2000 ; - } - } - - return 0; -} - -static int avg_common_strobe1(vgdata *vg) +int avg_device::avg_common_strobe1() { if (OP2) { if (OP1) - vg->sp = (vg->sp - 1) & 0xf; + m_sp = (m_sp - 1) & 0xf; else - vg->sp = (vg->sp + 1) & 0xf; + m_sp = (m_sp + 1) & 0xf; } return 0; } -static int avg_strobe1(vgdata *vg) +int avg_device::handler_5() // avg_strobe1 { int i; if (OP2 == 0) { - for (i = vg->bin_scale; i > 0; i--) + for (i = m_bin_scale; i > 0; i--) { - vg->timer >>= 1; - vg->timer |= 0x4000 | (OP1 << 6); + m_timer >>= 1; + m_timer |= 0x4000 | (OP1 << 6); } if (OP1) - vg->timer &= 0xff; + m_timer &= 0xff; } - return avg_common_strobe1(vg); + return avg_common_strobe1(); } -static int quantum_strobe1(vgdata *vg) -{ - int i; - if (OP2 == 0) - { - for (i = vg->bin_scale; i > 0; i--) - { - vg->timer >>= 1; - vg->timer |= 0x2000; - } - } - - return avg_common_strobe1(vg); -} - -static int avg_common_strobe2(vgdata *vg) +int avg_device::avg_common_strobe2() { if (OP2) { if (OP0) { - vg->pc = vg->dvy << 1; + m_pc = m_dvy << 1; - if (vg->dvy == 0) + if (m_dvy == 0) { /* * Tempest and Quantum keep the AVG in an endless @@ -756,211 +535,117 @@ static int avg_common_strobe2(vgdata *vg) * 'frames'. */ - vg->machine().device("vector")->clear_list(); - vg_flush(vg->machine()); + m_vector->clear_list(); + vg_flush(); } } else { - vg->pc = vg->stack[vg->sp & 3]; + m_pc = m_stack[m_sp & 3]; } } else { - if (vg->dvy12) + if (m_dvy12) { - vg->scale = vg->dvy & 0xff; - vg->bin_scale = (vg->dvy >> 8) & 7; + m_scale = m_dvy & 0xff; + m_bin_scale = (m_dvy >> 8) & 7; } } return 0; } -static int avg_strobe2(vgdata *vg) +int avg_device::handler_6() // avg_strobe2 { - if ((OP2 == 0) && (vg->dvy12 == 0)) + if ((OP2 == 0) && (m_dvy12 == 0)) { - vg->color = vg->dvy & 0x7; - vg->intensity = (vg->dvy >> 4) & 0xf; + m_color = m_dvy & 0x7; + m_intensity = (m_dvy >> 4) & 0xf; } - return avg_common_strobe2(vg); + return avg_common_strobe2(); } -static int mhavoc_strobe2(vgdata *vg) -{ - if (OP2 == 0) - { - if (vg->dvy12) - { - if (vg->dvy & 0x800) - vg->lst = 0; - } - else - { - vg->color = vg->dvy & 0xf; - - vg->intensity = (vg->dvy >> 4) & 0xf; - vg->map = (vg->dvy >> 8) & 0x3; - if (vg->dvy & 0x800) - { - vg->enspkl = 1; - vg->spkl_shift = ((vg->dvy >> 3) & 1) - | ((vg->dvy >> 1) & 2) - | ((vg->dvy << 1) & 4) - | ((vg->dvy << 2) & 8) - | ((vg->machine().rand() & 0x7) << 4); - } - else - { - vg->enspkl = 0; - } - - /* Major Havoc can do X-flipping by inverting the DAC input */ - if (vg->dvy & 0x400) - vg->xdac_xor = 0x1ff; - else - vg->xdac_xor = 0x200; - } - } - - return avg_common_strobe2(vg); -} - -static int tempest_strobe2(vgdata *vg) -{ - if ((OP2 == 0) && (vg->dvy12 == 0)) - { - /* Contrary to previous documentation in MAME, - Tempest does not have the vg->enspkl bit. */ - if (vg->dvy & 0x800) - vg->color = vg->dvy & 0xf; - else - vg->intensity = (vg->dvy >> 4) & 0xf; - } - - return avg_common_strobe2(vg); -} - -static int quantum_strobe2(vgdata *vg) -{ - if ((OP2 == 0) && (vg->dvy12 == 0) && (vg->dvy & 0x800)) - { - vg->color = vg->dvy & 0xf; - vg->intensity = (vg->dvy >> 4) & 0xf; - } - - return avg_common_strobe2(vg); -} - -static int starwars_strobe2(vgdata *vg) -{ - if ((OP2 == 0) && (vg->dvy12 == 0)) - { - vg->intensity = vg->dvy & 0xff; - vg->color = (vg->dvy >> 8) & 0xf; - } - - return avg_common_strobe2(vg); -} - -static int bzone_strobe2(vgdata *vg) -{ - if ((OP2 == 0) && (vg->dvy12 == 0)) - { - vg->intensity = (vg->dvy >> 4) & 0xf; - - if (!(vg->dvy & 0x400)) - { - vg->lst = vg->dvy & 0x200; - vg->hst = vg->lst ^ 0x200; - /* - * If izblank is true the zblank signal gets - * inverted. This behaviour can't be handled with the - * clipping we have right now. Battle Zone doesn't seem to - * invert zblank so it's no issue. - */ - vg->izblank = vg->dvy & 0x100; - } - } - return avg_common_strobe2(vg); -} - -static int avg_common_strobe3(vgdata *vg) +int avg_device::avg_common_strobe3() { int cycles=0; - vg->halt = OP0; + m_halt = OP0; - if ((vg->op & 5) == 0) + if ((m_op & 5) == 0) { if (OP1) { - cycles = 0x100 - (vg->timer & 0xff); + cycles = 0x100 - (m_timer & 0xff); } else { - cycles = 0x8000 - vg->timer; + cycles = 0x8000 - m_timer; } - vg->timer = 0; + m_timer = 0; - vg->xpos += ((((vg->dvx >> 3) ^ vg->xdac_xor) - 0x200) * cycles * (vg->scale ^ 0xff)) >> 4; - vg->ypos -= ((((vg->dvy >> 3) ^ vg->ydac_xor) - 0x200) * cycles * (vg->scale ^ 0xff)) >> 4; + m_xpos += ((((m_dvx >> 3) ^ m_xdac_xor) - 0x200) * cycles * (m_scale ^ 0xff)) >> 4; + m_ypos -= ((((m_dvy >> 3) ^ m_ydac_xor) - 0x200) * cycles * (m_scale ^ 0xff)) >> 4; } if (OP2) { - cycles = 0x8000 - vg->timer; - vg->timer = 0; - vg->xpos = xcenter; - vg->ypos = ycenter; - vg_add_point_buf(vg->xpos, vg->ypos, 0, 0); + cycles = 0x8000 - m_timer; + m_timer = 0; + m_xpos = xcenter; + m_ypos = ycenter; + vg_add_point_buf(m_xpos, m_ypos, 0, 0); } return cycles; } -static int avg_strobe3(vgdata *vg) +int avg_device::handler_7() // avg_strobe3 { int cycles; - cycles = avg_common_strobe3(vg); + cycles = avg_common_strobe3(); - if ((vg->op & 5) == 0) + if ((m_op & 5) == 0) { - vg_add_point_buf(vg->xpos, vg->ypos, VECTOR_COLOR111(vg->color), - (((vg->int_latch >> 1) == 1)? vg->intensity: vg->int_latch & 0xe) << 4); + vg_add_point_buf(m_xpos, m_ypos, VECTOR_COLOR111(m_color), + (((m_int_latch >> 1) == 1)? m_intensity: m_int_latch & 0xe) << 4); } return cycles; } -static int bzone_strobe3(vgdata *vg) +/************************************* + * + * Tempest handler functions + * + *************************************/ + +int avg_tempest_device::handler_6() // tempest_strobe2 { - /* Battle Zone is B/W */ - int cycles; - - cycles = avg_common_strobe3(vg); - - if ((vg->op & 5) == 0) + if ((OP2 == 0) && (m_dvy12 == 0)) { - vg_add_point_buf(vg->xpos, vg->ypos, VECTOR_COLOR111(7), - (((vg->int_latch >> 1) == 1)? vg->intensity: vg->int_latch & 0xe) << 4); + /* Contrary to previous documentation in MAME, + Tempest does not have the m_enspkl bit. */ + if (m_dvy & 0x800) + m_color = m_dvy & 0xf; + else + m_intensity = (m_dvy >> 4) & 0xf; } - return cycles; + return avg_common_strobe2(); } -static int tempest_strobe3(vgdata *vg) +int avg_tempest_device::handler_7() // tempest_strobe3 { int cycles, r, g, b, bit0, bit1, bit2, bit3, x, y; UINT8 data; - cycles = avg_common_strobe3(vg); + cycles = avg_common_strobe3(); - if ((vg->op & 5) == 0) + if ((m_op & 5) == 0) { - data = avgdvg_colorram[vg->color]; + data = avgdvg_colorram[m_color]; bit3 = (~data >> 3) & 1; bit2 = (~data >> 2) & 1; bit1 = (~data >> 1) & 1; @@ -970,175 +655,23 @@ static int tempest_strobe3(vgdata *vg) g = bit3 * 0xf3; b = bit2 * 0xf3; - x = vg->xpos; - y = vg->ypos; + x = m_xpos; + y = m_ypos; - avg_apply_flipping(&x, &y); + apply_flipping(&x, &y); vg_add_point_buf(y - ycenter + xcenter, x - xcenter + ycenter, rgb_t(r, g, b), - (((vg->int_latch >> 1) == 1)? vg->intensity: vg->int_latch & 0xe) << 4); + (((m_int_latch >> 1) == 1)? m_intensity: m_int_latch & 0xe) << 4); } return cycles; } -static int mhavoc_strobe3(vgdata *vg) +void avg_tempest_device::vggo() // tempest_vggo { - int cycles, r, g, b, bit0, bit1, bit2, bit3, dx, dy, i; - - UINT8 data; - - vg->halt = OP0; - cycles = 0; - - if ((vg->op & 5) == 0) - { - if (OP1) - { - cycles = 0x100 - (vg->timer & 0xff); - } - else - { - cycles = 0x8000 - vg->timer; - } - vg->timer = 0; - dx = ((((vg->dvx >> 3) ^ vg->xdac_xor) - 0x200) * (vg->scale ^ 0xff)); - dy = ((((vg->dvy >> 3) ^ vg->ydac_xor) - 0x200) * (vg->scale ^ 0xff)); - - - if (vg->enspkl) - { - for (i=0; ixpos += dx/2; - vg->ypos -= dy/2; - data = avgdvg_colorram[0xf + - (((vg->spkl_shift & 1) << 3) - | (vg->spkl_shift & 4) - | ((vg->spkl_shift & 0x10) >> 3) - | ((vg->spkl_shift & 0x40) >> 6))]; - bit3 = (~data >> 3) & 1; - bit2 = (~data >> 2) & 1; - bit1 = (~data >> 1) & 1; - bit0 = (~data >> 0) & 1; - r = bit3 * 0xcb + bit2 * 0x34; - g = bit1 * 0xcb; - b = bit0 * 0xcb; - - vg_add_point_buf(vg->xpos, vg->ypos, rgb_t(r, g, b), - (((vg->int_latch >> 1) == 1)? vg->intensity: vg->int_latch & 0xe) << 4); - vg->spkl_shift = (((vg->spkl_shift & 0x40) >> 6) - ^ ((vg->spkl_shift & 0x20) >> 5) - ^ 1 ) - | (vg->spkl_shift << 1); - - if ((vg->spkl_shift & 0x7f) == 0x7f) - vg->spkl_shift = 0; - } - } - else - { - vg->xpos += (dx * cycles) >> 4; - vg->ypos -= (dy * cycles) >> 4; - data = avgdvg_colorram[vg->color]; - - bit3 = (~data >> 3) & 1; - bit2 = (~data >> 2) & 1; - bit1 = (~data >> 1) & 1; - bit0 = (~data >> 0) & 1; - r = bit3 * 0xcb + bit2 * 0x34; - g = bit1 * 0xcb; - b = bit0 * 0xcb; - - vg_add_point_buf(vg->xpos, vg->ypos, rgb_t(r, g, b), - (((vg->int_latch >> 1) == 1)? vg->intensity: vg->int_latch & 0xe) << 4); - } - } - if (OP2) - { - cycles = 0x8000 - vg->timer; - vg->timer = 0; - vg->xpos = xcenter; - vg->ypos = ycenter; - vg_add_point_buf(vg->xpos, vg->ypos, 0, 0); - } - - return cycles; -} - -static int starwars_strobe3(vgdata *vg) -{ - int cycles; - - cycles = avg_common_strobe3(vg); - - if ((vg->op & 5) == 0) - { - vg_add_point_buf(vg->xpos, vg->ypos, VECTOR_COLOR111(vg->color), - ((vg->int_latch >> 1) * vg->intensity) >> 3); - } - - return cycles; -} - -static int quantum_strobe3(vgdata *vg) -{ - int cycles=0, r, g, b, bit0, bit1, bit2, bit3, x, y; - - UINT16 data; - - vg->halt = OP0; - - if ((vg->op & 5) == 0) - { - data = ((UINT16 *)avgdvg_colorram)[vg->color]; - bit3 = (~data >> 3) & 1; - bit2 = (~data >> 2) & 1; - bit1 = (~data >> 1) & 1; - bit0 = (~data >> 0) & 1; - - g = bit1 * 0xaa + bit0 * 0x54; - b = bit2 * 0xce; - r = bit3 * 0xce; - - cycles = 0x4000 - vg->timer; - vg->timer = 0; - - vg->xpos += (((((vg->dvx & 0xfff) >> 2) ^ vg->xdac_xor) - 0x200) * cycles * (vg->scale ^ 0xff)) >> 4; - vg->ypos -= (((((vg->dvy & 0xfff) >> 2) ^ vg->ydac_xor) - 0x200) * cycles * (vg->scale ^ 0xff)) >> 4; - - x = vg->xpos; - y = vg->ypos; - - avg_apply_flipping(&x, &y); - - vg_add_point_buf(y - ycenter + xcenter, - x - xcenter + ycenter, rgb_t(r, g, b), - ((vg->int_latch == 2)? vg->intensity: vg->int_latch) << 4); - } - if (OP2) - { - cycles = 0x4000 - vg->timer; - vg->timer = 0; - vg->xpos = xcenter; - vg->ypos = ycenter; - vg_add_point_buf(vg->xpos, vg->ypos, 0, 0); - } - - return cycles; -} - -static void avg_vggo(vgdata *vg) -{ - vg->pc = 0; - vg->sp = 0; -} - -static void tempest_vggo(vgdata *vg) -{ - vg->pc = 0; - vg->sp = 0; + m_pc = 0; + m_sp = 0; /* * Tempest and Quantum trigger VGGO from time to time even though * the VG runs in an endless loop for these games (see @@ -1148,40 +681,499 @@ static void tempest_vggo(vgdata *vg) nvect = 0; } -static void dvg_vggo(vgdata *vg) + + /************************************* + * + * Mhavoc handler functions + * + *************************************/ + + int avg_mhavoc_device::handler_1() // mhavoc_latch1 { - vg->dvy = 0; - vg->op = 0; + /* + * Major Havoc just has ymin clipping + */ + + if (m_lst == 0) + { + vg_add_clip(0, m_ypos, xmax << 16, ymax << 16); + } + m_lst = 1; + + return avg_device::handler_1(); //avg_latch1() } -static void avg_vgrst(vgdata *vg) +int avg_mhavoc_device::handler_6() // mhavoc_strobe2 { - vg->state_latch = 0; - vg->bin_scale = 0; - vg->scale = 0; - vg->color = 0; + if (OP2 == 0) + { + if (m_dvy12) + { + if (m_dvy & 0x800) + m_lst = 0; + } + else + { + m_color = m_dvy & 0xf; + + m_intensity = (m_dvy >> 4) & 0xf; + m_map = (m_dvy >> 8) & 0x3; + if (m_dvy & 0x800) + { + m_enspkl = 1; + m_spkl_shift = ((m_dvy >> 3) & 1) + | ((m_dvy >> 1) & 2) + | ((m_dvy << 1) & 4) + | ((m_dvy << 2) & 8) + | ((machine().rand() & 0x7) << 4); + } + else + { + m_enspkl = 0; + } + + /* Major Havoc can do X-flipping by inverting the DAC input */ + if (m_dvy & 0x400) + m_xdac_xor = 0x1ff; + else + m_xdac_xor = 0x200; + } + } + + return avg_common_strobe2(); } -static void mhavoc_vgrst(vgdata *vg) +int avg_mhavoc_device::handler_7() // mhavoc_strobe3 { - avg_vgrst(vg); - vg->enspkl = 0; + int cycles, r, g, b, bit0, bit1, bit2, bit3, dx, dy, i; + + UINT8 data; + + m_halt = OP0; + cycles = 0; + + if ((m_op & 5) == 0) + { + if (OP1) + { + cycles = 0x100 - (m_timer & 0xff); + } + else + { + cycles = 0x8000 - m_timer; + } + m_timer = 0; + dx = ((((m_dvx >> 3) ^ m_xdac_xor) - 0x200) * (m_scale ^ 0xff)); + dy = ((((m_dvy >> 3) ^ m_ydac_xor) - 0x200) * (m_scale ^ 0xff)); + + + if (m_enspkl) + { + for (i=0; i> 3) + | ((m_spkl_shift & 0x40) >> 6))]; + bit3 = (~data >> 3) & 1; + bit2 = (~data >> 2) & 1; + bit1 = (~data >> 1) & 1; + bit0 = (~data >> 0) & 1; + r = bit3 * 0xcb + bit2 * 0x34; + g = bit1 * 0xcb; + b = bit0 * 0xcb; + + vg_add_point_buf(m_xpos, m_ypos, rgb_t(r, g, b), + (((m_int_latch >> 1) == 1)? m_intensity: m_int_latch & 0xe) << 4); + m_spkl_shift = (((m_spkl_shift & 0x40) >> 6) + ^ ((m_spkl_shift & 0x20) >> 5) + ^ 1 ) + | (m_spkl_shift << 1); + + if ((m_spkl_shift & 0x7f) == 0x7f) + m_spkl_shift = 0; + } + } + else + { + m_xpos += (dx * cycles) >> 4; + m_ypos -= (dy * cycles) >> 4; + data = avgdvg_colorram[m_color]; + + bit3 = (~data >> 3) & 1; + bit2 = (~data >> 2) & 1; + bit1 = (~data >> 1) & 1; + bit0 = (~data >> 0) & 1; + r = bit3 * 0xcb + bit2 * 0x34; + g = bit1 * 0xcb; + b = bit0 * 0xcb; + + vg_add_point_buf(m_xpos, m_ypos, rgb_t(r, g, b), + (((m_int_latch >> 1) == 1)? m_intensity: m_int_latch & 0xe) << 4); + } + } + if (OP2) + { + cycles = 0x8000 - m_timer; + m_timer = 0; + m_xpos = xcenter; + m_ypos = ycenter; + vg_add_point_buf(m_xpos, m_ypos, 0, 0); + } + + return cycles; } -static void dvg_vgrst(vgdata *vg) +void avg_mhavoc_device::update_databus() // mhavoc_data { - vg->state_latch = 0; - vg->dvy = 0; - vg->op = 0; + UINT8 *bank; + + if (m_pc & 0x2000) + { + bank = &machine().root_device().memregion("alpha")->base()[0x18000]; + m_data = bank[(m_map << 13) | ((m_pc ^ 1) & 0x1fff)]; + } + else + { + m_data = avgdvg_vectorram[m_pc ^ 1]; + } } -static void vg_set_halt(int dummy) +void avg_mhavoc_device::vgrst() // mhavoc_vgrst { - vg->halt = dummy; - vg->sync_halt = dummy; + avg_device::vgrst(); // avg_vgrst + m_enspkl = 0; } -static TIMER_CALLBACK( vg_set_halt_callback ) + +/************************************* + * + * Starwars handler functions + * + *************************************/ + +void avg_starwars_device::update_databus() // starwars_data +{ + m_data = avgdvg_vectorram[m_pc]; +} + + +int avg_starwars_device::handler_6() // starwars_strobe2 +{ + if ((OP2 == 0) && (m_dvy12 == 0)) + { + m_intensity = m_dvy & 0xff; + m_color = (m_dvy >> 8) & 0xf; + } + + return avg_common_strobe2(); +} + +int avg_starwars_device::handler_7() // starwars_strobe3 +{ + int cycles; + + cycles = avg_common_strobe3(); + + if ((m_op & 5) == 0) + { + vg_add_point_buf(m_xpos, m_ypos, VECTOR_COLOR111(m_color), + ((m_int_latch >> 1) * m_intensity) >> 3); + } + + return cycles; +} + + /************************************* + * + * Quantum handler functions + * + *************************************/ +void avg_quantum_device::update_databus() // quantum_data +{ + m_data = ((UINT16 *)avgdvg_vectorram)[m_pc >> 1]; +} + +void avg_quantum_device::vggo() // tempest_vggo +{ + m_pc = 0; + m_sp = 0; + /* + * Tempest and Quantum trigger VGGO from time to time even though + * the VG runs in an endless loop for these games (see + * avg_common_strobe2). If we don't discard all vectors in the + * current buffer at this point, the screen starts flickering. + */ + nvect = 0; +} + + +int avg_quantum_device::handler_0() // quantum_st2st3 +{ + /* Quantum doesn't decode latch0 or latch2 but ST2 and ST3 are fed + * into the address controller which increments the PC + */ + m_pc++; + return 0; +} + +int avg_quantum_device::handler_1() // quantum_latch1 +{ + m_dvy = m_data & 0x1fff; + m_dvy12 = (m_data >> 12) & 1; + m_op = m_data >> 13; + + m_int_latch = 0; + m_dvx = 0; + m_pc++; + + return 0; +} + +int avg_quantum_device::handler_2() // quantum_st2st3 +{ + /* Quantum doesn't decode latch0 or latch2 but ST2 and ST3 are fed + * into the address controller which increments the PC + */ + m_pc++; + return 0; +} + +int avg_quantum_device::handler_3() // quantum_latch3 +{ + m_int_latch = m_data >> 12; + m_dvx = m_data & 0xfff; + m_pc++; + + return 0; +} + + +int avg_quantum_device::handler_4() // quantum_strobe0 +{ + int i; + + if (OP0) + { + m_stack[m_sp & 3] = m_pc; + } + else + { + /* + * Quantum normalizes to 12 bit + */ + i = 0; + while ((((m_dvy ^ (m_dvy << 1)) & 0x800) == 0) + && (((m_dvx ^ (m_dvx << 1)) & 0x800) == 0) + && (i++ < 16)) + { + m_dvy = (m_dvy << 1) & 0xfff; + m_dvx = (m_dvx << 1) & 0xfff; + m_timer >>= 1; + m_timer |= 0x2000 ; + } + } + + return 0; +} + +int avg_quantum_device::handler_5() // quantum_strobe1 +{ + int i; + + if (OP2 == 0) + { + for (i = m_bin_scale; i > 0; i--) + { + m_timer >>= 1; + m_timer |= 0x2000; + } + } + + return avg_common_strobe1(); +} + +int avg_quantum_device::handler_6() // quantum_strobe2 +{ + if ((OP2 == 0) && (m_dvy12 == 0) && (m_dvy & 0x800)) + { + m_color = m_dvy & 0xf; + m_intensity = (m_dvy >> 4) & 0xf; + } + + return avg_common_strobe2(); +} + +int avg_quantum_device::handler_7() // quantum_strobe3 +{ + int cycles=0, r, g, b, bit0, bit1, bit2, bit3, x, y; + + UINT16 data; + + m_halt = OP0; + + if ((m_op & 5) == 0) + { + data = ((UINT16 *)avgdvg_colorram)[m_color]; + bit3 = (~data >> 3) & 1; + bit2 = (~data >> 2) & 1; + bit1 = (~data >> 1) & 1; + bit0 = (~data >> 0) & 1; + + g = bit1 * 0xaa + bit0 * 0x54; + b = bit2 * 0xce; + r = bit3 * 0xce; + + cycles = 0x4000 - m_timer; + m_timer = 0; + + m_xpos += (((((m_dvx & 0xfff) >> 2) ^ m_xdac_xor) - 0x200) * cycles * (m_scale ^ 0xff)) >> 4; + m_ypos -= (((((m_dvy & 0xfff) >> 2) ^ m_ydac_xor) - 0x200) * cycles * (m_scale ^ 0xff)) >> 4; + + x = m_xpos; + y = m_ypos; + + apply_flipping(&x, &y); + + vg_add_point_buf(y - ycenter + xcenter, + x - xcenter + ycenter, rgb_t(r, g, b), + ((m_int_latch == 2)? m_intensity: m_int_latch) << 4); + } + if (OP2) + { + cycles = 0x4000 - m_timer; + m_timer = 0; + m_xpos = xcenter; + m_ypos = ycenter; + vg_add_point_buf(m_xpos, m_ypos, 0, 0); + } + + return cycles; +} + + /************************************* + * + * Bzone handler functions + * + *************************************/ +int avg_bzone_device::handler_1() // bzone_latch1 +{ + /* + * Battle Zone has clipping hardware. We need to remember the + * position of the beam when the analog switches hst or lst get + * turned off. + */ + + if (m_hst == 0) + { + m_clipx_max = m_xpos; + m_clipy_min = m_ypos; + } + + if (m_lst == 0) + { + m_clipx_min = m_xpos; + m_clipy_max = m_ypos; + } + + if (m_lst==0 || m_hst==0) + { + vg_add_clip(m_clipx_min, m_clipy_min, m_clipx_max, m_clipy_max); + } + m_lst = m_hst = 1; + + return avg_device::handler_1(); // avg_latch1() +} + + +int avg_bzone_device::handler_6() // bzone_strobe2 +{ + if ((OP2 == 0) && (m_dvy12 == 0)) + { + m_intensity = (m_dvy >> 4) & 0xf; + + if (!(m_dvy & 0x400)) + { + m_lst = m_dvy & 0x200; + m_hst = m_lst ^ 0x200; + /* + * If izblank is true the zblank signal gets + * inverted. This behaviour can't be handled with the + * clipping we have right now. Battle Zone doesn't seem to + * invert zblank so it's no issue. + */ + m_izblank = m_dvy & 0x100; + } + } + return avg_common_strobe2(); +} + + +int avg_bzone_device::handler_7() // bzone_strobe3 +{ + /* Battle Zone is B/W */ + int cycles; + + cycles = avg_common_strobe3(); + + if ((m_op & 5) == 0) + { + vg_add_point_buf(m_xpos, m_ypos, VECTOR_COLOR111(7), + (((m_int_latch >> 1) == 1)? m_intensity: m_int_latch & 0xe) << 4); + } + + return cycles; +} + +/************************************* + * + * Tomcat handler functions + * + *************************************/ + +int avg_tomcat_device::handler_6() // starwars_strobe2 +{ + if ((OP2 == 0) && (m_dvy12 == 0)) + { + m_intensity = m_dvy & 0xff; + m_color = (m_dvy >> 8) & 0xf; + } + + return avg_common_strobe2(); +} + +int avg_tomcat_device::handler_7() // starwars_strobe3 +{ + int cycles; + + cycles = avg_common_strobe3(); + + if ((m_op & 5) == 0) + { + vg_add_point_buf(m_xpos, m_ypos, VECTOR_COLOR111(m_color), + ((m_int_latch >> 1) * m_intensity) >> 3); + } + + return cycles; +} + + +/************************************* + * + * halt functions + * + *************************************/ + +void avgdvg_device::vg_set_halt(int dummy) +{ + m_halt = dummy; + m_sync_halt = dummy; +} + +TIMER_CALLBACK_MEMBER( avgdvg_device::vg_set_halt_callback ) { vg_set_halt(param); } @@ -1200,31 +1192,40 @@ static TIMER_CALLBACK( vg_set_halt_callback ) * *******************************************************************/ -static TIMER_CALLBACK( run_state_machine ) +TIMER_CALLBACK_MEMBER( avgdvg_device::run_state_machine ) { int cycles = 0; - UINT8 *state_prom = machine.root_device().memregion("user1")->base(); + UINT8 *state_prom = machine().root_device().memregion("user1")->base(); while (cycles < VGSLICE) { /* Get next state */ - vg->state_latch = (vg->state_latch & 0x10) - | (state_prom[vgc->state_addr(vg)] & 0xf); + m_state_latch = (m_state_latch & 0x10) + | (state_prom[state_addr()] & 0xf); if (ST3) { /* Read vector RAM/ROM */ - vgc->update_databus(vg); + update_databus(); /* Decode state and call the corresponding handler */ - cycles += (vgc->handler[vg->state_latch & 7])(vg); + switch(m_state_latch & 7) { + case 0 : cycles += handler_0(); break; + case 1 : cycles += handler_1(); break; + case 2 : cycles += handler_2(); break; + case 3 : cycles += handler_3(); break; + case 4 : cycles += handler_4(); break; + case 5 : cycles += handler_5(); break; + case 6 : cycles += handler_6(); break; + case 7 : cycles += handler_7(); break; + } } /* If halt flag was set, let CPU catch up before we make halt visible */ - if (vg->halt && !(vg->state_latch & 0x10)) + if (m_halt && !(m_state_latch & 0x10)) vg_halt_timer->adjust(attotime::from_hz(MASTER_CLOCK) * cycles, 1); - vg->state_latch = (vg->halt << 4) | (vg->state_latch & 0xf); + m_state_latch = (m_halt << 4) | (m_state_latch & 0xf); cycles += 8; } @@ -1238,33 +1239,33 @@ static TIMER_CALLBACK( run_state_machine ) * ************************************/ -CUSTOM_INPUT( avgdvg_done_r ) +CUSTOM_INPUT_MEMBER( avgdvg_device::done_r ) { - return vg->sync_halt ? 0x01 : 0x00; + return m_sync_halt ? 0x01 : 0x00; } -WRITE8_HANDLER( avgdvg_go_w ) +WRITE8_MEMBER( avgdvg_device::go_w ) { - vgc->vggo(vg); + vggo(); - if (vg->sync_halt && (nvect > 10)) + if (m_sync_halt && (nvect > 10)) { /* * This is a good time to start a new frame. Major Havoc * sometimes sets VGGO after a very short vector list. That's * why we ignore frames with less than 10 vectors. */ - space.machine().device("vector")->clear_list(); + m_vector->clear_list(); } - vg_flush(space.machine()); + vg_flush(); vg_set_halt(0); vg_run_timer->adjust(attotime::zero); } -WRITE16_HANDLER( avgdvg_go_word_w ) +WRITE16_MEMBER( avgdvg_device::go_word_w ) { - avgdvg_go_w(space, offset, data); + go_w(space, offset, data); } @@ -1274,224 +1275,74 @@ WRITE16_HANDLER( avgdvg_go_word_w ) * ************************************/ -WRITE8_HANDLER( avgdvg_reset_w ) +WRITE8_MEMBER( avgdvg_device::reset_w ) { - vgc->vgrst(vg); + vgrst(); vg_set_halt(1); } -WRITE16_HANDLER( avgdvg_reset_word_w ) +WRITE16_MEMBER( avgdvg_device::reset_word_w ) { - avgdvg_reset_w (space,0,0); + reset_w (space,0,0); } -/************************************* - * - * Configuration of VG variants - * - *************************************/ - -static const vgconf dvg_default = -{ - { - dvg_dmapush, - dvg_dmald, - dvg_gostrobe, - dvg_haltstrobe, - dvg_latch0, - dvg_latch1, - dvg_latch2, - dvg_latch3 - }, - dvg_state_addr, - dvg_data, - dvg_vggo, - dvg_vgrst -}; - -static const vgconf avg_default = -{ - { - avg_latch0, - avg_latch1, - avg_latch2, - avg_latch3, - avg_strobe0, - avg_strobe1, - avg_strobe2, - avg_strobe3 - }, - avg_state_addr, - avg_data, - avg_vggo, - avg_vgrst -}; - -static const vgconf avg_mhavoc = -{ - { - avg_latch0, - mhavoc_latch1, - avg_latch2, - avg_latch3, - avg_strobe0, - avg_strobe1, - mhavoc_strobe2, - mhavoc_strobe3 - }, - avg_state_addr, - mhavoc_data, - avg_vggo, - mhavoc_vgrst -}; - -static const vgconf avg_starwars = -{ - { - avg_latch0, - avg_latch1, - avg_latch2, - avg_latch3, - avg_strobe0, - avg_strobe1, - starwars_strobe2, - starwars_strobe3 - }, - avg_state_addr, - starwars_data, - avg_vggo, - avg_vgrst -}; - -static const vgconf avg_tempest = -{ - { - avg_latch0, - avg_latch1, - avg_latch2, - avg_latch3, - avg_strobe0, - avg_strobe1, - tempest_strobe2, - tempest_strobe3 - }, - avg_state_addr, - avg_data, - tempest_vggo, - avg_vgrst -}; - -static const vgconf avg_bzone = -{ - { - avg_latch0, - bzone_latch1, - avg_latch2, - avg_latch3, - avg_strobe0, - avg_strobe1, - bzone_strobe2, - bzone_strobe3 - }, - avg_state_addr, - avg_data, - avg_vggo, - avg_vgrst -}; - -static const vgconf avg_quantum = -{ - { - quantum_st2st3, - quantum_latch1, - quantum_st2st3, - quantum_latch3, - quantum_strobe0, - quantum_strobe1, - quantum_strobe2, - quantum_strobe3 - }, - avg_state_addr, - quantum_data, - tempest_vggo, - avg_vgrst -}; - -static const vgconf avg_tomcat = -{ - { - avg_latch0, - avg_latch1, - avg_latch2, - avg_latch3, - avg_strobe0, - avg_strobe1, - starwars_strobe2, - starwars_strobe3 - }, - avg_state_addr, - avg_data, - avg_vggo, - avg_vgrst -}; - /************************************* * * Vector generator init * ************************************/ -static void register_state (running_machine &machine) +void avgdvg_device::register_state() { - state_save_register_item(machine, "AVG", NULL, 0, vg->pc); - state_save_register_item(machine, "AVG", NULL, 0, vg->sp); - state_save_register_item(machine, "AVG", NULL, 0, vg->dvx); - state_save_register_item(machine, "AVG", NULL, 0, vg->dvy); - state_save_register_item(machine, "AVG", NULL, 0, vg->dvy12); - state_save_register_item(machine, "AVG", NULL, 0, vg->timer); - state_save_register_item_array(machine, "AVG", NULL, 0, vg->stack); - state_save_register_item(machine, "AVG", NULL, 0, vg->data); - state_save_register_item(machine, "AVG", NULL, 0, vg->state_latch); - state_save_register_item(machine, "AVG", NULL, 0, vg->int_latch); - state_save_register_item(machine, "AVG", NULL, 0, vg->scale); - state_save_register_item(machine, "AVG", NULL, 0, vg->bin_scale); - state_save_register_item(machine, "AVG", NULL, 0, vg->intensity); - state_save_register_item(machine, "AVG", NULL, 0, vg->color); - state_save_register_item(machine, "AVG", NULL, 0, vg->enspkl); - state_save_register_item(machine, "AVG", NULL, 0, vg->spkl_shift); - state_save_register_item(machine, "AVG", NULL, 0, vg->map); - state_save_register_item(machine, "AVG", NULL, 0, vg->hst); - state_save_register_item(machine, "AVG", NULL, 0, vg->lst); - state_save_register_item(machine, "AVG", NULL, 0, vg->izblank); - state_save_register_item(machine, "AVG", NULL, 0, vg->op); - state_save_register_item(machine, "AVG", NULL, 0, vg->halt); - state_save_register_item(machine, "AVG", NULL, 0, vg->sync_halt); - state_save_register_item(machine, "AVG", NULL, 0, vg->xdac_xor); - state_save_register_item(machine, "AVG", NULL, 0, vg->ydac_xor); - state_save_register_item(machine, "AVG", NULL, 0, vg->xpos); - state_save_register_item(machine, "AVG", NULL, 0, vg->ypos); - state_save_register_item(machine, "AVG", NULL, 0, vg->clipx_min); - state_save_register_item(machine, "AVG", NULL, 0, vg->clipy_min); - state_save_register_item(machine, "AVG", NULL, 0, vg->clipx_max); - state_save_register_item(machine, "AVG", NULL, 0, vg->clipy_max); + save_item(NAME(m_pc)); + save_item(NAME(m_sp)); + save_item(NAME(m_dvx)); + save_item(NAME(m_dvy)); + save_item(NAME(m_dvy12)); + save_item(NAME(m_timer)); + save_item(NAME(m_stack)); + save_item(NAME(m_data)); + save_item(NAME(m_state_latch)); + save_item(NAME(m_int_latch)); + save_item(NAME(m_scale)); + save_item(NAME(m_bin_scale)); + save_item(NAME(m_intensity)); + save_item(NAME(m_color)); + save_item(NAME(m_enspkl)); + save_item(NAME(m_spkl_shift)); + save_item(NAME(m_map)); + save_item(NAME(m_hst)); + save_item(NAME(m_lst)); + save_item(NAME(m_izblank)); + save_item(NAME(m_op)); + save_item(NAME(m_halt)); + save_item(NAME(m_sync_halt)); + save_item(NAME(m_xdac_xor)); + save_item(NAME(m_ydac_xor)); + save_item(NAME(m_xpos)); + save_item(NAME(m_ypos)); + save_item(NAME(m_clipx_min)); + save_item(NAME(m_clipy_min)); + save_item(NAME(m_clipx_max)); + save_item(NAME(m_clipy_max)); - state_save_register_item(machine, "AVG", NULL, 0, flip_x); - state_save_register_item(machine, "AVG", NULL, 0, flip_y); - state_save_register_item_pointer(machine, "AVG", NULL, 0, avgdvg_vectorram, avgdvg_vectorram_size); + save_item(NAME(flip_x)); + save_item(NAME(flip_y)); + save_pointer(NAME(avgdvg_vectorram), avgdvg_vectorram_size); } -static VIDEO_START( avg_common ) +void avg_device::device_start() { - const rectangle &visarea = machine.first_screen()->visible_area(); + if(!m_vector->started()) + throw device_missing_dependencies(); - avgdvg_vectorram = reinterpret_cast(machine.root_device().memshare("vectorram")->ptr()); - avgdvg_vectorram_size = machine.root_device().memshare("vectorram")->bytes(); + const rectangle &visarea = machine().first_screen()->visible_area(); - avgdvg_colorram = reinterpret_cast(machine.root_device().memshare("colorram")->ptr()); - - vg = &vgd; - vg->set_machine(machine); + avgdvg_vectorram = reinterpret_cast(machine().root_device().memshare("vectorram")->ptr()); + avgdvg_vectorram_size = machine().root_device().memshare("vectorram")->bytes(); + avgdvg_colorram = reinterpret_cast(machine().root_device().memshare("colorram")->ptr()); + xmin = visarea.min_x; ymin = visarea.min_y; xmax = visarea.max_x; @@ -1502,83 +1353,152 @@ static VIDEO_START( avg_common ) flip_x = flip_y = 0; - vg_halt_timer = machine.scheduler().timer_alloc(FUNC(vg_set_halt_callback)); - vg_run_timer = machine.scheduler().timer_alloc(FUNC(run_state_machine)); + vg_halt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(avgdvg_device::vg_set_halt_callback),this)); + vg_run_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(avgdvg_device::run_state_machine),this)); /* * The x and y DACs use 10 bit of the counter values which are in * two's complement representation. The DAC input is xored with * 0x200 to convert the value to unsigned. */ - vg->xdac_xor = 0x200; - vg->ydac_xor = 0x200; + m_xdac_xor = 0x200; + m_ydac_xor = 0x200; - register_state (machine); - machine.device("vector")->device_start(); + register_state(); } -VIDEO_START( dvg ) +void dvg_device::device_start() { - const rectangle &visarea = machine.first_screen()->visible_area(); + if(!m_vector->started()) + throw device_missing_dependencies(); + + const rectangle &visarea = machine().first_screen()->visible_area(); - avgdvg_vectorram = reinterpret_cast(machine.root_device().memshare("vectorram")->ptr()); - avgdvg_vectorram_size = machine.root_device().memshare("vectorram")->bytes(); + avgdvg_vectorram = reinterpret_cast(machine().root_device().memshare("vectorram")->ptr()); + avgdvg_vectorram_size = machine().root_device().memshare("vectorram")->bytes(); - avgdvg_colorram = reinterpret_cast(machine.root_device().memshare("colorram")->ptr()); - - vgc = &dvg_default; - vg = &vgd; - vg->set_machine(machine); + avgdvg_colorram = reinterpret_cast(machine().root_device().memshare("colorram")->ptr()); xmin = visarea.min_x; ymin = visarea.min_y; - vg_halt_timer = machine.scheduler().timer_alloc(FUNC(vg_set_halt_callback)); - vg_run_timer = machine.scheduler().timer_alloc(FUNC(run_state_machine)); - - register_state (machine); - - machine.device("vector")->device_start(); + vg_halt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(avgdvg_device::vg_set_halt_callback),this)); + vg_run_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(avgdvg_device::run_state_machine),this)); + + register_state(); } -VIDEO_START( avg ) +void avgdvg_device::static_set_vector_tag(device_t &device, const char *tag) { - vgc = &avg_default; - VIDEO_START_CALL(avg_common); + downcast(device).m_vector.set_tag(tag); } -VIDEO_START( avg_starwars ) +avgdvg_device::avgdvg_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : + device_t(mconfig, type, name, tag, owner, clock, shortname, source), + m_vector(*this) { - vgc = &avg_starwars; - VIDEO_START_CALL(avg_common); + m_pc = 0; + m_sp = 0; + m_dvx = 0; + m_dvy = 0; + m_dvy12 = 0; + m_timer = 0; + m_stack[0] = 0; + m_stack[1] = 0; + m_stack[2] = 0; + m_stack[3] = 0; + m_data = 0; + + m_state_latch = 0; + m_int_latch = 0; + m_scale = 0; + m_bin_scale = 0; + m_intensity = 0; + m_color = 0; + m_enspkl = 0; + m_spkl_shift = 0; + m_map = 0; + + m_hst = 0; + m_lst = 0; + m_izblank = 0; + + m_op = 0; + m_halt = 0; + m_sync_halt = 0; + + m_xdac_xor = 0; + m_ydac_xor = 0; + + m_xpos = 0; + m_ypos = 0; + + m_clipx_min = 0; + m_clipy_min = 0; + m_clipx_max = 0; + m_clipy_max = 0; + + xmin = 0; + xmax = 0; + ymin = 0; + ymax = 0; + xcenter = 0; + ycenter = 0; + flip_x = 0; + flip_y = 0; + nvect = 0; } -VIDEO_START( avg_tempest ) +dvg_device::dvg_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + avgdvg_device(mconfig, DVG, "DVG", tag, owner, clock, "dvg", __FILE__) { - vgc = &avg_tempest; - VIDEO_START_CALL(avg_common); } -VIDEO_START( avg_mhavoc ) +avg_device::avg_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + avgdvg_device(mconfig, AVG, "AVG", tag, owner, clock, "avg", __FILE__) { - vgc = &avg_mhavoc; - VIDEO_START_CALL(avg_common); } -VIDEO_START( avg_bzone ) +avg_device::avg_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : + avgdvg_device(mconfig, type, name, tag, owner, clock, shortname, source) { - vgc = &avg_bzone; - VIDEO_START_CALL(avg_common); } -VIDEO_START( avg_quantum ) + +avg_tempest_device::avg_tempest_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + avg_device(mconfig, AVG_TEMPEST, "AVG_TEMPEST", tag, owner, clock, "avg_tempest", __FILE__) +{ +} +avg_mhavoc_device::avg_mhavoc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + avg_device(mconfig, AVG_MHAVOC, "AVG_MHAVOC", tag, owner, clock, "avg_mhavoc", __FILE__) { - vgc = &avg_quantum; - VIDEO_START_CALL(avg_common); } -VIDEO_START( avg_tomcat ) +avg_starwars_device::avg_starwars_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + avg_device(mconfig, AVG_STARWARS, "AVG_STARWARS", tag, owner, clock, "avg_starwars", __FILE__) { - vgc = &avg_tomcat; - VIDEO_START_CALL(avg_common); } + +avg_quantum_device::avg_quantum_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + avg_device(mconfig, AVG_QUANTUM, "AVG_QUANTUM", tag, owner, clock, "avg_quantum", __FILE__) +{ +} + +avg_bzone_device::avg_bzone_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + avg_device(mconfig, AVG_BZONE, "AVG_BZONE", tag, owner, clock, "avg_bzone", __FILE__) +{ +} + +avg_tomcat_device::avg_tomcat_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + avg_device(mconfig, AVG_TOMCAT, "AVG_TOMCAT", tag, owner, clock, "avg_tomcat", __FILE__) +{ +} + +const device_type DVG = &device_creator; +const device_type AVG = &device_creator; +const device_type AVG_TEMPEST = &device_creator; +const device_type AVG_MHAVOC = &device_creator; +const device_type AVG_STARWARS = &device_creator; +const device_type AVG_QUANTUM = &device_creator; +const device_type AVG_BZONE = &device_creator; +const device_type AVG_TOMCAT = &device_creator; diff --git a/src/mame/video/avgdvg.h b/src/mame/video/avgdvg.h index e14d9cb7ae4..15afd994fc6 100644 --- a/src/mame/video/avgdvg.h +++ b/src/mame/video/avgdvg.h @@ -1,23 +1,272 @@ #ifndef __AVGDVG__ #define __AVGDVG__ -CUSTOM_INPUT( avgdvg_done_r ); -DECLARE_WRITE8_HANDLER( avgdvg_go_w ); -DECLARE_WRITE8_HANDLER( avgdvg_reset_w ); -DECLARE_WRITE16_HANDLER( avgdvg_go_word_w ); -DECLARE_WRITE16_HANDLER( avgdvg_reset_word_w ); +#define MAXVECT (10000) -/* Tempest and Quantum use this capability */ -void avg_set_flip_x(int flip); -void avg_set_flip_y(int flip); +#include "video/vector.h" + +#define MCFG_AVGDVG_VECTOR(_tag) \ + avgdvg_device::static_set_vector_tag(*device, "^" _tag); + +struct vgvector +{ + int x; int y; + rgb_t color; + int intensity; + int arg1; int arg2; + int status; +}; + +// ======================> avgdvg_device + +class avgdvg_device : public device_t +{ +public: + // construction/destruction + avgdvg_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); + + static void static_set_vector_tag(device_t &device, const char *tag); + + DECLARE_CUSTOM_INPUT_MEMBER(done_r); + DECLARE_WRITE8_MEMBER(go_w); + DECLARE_WRITE8_MEMBER(reset_w); + + DECLARE_WRITE16_MEMBER(go_word_w); + DECLARE_WRITE16_MEMBER(reset_word_w); + + /* Tempest and Quantum use this capability */ + void set_flip_x(int flip); + void set_flip_y(int flip); + + TIMER_CALLBACK_MEMBER(vg_set_halt_callback); + TIMER_CALLBACK_MEMBER(run_state_machine); +protected: + void apply_flipping(int *x, int *y); + void vg_set_halt(int dummy); + + void vg_flush(); + void vg_add_point_buf(int x, int y, rgb_t color, int intensity); + void vg_add_clip (int xmin, int ymin, int xmax, int ymax); + + void register_state(); + + UINT8 *avgdvg_vectorram; + size_t avgdvg_vectorram_size; + + UINT8 *avgdvg_colorram; + + + int xmin, xmax, ymin, ymax; + int xcenter, ycenter; + emu_timer *vg_run_timer, *vg_halt_timer; + + int flip_x, flip_y; + + int nvect; + vgvector vectbuf[MAXVECT]; + + + UINT16 m_pc; + UINT8 m_sp; + UINT16 m_dvx; + UINT16 m_dvy; + UINT8 m_dvy12; + UINT16 m_timer; + UINT16 m_stack[4]; + UINT16 m_data; + + UINT8 m_state_latch; + UINT8 m_int_latch; + UINT8 m_scale; + UINT8 m_bin_scale; + UINT8 m_intensity; + UINT8 m_color; + UINT8 m_enspkl; + UINT8 m_spkl_shift; + UINT8 m_map; + + UINT16 m_hst; + UINT16 m_lst; + UINT16 m_izblank; + + UINT8 m_op; + UINT8 m_halt; + UINT8 m_sync_halt; + + UINT16 m_xdac_xor; + UINT16 m_ydac_xor; + + INT32 m_xpos; + INT32 m_ypos; + + INT32 m_clipx_min; + INT32 m_clipy_min; + INT32 m_clipx_max; + INT32 m_clipy_max; + + + virtual int handler_0() = 0; + virtual int handler_1() = 0; + virtual int handler_2() = 0; + virtual int handler_3() = 0; + virtual int handler_4() = 0; + virtual int handler_5() = 0; + virtual int handler_6() = 0; + virtual int handler_7() = 0; + virtual UINT8 state_addr() = 0; + virtual void update_databus() = 0; + virtual void vggo() = 0; + virtual void vgrst() = 0; + + required_device m_vector; +}; + +class dvg_device : public avgdvg_device +{ +public: + // construction/destruction + dvg_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + void dvg_draw_to(int x, int y, int intensity); + + virtual int handler_0(); + virtual int handler_1(); + virtual int handler_2(); + virtual int handler_3(); + virtual int handler_4(); + virtual int handler_5(); + virtual int handler_6(); + virtual int handler_7(); + virtual UINT8 state_addr(); + virtual void update_databus(); + virtual void vggo(); + virtual void vgrst(); + + virtual void device_start(); +}; + +// device type definition +extern const device_type DVG; + +class avg_device : public avgdvg_device +{ +public: + // construction/destruction + avg_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + avg_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); + + int avg_common_strobe1(); + int avg_common_strobe2(); + int avg_common_strobe3(); + + virtual int handler_0(); + virtual int handler_1(); + virtual int handler_2(); + virtual int handler_3(); + virtual int handler_4(); + virtual int handler_5(); + virtual int handler_6(); + virtual int handler_7(); + virtual UINT8 state_addr(); + virtual void update_databus(); + virtual void vggo(); + virtual void vgrst(); + + virtual void device_start(); + void avg_start_common(); +}; + +// device type definition +extern const device_type AVG; + +class avg_tempest_device : public avg_device +{ +public: + // construction/destruction + avg_tempest_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + virtual int handler_6(); + virtual int handler_7(); + virtual void vggo(); +}; + +// device type definition +extern const device_type AVG_TEMPEST; + +class avg_mhavoc_device : public avg_device +{ +public: + // construction/destruction + avg_mhavoc_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + virtual int handler_1(); + virtual int handler_6(); + virtual int handler_7(); + virtual void update_databus(); + virtual void vgrst(); +}; + +// device type definition +extern const device_type AVG_MHAVOC; + +class avg_starwars_device : public avg_device +{ +public: + // construction/destruction + avg_starwars_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + virtual int handler_6(); + virtual int handler_7(); + virtual void update_databus(); +}; + +// device type definition +extern const device_type AVG_STARWARS; + +class avg_quantum_device : public avg_device +{ +public: + // construction/destruction + avg_quantum_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + virtual int handler_0(); + virtual int handler_1(); + virtual int handler_2(); + virtual int handler_3(); + virtual int handler_4(); + virtual int handler_5(); + virtual int handler_6(); + virtual int handler_7(); + virtual void update_databus(); + virtual void vggo(); +}; + +// device type definition +extern const device_type AVG_QUANTUM; + +class avg_bzone_device : public avg_device +{ +public: + // construction/destruction + avg_bzone_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + virtual int handler_1(); + virtual int handler_6(); + virtual int handler_7(); +}; + +// device type definition +extern const device_type AVG_BZONE; + +class avg_tomcat_device : public avg_device +{ +public: + // construction/destruction + avg_tomcat_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + virtual int handler_6(); + virtual int handler_7(); +}; + +// device type definition +extern const device_type AVG_TOMCAT; -VIDEO_START( dvg ); -VIDEO_START( avg ); -VIDEO_START( avg_tempest ); -VIDEO_START( avg_mhavoc ); -VIDEO_START( avg_starwars ); -VIDEO_START( avg_quantum ); -VIDEO_START( avg_bzone ); -VIDEO_START( avg_tomcat ); #endif