diff options
author | Zsolt Vasvari <zsoltvas@mamedev.org> | 2008-02-21 00:46:44 +0000 |
---|---|---|
committer | Zsolt Vasvari <zsoltvas@mamedev.org> | 2008-02-21 00:46:44 +0000 |
commit | 4606ca9dc21c0221c660a2be31981468ab4a7d7e (patch) | |
tree | ba0abb96517049e3f8987be7070935dff551dfc5 | |
parent | 930f6ecac0bd2416f2297ef6ccb59f01ef9906fd (diff) |
- Reorganized Gameplan driver
- Changed Trivia Quest use the Gameplan video code
- Added crystal for Gameplan pixel clock
-rw-r--r-- | .gitattributes | 2 | ||||
-rw-r--r-- | src/emu/drivers/xtal.h | 1 | ||||
-rw-r--r-- | src/mame/drivers/gameplan.c | 443 | ||||
-rw-r--r-- | src/mame/drivers/trvquest.c | 126 | ||||
-rw-r--r-- | src/mame/includes/gameplan.h | 41 | ||||
-rw-r--r-- | src/mame/video/gameplan.c | 383 |
6 files changed, 552 insertions, 444 deletions
diff --git a/.gitattributes b/.gitattributes index 1b18d45d30b..6f72410b663 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2185,6 +2185,7 @@ src/mame/includes/fromance.h svneol=native#text/plain src/mame/includes/gaelco3d.h svneol=native#text/plain src/mame/includes/galaga.h svneol=native#text/plain src/mame/includes/galaxian.h svneol=native#text/plain +src/mame/includes/gameplan.h svneol=native#text/plain src/mame/includes/gauntlet.h svneol=native#text/plain src/mame/includes/gcpinbal.h svneol=native#text/plain src/mame/includes/genesis.h svneol=native#text/plain @@ -2787,6 +2788,7 @@ src/mame/video/galivan.c svneol=native#text/plain src/mame/video/galpani2.c svneol=native#text/plain src/mame/video/galpanic.c svneol=native#text/plain src/mame/video/galspnbl.c svneol=native#text/plain +src/mame/video/gameplan.c svneol=native#text/plain src/mame/video/gaplus.c svneol=native#text/plain src/mame/video/gauntlet.c svneol=native#text/plain src/mame/video/gberet.c svneol=native#text/plain diff --git a/src/emu/drivers/xtal.h b/src/emu/drivers/xtal.h index b87b12a96d0..849e7ccf215 100644 --- a/src/emu/drivers/xtal.h +++ b/src/emu/drivers/xtal.h @@ -68,6 +68,7 @@ enum XTAL_11_0592MHz = 11059200, /* Lethal Justice */ XTAL_11_2MHz = 11200000, /* New York, New York */ XTAL_11_289MHz = 11289000, /* Vanguard */ + XTAL_11_6688MHz = 11668800, /* Gameplan pixel clock */ XTAL_12MHz = 12000000, /* Extremely common, used on 100's of PCBs */ XTAL_12_096MHz = 12096000, /* Some early 80's Atari games */ XTAL_12_288MHz = 12288000, /* Sega Model 3 digital audio board */ diff --git a/src/mame/drivers/gameplan.c b/src/mame/drivers/gameplan.c index 1f625c8d166..dbdae329024 100644 --- a/src/mame/drivers/gameplan.c +++ b/src/mame/drivers/gameplan.c @@ -16,7 +16,7 @@ Address Dir Data Name Description 00011----------- n.c. 00100-------xxxx R/W xxxxxxxx VIA 1 6522 for video interface 00101-------xxxx R/W xxxxxxxx VIA 2 6522 for I/O interface -00110-------xxxx R/W xxxxxxxx VIA 3 6522 for interface with sound CPU +00110-------xxxx R/W xxxxxxxx VIA 3 6522 for interface with audio CPU 00111----------- n.c. 01-------------- n.c. 10-------------- n.c. @@ -68,266 +68,7 @@ TODO: #include "machine/6532riot.h" #include "machine/6522via.h" #include "sound/ay8910.h" - - - -#define MAIN_MASTER_CLOCK (3579000) -#define AUDIO_MASTER_CLOCK (3579000) -#define MAIN_CPU_CLOCK (MAIN_MASTER_CLOCK / 4) -#define AUDIO_CPU_CLOCK (AUDIO_MASTER_CLOCK / 4) -#define AY8910_CLOCK (AUDIO_MASTER_CLOCK / 2) -#define PIXEL_CLOCK (11668800 / 2) -#define HTOTAL (0x160) -#define HBEND (0x000) -#define HBSTART (0x100) -#define VTOTAL (0x118) -#define VBEND (0x000) -#define VBSTART (0x100) - -#define GAMEPLAN_NUM_PENS (0x08) -#define LEPRECHN_NUM_PENS (0x10) - - - -/************************************* - * - * Video system - * - *************************************/ - -static UINT8 *gameplan_videoram; -static size_t gameplan_videoram_size; -static UINT8 video_x; -static UINT8 video_y; -static UINT8 video_command; -static UINT8 video_data; - - -static VIDEO_START( gameplan ) -{ - gameplan_videoram_size = (HBSTART - HBEND) * (VBSTART - VBEND); - gameplan_videoram = auto_malloc(gameplan_videoram_size); -} - - -static void gameplan_get_pens(pen_t *pens) -{ - offs_t i; - - for (i = 0; i < GAMEPLAN_NUM_PENS; i++) - { - pens[i] = MAKE_RGB(pal1bit(i >> 0), pal1bit(i >> 1), pal1bit(i >> 2)); - } -} - - -/* RGBI palette. Is it correct, or does it use the standard RGB? */ -static void leprechn_get_pens(pen_t *pens) -{ - offs_t i; - - for (i = 0; i < LEPRECHN_NUM_PENS; i++) - { - UINT8 bk = (i & 8) ? 0x40 : 0x00; - UINT8 r = (i & 1) ? 0xff : bk; - UINT8 g = (i & 2) ? 0xff : bk; - UINT8 b = (i & 4) ? 0xff : bk; - - pens[i] = MAKE_RGB(r, g, b); - } -} - - -static VIDEO_UPDATE( gameplan ) -{ - pen_t pens[GAMEPLAN_NUM_PENS]; - offs_t offs; - - gameplan_get_pens(pens); - - for (offs = 0; offs < gameplan_videoram_size; offs++) - { - UINT8 y = offs >> 8; - UINT8 x = offs & 0xff; - - *BITMAP_ADDR32(bitmap, y, x) = pens[gameplan_videoram[offs] & 0x07]; - } - - return 0; -} - - -static VIDEO_UPDATE( leprechn ) -{ - pen_t pens[LEPRECHN_NUM_PENS]; - offs_t offs; - - leprechn_get_pens(pens); - - for (offs = 0; offs < gameplan_videoram_size; offs++) - { - UINT8 y = offs >> 8; - UINT8 x = offs & 0xff; - - *BITMAP_ADDR32(bitmap, y, x) = pens[gameplan_videoram[offs]]; - } - - return 0; -} - - - -/************************************* - * - * VIA 1 - video - * - *************************************/ - -static emu_timer *via_0_ca1_timer; - - - -static WRITE8_HANDLER( video_data_w ) -{ - video_data = data; -} - - -static WRITE8_HANDLER( gameplan_video_command_w ) -{ - video_command = data & 0x07; -} - - -static WRITE8_HANDLER( leprechn_video_command_w ) -{ - video_command = (data >> 3) & 0x07; -} - - -static TIMER_CALLBACK( clear_screen_done_callback ) -{ - /* indicate that the we are done clearing the screen */ - via_0_ca1_w(0, 0); -} - - -static WRITE8_HANDLER( video_command_trigger_w ) -{ - if (data == 0) - { - switch (video_command) - { - /* draw pixel */ - case 0: - /* auto-adjust X? */ - if (video_data & 0x10) - { - if (video_data & 0x40) - video_x = video_x - 1; - else - video_x = video_x + 1; - } - - /* auto-adjust Y? */ - if (video_data & 0x20) - { - if (video_data & 0x80) - video_y = video_y - 1; - else - video_y = video_y + 1; - } - - gameplan_videoram[video_y * (HBSTART - HBEND) + video_x] = video_data & 0x0f; - - break; - - /* load X register */ - case 1: - video_x = video_data; - break; - - /* load Y register */ - case 2: - video_y = video_data; - break; - - /* clear screen */ - case 3: - - /* indicate that the we are busy */ - via_0_ca1_w(0, 1); - - memset(gameplan_videoram, video_data & 0x0f, gameplan_videoram_size); - - /* set a timer for an arbitrarily short period. - The real time it takes to clear to screen is not - important to the software */ - timer_call_after_resynch(NULL, 0, clear_screen_done_callback); - - break; - } - } -} - - -static TIMER_CALLBACK( via_irq_delayed ) -{ - cpunum_set_input_line(machine, 0, 0, param); -} - - -static void via_irq(int state) -{ - /* Kaos sits in a tight loop polling the VIA irq flags register, but that register is - cleared by the irq handler. Therefore, I wait a bit before triggering the irq to - leave time for the program to see the flag change. */ - timer_set(ATTOTIME_IN_USEC(50), NULL, state, via_irq_delayed); -} - - -static const struct via6522_interface gameplan_via_0_interface = -{ - 0, 0, /*inputs : A/B */ - /*vblank*/0, 0, 0, 0, /*inputs : CA/B1,CA/B2 */ - video_data_w, gameplan_video_command_w, /*outputs: A/B */ - 0, 0, video_command_trigger_w, 0, /*outputs: CA/B1,CA/B2 */ - via_irq /*irq */ -}; - - -static const struct via6522_interface leprechn_via_0_interface = -{ - 0, 0, /*inputs : A/B */ - /*vblank*/0, 0, 0, 0, /*inputs : CA/B1,CA/B2 */ - video_data_w, leprechn_video_command_w, /*outputs: A/B */ - 0, 0, video_command_trigger_w, 0, /*outputs: CA/B1,CA/B2 */ - via_irq /*irq */ -}; - - -static TIMER_CALLBACK( via_0_ca1_timer_callback ) -{ - /* !VBLANK is connected to CA1 */ - via_0_ca1_w(0, (UINT8)param); - - if (param) - timer_adjust_oneshot(via_0_ca1_timer, video_screen_get_time_until_pos(0, VBSTART, 0), 0); - else - timer_adjust_oneshot(via_0_ca1_timer, video_screen_get_time_until_pos(0, VBEND, 0), 1); -} - - -static void create_via_0_timer(void) -{ - via_0_ca1_timer = timer_alloc(via_0_ca1_timer_callback, NULL); -} - - -static void start_via_0_timer(void) -{ - timer_adjust_oneshot(via_0_ca1_timer, video_screen_get_time_until_pos(0, VBSTART, 0), 0); -} +#include "gameplan.h" @@ -337,26 +78,27 @@ static void start_via_0_timer(void) * *************************************/ -static UINT8 current_port; - - static WRITE8_HANDLER( io_select_w ) { + gameplan_state *state = Machine->driver_data; + switch (data) { - case 0x01: current_port = 0; break; - case 0x02: current_port = 1; break; - case 0x04: current_port = 2; break; - case 0x08: current_port = 3; break; - case 0x80: current_port = 4; break; - case 0x40: current_port = 5; break; + case 0x01: state->current_port = 0; break; + case 0x02: state->current_port = 1; break; + case 0x04: state->current_port = 2; break; + case 0x08: state->current_port = 3; break; + case 0x80: state->current_port = 4; break; + case 0x40: state->current_port = 5; break; } } static READ8_HANDLER( io_port_r ) { - return readinputport(current_port); + gameplan_state *state = Machine->driver_data; + + return readinputport(state->current_port); } @@ -379,28 +121,29 @@ static const struct via6522_interface via_1_interface = /************************************* * - * VIA 3 - sound + * VIA 3 - audio * *************************************/ -static UINT8 sound_cmd; - - -static WRITE8_HANDLER( sound_reset_w ) +static WRITE8_HANDLER( audio_reset_w ) { cpunum_set_input_line(Machine, 1, INPUT_LINE_RESET, (data & 1) ? CLEAR_LINE : ASSERT_LINE); } -static WRITE8_HANDLER( sound_cmd_w ) +static WRITE8_HANDLER( audio_cmd_w ) { - sound_cmd = data & 0x7f; + gameplan_state *state = Machine->driver_data; + + state->audio_cmd = data & 0x7f; } -static WRITE8_HANDLER( sound_trigger_w ) +static WRITE8_HANDLER( audio_trigger_w ) { - UINT8 cmd = (data << 7) | sound_cmd; + gameplan_state *state = Machine->driver_data; + + UINT8 cmd = (data << 7) | (state->audio_cmd & 0x7f); soundlatch_w(0, cmd); r6532_0_porta_w(0, cmd); @@ -411,8 +154,8 @@ static const struct via6522_interface via_2_interface = { 0, soundlatch2_r, /*inputs : A/B */ 0, 0, 0, 0, /*inputs : CA/B1,CA/B2 */ - sound_cmd_w, 0, /*outputs: A/B */ - 0, 0, sound_trigger_w, sound_reset_w, /*outputs: CA/B1,CA/B2 */ + audio_cmd_w, 0, /*outputs: A/B */ + 0, 0, audio_trigger_w, audio_reset_w, /*outputs: CA/B1,CA/B2 */ 0 /*irq */ }; @@ -420,7 +163,7 @@ static const struct via6522_interface via_2_interface = /************************************* * - * VIA 5 - sound + * RIOT - audio * *************************************/ @@ -443,47 +186,47 @@ static const struct riot6532_interface r6532_interface = /************************************* * - * Machine start-up + * Start * *************************************/ static MACHINE_START( gameplan ) { - via_config(0, &gameplan_via_0_interface); + gameplan_state *state = machine->driver_data; + via_config(1, &via_1_interface); via_config(2, &via_2_interface); r6532_config(0, &r6532_interface); - r6532_set_clock(0, AUDIO_CPU_CLOCK); + r6532_set_clock(0, GAMEPLAN_AUDIO_CPU_CLOCK); r6532_reset(0); - create_via_0_timer(); + /* register for save states */ + state_save_register_global(state->current_port); + state_save_register_global(state->audio_cmd); } -static MACHINE_START( leprechn ) -{ - via_config(0, &leprechn_via_0_interface); - via_config(1, &via_1_interface); - via_config(2, &via_2_interface); - - r6532_config(0, &r6532_interface); - r6532_set_clock(0, AUDIO_CPU_CLOCK); - r6532_reset(0); - - create_via_0_timer(); -} +/************************************* + * + * Reset + * + *************************************/ static MACHINE_RESET( gameplan ) { via_reset(); - - start_via_0_timer(); } +/************************************* + * + * Main CPU memory handlers + * + *************************************/ + static ADDRESS_MAP_START( gameplan_main_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x1c00) AM_RAM AM_RANGE(0x2000, 0x200f) AM_MIRROR(0x07f0) AM_READWRITE(via_0_r, via_0_w) /* VIA 1 */ @@ -495,6 +238,13 @@ static ADDRESS_MAP_START( gameplan_main_map, ADDRESS_SPACE_PROGRAM, 8 ) ADDRESS_MAP_END + +/************************************* + * + * Audio CPU memory handlers + * + *************************************/ + static ADDRESS_MAP_START( gameplan_audio_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x1780) AM_RAM /* 6532 internal RAM */ AM_RANGE(0x0800, 0x081f) AM_MIRROR(0x17e0) AM_READWRITE(r6532_0_r, r6532_0_w) @@ -523,6 +273,12 @@ ADDRESS_MAP_END +/************************************* + * + * Input ports + * + *************************************/ + static INPUT_PORTS_START( killcom ) PORT_START /* COL. A - from "TEST NO.7 - status locator - coin-door" */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) @@ -614,7 +370,7 @@ static INPUT_PORTS_START( killcom ) PORT_DIPSETTING( 0x80, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) - PORT_START /* sound board DSW A */ + PORT_START /* audio board DSW A */ PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -640,7 +396,7 @@ static INPUT_PORTS_START( killcom ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_START /* sound board DSW B */ + PORT_START /* audio board DSW B */ PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -760,7 +516,7 @@ static INPUT_PORTS_START( megatack ) PORT_DIPSETTING( 0x80, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) - PORT_START /* sound board DSW A */ + PORT_START /* audio board DSW A */ PORT_DIPNAME( 0x01, 0x00, "Sound Test A 0" ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -786,7 +542,7 @@ static INPUT_PORTS_START( megatack ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_START /* sound board DSW B */ + PORT_START /* audio board DSW B */ PORT_DIPNAME( 0x01, 0x00, "Sound Test B 0" ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -905,7 +661,7 @@ static INPUT_PORTS_START( challeng ) PORT_DIPSETTING( 0x80, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) - PORT_START /* sound board DSW A */ + PORT_START /* audio board DSW A */ PORT_DIPNAME( 0x01, 0x00, "Sound Test A 0" ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -931,7 +687,7 @@ static INPUT_PORTS_START( challeng ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_START /* sound board DSW B */ + PORT_START /* audio board DSW B */ PORT_DIPNAME( 0x01, 0x00, "Sound Test B 0" ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -1055,7 +811,7 @@ static INPUT_PORTS_START( kaos ) PORT_DIPSETTING( 0x80, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) - PORT_START /* sound board DSW A */ + PORT_START /* audio board DSW A */ PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -1081,7 +837,7 @@ static INPUT_PORTS_START( kaos ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_START /* sound board DSW B */ + PORT_START /* audio board DSW B */ PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -1198,7 +954,7 @@ static INPUT_PORTS_START( leprechn ) PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_START /* sound board DSW A */ + PORT_START /* audio board DSW A */ PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -1224,7 +980,7 @@ static INPUT_PORTS_START( leprechn ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_START /* sound board DSW B */ + PORT_START /* audio board DSW B */ PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -1341,7 +1097,7 @@ static INPUT_PORTS_START( piratetr ) PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_START /* sound board DSW A */ + PORT_START /* audio board DSW A */ PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -1367,7 +1123,7 @@ static INPUT_PORTS_START( piratetr ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) - PORT_START /* sound board DSW B */ + PORT_START /* audio board DSW B */ PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) ) PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) @@ -1396,6 +1152,12 @@ INPUT_PORTS_END +/************************************* + * + * Machine drivers + * + *************************************/ + static const struct AY8910interface ay8910_interface = { input_port_6_r, @@ -1405,51 +1167,50 @@ static const struct AY8910interface ay8910_interface = static MACHINE_DRIVER_START( gameplan ) + MDRV_DRIVER_DATA(gameplan_state) + /* basic machine hardware */ - MDRV_CPU_ADD(M6502, MAIN_CPU_CLOCK) + MDRV_CPU_ADD(M6502, GAMEPLAN_MAIN_CPU_CLOCK) MDRV_CPU_PROGRAM_MAP(gameplan_main_map,0) - MDRV_CPU_ADD_TAG("audio", M6502, AUDIO_CPU_CLOCK) + MDRV_CPU_ADD_TAG("audio", M6502, GAMEPLAN_AUDIO_CPU_CLOCK) MDRV_CPU_PROGRAM_MAP(gameplan_audio_map,0) MDRV_MACHINE_START(gameplan) MDRV_MACHINE_RESET(gameplan) /* video hardware */ - MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) - MDRV_VIDEO_START(gameplan) - MDRV_VIDEO_UPDATE(gameplan) - - MDRV_SCREEN_ADD("main", 0) - MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) - MDRV_SCREEN_RAW_PARAMS(PIXEL_CLOCK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART) + MDRV_IMPORT_FROM(gameplan_video); - /* sound hardware */ + /* audio hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD(AY8910, AY8910_CLOCK) + MDRV_SOUND_ADD(AY8910, GAMEPLAN_AY8910_CLOCK) MDRV_SOUND_CONFIG(ay8910_interface) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.33) - MACHINE_DRIVER_END static MACHINE_DRIVER_START( leprechn ) - /* basic machine hardware */ MDRV_IMPORT_FROM(gameplan) + + /* basic machine hardware */ MDRV_CPU_MODIFY("audio") MDRV_CPU_PROGRAM_MAP(leprechn_audio_map,0) - MDRV_MACHINE_START(leprechn) - /* video hardware */ - MDRV_VIDEO_UPDATE(leprechn) - + MDRV_IMPORT_FROM(leprechn_video); MACHINE_DRIVER_END +/************************************* + * + * ROM defintions + * + *************************************/ + ROM_START( killcom ) ROM_REGION( 0x10000, REGION_CPU1, 0 ) ROM_LOAD( "killcom.e2", 0xc000, 0x0800, CRC(a01cbb9a) SHA1(a8769243adbdddedfda5f3c8f054e9281a0eca46) ) @@ -1574,11 +1335,17 @@ ROM_END -GAME( 1980, killcom, 0, gameplan, killcom, 0, ROT0, "GamePlan (Centuri license)", "Killer Comet", 0 ) -GAME( 1980, megatack, 0, gameplan, megatack, 0, ROT0, "GamePlan (Centuri license)", "Megatack", 0 ) -GAME( 1981, challeng, 0, gameplan, challeng, 0, ROT0, "GamePlan (Centuri license)", "Challenger", 0 ) -GAME( 1981, kaos, 0, gameplan, kaos, 0, ROT270, "GamePlan", "Kaos", 0 ) -GAME( 1982, leprechn, 0, leprechn, leprechn, 0, ROT0, "Tong Electronic", "Leprechaun", 0 ) -GAME( 1982, potogold, leprechn, leprechn, leprechn, 0, ROT0, "GamePlan", "Pot of Gold", 0 ) -GAME( 1982, leprechp, leprechn, leprechn, leprechn, 0, ROT0, "Tong Electronic", "Leprechaun (Pacific Polytechnical license)", 0 ) -GAME( 1982, piratetr, 0, leprechn, piratetr, 0, ROT0, "Tong Electronic", "Pirate Treasure", 0 ) +/************************************* + * + * Game drivers + * + *************************************/ + +GAME( 1980, killcom, 0, gameplan, killcom, 0, ROT0, "GamePlan (Centuri license)", "Killer Comet", GAME_SUPPORTS_SAVE ) +GAME( 1980, megatack, 0, gameplan, megatack, 0, ROT0, "GamePlan (Centuri license)", "Megatack", GAME_SUPPORTS_SAVE ) +GAME( 1981, challeng, 0, gameplan, challeng, 0, ROT0, "GamePlan (Centuri license)", "Challenger", GAME_SUPPORTS_SAVE ) +GAME( 1981, kaos, 0, gameplan, kaos, 0, ROT270, "GamePlan", "Kaos", GAME_SUPPORTS_SAVE ) +GAME( 1982, leprechn, 0, leprechn, leprechn, 0, ROT0, "Tong Electronic", "Leprechaun", GAME_SUPPORTS_SAVE ) +GAME( 1982, potogold, leprechn, leprechn, leprechn, 0, ROT0, "GamePlan", "Pot of Gold", GAME_SUPPORTS_SAVE ) +GAME( 1982, leprechp, leprechn, leprechn, leprechn, 0, ROT0, "Tong Electronic", "Leprechaun (Pacific Polytechnical license)", GAME_SUPPORTS_SAVE ) +GAME( 1982, piratetr, 0, leprechn, piratetr, 0, ROT0, "Tong Electronic", "Pirate Treasure", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/trvquest.c b/src/mame/drivers/trvquest.c index 7c6868722c7..9e2358b10d1 100644 --- a/src/mame/drivers/trvquest.c +++ b/src/mame/drivers/trvquest.c @@ -38,74 +38,13 @@ Notes: #include "deprecat.h" #include "machine/6522via.h" #include "sound/ay8910.h" - -static int cmd,portA; -static UINT8 xpos,ypos; - -static int trvquest_question = 0; - -static WRITE8_HANDLER( trvquest_video_portA_w ) -{ - portA = data; -} - -static WRITE8_HANDLER( trvquest_video_portB_w ) -{ - cmd = data & 7; -} - -static WRITE8_HANDLER( trvquest_video_CA2_w ) -{ - if (data != 0) return; - - switch (cmd) - { - case 0: // draw pixel - if (portA & 0x10) // auto increment X - { - if (portA & 0x40) - xpos--; - else - xpos++; - } - if (portA & 0x20) // auto increment Y - { - if (portA & 0x80) - ypos--; - else - ypos++; - } - - *BITMAP_ADDR16(tmpbitmap, ypos, xpos) = Machine->pens[portA & 7]; - break; - - case 1: // load X register - xpos = portA; - break; - - case 2: // load Y register - ypos = portA; - break; - - case 3: // clear screen - fillbitmap(tmpbitmap, Machine->pens[portA & 7], NULL); - break; - } -} - -static WRITE8_HANDLER( trvquest_question_w ) -{ - trvquest_question = data; -} +#include "gameplan.h" static READ8_HANDLER( trvquest_question_r ) { - return memory_region(REGION_USER1)[trvquest_question * 0x2000 + offset]; -} + gameplan_state *state = Machine->driver_data; -static READ8_HANDLER( trvquest_vblank_r ) -{ - return 0x20; + return memory_region(REGION_USER1)[*state->trvquest_question * 0x2000 + offset]; } static WRITE8_HANDLER( trvquest_coin_w ) @@ -121,16 +60,16 @@ static WRITE8_HANDLER( trvquest_misc_w ) static ADDRESS_MAP_START( cpu_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size) // cmos ram AM_RANGE(0x2000, 0x27ff) AM_RAM // main ram - AM_RANGE(0x3800, 0x380f) AM_READWRITE(via_0_r, via_0_w) - AM_RANGE(0x3810, 0x381f) AM_READWRITE(via_1_r, via_1_w) - AM_RANGE(0x3820, 0x382f) AM_READWRITE(via_2_r, via_2_w) + AM_RANGE(0x3800, 0x380f) AM_READWRITE(via_1_r, via_1_w) + AM_RANGE(0x3810, 0x381f) AM_READWRITE(via_2_r, via_2_w) + AM_RANGE(0x3820, 0x382f) AM_READWRITE(via_0_r, via_0_w) AM_RANGE(0x3830, 0x3830) AM_WRITE(AY8910_control_port_0_w) AM_RANGE(0x3831, 0x3831) AM_WRITE(AY8910_write_port_0_w) AM_RANGE(0x3840, 0x3840) AM_WRITE(AY8910_control_port_1_w) AM_RANGE(0x3841, 0x3841) AM_WRITE(AY8910_write_port_1_w) AM_RANGE(0x3850, 0x3850) AM_READNOP //watchdog_reset_r ? AM_RANGE(0x8000, 0x9fff) AM_READ(trvquest_question_r) - AM_RANGE(0xa000, 0xa000) AM_WRITE(trvquest_question_w) + AM_RANGE(0xa000, 0xa000) AM_WRITE(MWA8_RAM) AM_BASE_MEMBER(gameplan_state, trvquest_question) AM_RANGE(0xa000, 0xa000) AM_READNOP // bogus read from the game code when reads question roms AM_RANGE(0xb000, 0xffff) AM_ROM ADDRESS_MAP_END @@ -225,7 +164,7 @@ static void via_irq(int state) } -static const struct via6522_interface via_0_interface = +static const struct via6522_interface via_1_interface = { /*inputs : A/B */ input_port_0_r, input_port_1_r, /*inputs : CA/B1,CA/B2 */ NULL, NULL, NULL, NULL, @@ -234,7 +173,7 @@ static const struct via6522_interface via_0_interface = /*irq */ NULL }; -static const struct via6522_interface via_1_interface = +static const struct via6522_interface via_2_interface = { /*inputs : A/B */ input_port_2_r, input_port_3_r, /*inputs : CA/B1,CA/B2 */ NULL, NULL, NULL, NULL, @@ -243,63 +182,38 @@ static const struct via6522_interface via_1_interface = /*irq */ via_irq }; -static const struct via6522_interface via_2_interface = -{ - /*inputs : A/B */ NULL, trvquest_vblank_r, - /*inputs : CA/B1,CA/B2 */ NULL, NULL, NULL, NULL, - /*outputs: A/B */ trvquest_video_portA_w, trvquest_video_portB_w, - /*outputs: CA/B1,CA/B2 */ NULL, NULL, trvquest_video_CA2_w, NULL, - /*irq */ NULL -}; -static PALETTE_INIT( trvquest ) +static MACHINE_START( trvquest ) { - palette_set_color(machine,0,MAKE_RGB(0x00,0x00,0x00)); /* 0 BLACK */ - palette_set_color(machine,1,MAKE_RGB(0xff,0x00,0x00)); /* 1 RED */ - palette_set_color(machine,2,MAKE_RGB(0x00,0xff,0x00)); /* 2 GREEN */ - palette_set_color(machine,3,MAKE_RGB(0xff,0xff,0x00)); /* 3 YELLOW */ - palette_set_color(machine,4,MAKE_RGB(0x00,0x00,0xff)); /* 4 BLUE */ - palette_set_color(machine,5,MAKE_RGB(0xff,0x00,0xff)); /* 5 MAGENTA */ - palette_set_color(machine,6,MAKE_RGB(0x00,0xff,0xff)); /* 6 CYAN */ - palette_set_color(machine,7,MAKE_RGB(0xff,0xff,0xff)); /* 7 WHITE */ + via_config(1, &via_1_interface); + via_config(2, &via_2_interface); } static MACHINE_RESET( trvquest ) { - via_config(0, &via_0_interface); - via_config(1, &via_1_interface); - via_config(2, &via_2_interface); via_reset(); } static INTERRUPT_GEN( trvquest_interrupt ) { - via_1_ca1_w(0,1); - via_1_ca1_w(0,0); + via_2_ca1_w(0,1); + via_2_ca1_w(0,0); } static MACHINE_DRIVER_START( trvquest ) + + MDRV_DRIVER_DATA(gameplan_state) + MDRV_CPU_ADD(M6809,6000000) MDRV_CPU_PROGRAM_MAP(cpu_map,0) MDRV_CPU_VBLANK_INT(trvquest_interrupt,1) - MDRV_SCREEN_REFRESH_RATE(60) - MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) - MDRV_NVRAM_HANDLER(generic_1fill) + MDRV_MACHINE_START(trvquest) MDRV_MACHINE_RESET(trvquest) /* video hardware */ - MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) - MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) - MDRV_SCREEN_SIZE(256, 256) - MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1) - - MDRV_PALETTE_LENGTH(8) - - MDRV_PALETTE_INIT(trvquest) - MDRV_VIDEO_START(generic_bitmapped) - MDRV_VIDEO_UPDATE(generic_bitmapped) + MDRV_IMPORT_FROM(trvquest_video); /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -332,4 +246,4 @@ ROM_START( trvquest ) ROM_LOAD( "roma", 0x16000, 0x2000, CRC(b4bcaf33) SHA1(c6b08fb8d55b2834d0c6c5baff9f544c795e4c15) ) ROM_END -GAME( 1984, trvquest, 0, trvquest, trvquest, 0, ROT90, "Sunn / Techstar", "Trivia Quest", 0 ) +GAME( 1984, trvquest, 0, trvquest, trvquest, 0, ROT90, "Sunn / Techstar", "Trivia Quest", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/includes/gameplan.h b/src/mame/includes/gameplan.h new file mode 100644 index 00000000000..f3c1bd0d378 --- /dev/null +++ b/src/mame/includes/gameplan.h @@ -0,0 +1,41 @@ +/*************************************************************************** + +GAME PLAN driver + +driver by Chris Moore + +***************************************************************************/ + + +#define GAMEPLAN_MAIN_MASTER_CLOCK (XTAL_3_579545MHz) +#define GAMEPLAN_AUDIO_MASTER_CLOCK (XTAL_3_579545MHz) +#define GAMEPLAN_MAIN_CPU_CLOCK (GAMEPLAN_MAIN_MASTER_CLOCK / 4) +#define GAMEPLAN_AUDIO_CPU_CLOCK (GAMEPLAN_AUDIO_MASTER_CLOCK / 4) +#define GAMEPLAN_AY8910_CLOCK (GAMEPLAN_AUDIO_MASTER_CLOCK / 2) +#define GAMEPLAN_PIXEL_CLOCK (XTAL_11_6688MHz / 2) + + +typedef struct _gameplan_state gameplan_state; +struct _gameplan_state +{ + /* machine state */ + UINT8 current_port; + UINT8 audio_cmd; + UINT8 *trvquest_question; + + /* video state */ + UINT8 *videoram; + size_t videoram_size; + UINT8 video_x; + UINT8 video_y; + UINT8 video_command; + UINT8 video_data; + emu_timer *via_0_ca1_timer; +}; + + +/*----------- defined in video/gameplan.c -----------*/ + +MACHINE_DRIVER_EXTERN( gameplan_video ); +MACHINE_DRIVER_EXTERN( leprechn_video ); +MACHINE_DRIVER_EXTERN( trvquest_video ); diff --git a/src/mame/video/gameplan.c b/src/mame/video/gameplan.c new file mode 100644 index 00000000000..b6b37f2a830 --- /dev/null +++ b/src/mame/video/gameplan.c @@ -0,0 +1,383 @@ +/*************************************************************************** + +GAME PLAN driver + +driver by Chris Moore + +****************************************************************************/ + +#include "driver.h" +#include "deprecat.h" +#include "machine/6522via.h" +#include "gameplan.h" + + + +/************************************* + * + * Constants + * + *************************************/ + +#define HTOTAL (0x160) +#define HBEND (0x000) +#define HBSTART (0x100) +#define VTOTAL (0x118) +#define VBEND (0x000) +#define VBSTART (0x100) + +#define GAMEPLAN_NUM_PENS (0x08) +#define LEPRECHN_NUM_PENS (0x10) + + + +/************************************* + * + * Palette handling + * + *************************************/ + +static void gameplan_get_pens(pen_t *pens) +{ + offs_t i; + + for (i = 0; i < GAMEPLAN_NUM_PENS; i++) + pens[i] = MAKE_RGB(pal1bit(i >> 0), pal1bit(i >> 1), pal1bit(i >> 2)); +} + + +/* RGBI palette. Is it correct, or does it use the standard RGB? */ +static void leprechn_get_pens(pen_t *pens) +{ + offs_t i; + + for (i = 0; i < LEPRECHN_NUM_PENS; i++) + { + UINT8 bk = (i & 8) ? 0x40 : 0x00; + UINT8 r = (i & 1) ? 0xff : bk; + UINT8 g = (i & 2) ? 0xff : bk; + UINT8 b = (i & 4) ? 0xff : bk; + + pens[i] = MAKE_RGB(r, g, b); + } +} + + + +/************************************* + * + * Update + * + *************************************/ + +static VIDEO_UPDATE( gameplan ) +{ + gameplan_state *state = machine->driver_data; + pen_t pens[GAMEPLAN_NUM_PENS]; + offs_t offs; + + gameplan_get_pens(pens); + + for (offs = 0; offs < state->videoram_size; offs++) + { + UINT8 y = offs >> 8; + UINT8 x = offs & 0xff; + + *BITMAP_ADDR32(bitmap, y, x) = pens[state->videoram[offs] & 0x07]; + } + + return 0; +} + + +static VIDEO_UPDATE( leprechn ) +{ + gameplan_state *state = machine->driver_data; + pen_t pens[LEPRECHN_NUM_PENS]; + offs_t offs; + + leprechn_get_pens(pens); + + for (offs = 0; offs < state->videoram_size; offs++) + { + UINT8 y = offs >> 8; + UINT8 x = offs & 0xff; + + *BITMAP_ADDR32(bitmap, y, x) = pens[state->videoram[offs]]; + } + + return 0; +} + + + +/************************************* + * + * VIA + * + *************************************/ + +static WRITE8_HANDLER( video_data_w ) +{ + gameplan_state *state = Machine->driver_data; + + state->video_data = data; +} + + +static WRITE8_HANDLER( gameplan_video_command_w ) +{ + gameplan_state *state = Machine->driver_data; + + state->video_command = data & 0x07; +} + + +static WRITE8_HANDLER( leprechn_video_command_w ) +{ + gameplan_state *state = Machine->driver_data; + + state->video_command = (data >> 3) & 0x07; +} + + +static TIMER_CALLBACK( clear_screen_done_callback ) +{ + /* indicate that the we are done clearing the screen */ + via_0_ca1_w(0, 0); +} + + +static WRITE8_HANDLER( video_command_trigger_w ) +{ + gameplan_state *state = Machine->driver_data; + + if (data == 0) + { + switch (state->video_command) + { + /* draw pixel */ + case 0: + /* auto-adjust X? */ + if (state->video_data & 0x10) + { + if (state->video_data & 0x40) + state->video_x = state->video_x - 1; + else + state->video_x = state->video_x + 1; + } + + /* auto-adjust Y? */ + if (state->video_data & 0x20) + { + if (state->video_data & 0x80) + state->video_y = state->video_y - 1; + else + state->video_y = state->video_y + 1; + } + + state->videoram[state->video_y * (HBSTART - HBEND) + state->video_x] = state->video_data & 0x0f; + + break; + + /* load X register */ + case 1: + state->video_x = state->video_data; + break; + + /* load Y register */ + case 2: + state->video_y = state->video_data; + break; + + /* clear screen */ + case 3: + /* indicate that the we are busy */ + via_0_ca1_w(0, 1); + + memset(state->videoram, state->video_data & 0x0f, state->videoram_size); + + /* set a timer for an arbitrarily short period. + The real time it takes to clear to screen is not + important to the software */ + timer_call_after_resynch(NULL, 0, clear_screen_done_callback); + + break; + } + } +} + + +static TIMER_CALLBACK( via_irq_delayed ) +{ + cpunum_set_input_line(machine, 0, 0, param); +} + + +static void via_irq(int state) +{ + /* Kaos sits in a tight loop polling the VIA irq flags register, but that register is + cleared by the irq handler. Therefore, I wait a bit before triggering the irq to + leave time for the program to see the flag change. */ + timer_set(ATTOTIME_IN_USEC(50), NULL, state, via_irq_delayed); +} + + +static READ8_HANDLER( vblank_r ) +{ + /* this is needed for trivia quest */ + return 0x20; +} + + +static const struct via6522_interface gameplan_via_0_interface = +{ + 0, vblank_r, /*inputs : A/B */ + 0, 0, 0, 0, /*inputs : CA/B1,CA/B2 */ + video_data_w, gameplan_video_command_w, /*outputs: A/B */ + 0, 0, video_command_trigger_w, 0, /*outputs: CA/B1,CA/B2 */ + via_irq /*irq */ +}; + + +static const struct via6522_interface leprechn_via_0_interface = +{ + 0, vblank_r, /*inputs : A/B */ + 0, 0, 0, 0, /*inputs : CA/B1,CA/B2 */ + video_data_w, leprechn_video_command_w, /*outputs: A/B */ + 0, 0, video_command_trigger_w, 0, /*outputs: CA/B1,CA/B2 */ + via_irq /*irq */ +}; + + +static const struct via6522_interface trvquest_via_0_interface = +{ + 0, vblank_r, /*inputs : A/B */ + 0, 0, 0, 0, /*inputs : CA/B1,CA/B2 */ + video_data_w, gameplan_video_command_w, /*outputs: A/B */ + 0, 0, video_command_trigger_w, 0, /*outputs: CA/B1,CA/B2 */ + 0 /*irq */ +}; + + +static TIMER_CALLBACK( via_0_ca1_timer_callback ) +{ + gameplan_state *state = machine->driver_data; + + /* !VBLANK is connected to CA1 */ + via_0_ca1_w(0, (UINT8)param); + + if (param) + timer_adjust_oneshot(state->via_0_ca1_timer, video_screen_get_time_until_pos(0, VBSTART, 0), 0); + else + timer_adjust_oneshot(state->via_0_ca1_timer, video_screen_get_time_until_pos(0, VBEND, 0), 1); +} + + +static void create_via_0_timer(gameplan_state *state) +{ + state->via_0_ca1_timer = timer_alloc(via_0_ca1_timer_callback, NULL); +} + + +static void start_via_0_timer(gameplan_state *state) +{ + timer_adjust_oneshot(state->via_0_ca1_timer, video_screen_get_time_until_pos(0, VBSTART, 0), 0); +} + + + +/************************************* + * + * Start + * + *************************************/ + +static VIDEO_START( common ) +{ + gameplan_state *state = machine->driver_data; + + state->videoram_size = (HBSTART - HBEND) * (VBSTART - VBEND); + state->videoram = auto_malloc(state->videoram_size); + + create_via_0_timer(state); + + /* register for save states */ + state_save_register_global_pointer(state->videoram, state->videoram_size); + state_save_register_global(state->video_x); + state_save_register_global(state->video_y); + state_save_register_global(state->video_command); + state_save_register_global(state->video_data); +} + + +static VIDEO_START( gameplan ) +{ + via_config(0, &gameplan_via_0_interface); + + VIDEO_START_CALL(common); +} + + +static VIDEO_START( leprechn ) +{ + via_config(0, &leprechn_via_0_interface); + + VIDEO_START_CALL(common); +} + + +static VIDEO_START( trvquest ) +{ + via_config(0, &trvquest_via_0_interface); + + VIDEO_START_CALL(common); +} + + + +/************************************* + * + * Reset + * + *************************************/ + +static VIDEO_RESET( gameplan ) +{ + via_reset(); + start_via_0_timer(machine->driver_data); +} + + + +/************************************* + * + * Machine drivers + * + *************************************/ + +MACHINE_DRIVER_START( gameplan_video ) + MDRV_VIDEO_START(gameplan) + MDRV_VIDEO_RESET(gameplan) + + MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) + MDRV_VIDEO_START(gameplan) + MDRV_VIDEO_UPDATE(gameplan) + + MDRV_SCREEN_ADD("main", 0) + MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) + MDRV_SCREEN_RAW_PARAMS(GAMEPLAN_PIXEL_CLOCK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART) +MACHINE_DRIVER_END + + +MACHINE_DRIVER_START( leprechn_video ) + MDRV_VIDEO_START(leprechn) + MDRV_VIDEO_UPDATE(leprechn) +MACHINE_DRIVER_END + + +MACHINE_DRIVER_START( trvquest_video ) + MDRV_IMPORT_FROM(gameplan_video) + MDRV_VIDEO_START(trvquest) + MDRV_VIDEO_UPDATE(gameplan) +MACHINE_DRIVER_END |