1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 /***************************************************************************
4
5 F-1 Grand Prix (c) 1991 Video System Co.
6
7 driver by Nicola Salmoria
8
9 Notes:
10 - The ROZ layer generator is a Konami 053936.
11 - f1gp2's hardware is very similar to Lethal Crash Race, main difference
12 being an extra 68000.
13
14 TODO:
15 - Hook up link for Multi Player game mode. Currently will show ID CHECK
16 ERROR then hang.
17
18 f1gp:
19 - gfxctrl register not understood - handling of fg/sprite priority to fix
20 "continue" screen is just a kludge.
21 f1gp2:
22 - sprite lag noticeable in the animation at the end of a race (the wheels
23 of the car are sprites while the car is the fg tilemap)
24
25 ***************************************************************************/
26
27 #include "emu.h"
28 #include "includes/f1gp.h"
29
30 #include "cpu/z80/z80.h"
31 #include "cpu/m68000/m68000.h"
32
33 #include "machine/clock.h"
34
35 #include "sound/2610intf.h"
36 #include "sound/okim6295.h"
37
38 #include "video/vsystem_gga.h"
39
40 #include "screen.h"
41 #include "speaker.h"
42
43
sh_bankswitch_w(uint8_t data)44 void f1gp_state::sh_bankswitch_w(uint8_t data)
45 {
46 m_z80bank->set_entry(data & 0x01);
47 }
48
49
command_pending_r()50 uint8_t f1gp_state::command_pending_r()
51 {
52 return (m_soundlatch->pending_r() ? 0xff : 0);
53 }
54
55
f1gp_cpu1_map(address_map & map)56 void f1gp_state::f1gp_cpu1_map(address_map &map)
57 {
58 map(0x000000, 0x03ffff).rom();
59 map(0x100000, 0x2fffff).rom().region("user1", 0);
60 map(0xa00000, 0xbfffff).rom().region("user2", 0);
61 map(0xc00000, 0xc3ffff).ram().w(FUNC(f1gp_state::rozgfxram_w)).share("rozgfxram");
62 map(0xd00000, 0xd01fff).mirror(0x006000).ram().w(FUNC(f1gp_state::rozvideoram_w)).share("rozvideoram");
63 map(0xe00000, 0xe03fff).ram().share("spr1cgram"); // SPR-1 CG RAM
64 map(0xe04000, 0xe07fff).ram().share("spr2cgram"); // SPR-2 CG RAM
65 map(0xf00000, 0xf003ff).ram().share("spr1vram"); // SPR-1 VRAM
66 map(0xf10000, 0xf103ff).ram().share("spr2vram"); // SPR-2 VRAM
67 map(0xff8000, 0xffbfff).ram(); // WORK RAM-1
68 map(0xffc000, 0xffcfff).ram().share("sharedram"); // DUAL RAM
69 map(0xffd000, 0xffdfff).ram().w(FUNC(f1gp_state::fgvideoram_w)).share("fgvideoram"); // CHARACTER
70 map(0xffe000, 0xffefff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); // PALETTE
71 map(0xfff000, 0xfff001).portr("INPUTS");
72 map(0xfff001, 0xfff001).w(FUNC(f1gp_state::gfxctrl_w));
73 map(0xfff002, 0xfff003).portr("WHEEL");
74 map(0xfff004, 0xfff005).portr("DSW1");
75 map(0xfff002, 0xfff005).w(FUNC(f1gp_state::fgscroll_w));
76 map(0xfff006, 0xfff007).portr("DSW2");
77 map(0xfff009, 0xfff009).r(FUNC(f1gp_state::command_pending_r)).w(m_soundlatch, FUNC(generic_latch_8_device::write)).umask16(0x00ff);
78 map(0xfff020, 0xfff023).w("gga", FUNC(vsystem_gga_device::write)).umask16(0x00ff);
79 map(0xfff040, 0xfff05f).w(m_k053936, FUNC(k053936_device::ctrl_w));
80 map(0xfff050, 0xfff051).portr("DSW3");
81 }
82
f1gp2_cpu1_map(address_map & map)83 void f1gp2_state::f1gp2_cpu1_map(address_map &map)
84 {
85 map(0x000000, 0x03ffff).rom();
86 map(0x100000, 0x2fffff).rom().region("user1", 0);
87 map(0xa00000, 0xa07fff).ram().share("spr1cgram"); // SPR-1 CG RAM + SPR-2 CG RAM
88 map(0xd00000, 0xd01fff).ram().w(FUNC(f1gp2_state::rozvideoram_w)).share("rozvideoram"); // BACK VRAM
89 map(0xe00000, 0xe00fff).ram().share("spr1vram"); // not checked + SPR-1 VRAM + SPR-2 VRAM
90 map(0xff8000, 0xffbfff).ram(); // WORK RAM-1
91 map(0xffc000, 0xffcfff).ram().share("sharedram"); // DUAL RAM
92 map(0xffd000, 0xffdfff).ram().w(FUNC(f1gp2_state::fgvideoram_w)).share("fgvideoram"); // CHARACTER
93 map(0xffe000, 0xffefff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette"); // PALETTE
94 map(0xfff000, 0xfff001).portr("INPUTS");
95 map(0xfff000, 0xfff000).w(FUNC(f1gp2_state::rozbank_w));
96 map(0xfff001, 0xfff001).w(FUNC(f1gp2_state::gfxctrl_w));
97 map(0xfff002, 0xfff003).portr("WHEEL");
98 map(0xfff004, 0xfff005).portr("DSW1");
99 map(0xfff006, 0xfff007).portr("DSW2");
100 map(0xfff009, 0xfff009).r(FUNC(f1gp2_state::command_pending_r)).w(m_soundlatch, FUNC(generic_latch_8_device::write)).umask16(0x00ff);
101 map(0xfff00a, 0xfff00b).portr("DSW3");
102 map(0xfff020, 0xfff03f).w(m_k053936, FUNC(k053936_device::ctrl_w));
103 map(0xfff044, 0xfff047).w(FUNC(f1gp2_state::fgscroll_w));
104 }
105
f1gp_cpu2_map(address_map & map)106 void f1gp_state::f1gp_cpu2_map(address_map &map)
107 {
108 map(0x000000, 0x01ffff).rom();
109 map(0xff8000, 0xffbfff).ram();
110 map(0xffc000, 0xffcfff).ram().share("sharedram");
111 map(0xfff030, 0xfff033).rw(m_acia, FUNC(acia6850_device::read), FUNC(acia6850_device::write)).umask16(0x00ff);
112 }
113
sound_map(address_map & map)114 void f1gp_state::sound_map(address_map &map)
115 {
116 map(0x0000, 0x77ff).rom();
117 map(0x7800, 0x7fff).ram();
118 map(0x8000, 0xffff).bankr("z80bank");
119 }
120
sound_io_map(address_map & map)121 void f1gp_state::sound_io_map(address_map &map)
122 {
123 map.global_mask(0xff);
124 map(0x00, 0x00).w(FUNC(f1gp_state::sh_bankswitch_w)); // f1gp
125 map(0x0c, 0x0c).w(FUNC(f1gp_state::sh_bankswitch_w)); // f1gp2
126 map(0x14, 0x14).rw(m_soundlatch, FUNC(generic_latch_8_device::read), FUNC(generic_latch_8_device::acknowledge_w));
127 map(0x18, 0x1b).rw("ymsnd", FUNC(ym2610_device::read), FUNC(ym2610_device::write));
128 }
129
f1gpb_misc_w(uint16_t data)130 void f1gp_state::f1gpb_misc_w(uint16_t data)
131 {
132 /*
133 static int old=-1;
134 static int old_bank = -1;
135 int new_bank = (data & 0xf0) >> 4; //wrong!
136
137 if(old_bank != new_bank && new_bank < 5)
138 {
139 // oki banking
140 uint8_t *src = memregion("oki")->base() + 0x40000 + 0x10000 * new_bank;
141 uint8_t *dst = memregion("oki")->base() + 0x30000;
142 memcpy(dst, src, 0x10000);
143
144 old_bank = new_bank;
145 }
146
147 //data & 0x80 toggles
148
149 if((data & 0x7f) != old)
150 printf("misc = %X\n",old=data & 0x7f);
151
152 */
153 }
154
f1gpb_cpu1_map(address_map & map)155 void f1gp_state::f1gpb_cpu1_map(address_map &map)
156 {
157 map(0x000000, 0x03ffff).rom();
158 map(0x100000, 0x2fffff).rom().region("user1", 0);
159 map(0xa00000, 0xbfffff).rom().region("user2", 0);
160 map(0x800000, 0x801fff).ram().share("spriteram");
161 map(0xc00000, 0xc3ffff).ram().w(FUNC(f1gp_state::rozgfxram_w)).share("rozgfxram");
162 map(0xd00000, 0xd01fff).mirror(0x006000).ram().w(FUNC(f1gp_state::rozvideoram_w)).share("rozvideoram");
163 map(0xe00000, 0xe03fff).ram(); //unused
164 map(0xe04000, 0xe07fff).ram(); //unused
165 map(0xf00000, 0xf003ff).ram(); //unused
166 map(0xf10000, 0xf103ff).ram(); //unused
167 map(0xff8000, 0xffbfff).ram();
168 map(0xffc000, 0xffcfff).ram().share("sharedram");
169 map(0xffd000, 0xffdfff).ram().w(FUNC(f1gp_state::fgvideoram_w)).share("fgvideoram");
170 map(0xffe000, 0xffefff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
171 map(0xfff000, 0xfff001).portr("INPUTS");
172 map(0xfff002, 0xfff003).portr("WHEEL");
173 map(0xfff004, 0xfff005).portr("DSW1");
174 map(0xfff006, 0xfff007).portr("DSW2");
175 map(0xfff008, 0xfff009).nopr(); //?
176 map(0xfff006, 0xfff007).nopw();
177 map(0xfff00a, 0xfff00b).ram().share("fgregs");
178 map(0xfff00f, 0xfff00f).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write));
179 map(0xfff00c, 0xfff00d).w(FUNC(f1gp_state::f1gpb_misc_w));
180 map(0xfff010, 0xfff011).nopw();
181 map(0xfff020, 0xfff023).nopw(); // GGA access
182 map(0xfff050, 0xfff051).portr("DSW3");
183 map(0xfff800, 0xfff809).ram().share("rozregs");
184 }
185
f1gpb_cpu2_map(address_map & map)186 void f1gp_state::f1gpb_cpu2_map(address_map &map)
187 {
188 map(0x000000, 0x01ffff).rom();
189 map(0xff8000, 0xffbfff).ram();
190 map(0xffc000, 0xffcfff).ram().share("sharedram");
191 map(0xfff030, 0xfff033).rw(m_acia, FUNC(acia6850_device::read), FUNC(acia6850_device::write)).umask16(0x00ff);
192 }
193
194 static INPUT_PORTS_START( f1gp )
195 PORT_START("INPUTS")
196 PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_CONDITION("JOY_TYPE", 0x01, NOTEQUALS, 0x01)
197 PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_CONDITION("JOY_TYPE", 0x01, NOTEQUALS, 0x01)
198 PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_CONDITION("JOY_TYPE", 0x01, NOTEQUALS, 0x01)
199 PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_CONDITION("JOY_TYPE", 0x01, NOTEQUALS, 0x01)
200 PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CONDITION("JOY_TYPE", 0x01, EQUALS, 0x01)
201 PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CONDITION("JOY_TYPE", 0x01, EQUALS, 0x01)
202 PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_CONDITION("JOY_TYPE", 0x01, EQUALS, 0x01)
203 PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_CONDITION("JOY_TYPE", 0x01, EQUALS, 0x01)
204 // following two are logically arranged as per service mode
205 PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 Brake Button")
206 PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("P1 Accelerator Button")
207 PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
208 PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
209 PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_COIN1 )
210 PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_COIN2 )
211 PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_START1 )
212 PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
213 PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
214 PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
215 PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_SERVICE1 )
216 PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
217
218 PORT_START("WHEEL")
219 PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_SENSITIVITY(10) PORT_KEYDELTA(5)
220
221 PORT_START("DSW1")
222 // listed as "unused" in manual, actually enables free play
DEF_STR(Free_Play)223 PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Free_Play ) ) PORT_DIPLOCATION("SW1:1")
224 PORT_DIPSETTING( 0x0100, DEF_STR( No ) )
225 PORT_DIPSETTING( 0x0000, DEF_STR( Yes ) )
226 PORT_DIPNAME( 0x0e00, 0x0e00, DEF_STR( Coin_A ) ) PORT_CONDITION("DSW1",0x8000,EQUALS,0x8000) PORT_DIPLOCATION("SW1:2,3,4")
227 PORT_DIPSETTING( 0x0a00, DEF_STR( 3C_1C ) )
228 PORT_DIPSETTING( 0x0c00, DEF_STR( 2C_1C ) )
229 PORT_DIPSETTING( 0x0e00, DEF_STR( 1C_1C ) )
230 PORT_DIPSETTING( 0x0800, DEF_STR( 1C_2C ) )
231 PORT_DIPSETTING( 0x0600, DEF_STR( 1C_3C ) )
232 PORT_DIPSETTING( 0x0400, DEF_STR( 1C_4C ) )
233 PORT_DIPSETTING( 0x0200, DEF_STR( 1C_5C ) )
234 PORT_DIPSETTING( 0x0000, DEF_STR( 1C_6C ) )
235 PORT_DIPNAME( 0x7000, 0x7000, DEF_STR( Coin_B ) ) PORT_CONDITION("DSW1",0x8000,EQUALS,0x8000) PORT_DIPLOCATION("SW1:5,6,7")
236 PORT_DIPSETTING( 0x5000, DEF_STR( 3C_1C ) )
237 PORT_DIPSETTING( 0x6000, DEF_STR( 2C_1C ) )
238 PORT_DIPSETTING( 0x7000, DEF_STR( 1C_1C ) )
239 PORT_DIPSETTING( 0x4000, DEF_STR( 1C_2C ) )
240 PORT_DIPSETTING( 0x3000, DEF_STR( 1C_3C ) )
241 PORT_DIPSETTING( 0x2000, DEF_STR( 1C_4C ) )
242 PORT_DIPSETTING( 0x1000, DEF_STR( 1C_5C ) )
243 PORT_DIPSETTING( 0x0000, DEF_STR( 1C_6C ) )
244 PORT_DIPNAME( 0x7e00, 0x7e00, DEF_STR( Coinage ) ) PORT_CONDITION("DSW1",0x8000,NOTEQUALS,0x8000) PORT_DIPLOCATION("SW1:2,3,4,5,6,7")
245 PORT_DIPSETTING( 0x7e00, "2 to Start, 1 to Continue" )
246 PORT_DIPNAME( 0x8000, 0x8000, "Continue Coin" ) PORT_DIPLOCATION("SW1:8")
247 PORT_DIPSETTING( 0x8000, "Normal Coinage" )
248 PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
249 PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:1,2")
250 PORT_DIPSETTING( 0x0002, DEF_STR( Easy ) )
251 PORT_DIPSETTING( 0x0003, DEF_STR( Normal ) )
252 PORT_DIPSETTING( 0x0001, DEF_STR( Hard ) )
253 PORT_DIPSETTING( 0x0000, DEF_STR( Hardest ) )
254 PORT_DIPNAME( 0x0004, 0x0004, "Game Mode" ) PORT_DIPLOCATION("SW2:3") /* Setting to Multiple results in "ID CHECK ERROR" then hang */
255 PORT_DIPSETTING( 0x0004, DEF_STR( Single ) )
256 PORT_DIPSETTING( 0x0000, "Multiple" )
257 PORT_DIPNAME( 0x0008, 0x0008, "Multi Player Mode" ) PORT_DIPLOCATION("SW2:4")
258 PORT_DIPSETTING( 0x0008, "Single or Multi Player" ) PORT_CONDITION("DSW1",0x0004,EQUALS,0x0000)
259 PORT_DIPSETTING( 0x0000, "Multi Player Game Only" ) PORT_CONDITION("DSW1",0x0004,EQUALS,0x0000)
260 PORT_DIPSETTING( 0x0008, "Multi Player Off" ) PORT_CONDITION("DSW1",0x0004,NOTEQUALS,0x0000)
261 PORT_DIPSETTING( 0x0000, "Multi Player Off" ) PORT_CONDITION("DSW1",0x0004,NOTEQUALS,0x0000)
262 PORT_DIPUNUSED_DIPLOC( 0x0010, 0x0010, "SW2:5" ) /* Listed as "Unused", reverses joystick left/right directions? */
263 PORT_DIPUNUSED_DIPLOC( 0x0020, 0x0020, "SW2:6" ) /* Listed as "Unused", two buttons to accelerate? */
264 PORT_DIPUNUSED_DIPLOC( 0x0040, 0x0040, "SW2:7" ) /* Listed as "Unused", reverses button activeness? */
265 PORT_DIPUNUSED_DIPLOC( 0x0080, 0x0080, "SW2:8" ) /* Listed as "Unused" */
266
267 PORT_START("DSW2")
268 PORT_SERVICE_DIPLOC( 0x0100, IP_ACTIVE_LOW, "SW3:1" )
269 PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW3:2")
270 PORT_DIPSETTING( 0x0200, DEF_STR( Off ) )
271 PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
272 PORT_DIPNAME( 0x0400, 0x0000, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW3:3")
273 PORT_DIPSETTING( 0x0400, DEF_STR( Off ) )
274 PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
275 PORT_DIPUNUSED_DIPLOC( 0x0800, 0x0800, "SW3:4" ) /* Listed as "Unused" */
276 PORT_DIPUNUSED_DIPLOC( 0x1000, 0x1000, "SW3:5" ) /* Listed as "Unused" */
277 PORT_DIPUNUSED_DIPLOC( 0x2000, 0x2000, "SW3:6" ) /* Listed as "Unused" */
278 PORT_DIPUNUSED_DIPLOC( 0x4000, 0x4000, "SW3:7" ) /* Listed as "Unused" */
279 // listed as "Unused" in manual, it selects between joystick or steering wheel
280 PORT_DIPNAME( 0x8000, 0x8000, "Input Method" ) PORT_DIPLOCATION("SW3:8")
281 PORT_DIPSETTING( 0x8000, "Joystick" )
282 // TODO: doesn't work in-game, reads from $fff002 ingame too but doesn't have an effect,
283 // maybe outputs threshold to $fff000 or it's not supposed to be enabled like the manual claims.
284 PORT_DIPSETTING( 0x0000, "Steering Wheel" )
285
286 PORT_START("DSW3")
287 PORT_DIPNAME( 0x001f, 0x0010, DEF_STR( Region ) ) /* Jumpers?? */
288 PORT_DIPSETTING( 0x0010, DEF_STR( World ) )
289 PORT_DIPSETTING( 0x0001, "USA & Canada" )
290 PORT_DIPSETTING( 0x0000, DEF_STR( Japan ) )
291 PORT_DIPSETTING( 0x0002, DEF_STR( Korea ) )
292 PORT_DIPSETTING( 0x0004, DEF_STR( Hong_Kong ) )
293 PORT_DIPSETTING( 0x0008, DEF_STR( Taiwan ) )
294 /* all other values are invalid */
295
296 PORT_START("JOY_TYPE")
297 PORT_CONFNAME( 0x01, 0x01, "Joystick Type" )
298 PORT_CONFSETTING( 0x01, "2-Way" )
299 // in "free run" course select lets you go up/down
300 PORT_CONFSETTING( 0x00, "4-Way" )
301 INPUT_PORTS_END
302
303
304 static INPUT_PORTS_START( f1gp2 )
305 PORT_INCLUDE( f1gp )
306
307 PORT_MODIFY("INPUTS")
308 // additional button, complies with 1992 F1 season
309 PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("P1 Turbo Button")
310
311 PORT_MODIFY("DSW3")
312 PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Region ) )
313 PORT_DIPSETTING( 0x0001, DEF_STR( World ) )
314 PORT_DIPSETTING( 0x0000, DEF_STR( Japan ) )
315 PORT_DIPUNUSED( 0x001e, 0x001e )
316 INPUT_PORTS_END
317
318
319
320 static GFXDECODE_START( gfx_f1gp )
321 GFXDECODE_ENTRY( "gfx1", 0, gfx_8x8x8_raw, 0x000, 1 )
322 GFXDECODE_ENTRY( "gfx2", 0, gfx_16x16x4_packed_lsb, 0x100, 16 )
323 GFXDECODE_ENTRY( "gfx3", 0, gfx_16x16x4_packed_lsb, 0x200, 16 )
324 GFXDECODE_RAM( "rozgfxram", 0, gfx_16x16x4_packed_msb, 0x300, 16 )
325 GFXDECODE_END
326
327 static GFXDECODE_START( gfx_f1gp2 )
328 GFXDECODE_ENTRY( "gfx1", 0, gfx_8x8x8_raw, 0x000, 1 )
329 GFXDECODE_ENTRY( "gfx2", 0, gfx_16x16x4_packed_lsb, 0x200, 32 )
330 GFXDECODE_ENTRY( "gfx3", 0, gfx_16x16x4_packed_msb, 0x100, 16 )
331 GFXDECODE_END
332
333
334 void f1gp_state::machine_start()
335 {
336 if (m_z80bank)
337 m_z80bank->configure_entries(0, 2, memregion("audiocpu")->base() + 0x8000, 0x8000);
338
339 m_acia->write_cts(0);
340 m_acia->write_dcd(0);
341 }
342
machine_reset()343 void f1gp_state::machine_reset()
344 {
345 m_flipscreen = 0;
346 m_gfxctrl = 0;
347 m_scroll[0] = 0;
348 m_scroll[1] = 0;
349 }
350
machine_reset()351 void f1gp2_state::machine_reset()
352 {
353 f1gp_state::machine_reset();
354 m_roz_bank = 0;
355 }
356
357 template<int Chip>
tile_callback(uint32_t code)358 uint32_t f1gp_state::tile_callback( uint32_t code )
359 {
360 return m_sprcgram[Chip][code & (m_sprcgram[Chip].mask()>>1)];
361 }
362
f1gp(machine_config & config)363 void f1gp_state::f1gp(machine_config &config)
364 {
365 /* basic machine hardware */
366 M68000(config, m_maincpu, XTAL(20'000'000)/2); /* verified on pcb */
367 m_maincpu->set_addrmap(AS_PROGRAM, &f1gp_state::f1gp_cpu1_map);
368 m_maincpu->set_vblank_int("screen", FUNC(f1gp_state::irq1_line_hold));
369
370 m68000_device &sub(M68000(config, "sub", XTAL(20'000'000)/2)); /* verified on pcb */
371 sub.set_addrmap(AS_PROGRAM, &f1gp_state::f1gp_cpu2_map);
372 sub.set_vblank_int("screen", FUNC(f1gp_state::irq1_line_hold));
373
374 Z80(config, m_audiocpu, XTAL(20'000'000)/4); /* verified on pcb */
375 m_audiocpu->set_addrmap(AS_PROGRAM, &f1gp_state::sound_map);
376 m_audiocpu->set_addrmap(AS_IO, &f1gp_state::sound_io_map);
377
378 config.set_maximum_quantum(attotime::from_hz(6000)); /* 100 CPU slices per frame */
379
380 ACIA6850(config, m_acia, 0);
381 m_acia->irq_handler().set_inputline("sub", M68K_IRQ_3);
382 m_acia->txd_handler().set("acia", FUNC(acia6850_device::write_rxd)); // loopback for now
383
384 clock_device &acia_clock(CLOCK(config, "acia_clock", 1000000)); // guessed
385 acia_clock.signal_handler().set(m_acia, FUNC(acia6850_device::write_txc));
386 acia_clock.signal_handler().append(m_acia, FUNC(acia6850_device::write_rxc));
387
388 /* video hardware */
389 screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
390 screen.set_refresh_hz(60);
391 screen.set_size(64*8, 32*8);
392 screen.set_visarea(0*8, 40*8-1, 1*8, 31*8-1);
393 screen.set_screen_update(FUNC(f1gp_state::screen_update_f1gp));
394 screen.set_palette(m_palette);
395
396 GFXDECODE(config, m_gfxdecode, m_palette, gfx_f1gp);
397 PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 2048);
398
399 VSYSTEM_GGA(config, "gga", XTAL(14'318'181) / 2); // divider not verified
400
401 VSYSTEM_SPR2(config, m_spr_old[0], 0);
402 m_spr_old[0]->set_tile_indirect_cb(FUNC(f1gp2_state::tile_callback<0>));
403 m_spr_old[0]->set_gfx_region(1);
404 m_spr_old[0]->set_pritype(2);
405 m_spr_old[0]->set_gfxdecode_tag(m_gfxdecode);
406
407 VSYSTEM_SPR2(config, m_spr_old[1], 0);
408 m_spr_old[1]->set_tile_indirect_cb(FUNC(f1gp2_state::tile_callback<1>));
409 m_spr_old[1]->set_gfx_region(2);
410 m_spr_old[1]->set_pritype(2);
411 m_spr_old[1]->set_gfxdecode_tag(m_gfxdecode);
412
413 K053936(config, m_k053936, 0);
414 m_k053936->set_wrap(1);
415 m_k053936->set_offsets(-58, -2);
416
417 /* sound hardware */
418 SPEAKER(config, "lspeaker").front_left();
419 SPEAKER(config, "rspeaker").front_right();
420
421 GENERIC_LATCH_8(config, m_soundlatch);
422 m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI);
423 m_soundlatch->set_separate_acknowledge(true);
424
425 ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(8'000'000)));
426 ymsnd.irq_handler().set_inputline(m_audiocpu, 0);
427 ymsnd.add_route(0, "lspeaker", 0.25);
428 ymsnd.add_route(0, "rspeaker", 0.25);
429 ymsnd.add_route(1, "lspeaker", 1.0);
430 ymsnd.add_route(2, "rspeaker", 1.0);
431 }
432
f1gpb(machine_config & config)433 void f1gp_state::f1gpb(machine_config &config)
434 {
435 /* basic machine hardware */
436 M68000(config, m_maincpu, 10000000); /* 10 MHz ??? */
437 m_maincpu->set_addrmap(AS_PROGRAM, &f1gp_state::f1gpb_cpu1_map);
438 m_maincpu->set_vblank_int("screen", FUNC(f1gp_state::irq1_line_hold));
439
440 m68000_device &sub(M68000(config, "sub", 10000000)); /* 10 MHz ??? */
441 sub.set_addrmap(AS_PROGRAM, &f1gp_state::f1gpb_cpu2_map);
442 sub.set_vblank_int("screen", FUNC(f1gp_state::irq1_line_hold));
443
444 /* NO sound CPU */
445 config.set_maximum_quantum(attotime::from_hz(6000)); /* 100 CPU slices per frame */
446
447 ACIA6850(config, m_acia, 0);
448 m_acia->irq_handler().set_inputline("sub", M68K_IRQ_3);
449 m_acia->txd_handler().set("acia", FUNC(acia6850_device::write_rxd)); // loopback for now
450
451 clock_device &acia_clock(CLOCK(config, "acia_clock", 1000000)); // guessed
452 acia_clock.signal_handler().set(m_acia, FUNC(acia6850_device::write_txc));
453 acia_clock.signal_handler().append(m_acia, FUNC(acia6850_device::write_rxc));
454
455 /* video hardware */
456 screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
457 screen.set_refresh_hz(60);
458 screen.set_size(64*8, 32*8);
459 screen.set_visarea(0*8, 40*8-1, 1*8, 31*8-1);
460 screen.set_screen_update(FUNC(f1gp_state::screen_update_f1gpb));
461 screen.set_palette(m_palette);
462
463 GFXDECODE(config, m_gfxdecode, m_palette, gfx_f1gp);
464 PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 2048);
465
466 //VSYSTEM_GGA(config, "gga", 0);
467
468 /* sound hardware */
469 SPEAKER(config, "mono").front_center();
470
471 okim6295_device &oki(OKIM6295(config, "oki", 1000000, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified
472 oki.add_route(ALL_OUTPUTS, "mono", 1.00);
473 }
474
f1gp2(machine_config & config)475 void f1gp2_state::f1gp2(machine_config &config)
476 {
477 f1gp_state::f1gp(config);
478
479 /* basic machine hardware */
480 m_maincpu->set_addrmap(AS_PROGRAM, &f1gp2_state::f1gp2_cpu1_map);
481
482 /* video hardware */
483 m_gfxdecode->set_info(gfx_f1gp2);
484
485 subdevice<screen_device>("screen")->set_visarea(0*8, 40*8-1, 0*8, 28*8-1);
486 subdevice<screen_device>("screen")->set_screen_update(FUNC(f1gp2_state::screen_update));
487
488 config.device_remove("gga");
489 config.device_remove("vsystem_spr_old1");
490 config.device_remove("vsystem_spr_old2");
491
492 VSYSTEM_SPR(config, m_spr, 0);
493 m_spr->set_tile_indirect_cb(FUNC(f1gp2_state::tile_callback<0>));
494 m_spr->set_gfx_region(1);
495 m_spr->set_gfxdecode_tag(m_gfxdecode);
496
497 m_k053936->set_offsets(-48, -21);
498 }
499
500
501
502 ROM_START( f1gp )
503 ROM_REGION( 0x40000, "maincpu", 0 ) /* 68000 code */
504 ROM_LOAD16_WORD_SWAP( "rom1-a.3", 0x000000, 0x20000, CRC(2d8f785b) SHA1(6eca42ad2d57a31e055496141c89cb537f284378) )
505
506 ROM_REGION16_BE( 0x200000, "user1", 0 ) /* extra ROMs mapped at 100000 */
507 ROM_LOAD16_BYTE( "rom10-a.1", 0x000000, 0x40000, CRC(46a289fb) SHA1(6a8c19e08b6d836fe83378fd77fead82a0b2db7c) )
508 ROM_LOAD16_BYTE( "rom11-a.2", 0x000001, 0x40000, CRC(53df8ea1) SHA1(25d50bb787f3bd35c9a8ae2b0ab9a21e000debb0) )
509 ROM_LOAD16_BYTE( "rom12-a.3", 0x080000, 0x40000, CRC(d8c1bcf4) SHA1(d6d77354eb1ab413ba8cfa5d973cf5b0c851c23b) )
510 ROM_LOAD16_BYTE( "rom13-a.4", 0x080001, 0x40000, CRC(7d92e1fa) SHA1(c23f5beea85b0804c61ef9e7f131b186d076221f) )
511 ROM_LOAD16_BYTE( "rom7-a.5", 0x100000, 0x40000, CRC(7a014ba6) SHA1(8f0abbb68100e396e5a41337254cb6bf1a2ed00b) )
512 ROM_LOAD16_BYTE( "rom6-a.6", 0x100001, 0x40000, CRC(6d947a3f) SHA1(2cd01ee2a73ab105a45a5464a29fd75aa43ba2db) )
513 ROM_LOAD16_BYTE( "rom8-a.7", 0x180000, 0x40000, CRC(0ed783c7) SHA1(c0c467ede51c08d84999897c6d5cc8b584b23b67) )
514 ROM_LOAD16_BYTE( "rom9-a.8", 0x180001, 0x40000, CRC(49286572) SHA1(c5e16bd1ccd43452337a4cd76db70db079ca0706) )
515
516 ROM_REGION16_BE( 0x200000, "user2", 0 ) /* extra ROMs mapped at a00000 */
517 /* containing gfx data for the 053936 */
518 ROM_LOAD16_WORD_SWAP( "rom2-a.06", 0x000000, 0x100000, CRC(747dd112) SHA1(b9264bec61467ab256cf6cb698b6e0ea8f8006e0) )
519 ROM_LOAD16_WORD_SWAP( "rom3-a.05", 0x100000, 0x100000, CRC(264aed13) SHA1(6f0de860d4299befffc530b7a8f19656982a51c4) )
520
521 ROM_REGION( 0x20000, "sub", 0 ) /* 68000 code */
522 ROM_LOAD16_WORD_SWAP( "rom4-a.4", 0x000000, 0x20000, CRC(8e811d36) SHA1(2b806b50a3a307a21894687f16485ace287a7c4c) )
523
524 ROM_REGION( 0x20000, "audiocpu", 0 ) /* 64k for the audio CPU + banks */
525 ROM_LOAD( "rom5-a.8", 0x00000, 0x20000, CRC(9ea36e35) SHA1(9254dea8362318d8cfbd5e36e476e0e235e6326a) )
526
527 ROM_REGION( 0x200000, "gfx1", 0 )
528 ROM_LOAD( "rom3-b.07", 0x000000, 0x100000, CRC(ffb1d489) SHA1(9330b67e0eaaf67d6c38f40a02c72419bd38fb81) )
529 ROM_LOAD( "rom2-b.04", 0x100000, 0x100000, CRC(d1b3471f) SHA1(d1a95fbaad1c3d9ec2121bf65abbcdb5441bd0ac) )
530
531 ROM_REGION( 0x100000, "gfx2", 0 )
532 ROM_LOAD32_WORD( "rom5-b.2", 0x000000, 0x80000, CRC(17572b36) SHA1(c58327c2f708783a3e8470e290cae0d71454f1da) )
533 ROM_LOAD32_WORD( "rom4-b.3", 0x000002, 0x80000, CRC(72d12129) SHA1(11da6990a54ae1b6f6d0bed5d0431552f83a0dda) )
534
535 ROM_REGION( 0x080000, "gfx3", 0 )
536 ROM_LOAD32_WORD( "rom7-b.17", 0x000000, 0x40000, CRC(2aed9003) SHA1(45ff9953ad98063573e7fd7b930ae8b0183cdd04) )
537 ROM_LOAD32_WORD( "rom6-b.16", 0x000002, 0x40000, CRC(6789ef12) SHA1(9b0d1cc6e9c6398ccb7f635c4c148fddd224a21f) )
538
539 ROM_REGION( 0x40000, "gfx4", ROMREGION_ERASE00 ) /* gfx data for the 053936 */
540 /* RAM, not ROM - handled at run time */
541
542 ROM_REGION( 0x100000, "ymsnd.deltat", 0 ) /* sound samples */
543 ROM_LOAD( "rom14-a.09", 0x000000, 0x100000, CRC(b4c1ac31) SHA1(acab2e1b5ce4ca3a5c4734562481b54db4b46995) )
544
545 ROM_REGION( 0x100000, "ymsnd", 0 ) /* sound samples */
546 ROM_LOAD( "rom17-a.08", 0x000000, 0x100000, CRC(ea70303d) SHA1(8de1a0e6d47cd80a622663c1745a1da54cd0ea05) )
547 ROM_END
548
549 /* This is a bootleg of f1gp, produced by Playmark in Italy
550 the video hardware is different, it lacks the sound z80, and has less samples
551 */
552
553 ROM_START( f1gpb )
554 ROM_REGION( 0x40000, "maincpu", 0 ) /* 68000 code */
555 /* these have extra data at 0x30000 which isn't preset in the f1gp set, is it related to the changed sound hardware? */
556 ROM_LOAD16_BYTE( "1.ic38", 0x000001, 0x20000, CRC(046dd83a) SHA1(ea65fa88f9d9a79664de666e63594a7a7de86650) )
557 ROM_LOAD16_BYTE( "7.ic39", 0x000000, 0x20000, CRC(960f5db4) SHA1(addc461538e2140afae400e8d7364d0bcc42a0cb) )
558
559 ROM_REGION16_BE( 0x200000, "user1", 0 ) /* extra ROMs mapped at 100000 */
560 ROM_LOAD16_BYTE( "8.ic41", 0x000000, 0x80000, CRC(39af8180) SHA1(aa1577195b1463069870db2d64db3b5e61d6bbe8) )
561 ROM_LOAD16_BYTE( "2.ic48", 0x000001, 0x80000, CRC(b3b315c3) SHA1(568592e450401cd95206dbe439e565dd28499dd1) )
562 ROM_LOAD16_BYTE( "9.ic166", 0x100000, 0x80000, CRC(bb596d5b) SHA1(f29ed135e8f09d4a15353360a811c13aba681382) )
563 ROM_LOAD16_BYTE( "3.ic165", 0x100001, 0x80000, CRC(b7295a30) SHA1(4120dda38673d59343aea0f030d2f275a0ae3d95) )
564
565 ROM_REGION16_BE( 0x200000, "user2", 0 ) /* extra ROMs mapped at a00000 */
566 ROM_LOAD16_BYTE( "10.ic43", 0x000000, 0x80000, CRC(d60e7706) SHA1(23c383e47e6600a68d6fd8bcfc9552fe0d660630) )
567 ROM_LOAD16_BYTE( "4.ic42", 0x000001, 0x80000, CRC(5dbde98a) SHA1(536553eaad0ebfe219e44a4f50a4707209024469) )
568 ROM_LOAD16_BYTE( "11.ic168", 0x100000, 0x80000, CRC(92a28e52) SHA1(dc203486b96fdc1930f7e63021e84f203540a64e) )
569 ROM_LOAD16_BYTE( "5.ic167", 0x100001, 0x80000, CRC(48c36293) SHA1(2a5d92537ba331a99697d13b4394b8d2737eeaf2) )
570
571 ROM_REGION( 0x20000, "sub", 0 ) /* 68000 code */
572 ROM_LOAD16_BYTE( "16.u7", 0x000000, 0x10000, CRC(7609d818) SHA1(eb841b8e7b34f1c677f1a79bfeda5dafc1f6849f) )
573 ROM_LOAD16_BYTE( "17.u6", 0x000001, 0x10000, CRC(951befde) SHA1(28754f00ca0fe38fe1d4e68c203a7b401baa9714) )
574
575 ROM_REGION( 0x200000, "gfx1", 0 )
576 ROM_LOAD( "13.ic151", 0x000000, 0x080000, CRC(4238074b) SHA1(a6b169165c7f7da9e746db8f1fb02e15c02c2b60) )
577 ROM_LOAD( "12.ic152", 0x080000, 0x080000, CRC(e97c2b6e) SHA1(3d964999b70af2f39a734eba3feec6d4583261c7) )
578 ROM_LOAD( "15.ic153", 0x100000, 0x080000, CRC(c2867d7f) SHA1(86b1be9672cf9f610e1d7efff90d6a73dc1cdb90) )
579 ROM_LOAD( "14.ic154", 0x180000, 0x080000, CRC(0cd20423) SHA1(cddad02247b898c0a5a2fe061c41f68ecdf04d5c) )
580
581 /*
582 Roms 20 and 21 were missing from the PCB, however the others match perfectly (just with a different data layout)
583 I've reconstructed what should be the correct data for this bootleg.
584
585 Note, the bootleg combines 2 GFX regions into a single set of 4-way interleaved roms, so we load them in a user
586 region and use ROM_COPY.
587 */
588
589 ROM_REGION( 0x200000, "user3", 0 )
590 ROMX_LOAD( "rom21", 0x000003, 0x80000, CRC(7a08c3b7) SHA1(369123348a88513c066c239ed6aa4db5ae4ef0ac), ROM_SKIP(3) )
591 ROMX_LOAD( "rom20", 0x000001, 0x80000, CRC(bd1273d0) SHA1(cc7caee231fe3bd87d8403d34059e1292c7f7a00), ROM_SKIP(3) )
592 ROMX_LOAD( "19.ic141", 0x000002, 0x80000, CRC(aa4ebdfe) SHA1(ed117e6a84554c5ed2ad4379b834898a4c40d51e), ROM_SKIP(3) )
593 ROMX_LOAD( "18.ic140", 0x000000, 0x80000, CRC(9b2a4325) SHA1(b2020e08251366686c4c0045f3fd523fa327badf), ROM_SKIP(3) )
594
595 ROM_REGION( 0x100000, "gfx2", 0 )
596 ROM_COPY("user3", 0x000000, 0, 0x100000)
597
598 ROM_REGION( 0x080000, "gfx3", 0 )
599 ROM_COPY("user3", 0x100000, 0, 0x80000)
600
601 ROM_REGION( 0x40000, "gfx4", ROMREGION_ERASE00 ) /* gfx data for the 053936 */
602 /* RAM, not ROM - handled at run time */
603
604 ROM_REGION( 0x90000, "oki", 0 ) /* sound samples */
605 ROM_LOAD( "6.ic13", 0x000000, 0x030000, CRC(6e83ffd8) SHA1(618fd6cd6c0844a4be96f77ff22cd41364718d16) )
606 ROM_CONTINUE( 0x040000, 0x050000 )
607 ROM_END
608
609
610 ROM_START( f1gp2 )
611 ROM_REGION( 0x40000, "maincpu", 0 ) /* 68000 code */
612 ROM_LOAD16_BYTE( "rom12.v1", 0x000000, 0x20000, CRC(c5c5f199) SHA1(56fcbf1d9b15a37204296c578e1585599f76a107) )
613 ROM_LOAD16_BYTE( "rom14.v2", 0x000001, 0x20000, CRC(dd5388e2) SHA1(66e88f86edc2407e5794519f988203a52d65636d) )
614
615 ROM_REGION16_BE( 0x200000, "user1", 0 ) /* extra ROMs mapped at 100000 */
616 ROM_LOAD16_WORD_SWAP( "rom2", 0x100000, 0x100000, CRC(3b0cfa82) SHA1(ea6803dd8d30aa9f3bd578e113fc26f20c640751) )
617 ROM_CONTINUE( 0x000000, 0x100000 )
618
619 ROM_REGION( 0x20000, "sub", 0 ) /* 68000 code */
620 ROM_LOAD16_WORD_SWAP( "rom13.v3", 0x000000, 0x20000, CRC(c37aa303) SHA1(0fe09b398191888620fb676ed0f1593be575512d) )
621
622 ROM_REGION( 0x20000, "audiocpu", 0 ) /* 64k for the audio CPU + banks */
623 ROM_LOAD( "rom5.v4", 0x00000, 0x20000, CRC(6a9398a1) SHA1(e907fe5f9c135c5b10ec650ec0c6d08cb856230c) )
624
625 ROM_REGION( 0x200000, "gfx1", 0 )
626 ROM_LOAD( "rom1", 0x000000, 0x200000, CRC(f2d55ad7) SHA1(2f2d9dc4fab63b06ed7cba0ef1ced286dbfaa7b4) )
627
628 ROM_REGION( 0x200000, "gfx2", 0 )
629 ROM_LOAD( "rom15", 0x000000, 0x200000, CRC(1ac03e2e) SHA1(9073d0ae24364229a993046bd71e403988692993) )
630
631 ROM_REGION( 0x400000, "gfx3", 0 )
632 ROM_LOAD16_WORD_SWAP( "rom11", 0x000000, 0x100000, CRC(b22a2c1f) SHA1(b5e67726be5a8561cd04c3c07895b8518b73b89c) )
633 ROM_LOAD16_WORD_SWAP( "rom10", 0x100000, 0x100000, CRC(43fcbe23) SHA1(54ab58d904890a0b907e674f855092e974c45edc) )
634 ROM_LOAD16_WORD_SWAP( "rom9", 0x200000, 0x100000, CRC(1bede8a1) SHA1(325ecc3afb30d281c2c8a56719e83e4dc20545bb) )
635 ROM_LOAD16_WORD_SWAP( "rom8", 0x300000, 0x100000, CRC(98baf2a1) SHA1(df7bd1a743ad0a6e067641e2b7a352c466875ef6) )
636
637 ROM_REGION( 0x080000, "ymsnd.deltat", 0 ) /* sound samples */
638 ROM_LOAD( "rom4", 0x000000, 0x080000, CRC(c2d3d7ad) SHA1(3178096741583cfef1ca8f53e6efa0a59e1d5cb6) )
639
640 ROM_REGION( 0x100000, "ymsnd", 0 ) /* sound samples */
641 ROM_LOAD( "rom3", 0x000000, 0x100000, CRC(7f8f066f) SHA1(5e051d5feb327ac818e9c7f7ac721dada3a102b6) )
642 ROM_END
643
644
645 GAME( 1991, f1gp, 0, f1gp, f1gp, f1gp_state, empty_init, ROT90, "Video System Co.", "F-1 Grand Prix", MACHINE_NO_COCKTAIL | MACHINE_NODEVICE_LAN | MACHINE_SUPPORTS_SAVE )
646 GAME( 1991, f1gpb, f1gp, f1gpb, f1gp, f1gp_state, empty_init, ROT90, "bootleg (Playmark)", "F-1 Grand Prix (Playmark bootleg)", MACHINE_NOT_WORKING | MACHINE_NODEVICE_LAN | MACHINE_SUPPORTS_SAVE ) // PCB marked 'Super Formula II', manufactured by Playmark.
647
648 GAME( 1992, f1gp2, 0, f1gp2, f1gp2, f1gp2_state, empty_init, ROT90, "Video System Co.", "F-1 Grand Prix Part II", MACHINE_NO_COCKTAIL | MACHINE_NODEVICE_LAN | MACHINE_SUPPORTS_SAVE )
649