1 // license:BSD-3-Clause
2 // copyright-holders:R. Belmont
3 /***************************************************************************
4 
5  GI Classic / GI Classic EX
6  (c) 1995, 1998 Konami
7  Preliminary driver by R. Belmont
8 
9  GI Classic EX Main PCB:
10  Main CPU: 68000
11  Video: 056832 + 058143 (GX tilemaps)
12  Video: 055673(x2) + 053246 (GX sprites)
13  Video: 055555 (Mixer)
14  053252 (x2) (CRTC?)
15 
16  GI Classic EX Satellite PCB:
17  Main CPU: 68000-12
18  Video: 056832 / 058143 (GX tilemaps)
19  Video: 000907 LCD Controller
20 
21  WANTED: main PCB and any other PCBs for GI Classic EX, plus any and all
22  PCBs for other games also believed to be on this h/w:
23  - GI-Classic (1995)
24  - GI-Classic Special (1996)
25  - GI-Classic WINDS (1996)
26  - GI-Classic WINDS EX (1998)
27 
28  Other "GI" games, list from http://www.konami.jp/am/g1/
29  - GI-LEADING SIRE (1999)
30  - GI-LEADING SIRE Ver. 2 (2000)
31  - GI-LEADING SIRE Ver. 3 (2001)
32  - GI-WINNING SIRE (2002)
33  - GI-TURFWILD (2003)
34  - GI-WINNING SIRE Ver. 2 (2003)
35  - GI-TURFWILD 2 (2004)
36  - GI-TURFWILD 3 (2005)
37  - GI-HORSEPARK (2005)
38  - GI-HORSEPARK EX (2006)
39  - GI-HORSEPARK EX STD (2006)
40  - GI-HORSEPARK GX STD (2009)
41  - GI-HORSEPARK GX (2009)
42  - GI-Turf TV (2010)
43 
44 ***************************************************************************/
45 
46 #include "emu.h"
47 #include "cpu/m68000/m68000.h"
48 #include "machine/k053252.h"
49 #include "video/k055555.h"
50 #include "video/k054156_k054157_k056832.h"
51 #include "video/k053246_k053247_k055673.h"
52 #include "video/konami_helper.h"
53 #include "emupal.h"
54 #include "screen.h"
55 #include "speaker.h"
56 
57 class giclassic_state : public driver_device
58 {
59 public:
giclassic_state(const machine_config & mconfig,device_type type,const char * tag)60 	giclassic_state(const machine_config &mconfig, device_type type, const char *tag) :
61 		driver_device(mconfig, type, tag),
62 		m_maincpu(*this, "maincpu"),
63 		m_k056832(*this, "k056832"),
64 		m_palette(*this, "palette")
65 	{ }
66 
67 	void giclassic(machine_config &config);
68 
69 private:
70 	required_device<cpu_device> m_maincpu;
71 	required_device<k056832_device> m_k056832;
72 	required_device<palette_device> m_palette;
73 
74 	INTERRUPT_GEN_MEMBER(giclassic_interrupt);
75 
76 	virtual void machine_start() override;
77 	virtual void machine_reset() override;
78 	virtual void video_start() override;
79 	uint32_t screen_update_giclassic(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
80 	K056832_CB_MEMBER(tile_callback);
81 
82 	void control_w(uint16_t data);
83 	uint16_t vrom_r(offs_t offset);
84 
85 	void satellite_main(address_map &map);
86 
87 	uint8_t m_control;
88 };
89 
90 // --------------------------------------------------------------------------------------------------------------
91 // Client portion
92 // --------------------------------------------------------------------------------------------------------------
93 
K056832_CB_MEMBER(giclassic_state::tile_callback)94 K056832_CB_MEMBER(giclassic_state::tile_callback)
95 {
96 	*color = (*color & 0xf);
97 }
98 
video_start()99 void giclassic_state::video_start()
100 {
101 }
102 
screen_update_giclassic(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)103 uint32_t giclassic_state::screen_update_giclassic(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
104 {
105 	bitmap.fill(0, cliprect);
106 	screen.priority().fill(0, cliprect);
107 
108 	m_k056832->tilemap_draw(screen, bitmap, cliprect, 3, 0, 1);
109 	m_k056832->tilemap_draw(screen, bitmap, cliprect, 2, 0, 2);
110 	m_k056832->tilemap_draw(screen, bitmap, cliprect, 1, 0, 4);
111 //  m_k056832->tilemap_draw(screen, bitmap, cliprect, 0, 0, 8);
112 
113 	return 0;
114 }
115 
INTERRUPT_GEN_MEMBER(giclassic_state::giclassic_interrupt)116 INTERRUPT_GEN_MEMBER(giclassic_state::giclassic_interrupt)
117 {
118 	if (m_control & 2)
119 	{
120 		m_maincpu->set_input_line(M68K_IRQ_1, HOLD_LINE);
121 		m_maincpu->set_input_line(M68K_IRQ_3, HOLD_LINE);
122 	}
123 }
124 
control_w(uint16_t data)125 void giclassic_state::control_w(uint16_t data)
126 {
127 	// bits:
128 	// 0 = ?
129 	// 1 = IRQ enable
130 	// 2 = ?
131 	// 3 = extra VROM readback bank
132 	// 4 = screen on?
133 
134 	m_control = data & 0xff;
135 }
136 
vrom_r(offs_t offset)137 uint16_t giclassic_state::vrom_r(offs_t offset)
138 {
139 	if (m_control & 8)
140 	{
141 		return m_k056832->piratesh_rom_r(offset + 0x1000);
142 	}
143 
144 	return m_k056832->piratesh_rom_r(offset);
145 }
146 
satellite_main(address_map & map)147 void giclassic_state::satellite_main(address_map &map)
148 {
149 	map(0x000000, 0x07ffff).rom().region("maincpu", 0);
150 	map(0x100000, 0x103fff).ram();
151 	map(0x200000, 0x200fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
152 	map(0x800000, 0x801fff).ram().rw(m_k056832, FUNC(k056832_device::ram_word_r), FUNC(k056832_device::ram_word_w));
153 	map(0x900000, 0x90003f).rw(m_k056832, FUNC(k056832_device::word_r), FUNC(k056832_device::word_w));
154 	map(0xb00000, 0xb01fff).r(FUNC(giclassic_state::vrom_r));
155 	map(0xc00000, 0xc00001).w(FUNC(giclassic_state::control_w));
156 	map(0xd00000, 0xd0003f).ram(); // these must read/write or 26S (LCD controller) fails
157 	map(0xe00000, 0xe0001f).w(m_k056832, FUNC(k056832_device::b_w)).umask16(0xff00);
158 	map(0xf00000, 0xf00001).noprw().nopw(); // watchdog reset
159 }
160 
INPUT_PORTS_START(giclassic)161 static INPUT_PORTS_START( giclassic )
162 INPUT_PORTS_END
163 
164 void giclassic_state::machine_start()
165 {
166 }
167 
machine_reset()168 void giclassic_state::machine_reset()
169 {
170 }
171 
172 // --------------------------------------------------------------------------------------------------------------
173 // Server portion
174 // --------------------------------------------------------------------------------------------------------------
175 
176 class giclassicsvr_state : public driver_device
177 {
178 public:
giclassicsvr_state(const machine_config & mconfig,device_type type,const char * tag)179 	giclassicsvr_state(const machine_config &mconfig, device_type type, const char *tag)
180 		: driver_device(mconfig, type, tag),
181 		m_maincpu(*this, "maincpu"),
182 		m_k056832(*this, "k056832"),
183 		m_k055673(*this, "k055673"),
184 		m_palette(*this, "palette")
185 	{ }
186 
187 	required_device<cpu_device> m_maincpu;
188 	required_device<k056832_device> m_k056832;
189 	required_device<k055673_device> m_k055673;
190 	required_device<palette_device> m_palette;
191 
192 	INTERRUPT_GEN_MEMBER(giclassicsvr_interrupt);
193 
194 	virtual void machine_start() override;
195 	virtual void machine_reset() override;
196 	uint32_t screen_update_giclassicsvr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
197 	K056832_CB_MEMBER(tile_callback);
198 	K055673_CB_MEMBER(sprite_callback);
199 
200 	void control_w(uint16_t data);
201 	uint16_t control_r();
202 
203 	void giclassvr(machine_config &config);
204 	void server_main(address_map &map);
205 private:
206 	uint16_t m_control;
207 };
208 
control_w(uint16_t data)209 void giclassicsvr_state::control_w(uint16_t data)
210 {
211 	m_control = data;
212 }
213 
control_r()214 uint16_t giclassicsvr_state::control_r()
215 {
216 	return m_control;
217 }
218 
INTERRUPT_GEN_MEMBER(giclassicsvr_state::giclassicsvr_interrupt)219 INTERRUPT_GEN_MEMBER(giclassicsvr_state::giclassicsvr_interrupt)
220 {
221 	//if (m_control & 2)
222 	{
223 		m_maincpu->set_input_line(M68K_IRQ_4, HOLD_LINE);
224 		m_maincpu->set_input_line(M68K_IRQ_5, HOLD_LINE);
225 	}
226 }
227 
K056832_CB_MEMBER(giclassicsvr_state::tile_callback)228 K056832_CB_MEMBER(giclassicsvr_state::tile_callback)
229 {
230 }
231 
K055673_CB_MEMBER(giclassicsvr_state::sprite_callback)232 K055673_CB_MEMBER(giclassicsvr_state::sprite_callback)
233 {
234 	int c = *color;
235 
236 	*color = (c & 0x001f);
237 	//int pri = (c >> 5) & 7;
238 	// .... .... ...x xxxx - Color
239 	// .... .... xxx. .... - Priority?
240 	// .... ..x. .... .... - ?
241 	// ..x. .... .... .... - ?
242 
243 	*priority_mask = 0;
244 
245 	// 0 - Sprites over everything
246 	// f0 -
247 	// f0 cc -
248 	// f0 cc aa -
249 
250 	// 1111 0000
251 	// 1100 1100
252 	// 1010 1010
253 }
254 
255 
screen_update_giclassicsvr(screen_device & screen,bitmap_ind16 & bitmap,const rectangle & cliprect)256 uint32_t giclassicsvr_state::screen_update_giclassicsvr(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
257 {
258 	bitmap.fill(0, cliprect);
259 	screen.priority().fill(0, cliprect);
260 
261 	m_k056832->tilemap_draw(screen, bitmap, cliprect, 3, 0, 1);
262 	m_k056832->tilemap_draw(screen, bitmap, cliprect, 2, 0, 2);
263 	m_k056832->tilemap_draw(screen, bitmap, cliprect, 1, 0, 4);
264 	m_k056832->tilemap_draw(screen, bitmap, cliprect, 0, 0, 8);
265 
266 	return 0;
267 }
268 
server_main(address_map & map)269 void giclassicsvr_state::server_main(address_map &map)
270 {
271 	map(0x000000, 0x07ffff).rom().region("maincpu", 0);
272 	map(0x080000, 0x08ffff).ram();
273 	map(0x090000, 0x093fff).ram();
274 	map(0x100000, 0x107fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
275 	map(0x180000, 0x183fff).ram();
276 	map(0x280000, 0x281fff).ram().rw(m_k056832, FUNC(k056832_device::ram_word_r), FUNC(k056832_device::ram_word_w));
277 	map(0x300000, 0x300007).w(m_k055673, FUNC(k055673_device::k053246_w)); // SPRITES
278 	map(0x300060, 0x30006f).r(m_k055673, FUNC(k055673_device::k055673_ps_rom_word_r)); // SPRITES
279 	map(0x308000, 0x30803f).rw(m_k056832, FUNC(k056832_device::word_r), FUNC(k056832_device::word_w));
280 	map(0x320000, 0x32001f).rw("k053252a", FUNC(k053252_device::read), FUNC(k053252_device::write)).umask16(0x00ff); // CRTC 1
281 	map(0x320000, 0x32001f).rw("k053252b", FUNC(k053252_device::read), FUNC(k053252_device::write)).umask16(0xff00); // CRTC 2
282 	map(0x380000, 0x380001).nopw();    // watchdog reset
283 	map(0x398000, 0x398001).rw(FUNC(giclassicsvr_state::control_r), FUNC(giclassicsvr_state::control_w));
284 	map(0x400000, 0x41ffff).ram();
285 }
286 
INPUT_PORTS_START(giclassvr)287 static INPUT_PORTS_START( giclassvr )
288 INPUT_PORTS_END
289 
290 void giclassicsvr_state::machine_start()
291 {
292 }
293 
machine_reset()294 void giclassicsvr_state::machine_reset()
295 {
296 }
297 
giclassic(machine_config & config)298 void giclassic_state::giclassic(machine_config &config)
299 {
300 	/* basic machine hardware */
301 	M68000(config, m_maincpu, XTAL(20'000'000) / 2); // PCB is marked "68000 12 MHz", but only visible osc is 20 MHz
302 	m_maincpu->set_addrmap(AS_PROGRAM, &giclassic_state::satellite_main);
303 	m_maincpu->set_vblank_int("screen", FUNC(giclassic_state::giclassic_interrupt));
304 
305 	/* video hardware */
306 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
307 	screen.set_refresh_hz(59.62);
308 	screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
309 	screen.set_size(600, 384);
310 	screen.set_visarea_full();
311 	screen.set_screen_update(FUNC(giclassic_state::screen_update_giclassic));
312 	screen.set_palette(m_palette);
313 
314 	PALETTE(config, m_palette).set_format(palette_device::xBGR_444, 256);
315 	m_palette->enable_shadows();
316 
317 	K056832(config, m_k056832, 0);
318 	m_k056832->set_tile_callback(FUNC(giclassic_state::tile_callback));
319 	m_k056832->set_config(K056832_BPP_4PIRATESH, 1, 0);
320 	m_k056832->set_palette(m_palette);
321 }
322 
giclassvr(machine_config & config)323 void giclassicsvr_state::giclassvr(machine_config &config)
324 {
325 	/* basic machine hardware */
326 	M68000(config, m_maincpu, XTAL(16'000'000)); // unknown speed
327 	m_maincpu->set_addrmap(AS_PROGRAM, &giclassicsvr_state::server_main);
328 	m_maincpu->set_vblank_int("screen", FUNC(giclassicsvr_state::giclassicsvr_interrupt));
329 
330 	/* video hardware */
331 	screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
332 	screen.set_refresh_hz(59.62);
333 	screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
334 	screen.set_visarea_full();
335 	screen.set_screen_update(FUNC(giclassicsvr_state::screen_update_giclassicsvr));
336 	screen.set_palette(m_palette);
337 
338 	PALETTE(config, m_palette).set_format(palette_device::xBGR_444, 16384);
339 	m_palette->enable_shadows();
340 
341 	K056832(config, m_k056832, 0);
342 	m_k056832->set_tile_callback(FUNC(giclassicsvr_state::tile_callback));
343 	m_k056832->set_config(K056832_BPP_4PIRATESH, 0, 0);
344 	m_k056832->set_palette(m_palette);
345 
346 	K055673(config, m_k055673, 0);
347 	m_k055673->set_sprite_callback(FUNC(giclassicsvr_state::sprite_callback));
348 	m_k055673->set_config(K055673_LAYOUT_PS, -60, 24);
349 	m_k055673->set_palette(m_palette);
350 
351 	K053252(config, "k053252a", XTAL(32'000'000)/4).set_offsets(40, 16); // TODO
352 	K053252(config, "k053252b", XTAL(32'000'000)/4).set_offsets(40, 16); // TODO
353 }
354 
355 ROM_START( giclasex )
356 	ROM_REGION( 0x80000, "maincpu", 0 ) /* main program */
357 	ROM_LOAD16_WORD_SWAP( "gsgu760ae01.12t", 0x000000, 0x080000, CRC(f0f9c118) SHA1(1753d53946bc0703d329e4a09c452713b260da75) )
358 
359 	ROM_REGION( 0x100000, "k056832", 0 )   /* tilemaps */
360 	ROM_LOAD( "gsgu760ae03.14c", 0x000000, 0x080000, CRC(1663d327) SHA1(98c1a9653d38f4918f78b3a11af0c29c658201f5) )
361 	ROM_LOAD( "gsgu760ae02.14e", 0x080000, 0x080000, CRC(2b9fe163) SHA1(f60190a9689a70d6c5bb14fb46b7ac2267cf0969) )
362 ROM_END
363 
364 ROM_START( giclassvr )
365 	ROM_REGION( 0x80000, "maincpu", 0 ) /* main program */
366 	ROM_LOAD16_WORD_SWAP( "gsgu_760_fd01.34e.bin", 0x000000, 0x080000, CRC(da89c1d7) SHA1(551d050a9b6e54fbf98e966eb37924b644037893) )
367 
368 	ROM_REGION( 0x100000, "k056832", 0 )   /* tilemaps */
369 	ROM_LOAD( "gsgu_760_ad04.25q", 0x080000, 0x080000, CRC(71a45742) SHA1(fbddd54f5fb236662f7cc7e9b350723bc5404f72) )
370 	ROM_LOAD( "gsgu_760_ad05.25r", 0x000000, 0x080000, CRC(44221eec) SHA1(966452e606e828b536ed11cbdd626a2fe3165199) )
371 
372 	ROM_REGION( 0x100000, "k055673", 0 )   /* tilemaps */
373 	ROM_LOAD32_WORD( "gsgu_760_ad02.34j", 0x000000, 0x080000, CRC(6d33c720) SHA1(35da3e1f0133a76480d2078fae89ea87b841ffc7) )
374 	ROM_LOAD32_WORD( "gsgu_760_ad02.34k", 0x000002, 0x080000, CRC(8057a417) SHA1(82d4a1d84729e9f0a8aff4c219a19601b89caf15) )
375 ROM_END
376 
377 GAME( 1998, giclasex, 0, giclassic, giclassic, giclassic_state,    empty_init, 0, "Konami", "GI-Classic EX (satellite terminal)", MACHINE_NOT_WORKING|MACHINE_NO_SOUND_HW)
378 GAME( 1998, giclassvr,0, giclassvr, giclassvr, giclassicsvr_state, empty_init, 0, "Konami", "GI-Classic EX (server)",             MACHINE_NOT_WORKING|MACHINE_NO_SOUND_HW)
379