1 // license:BSD-3-Clause
2 // copyright-holders:Ville Linde
3 /*  Konami NWK-TR System
4 
5     Driver by Ville Linde
6 
7 
8 
9     Hardware overview:
10 
11     GN676 CPU Board:
12     ----------------
13         IBM PowerPC 403GA at 32MHz (main CPU)
14         Motorola MC68EC000 at 16MHz (sound CPU)
15         Konami K056800 (MIRAC), sound system interface
16         Ricoh RF5c400 sound chip
17         National Semiconductor ADC12138
18 
19     GN676 GFX Board:
20     ----------------
21         Analog Devices ADSP-21062 SHARC DSP at 36MHz
22         Konami K001604 (2D tilemaps + 2x ROZ)
23         Konami 0000033906 (PCI bridge)
24         3DFX 500-0003-03 (Voodoo) FBI with 2MB RAM
25         2x 3DFX 500-0004-02 (Voodoo) TMU with 2MB RAM
26 
27     GN676 LAN Board:
28     ----------------
29         Xilinx XC5210 FPGA
30         Xilinx XC5204 FPGA
31 
32 
33 Konami 'NWK-TR' Hardware
34 Konami, 1998-1999
35 
36 Known games on this hardware include....
37 
38 Game                      (C)      Year
39 ---------------------------------------
40 Racing Jam                Konami   1998
41 Racing Jam : Chapter 2    Konami   1998
42 Thrill Drive              Konami   1998
43 
44 
45 PCB Layouts
46 -----------
47 
48 Note, the top board is virtually identical to GN715 used on Hornet.
49 Some extra RCA connectors have been added (for dual sound output), the LED and
50 DIPSW are present on the main board (instead of on the filter board) and the
51 SOIC8 chip (an XICOR X76F041 Secure SerialFlash) is not populated (the solder pads are there though).
52 There's an extra sound IC AN7395S (not populated on Hornet).
53 The PALs/PLDs are the same on both NWK-TR and Hornet.
54 Both Racing JAM/Chapter 2 and Thrill Drive use two video boards.
55 The top video board is set to MASTER/TWIN, lower video board is set to SLAVE
56 They are otherwise identical.
57 
58 
59 Top Board (CPU PCB)
60 GN676 PWB(A)B
61 Konami 1997
62 |--------------------------------------------------------------|
63 | SP485CS CN10       CN11  7805  CN9          JP8 JP9 JP10 JP11|
64 |CN19  7809                                              PAL1  |
65 |CN21       JP13 PAL2             68EC000          EPROM.7S    |
66 |   NE5532       PAL3                                      CN12|
67 |           JP12  JP16    DRM1M4SJ8                        CN13|
68 |   NE5532    AN7395S                 MASKROM.9P    MASKROM.9T |
69 |     SM5877 JP15         RF5C400                              |
70 |CN18                                 MASKROM.12P   MASKROM.12T|
71 |     SM5877     16.9344MHz                                 CN7|
72 |CN14            SRAM256K             MASKROM.14P   MASKROM.14T|
73 |                                                              |
74 |CN16            SRAM256K             MASKROM.16P   MASKROM.16T|
75 |  ADC12138                                                    |
76 |CN15         056800            JP5                            |
77 |                               JP4                            |
78 |CN17                  MACH111  JP3                |---------| |
79 |   TEST_SW                         EPROM.22P      |         | |
80 |CN1                   DRAM16X16                   |PPC403GA | |
81 |                                   EPROM.25P      |         | |
82 |                                                  |         | |
83 |                      DRAM16X16    EPROM.27P      |---------| |
84 | 4AK16                                                     JP6|
85 |                                                              |
86 |CN3                                                           |
87 |          PAL4                     CN5               7.3728MHz|
88 |          058232                                              |
89 |                                                     50.000MHz|
90 |CN2  RESET_SW                                     JP1  JP2    |
91 |M48T58Y-70PC1  CN4          DSW(8) CN6               64.000MHz|
92 |--------------------------------------------------------------|
93 Notes:
94       DRM1M4SJ8 - Fujitsu 81C4256 256kx4 DRAM (SOJ24)
95        SRAM256K - Cypress CY7C199 32kx8 SRAM (SOJ28)
96       DRAM16X16 - Fujitsu 8118160A-60 16megx16 DRAM (SOJ42)
97       M48T58Y-70PC1 - ST Timekeeper RAM
98         RF5C400 - Ricoh RF5C400 PCM 32Ch, 44.1 kHz Stereo, 3D Effect Spatializer, clock input 16.9344MHz
99          056800 - Konami Custom (QFP80)
100          058232 - Konami Custom Ceramic Package (SIL14)
101        ADC12138 - National Semiconductor ADC12138 A/D Converter, 12-bit + Serial I/O With MUX (SOP28)
102         MACH111 - AMD MACH111 CPLD (Stamped 'N676A1', PLCC44)
103         68EC000 - Motorola MC68EC000, running at 16.0MHz (64/4)
104        PPC403GA - IBM PowerPC 403GA CPU, clock input 32.0MHz (64/2) (QFP160)
105        SM5877AM - Nippon Precision Circuits 3rd Order 2-Channel D/A Converter (SOIC24)
106           4AK16 - Hitachi 4AK16 Silicon N-Channel Power MOS FET Array (SIL10)
107        NE5532AN - Philips, Dual Low-Noise High-Speed Audio OP Amp (DIP8)
108         SP485CS - Sipex SP485CS Low Power Half Duplex RS485 Transceiver (DIP8)
109         AN7395S - Panasonic AM7395S Spatializer Audio Processor IC for 3D surround (SOIC20)
110            PAL1 - AMD PALCE16V8 (stamped 'N676A4', DIP20)
111            PAL2 - AMD PALCE16V8 (stamped 'N676A2', DIP20)
112            PAL3 - AMD PALCE16V8 (stamped 'N676A3', DIP20)
113            PAL4 - AMD PALCE16V8 (stamped 'N676A5', DIP20)
114             JP1 -       25M O O-O 32M
115             JP2 -       25M O O-O 32M
116             JP3 -        RW O O O RO
117             JP4 - PROG  32M O O-O 16M
118             JP5 - DATA  32M O-O O 16M
119             JP6 - BOOT   16 O-O O 32
120             JP7 - SRC DOUT2 O O-O 0
121             JP8 -   64M&32M O-O O 16M
122             JP9 -       64M O O-O 32M&16M
123            JP10 -   64M&32M O-O O 16M
124            JP11 -       64M O O-O 32M&16M
125            JP12 -   through O-O O SP
126            JP13 -   through O-O O SP
127            JP14 -       WDT O O
128            JP15 -      MONO O-O O SURR
129            JP16 -      HIGH O O O MID (N/C LOW)
130     CN1 to  CN3 - D-SUB Connectors
131             CN4 - Multi-pin Connector for Network PCB
132             CN5 - DIN96 connector (pads only, not used)
133             CN6 - DIN96 joining connector to lower PCB
134             CN7 - Multi-pin connector (pads only, not used)
135     CN9 to CN13 - Power Connectors
136        CN14 to CN17 - RCA Stereo Audio OUT
137            CN18 - RCA Mono Audio OUT
138            CN19 - USB Connector
139 
140 
141 ROM Usage
142 ---------
143           |------------------------------- ROM Locations -------------------------------------|
144 Game         27P     25P  22P   16P     14P     12P     9P      16T     14T     12T     9T  7S
145 --------------------------------------------------------------------------------------------------
146 Racing Jam   676NC01 -    -     676A09  676A10  -       -       676A04  676A05  -       -   676A08
147 Racing Jam 2 888A01  -    -     888A09  888A10  -       -       676A04  676A05  888A06  -   888A08
148 Thrill Drive 713BE01 -    -     713A09  713A10  -       -       713A04  713A05  -       -   713A08
149 
150 
151 Network PCB (Racing Jam)
152 -----------
153 GN676-PWB(H)A
154 MADE IN JAPAN
155 (C)1998 KONAMI
156 |------------------------|
157 |  CY7C199       N676H1  |
158 |                        |
159 |CN3                     |
160 |  HYC2485S              |
161 |   XC5204        XC5210 |
162 |CN2                     |
163 |         CN1            |
164 |------------------------|
165 Notes:
166       CN1      - Connector joining to CPU board CN4
167       CN2/3    - RCA jacks for network cable
168       HYC2485S - Hybrid ceramic module for RS485
169       CY7C199  - 32k x8 SRAM
170       XC5204   - Xilinx XC5204 FPGA
171       XC5210   - Xilink XC5210 FPGA
172       N676H1   - PALCE16V8Q-15 stamped 'N676H1'
173 
174 Network PCB (Racing Jam 2 and Thrill Drive)
175 -----------
176 GN676-PWB(H)B
177 MADE IN JAPAN
178 (C)1998 KONAMI
179 |------------------------|
180 |  CY7C199       N676H1  |
181 |                      2G|
182 |CN3                     |
183 |  HYC2485S              |
184 |   XC5204        XC5210 |
185 |CN2                     |
186 |         CN1            |
187 |------------------------|
188 This pcb is the same as the A version but with one added chip:
189       2G       - XICOR X76F041 Secure SerialFlash (SOIC8)
190 
191                  Note: This chip is also present on *some* Hornet games on the GN715 CPU board at location
192                  30C. The chip refreshes game and region specific serial data to the Timekeeper RAM if the
193                  region ID matches the timekeeper. Because Racing Jam 2 and Thrill Drive came in a conversion
194                  kit for Racing Jam, the two former games will first boot with a "backup data error" because
195                  because of the timekeeper used for the incorrect game. Pressing the test switch then sets the
196                  timekeeper back to factory settings for the new kitted game installed. If the region ID in
197                  serialflash and timekeeper do not match, the game boots with a "hardware error" message.
198 
199 
200 Bottom Board (VIDEO PCB)
201 GN676 PWB(B)B
202 |-------------------------------------------------------------------------------------------|
203 |CN4          CN2      CN8               CN6                                             CN5|
204 |JP1                        |---------|          4M_EDO   4M_EDO                            |
205 |                           |         |     |----------|                                    |
206 |  4M_EDO   4M_EDO          | TEXELFX |     |          |       4M_EDO    MASKROM.8X         |
207 |CN3                        |         |     | PIXELFX  |                        MASKROM.8Y  |
208 |  4M_EDO   4M_EDO          |         |     |          |                                    |
209 |                           |---------|     |          |       4M_EDO                       |
210 |  4M_EDO   4M_EDO                          |----------|                                    |
211 |                           |---------|    50MHz         |--------|                         |
212 |  4M_EDO   4M_EDO          |         |                  |KONAMI  |                         |
213 |                           | TEXELFX |                  |33906   |      MASKROM.16X        |
214 |                           |         |                  |        |            MASKROM.16Y  |
215 |                           |         |  PLCC44_SOCKET   |--------| AM7201                  |
216 | MC44200                   |---------|                                                     |
217 |                                                                                           |
218 |                                                                                           |
219 |                             PAL3       256KSRAM                         36MHz             |
220 |                                        256KSRAM    AM7201   AM7201    |-------------|     |
221 |                                        256KSRAM                       |ANALOG       |     |
222 |         256KSRAM         MACH111       256KSRAM    AM7201   AM7201    |DEVICES      |     |
223 |         256KSRAM  AV9170                                              |ADSP-21062   |     |
224 |                                                                       |SHARC        |     |
225 |         |--------|                                                    |KS-160       |     |
226 |         |KONAMI  |                                                    |-------------|     |
227 |         |001604  |                        1MSRAM  1MSRAM  1MSRAM  1MSRAM                  |
228 |1MSRAM   |        |                                        1MSRAM  1MSRAM  1MSRAM  1MSRAM  |
229 |         |--------|                                                                        |
230 |1MSRAM       256KSRAM                                               PAL1                   |
231 |         256KSRAM 256KSRAM              JP2   CN1                   PAL2                   |
232 |-------------------------------------------------------------------------------------------|
233 Notes:
234       4M_EDO - Silicon Magic SM81C256K16CJ-35 EDO DRAM 66MHz (SOJ40)
235       1MSRAM - Cypress CY7C109-25VC 1Meg SRAM (SOJ32)
236     256KSRAM - Winbond W24257AJ-15 256k SRAM (SOJ28)
237      TEXELFX - 3DFX 500-0004-02 BD0665.1 TMU (QFP208)
238      PIXELFX - 3DFX 500-0003-03 F001701.1 FBI (QFP240)
239       001604 - Konami Custom (QFP208)
240        MC44200FT - Motorola MC44200FT 3 Channel Video D/A Converter (QFP44)
241      MACH111 - AMD MACH111 CPLD (Stamped '03161A', PLCC44)
242     PLCC44_SOCKET - empty PLCC44 socket
243       AV9170 - Integrated Circuit Systems Inc. Clock Multiplier (SOIC8)
244       AM7201 - AMD AM7201 FIFO (PLCC32)
245         PAL1 - AMD PALCE16V8 (stamped 'N676B4', DIP20)
246         PAL2 - AMD PALCE16V8 (stamped 'N676B5', DIP20)
247         PAL3 - AMD PALCE16V8 (stamped 'N676B2', DIP20)
248          JP1 - SLV O O-O MST,TWN (sets board to MASTER TWIN or SLAVE)
249          JP2 - SLV O O-O MST (sets board to MASTER or SLAVE)
250          CN1 - 96 Pin joining connector to upper PCB
251          CN2 - 8-Pin 24kHz RGB OUT
252          CN3 - 15-Pin DSUB VGA Video MAIN OUT
253          CN4 - 6-Pin Power Connector
254          CN5 - 4-Pin Power Connector
255          CN6 - 2-Pin Connector (Not Used)
256          CN7 - 6-Pin Connector
257 
258 
259 ROM Usage
260 ---------
261           |------ ROM Locations -------|
262 Game         8X      8Y      16X     16Y
263 -------------------------------------------
264 Racing Jam   676A13  -       676A14  -
265 Racing Jam 2 888A13  -       888A14  -
266 Thrill Drive 713A13  -       713A14  -
267 
268 */
269 
270 #include "emu.h"
271 #include "cpu/m68000/m68000.h"
272 #include "cpu/powerpc/ppc.h"
273 #include "cpu/sharc/sharc.h"
274 #include "machine/adc1213x.h"
275 #include "machine/k033906.h"
276 #include "machine/konppc.h"
277 #include "machine/timekpr.h"
278 //#include "machine/x76f041.h"
279 #include "sound/rf5c400.h"
280 #include "sound/k056800.h"
281 #include "video/voodoo.h"
282 #include "video/k001604.h"
283 #include "emupal.h"
284 #include "screen.h"
285 #include "speaker.h"
286 
287 
288 class nwktr_state : public driver_device
289 {
290 public:
nwktr_state(const machine_config & mconfig,device_type type,const char * tag)291 	nwktr_state(const machine_config &mconfig, device_type type, const char *tag)
292 		: driver_device(mconfig, type, tag),
293 		m_work_ram(*this, "work_ram"),
294 		m_maincpu(*this, "maincpu"),
295 		m_audiocpu(*this, "audiocpu"),
296 		m_dsp(*this, "dsp"),
297 		m_dsp2(*this, "dsp2"),
298 		m_k056800(*this, "k056800"),
299 		m_k001604_1(*this, "k001604_1"),
300 		m_k001604_2(*this, "k001604_2"),
301 		m_konppc(*this, "konppc"),
302 		m_adc12138(*this, "adc12138"),
303 		m_voodoo(*this, "voodoo%u", 0U),
304 		m_in0(*this, "IN0"),
305 		m_in1(*this, "IN1"),
306 		m_in2(*this, "IN2"),
307 		m_dsw(*this, "DSW"),
308 		m_analog1(*this, "ANALOG1"),
309 		m_analog2(*this, "ANALOG2"),
310 		m_analog3(*this, "ANALOG3"),
311 		m_analog4(*this, "ANALOG4"),
312 		m_analog5(*this, "ANALOG5"),
313 		m_pcb_digit(*this, "pcbdigit%u", 0U),
314 		m_palette(*this, "palette"),
315 		m_generic_paletteram_32(*this, "paletteram")
316 	{ }
317 
318 	void thrilld(machine_config &config);
319 	void nwktr(machine_config &config);
320 
321 	void init_nwktr();
322 	void init_racingj();
323 	void init_thrilld();
324 
325 private:
326 	// TODO: Needs verification on real hardware
327 	static const int m_sound_timer_usec = 2400;
328 
329 	required_shared_ptr<uint32_t> m_work_ram;
330 	required_device<ppc_device> m_maincpu;
331 	required_device<cpu_device> m_audiocpu;
332 	required_device<adsp21062_device> m_dsp;
333 	required_device<adsp21062_device> m_dsp2;
334 	required_device<k056800_device> m_k056800;
335 	required_device<k001604_device> m_k001604_1;
336 	required_device<k001604_device> m_k001604_2;
337 	required_device<konppc_device> m_konppc;
338 	required_device<adc12138_device> m_adc12138;
339 	required_device_array<voodoo_device, 2> m_voodoo;
340 	required_ioport m_in0, m_in1, m_in2, m_dsw, m_analog1, m_analog2, m_analog3, m_analog4, m_analog5;
341 	output_finder<2> m_pcb_digit;
342 	required_device<palette_device> m_palette;
343 	required_shared_ptr<uint32_t> m_generic_paletteram_32;
344 
345 	emu_timer *m_sound_irq_timer;
346 	int m_fpga_uploaded;
347 	int m_lanc2_ram_r;
348 	int m_lanc2_ram_w;
349 	uint8_t m_lanc2_reg[3];
350 	std::unique_ptr<uint8_t[]> m_lanc2_ram;
351 	std::unique_ptr<uint32_t[]> m_sharc0_dataram;
352 	std::unique_ptr<uint32_t[]> m_sharc1_dataram;
353 	void paletteram32_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
354 	uint32_t nwktr_k001604_tile_r(offs_t offset);
355 	void nwktr_k001604_tile_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
356 	uint32_t nwktr_k001604_char_r(offs_t offset);
357 	void nwktr_k001604_char_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
358 	uint32_t nwktr_k001604_reg_r(offs_t offset);
359 	void nwktr_k001604_reg_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
360 	uint8_t sysreg_r(offs_t offset);
361 	void sysreg_w(offs_t offset, uint8_t data);
362 	uint32_t lanc1_r(offs_t offset);
363 	void lanc1_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
364 	uint32_t lanc2_r(offs_t offset, uint32_t mem_mask = ~0);
365 	void lanc2_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
366 	uint32_t dsp_dataram0_r(offs_t offset);
367 	void dsp_dataram0_w(offs_t offset, uint32_t data);
368 	uint32_t dsp_dataram1_r(offs_t offset);
369 	void dsp_dataram1_w(offs_t offset, uint32_t data);
370 	void soundtimer_en_w(uint16_t data);
371 	void soundtimer_count_w(uint16_t data);
372 	DECLARE_WRITE_LINE_MEMBER(voodoo_vblank_0);
373 	DECLARE_WRITE_LINE_MEMBER(voodoo_vblank_1);
374 	double adc12138_input_callback(uint8_t input);
375 
376 	TIMER_CALLBACK_MEMBER(sound_irq);
377 	virtual void machine_start() override;
378 	virtual void machine_reset() override;
379 	uint32_t screen_update_lscreen(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
380 	uint32_t screen_update_rscreen(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
381 
382 	void lanc2_init();
383 
384 	void nwktr_map(address_map &map);
385 	void sharc0_map(address_map &map);
386 	void sharc1_map(address_map &map);
387 	void sound_memmap(address_map &map);
388 };
389 
paletteram32_w(offs_t offset,uint32_t data,uint32_t mem_mask)390 void nwktr_state::paletteram32_w(offs_t offset, uint32_t data, uint32_t mem_mask)
391 {
392 	COMBINE_DATA(&m_generic_paletteram_32[offset]);
393 	data = m_generic_paletteram_32[offset];
394 	m_palette->set_pen_color(offset, pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0));
395 }
396 
WRITE_LINE_MEMBER(nwktr_state::voodoo_vblank_0)397 WRITE_LINE_MEMBER(nwktr_state::voodoo_vblank_0)
398 {
399 	m_maincpu->set_input_line(INPUT_LINE_IRQ0, state);
400 }
401 
WRITE_LINE_MEMBER(nwktr_state::voodoo_vblank_1)402 WRITE_LINE_MEMBER(nwktr_state::voodoo_vblank_1)
403 {
404 	m_maincpu->set_input_line(INPUT_LINE_IRQ1, state);
405 }
406 
nwktr_k001604_tile_r(offs_t offset)407 uint32_t nwktr_state::nwktr_k001604_tile_r(offs_t offset)
408 {
409 	k001604_device *k001604 = (m_konppc->get_cgboard_id() ? m_k001604_2 : m_k001604_1);
410 	return k001604->tile_r(offset);
411 }
412 
nwktr_k001604_tile_w(offs_t offset,uint32_t data,uint32_t mem_mask)413 void nwktr_state::nwktr_k001604_tile_w(offs_t offset, uint32_t data, uint32_t mem_mask)
414 {
415 	k001604_device *k001604 = (m_konppc->get_cgboard_id() ? m_k001604_2 : m_k001604_1);
416 	k001604->tile_w(offset, data, mem_mask);
417 }
418 
nwktr_k001604_char_r(offs_t offset)419 uint32_t nwktr_state::nwktr_k001604_char_r(offs_t offset)
420 {
421 	k001604_device *k001604 = (m_konppc->get_cgboard_id() ? m_k001604_2 : m_k001604_1);
422 	return k001604->char_r(offset);
423 }
424 
nwktr_k001604_char_w(offs_t offset,uint32_t data,uint32_t mem_mask)425 void nwktr_state::nwktr_k001604_char_w(offs_t offset, uint32_t data, uint32_t mem_mask)
426 {
427 	k001604_device *k001604 = (m_konppc->get_cgboard_id() ? m_k001604_2 : m_k001604_1);
428 	k001604->char_w(offset, data, mem_mask);
429 }
430 
nwktr_k001604_reg_r(offs_t offset)431 uint32_t nwktr_state::nwktr_k001604_reg_r(offs_t offset)
432 {
433 	k001604_device *k001604 = (m_konppc->get_cgboard_id() ? m_k001604_2 : m_k001604_1);
434 	return k001604->reg_r(offset);
435 }
436 
nwktr_k001604_reg_w(offs_t offset,uint32_t data,uint32_t mem_mask)437 void nwktr_state::nwktr_k001604_reg_w(offs_t offset, uint32_t data, uint32_t mem_mask)
438 {
439 	k001604_device *k001604 = (m_konppc->get_cgboard_id() ? m_k001604_2 : m_k001604_1);
440 	k001604->reg_w(offset, data, mem_mask);
441 }
442 
screen_update_lscreen(screen_device & screen,bitmap_rgb32 & bitmap,const rectangle & cliprect)443 uint32_t nwktr_state::screen_update_lscreen(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
444 {
445 	bitmap.fill(m_palette->pen(0), cliprect);
446 
447 	m_voodoo[0]->voodoo_update(bitmap, cliprect);
448 	m_k001604_1->draw_front_layer(screen, bitmap, cliprect);
449 
450 	return 0;
451 }
452 
screen_update_rscreen(screen_device & screen,bitmap_rgb32 & bitmap,const rectangle & cliprect)453 uint32_t nwktr_state::screen_update_rscreen(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
454 {
455 	bitmap.fill(m_palette->pen(0), cliprect);
456 
457 	m_voodoo[1]->voodoo_update(bitmap, cliprect);
458 	m_k001604_2->draw_front_layer(screen, bitmap, cliprect);
459 
460 	return 0;
461 }
462 
463 /*****************************************************************************/
464 
sysreg_r(offs_t offset)465 uint8_t nwktr_state::sysreg_r(offs_t offset)
466 {
467 	uint8_t r = 0;
468 
469 	switch (offset)
470 	{
471 		case 0:
472 			r = m_in0->read();
473 			break;
474 		case 1:
475 			r = m_in1->read();
476 			break;
477 		case 2:
478 			r = m_in2->read();
479 			break;
480 		case 3:
481 			r = m_adc12138->do_r() | (m_adc12138->eoc_r() << 2);
482 			break;
483 		case 4:
484 			r = m_dsw->read();
485 			break;
486 		default:
487 			break;
488 	}
489 
490 	return r;
491 }
492 
sysreg_w(offs_t offset,uint8_t data)493 void nwktr_state::sysreg_w(offs_t offset, uint8_t data)
494 {
495 	switch (offset)
496 	{
497 		case 0:
498 		case 1:
499 			m_pcb_digit[offset] = bitswap<7>(~data,0,1,2,3,4,5,6);
500 			break;
501 
502 		case 4:
503 		{
504 			int cs = (data >> 3) & 0x1;
505 			int conv = (data >> 2) & 0x1;
506 			int di = (data >> 1) & 0x1;
507 			int sclk = data & 0x1;
508 
509 			m_adc12138->cs_w(cs);
510 			m_adc12138->conv_w(conv);
511 			m_adc12138->di_w(di);
512 			m_adc12138->sclk_w(sclk);
513 			break;
514 		}
515 
516 		case 7:
517 			if (data & 0x80) // CG Board 1 IRQ Ack
518 				m_maincpu->set_input_line(INPUT_LINE_IRQ1, CLEAR_LINE);
519 			if (data & 0x40) // CG Board 0 IRQ Ack
520 				m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
521 
522 			m_konppc->set_cgboard_id((data >> 4) & 3);
523 			break;
524 
525 		default:
526 			break;
527 	}
528 }
529 
530 
lanc2_init()531 void nwktr_state::lanc2_init()
532 {
533 	m_fpga_uploaded = 0;
534 	m_lanc2_ram_r = 0;
535 	m_lanc2_ram_w = 0;
536 	m_lanc2_ram = std::make_unique<uint8_t[]>(0x8000);
537 }
538 
lanc1_r(offs_t offset)539 uint32_t nwktr_state::lanc1_r(offs_t offset)
540 {
541 	switch (offset)
542 	{
543 		case 0x40/4:
544 		{
545 			uint32_t r = 0;
546 
547 			r |= (m_fpga_uploaded) ? (1 << 6) : 0;
548 			r |= 1 << 5;
549 
550 			return (r) << 24;
551 		}
552 
553 		default:
554 		{
555 			//printf("lanc1_r: %08X, %08X at %08X\n", offset, mem_mask, m_maincpu->pc());
556 			return 0xffffffff;
557 		}
558 	}
559 }
560 
lanc1_w(offs_t offset,uint32_t data,uint32_t mem_mask)561 void nwktr_state::lanc1_w(offs_t offset, uint32_t data, uint32_t mem_mask)
562 {
563 	//printf("lanc1_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, m_maincpu->pc());
564 }
565 
lanc2_r(offs_t offset,uint32_t mem_mask)566 uint32_t nwktr_state::lanc2_r(offs_t offset, uint32_t mem_mask)
567 {
568 	uint32_t r = 0;
569 
570 	if (offset == 0)
571 	{
572 		if (ACCESSING_BITS_0_7)
573 		{
574 			r |= m_lanc2_ram[m_lanc2_ram_r & 0x7fff];
575 			m_lanc2_ram_r++;
576 		}
577 		else
578 		{
579 			r |= 0xffffff00;
580 		}
581 	}
582 
583 	if (offset == 4)
584 	{
585 		if (ACCESSING_BITS_24_31)
586 		{
587 			r |= 0x00000000;
588 		}
589 	}
590 
591 	//printf("lanc2_r: %08X, %08X at %08X\n", offset, mem_mask, m_maincpu->pc());
592 
593 	return r;
594 }
595 
lanc2_w(offs_t offset,uint32_t data,uint32_t mem_mask)596 void nwktr_state::lanc2_w(offs_t offset, uint32_t data, uint32_t mem_mask)
597 {
598 	if (offset == 0)
599 	{
600 		if (ACCESSING_BITS_24_31)
601 		{
602 			uint8_t value = data >> 24;
603 
604 			value = ((value >> 7) & 0x01) |
605 					((value >> 5) & 0x02) |
606 					((value >> 3) & 0x04) |
607 					((value >> 1) & 0x08) |
608 					((value << 1) & 0x10) |
609 					((value << 3) & 0x20) |
610 					((value << 5) & 0x40) |
611 					((value << 7) & 0x80);
612 
613 			m_fpga_uploaded = 1;
614 			m_lanc2_reg[0] = (uint8_t)(data >> 24);
615 
616 			//printf("lanc2_fpga_w: %02X at %08X\n", value, m_maincpu->pc());
617 		}
618 		else if (ACCESSING_BITS_8_15)
619 		{
620 			m_lanc2_ram_r = 0;
621 			m_lanc2_ram_w = 0;
622 			m_lanc2_reg[1] = (uint8_t)(data >> 8);
623 		}
624 		else if (ACCESSING_BITS_16_23)
625 		{
626 			if (m_lanc2_reg[0] != 0)
627 			{
628 				m_lanc2_ram[2] = (data >> 20) & 0xf;
629 				m_lanc2_ram[3] = 0;
630 			}
631 			m_lanc2_reg[2] = (uint8_t)(data >> 16);
632 		}
633 		else if (ACCESSING_BITS_0_7)
634 		{
635 			m_lanc2_ram[m_lanc2_ram_w & 0x7fff] = data & 0xff;
636 			m_lanc2_ram_w++;
637 		}
638 		else
639 		{
640 			//printf("lanc2_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, m_maincpu->pc());
641 		}
642 	}
643 	if (offset == 4)
644 	{
645 		// TODO: The data below would normally be present on the serialflash at 2G.
646 
647 		if (core_stricmp(machine().system().name, "thrilld") == 0 ||
648 			core_stricmp(machine().system().name, "thrilldb") == 0 ||
649 			core_stricmp(machine().system().name, "thrilldbe") == 0)
650 		{
651 			m_work_ram[(0x3ffed0/4) + 0] = 0x472a3731;      // G*71
652 			m_work_ram[(0x3ffed0/4) + 1] = 0x33202020;      // 3
653 			m_work_ram[(0x3ffed0/4) + 2] = 0x2d2d2a2a;      // --**
654 			m_work_ram[(0x3ffed0/4) + 3] = 0x2a207878;      // *
655 
656 			m_work_ram[(0x3fff40/4) + 0] = 0x47433731;      // GC71
657 			m_work_ram[(0x3fff40/4) + 1] = 0x33000000;      // 3
658 			m_work_ram[(0x3fff40/4) + 2] = 0x19994a41;      //   JA
659 			m_work_ram[(0x3fff40/4) + 3] = 0x4100a9b1;      // A
660 		}
661 		else if (core_stricmp(machine().system().name, "racingj2") == 0)
662 		{
663 			m_work_ram[(0x3ffc80/4) + 0] = 0x47453838;      // GE88
664 			m_work_ram[(0x3ffc80/4) + 1] = 0x38003030;      // 8 00
665 			m_work_ram[(0x3ffc80/4) + 2] = 0x39374541;      // 97EA
666 			m_work_ram[(0x3ffc80/4) + 3] = 0x410058da;      // A
667 		}
668 	}
669 
670 	//printf("lanc2_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, m_maincpu->pc());
671 }
672 
673 /*****************************************************************************/
674 
TIMER_CALLBACK_MEMBER(nwktr_state::sound_irq)675 TIMER_CALLBACK_MEMBER(nwktr_state::sound_irq)
676 {
677 	m_audiocpu->set_input_line(M68K_IRQ_1, ASSERT_LINE);
678 }
679 
680 
soundtimer_en_w(uint16_t data)681 void nwktr_state::soundtimer_en_w(uint16_t data)
682 {
683 	if (data & 1)
684 	{
685 		// Reset and disable timer
686 		m_sound_irq_timer->adjust(attotime::from_usec(m_sound_timer_usec));
687 		m_sound_irq_timer->enable(false);
688 	}
689 	else
690 	{
691 		// Enable timer
692 		m_sound_irq_timer->enable(true);
693 	}
694 }
695 
soundtimer_count_w(uint16_t data)696 void nwktr_state::soundtimer_count_w(uint16_t data)
697 {
698 	// Reset the count
699 	m_sound_irq_timer->adjust(attotime::from_usec(m_sound_timer_usec));
700 	m_audiocpu->set_input_line(M68K_IRQ_1, CLEAR_LINE);
701 }
702 
703 
machine_start()704 void nwktr_state::machine_start()
705 {
706 	m_pcb_digit.resolve();
707 
708 	// set conservative DRC options
709 	m_maincpu->ppcdrc_set_options(PPCDRC_COMPATIBLE_OPTIONS);
710 
711 	// configure fast RAM regions for DRC
712 	m_maincpu->ppcdrc_add_fastram(0x00000000, 0x003fffff, false, m_work_ram);
713 
714 	m_sound_irq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(nwktr_state::sound_irq), this));
715 }
716 
nwktr_map(address_map & map)717 void nwktr_state::nwktr_map(address_map &map)
718 {
719 	map(0x00000000, 0x003fffff).ram().share("work_ram"); // Work RAM
720 	map(0x74000000, 0x740000ff).rw(FUNC(nwktr_state::nwktr_k001604_reg_r), FUNC(nwktr_state::nwktr_k001604_reg_w));
721 	map(0x74010000, 0x7401ffff).ram().w(FUNC(nwktr_state::paletteram32_w)).share("paletteram");
722 	map(0x74020000, 0x7403ffff).rw(FUNC(nwktr_state::nwktr_k001604_tile_r), FUNC(nwktr_state::nwktr_k001604_tile_w));
723 	map(0x74040000, 0x7407ffff).rw(FUNC(nwktr_state::nwktr_k001604_char_r), FUNC(nwktr_state::nwktr_k001604_char_w));
724 	map(0x78000000, 0x7800ffff).rw(m_konppc, FUNC(konppc_device::cgboard_dsp_shared_r_ppc), FUNC(konppc_device::cgboard_dsp_shared_w_ppc));
725 	map(0x780c0000, 0x780c0003).rw(m_konppc, FUNC(konppc_device::cgboard_dsp_comm_r_ppc), FUNC(konppc_device::cgboard_dsp_comm_w_ppc));
726 	map(0x7d000000, 0x7d00ffff).r(FUNC(nwktr_state::sysreg_r));
727 	map(0x7d010000, 0x7d01ffff).w(FUNC(nwktr_state::sysreg_w));
728 	map(0x7d020000, 0x7d021fff).rw("m48t58", FUNC(timekeeper_device::read), FUNC(timekeeper_device::write)); // M48T58Y RTC/NVRAM
729 	map(0x7d030000, 0x7d03000f).rw(m_k056800, FUNC(k056800_device::host_r), FUNC(k056800_device::host_w));
730 	map(0x7d040000, 0x7d04ffff).rw(FUNC(nwktr_state::lanc1_r), FUNC(nwktr_state::lanc1_w));
731 	map(0x7d050000, 0x7d05ffff).rw(FUNC(nwktr_state::lanc2_r), FUNC(nwktr_state::lanc2_w));
732 	map(0x7e000000, 0x7e7fffff).rom().region("user2", 0); // Data ROM
733 	map(0x7f000000, 0x7f1fffff).rom().share("share2");
734 	map(0x7fe00000, 0x7fffffff).rom().region("user1", 0).share("share2"); // Program ROM
735 }
736 
737 /*****************************************************************************/
738 
sound_memmap(address_map & map)739 void nwktr_state::sound_memmap(address_map &map)
740 {
741 	map(0x000000, 0x07ffff).rom();
742 	map(0x100000, 0x10ffff).ram();
743 	map(0x200000, 0x200fff).rw("rfsnd", FUNC(rf5c400_device::rf5c400_r), FUNC(rf5c400_device::rf5c400_w)); // Ricoh RF5C400
744 	map(0x300000, 0x30001f).rw(m_k056800, FUNC(k056800_device::sound_r), FUNC(k056800_device::sound_w)).umask16(0x00ff);
745 	map(0x500000, 0x500001).w(FUNC(nwktr_state::soundtimer_en_w)).nopr();
746 	map(0x600000, 0x600001).w(FUNC(nwktr_state::soundtimer_count_w)).nopr();
747 }
748 
749 /*****************************************************************************/
750 
751 
dsp_dataram0_r(offs_t offset)752 uint32_t nwktr_state::dsp_dataram0_r(offs_t offset)
753 {
754 	return m_sharc0_dataram[offset] & 0xffff;
755 }
756 
dsp_dataram0_w(offs_t offset,uint32_t data)757 void nwktr_state::dsp_dataram0_w(offs_t offset, uint32_t data)
758 {
759 	m_sharc0_dataram[offset] = data;
760 }
761 
dsp_dataram1_r(offs_t offset)762 uint32_t nwktr_state::dsp_dataram1_r(offs_t offset)
763 {
764 	return m_sharc1_dataram[offset] & 0xffff;
765 }
766 
dsp_dataram1_w(offs_t offset,uint32_t data)767 void nwktr_state::dsp_dataram1_w(offs_t offset, uint32_t data)
768 {
769 	m_sharc1_dataram[offset] = data;
770 }
771 
sharc0_map(address_map & map)772 void nwktr_state::sharc0_map(address_map &map)
773 {
774 	map(0x0400000, 0x041ffff).rw(m_konppc, FUNC(konppc_device::cgboard_0_shared_sharc_r), FUNC(konppc_device::cgboard_0_shared_sharc_w));
775 	map(0x0500000, 0x05fffff).rw(FUNC(nwktr_state::dsp_dataram0_r), FUNC(nwktr_state::dsp_dataram0_w));
776 	map(0x1400000, 0x14fffff).ram();
777 	map(0x2400000, 0x27fffff).rw(m_konppc, FUNC(konppc_device::nwk_voodoo_0_r), FUNC(konppc_device::nwk_voodoo_0_w));
778 	map(0x3400000, 0x34000ff).rw(m_konppc, FUNC(konppc_device::cgboard_0_comm_sharc_r), FUNC(konppc_device::cgboard_0_comm_sharc_w));
779 	map(0x3500000, 0x35000ff).rw(m_konppc, FUNC(konppc_device::K033906_0_r), FUNC(konppc_device::K033906_0_w));
780 	map(0x3600000, 0x37fffff).bankr("bank5");
781 }
782 
sharc1_map(address_map & map)783 void nwktr_state::sharc1_map(address_map &map)
784 {
785 	map(0x0400000, 0x041ffff).rw(m_konppc, FUNC(konppc_device::cgboard_1_shared_sharc_r), FUNC(konppc_device::cgboard_1_shared_sharc_w));
786 	map(0x0500000, 0x05fffff).rw(FUNC(nwktr_state::dsp_dataram1_r), FUNC(nwktr_state::dsp_dataram1_w));
787 	map(0x1400000, 0x14fffff).ram();
788 	map(0x2400000, 0x27fffff).rw(m_konppc, FUNC(konppc_device::nwk_voodoo_0_r), FUNC(konppc_device::nwk_voodoo_0_w));
789 	map(0x3400000, 0x34000ff).rw(m_konppc, FUNC(konppc_device::cgboard_1_comm_sharc_r), FUNC(konppc_device::cgboard_1_comm_sharc_w));
790 	map(0x3500000, 0x35000ff).rw(m_konppc, FUNC(konppc_device::K033906_1_r), FUNC(konppc_device::K033906_1_w));
791 	map(0x3600000, 0x37fffff).bankr("bank6");
792 }
793 
794 /*****************************************************************************/
795 
796 static INPUT_PORTS_START( nwktr )
797 	PORT_START("IN0")
798 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
799 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
800 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
801 	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
802 	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
803 	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
804 	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
805 	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
806 
807 	PORT_START("IN1")
808 	PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
809 
810 	PORT_START("IN2")
811 	PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
812 	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_CODE(KEYCODE_7)813 	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Service Button") PORT_CODE(KEYCODE_7)
814 	PORT_SERVICE_NO_TOGGLE( 0x10, IP_ACTIVE_LOW )
815 	PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNKNOWN )
816 
817 	PORT_START("DSW")
818 	PORT_DIPNAME( 0x80, 0x00, "Skip Post" ) PORT_DIPLOCATION("SW:1")
819 	PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
820 	PORT_DIPSETTING( 0x00, DEF_STR( On ) )
821 	PORT_DIPNAME( 0x40, 0x00, "Disable Machine Init" ) PORT_DIPLOCATION("SW:2")
822 	PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
823 	PORT_DIPSETTING( 0x00, DEF_STR( On ) )
824 	PORT_DIPNAME( 0x20, 0x20, "DIP3" ) PORT_DIPLOCATION("SW:3")
825 	PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
826 	PORT_DIPSETTING( 0x00, DEF_STR( On ) )
827 	PORT_DIPNAME( 0x10, 0x10, "DIP4" ) PORT_DIPLOCATION("SW:4")
828 	PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
829 	PORT_DIPSETTING( 0x00, DEF_STR( On ) )
830 	PORT_DIPNAME( 0x08, 0x08, "DIP5" ) PORT_DIPLOCATION("SW:5")
831 	PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
832 	PORT_DIPSETTING( 0x00, DEF_STR( On ) )
833 	PORT_DIPNAME( 0x04, 0x04, "DIP6" ) PORT_DIPLOCATION("SW:6")
834 	PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
835 	PORT_DIPSETTING( 0x00, DEF_STR( On ) )
836 	PORT_DIPNAME( 0x02, 0x02, "DIP7" ) PORT_DIPLOCATION("SW:7")
837 	PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
838 	PORT_DIPSETTING( 0x00, DEF_STR( On ) )
839 	PORT_DIPNAME( 0x01, 0x01, "DIP8" ) PORT_DIPLOCATION("SW:8")
840 	PORT_DIPSETTING( 0x01, DEF_STR( Off ) )
841 	PORT_DIPSETTING( 0x00, DEF_STR( On ) )
842 
843 	PORT_START("ANALOG1")
844 	PORT_BIT( 0xfff, 0x800, IPT_PADDLE ) PORT_NAME("Steering Wheel") PORT_MINMAX(0x000, 0xfff) PORT_SENSITIVITY(100) PORT_KEYDELTA(60)
845 
846 	PORT_START("ANALOG2")
847 	PORT_BIT( 0xfff, 0x000, IPT_PEDAL ) PORT_NAME("Gas Pedal") PORT_MINMAX(0x000, 0xfff) PORT_SENSITIVITY(100) PORT_KEYDELTA(60)
848 
849 	PORT_START("ANALOG3")
850 	PORT_BIT( 0xfff, 0x000, IPT_PEDAL2 ) PORT_NAME("Brake Pedal") PORT_MINMAX(0x000, 0xfff) PORT_SENSITIVITY(100) PORT_KEYDELTA(60)
851 
852 	PORT_START("ANALOG4")
853 	PORT_BIT( 0xfff, 0x000, IPT_AD_STICK_Y ) PORT_NAME("Handbrake Lever") PORT_MINMAX(0x000, 0xfff) PORT_SENSITIVITY(100) PORT_KEYDELTA(60) PORT_REVERSE
854 
855 	PORT_START("ANALOG5")
856 	PORT_BIT( 0xfff, 0x000, IPT_PEDAL3 ) PORT_NAME("Clutch Pedal") PORT_MINMAX(0x000, 0xfff) PORT_SENSITIVITY(100) PORT_KEYDELTA(60)
857 INPUT_PORTS_END
858 
859 
860 double nwktr_state::adc12138_input_callback(uint8_t input)
861 {
862 	int value = 0;
863 	switch (input)
864 	{
865 		case 0: value = m_analog1->read(); break;
866 		case 1: value = m_analog2->read(); break;
867 		case 2: value = m_analog3->read(); break;
868 		case 3: value = m_analog4->read(); break;
869 		case 4: value = m_analog5->read(); break;
870 	}
871 
872 	return (double)(value) / 4095.0;
873 }
874 
machine_reset()875 void nwktr_state::machine_reset()
876 {
877 	m_dsp->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
878 	m_dsp2->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
879 }
880 
nwktr(machine_config & config)881 void nwktr_state::nwktr(machine_config &config)
882 {
883 	// basic machine hardware
884 	PPC403GA(config, m_maincpu, XTAL(64'000'000)/2); // PowerPC 403GA 32MHz
885 	m_maincpu->set_addrmap(AS_PROGRAM, &nwktr_state::nwktr_map);
886 
887 	M68000(config, m_audiocpu, XTAL(64'000'000)/4); // 16MHz
888 	m_audiocpu->set_addrmap(AS_PROGRAM, &nwktr_state::sound_memmap);
889 
890 	ADSP21062(config, m_dsp, XTAL(36'000'000));
891 	m_dsp->set_boot_mode(adsp21062_device::BOOT_MODE_EPROM);
892 	m_dsp->set_addrmap(AS_DATA, &nwktr_state::sharc0_map);
893 
894 	ADSP21062(config, m_dsp2, XTAL(36'000'000));
895 	m_dsp2->set_boot_mode(adsp21062_device::BOOT_MODE_EPROM);
896 	m_dsp2->set_addrmap(AS_DATA, &nwktr_state::sharc1_map);
897 
898 	config.set_maximum_quantum(attotime::from_hz(9000));
899 
900 	M48T58(config, "m48t58", 0);
901 
902 	ADC12138(config, m_adc12138, 0);
903 	m_adc12138->set_ipt_convert_callback(FUNC(nwktr_state::adc12138_input_callback));
904 
905 	K033906(config, "k033906_1", 0, "voodoo0");
906 	K033906(config, "k033906_2", 0, "voodoo1");
907 
908 	// video hardware
909 	VOODOO_1(config, m_voodoo[0], XTAL(50'000'000));
910 	m_voodoo[0]->set_fbmem(2);
911 	m_voodoo[0]->set_tmumem(2,2);
912 	m_voodoo[0]->set_screen_tag("lscreen");
913 	m_voodoo[0]->set_cpu_tag(m_dsp);
914 	m_voodoo[0]->vblank_callback().set(FUNC(nwktr_state::voodoo_vblank_0));
915 
916 	VOODOO_1(config, m_voodoo[1], XTAL(50'000'000));
917 	m_voodoo[1]->set_fbmem(2);
918 	m_voodoo[1]->set_tmumem(2,2);
919 	m_voodoo[1]->set_screen_tag("rscreen");
920 	m_voodoo[1]->set_cpu_tag(m_dsp);
921 	m_voodoo[1]->vblank_callback().set(FUNC(nwktr_state::voodoo_vblank_1));
922 
923 	screen_device &lscreen(SCREEN(config, "lscreen", SCREEN_TYPE_RASTER));
924 	// default 24KHz parameter in both 001604 and voodoo, input clock correct? (58~Hz Vsync, 50MHz/3 or 64MHz/4?)
925 	lscreen.set_raw(XTAL(64'000'000) / 4, 644, 44, 44 + 512, 450, 31, 31 + 400);
926 	lscreen.set_screen_update(FUNC(nwktr_state::screen_update_lscreen));
927 
928 	screen_device &rscreen(SCREEN(config, "rscreen", SCREEN_TYPE_RASTER)); // for unused/debug screen from slave CG board
929 	// resolution currently unknown, input clock correct? (60~Hz Vsync, 50MHz/3 or 64MHz/4?)
930 	rscreen.set_raw(XTAL(64'000'000) / 4, 644, 44, 44 + 512, 450, 31, 31 + 400);
931 	rscreen.set_screen_update(FUNC(nwktr_state::screen_update_rscreen));
932 
933 	PALETTE(config, m_palette).set_entries(65536);
934 
935 	K001604(config, m_k001604_1, 0);
936 	m_k001604_1->set_layer_size(0);
937 	m_k001604_1->set_roz_size(1);
938 	m_k001604_1->set_txt_mem_offset(0);  // correct?
939 	m_k001604_1->set_roz_mem_offset(0);  // correct?
940 	m_k001604_1->set_palette(m_palette);
941 
942 	K001604(config, m_k001604_2, 0);
943 	m_k001604_2->set_layer_size(0);
944 	m_k001604_2->set_roz_size(1);
945 	m_k001604_2->set_txt_mem_offset(0);  // correct?
946 	m_k001604_2->set_roz_mem_offset(0);  // correct?
947 	m_k001604_2->set_palette(m_palette);
948 
949 	SPEAKER(config, "lspeaker").front_left();
950 	SPEAKER(config, "rspeaker").front_right();
951 
952 	K056800(config, m_k056800, XTAL(16'934'400));
953 	m_k056800->int_callback().set_inputline(m_audiocpu, M68K_IRQ_2);
954 
955 	rf5c400_device &rfsnd(RF5C400(config, "rfsnd", XTAL(16'934'400)));  // as per Guru readme above
956 	rfsnd.add_route(0, "lspeaker", 1.0);
957 	rfsnd.add_route(1, "rspeaker", 1.0);
958 
959 	KONPPC(config, m_konppc, 0);
960 	m_konppc->set_num_boards(2);
961 	m_konppc->set_cbboard_type(konppc_device::CGBOARD_TYPE_NWKTR);
962 }
963 
thrilld(machine_config & config)964 void nwktr_state::thrilld(machine_config &config)
965 {
966 	nwktr(config);
967 
968 	m_k001604_1->set_layer_size(1);
969 
970 	m_k001604_2->set_layer_size(1);
971 }
972 
973 /*****************************************************************************/
974 
init_nwktr()975 void nwktr_state::init_nwktr()
976 {
977 	m_sharc0_dataram = std::make_unique<uint32_t[]>(0x100000 / 4);
978 	m_sharc1_dataram = std::make_unique<uint32_t[]>(0x100000 / 4);
979 
980 	lanc2_init();
981 }
982 
init_racingj()983 void nwktr_state::init_racingj()
984 {
985 	m_konppc->set_cgboard_texture_bank(0, "bank5", memregion("user5")->base());
986 	m_konppc->set_cgboard_texture_bank(0, "bank6", memregion("user6")->base()); // for some reason, additional CG roms are located on the slave CG board...
987 
988 	init_nwktr();
989 }
990 
init_thrilld()991 void nwktr_state::init_thrilld()
992 {
993 	m_konppc->set_cgboard_texture_bank(0, "bank5", memregion("user5")->base());
994 	m_konppc->set_cgboard_texture_bank(0, "bank6", memregion("user5")->base()); // ...while this is not the case for thrilld
995 
996 	init_nwktr();
997 }
998 
999 /*****************************************************************************/
1000 
1001 ROM_START(racingj)
1002 	ROM_REGION32_BE(0x200000, "user1", 0) // PowerPC program roms
1003 	ROM_LOAD16_WORD_SWAP("676gnc01.27p", 0x000000, 0x200000, CRC(690346b5) SHA1(157ab6788382ef4f5a8772f08819f54d0856fcc8) )
1004 
1005 	ROM_REGION32_BE(0x800000, "user2", 0) // Data roms
1006 	ROM_LOAD32_WORD_SWAP("676a04.16t", 0x000000, 0x200000, CRC(d7808cb6) SHA1(0668fae5bb94cc120fe196d4b18200f7b512317f) )
1007 	ROM_LOAD32_WORD_SWAP("676a05.14t", 0x000002, 0x200000, CRC(fb4de1ad) SHA1(f6aa4eb1b5d22901a2aaf899ed3237a9dfdc55b5) )
1008 
1009 	ROM_REGION32_BE(0x800000, "user5", 0) // Master CG Board texture roms
1010 	ROM_LOAD32_WORD_SWAP( "676a13.8x",  0x000000, 0x400000, CRC(29077763) SHA1(ee087ca0d41966ca0fd10727055bb1dcd05a0873) )
1011 	ROM_LOAD32_WORD_SWAP( "676a14.16x", 0x000002, 0x400000, CRC(50a7e3c0) SHA1(7468a66111a3ddf7c043cd400fa175cae5f65632) )
1012 
1013 	ROM_REGION32_BE(0x800000, "user6", 0) // Slave CG Board texture roms
1014 	ROM_LOAD32_WORD_SWAP( "676a13.8x",  0x000000, 0x400000, CRC(29077763) SHA1(ee087ca0d41966ca0fd10727055bb1dcd05a0873) )
1015 	ROM_LOAD32_WORD_SWAP( "676a14.16x", 0x000002, 0x400000, CRC(50a7e3c0) SHA1(7468a66111a3ddf7c043cd400fa175cae5f65632) )
1016 
1017 	ROM_REGION(0x80000, "audiocpu", 0) // 68k program roms
1018 	ROM_LOAD16_WORD_SWAP( "676gna08.7s", 0x000000, 0x080000, CRC(8973f6f2) SHA1(f5648a7e0205f7e979ccacbb52936809ce14a184) )
1019 
1020 	ROM_REGION16_LE(0x1000000, "rfsnd", 0) // PCM sample roms
1021 	ROM_LOAD( "676a09.16p", 0x000000, 0x400000, CRC(f85c8dc6) SHA1(8b302c80be309b5cc68b75945fcd7b87a56a4c9b) )
1022 	ROM_LOAD( "676a10.14p", 0x400000, 0x400000, CRC(7b5b7828) SHA1(aec224d62e4b1e8fdb929d7947ce70d84ba676cf) )
1023 
1024 	ROM_REGION(0x2000, "m48t58",0)
1025 	ROM_LOAD( "676jac_m48t58y.35d", 0x000000, 0x002000, CRC(47e1628c) SHA1(7c42d06ae2f2cd24d083890f333552cbf4f1d3c9) )
1026 ROM_END
1027 
1028 ROM_START(racingj2)
1029 	ROM_REGION32_BE(0x200000, "user1", 0) // PowerPC program roms
1030 	ROM_LOAD16_WORD_SWAP("888a01.27p", 0x000000, 0x200000, CRC(d077890a) SHA1(08b252324cf46fbcdb95e8f9312287920cd87c5d) )
1031 
1032 	ROM_REGION32_BE(0x800000, "user2", 0) // Data roms
1033 	ROM_LOAD32_WORD_SWAP( "676a04.16t", 0x000000, 0x200000, CRC(d7808cb6) SHA1(0668fae5bb94cc120fe196d4b18200f7b512317f) )
1034 	ROM_LOAD32_WORD_SWAP( "676a05.14t", 0x000002, 0x200000, CRC(fb4de1ad) SHA1(f6aa4eb1b5d22901a2aaf899ed3237a9dfdc55b5) )
1035 	ROM_LOAD32_WORD_SWAP( "888a06.12t", 0x400000, 0x200000, CRC(00cbec4d) SHA1(1ce7807d86e90edbf4eecba462a27c725f5ad862) )
1036 
1037 	ROM_REGION32_BE(0x800000, "user5", 0) // Master CG Board texture roms
1038 	ROM_LOAD32_WORD_SWAP( "888a13.8x",  0x000000, 0x400000, CRC(2292f530) SHA1(0f4d1332708fd5366a065e0a928cc9610558b42d) )
1039 	ROM_LOAD32_WORD_SWAP( "888a14.16x", 0x000002, 0x400000, CRC(6a834a26) SHA1(d1fbd7ae6afd05f0edac4efde12a5a45aa2bc7df) )
1040 
1041 	ROM_REGION32_BE(0x800000, "user6", 0) // Slave CG Board texture roms
1042 	ROM_LOAD32_WORD_SWAP( "888a13.8x",  0x000000, 0x400000, CRC(2292f530) SHA1(0f4d1332708fd5366a065e0a928cc9610558b42d) )
1043 	ROM_LOAD32_WORD_SWAP( "888a14.16x", 0x000002, 0x400000, CRC(6a834a26) SHA1(d1fbd7ae6afd05f0edac4efde12a5a45aa2bc7df) )
1044 
1045 	ROM_REGION(0x80000, "audiocpu", 0) // 68k program roms
1046 	ROM_LOAD16_WORD_SWAP( "888a08.7s", 0x000000, 0x080000, CRC(55fbea65) SHA1(ad953f758181731efccadcabc4326e6634c359e8) )
1047 
1048 	ROM_REGION16_LE(0x1000000, "rfsnd", 0) // PCM sample roms
1049 	ROM_LOAD( "888a09.16p",   0x000000, 0x400000, CRC(11e2fed2) SHA1(24b8a367b59fedb62c56f066342f2fa87b135fc5) )
1050 	ROM_LOAD( "888a10.14p",   0x400000, 0x400000, CRC(328ce610) SHA1(dbbc779a1890c53298c0db129d496df048929496) )
1051 
1052 	ROM_REGION( 0x0000084, "laneeprom", 0 )
1053 	ROM_LOAD( "ge888ea.2g",   0x000000, 0x000084, NO_DUMP )
1054 
1055 	ROM_REGION(0x2000, "m48t58",0)
1056 	ROM_LOAD( "676eae_m48t58y.35d", 0x000000, 0x002000, CRC(f691f5ab) SHA1(e81f652c5caa2caa8bd1c6d6db488d849bda058e) )
1057 ROM_END
1058 
1059 ROM_START(racingj2j)
1060 	ROM_REGION32_BE(0x200000, "user1", 0) // PowerPC program roms
1061 	ROM_LOAD16_WORD_SWAP("888a01.27p", 0x000000, 0x200000, CRC(d077890a) SHA1(08b252324cf46fbcdb95e8f9312287920cd87c5d) )
1062 
1063 	ROM_REGION32_BE(0x800000, "user2", 0) // Data roms
1064 	ROM_LOAD32_WORD_SWAP( "676a04.16t", 0x000000, 0x200000, CRC(d7808cb6) SHA1(0668fae5bb94cc120fe196d4b18200f7b512317f) )
1065 	ROM_LOAD32_WORD_SWAP( "676a05.14t", 0x000002, 0x200000, CRC(fb4de1ad) SHA1(f6aa4eb1b5d22901a2aaf899ed3237a9dfdc55b5) )
1066 	ROM_LOAD32_WORD_SWAP( "888a06.12t", 0x400000, 0x200000, CRC(00cbec4d) SHA1(1ce7807d86e90edbf4eecba462a27c725f5ad862) )
1067 
1068 	ROM_REGION32_BE(0x800000, "user5", 0) // Master CG Board texture roms
1069 	ROM_LOAD32_WORD_SWAP( "888a13.8x",  0x000000, 0x400000, CRC(2292f530) SHA1(0f4d1332708fd5366a065e0a928cc9610558b42d) )
1070 	ROM_LOAD32_WORD_SWAP( "888a14.16x", 0x000002, 0x400000, CRC(6a834a26) SHA1(d1fbd7ae6afd05f0edac4efde12a5a45aa2bc7df) )
1071 
1072 	ROM_REGION32_BE(0x800000, "user6", 0) // Slave CG Board texture roms
1073 	ROM_LOAD32_WORD_SWAP( "888a13.8x",  0x000000, 0x400000, CRC(2292f530) SHA1(0f4d1332708fd5366a065e0a928cc9610558b42d) )
1074 	ROM_LOAD32_WORD_SWAP( "888a14.16x", 0x000002, 0x400000, CRC(6a834a26) SHA1(d1fbd7ae6afd05f0edac4efde12a5a45aa2bc7df) )
1075 
1076 	ROM_REGION(0x80000, "audiocpu", 0) // 68k program roms
1077 	ROM_LOAD16_WORD_SWAP( "888a08.7s", 0x000000, 0x080000, CRC(55fbea65) SHA1(ad953f758181731efccadcabc4326e6634c359e8) )
1078 
1079 	ROM_REGION16_LE(0x1000000, "rfsnd", 0) // PCM sample roms
1080 	ROM_LOAD( "888a09.16p", 0x000000, 0x400000, CRC(11e2fed2) SHA1(24b8a367b59fedb62c56f066342f2fa87b135fc5) )
1081 	ROM_LOAD( "888a10.14p", 0x400000, 0x400000, CRC(328ce610) SHA1(dbbc779a1890c53298c0db129d496df048929496) )
1082 
1083 	ROM_REGION( 0x0000084, "laneeprom", 0 )
1084 	ROM_LOAD( "ge888ja.2g",   0x000000, 0x000084, NO_DUMP )
1085 
1086 	ROM_REGION(0x2000, "m48t58",0)
1087 	ROM_LOAD( "676jae_m48t58y.35d", 0x000000, 0x002000, CRC(1aa43a1f) SHA1(814b691b8a358bf1545a13d595d17070e612e9a4) )
1088 ROM_END
1089 
1090 ROM_START(thrilld)
1091 	ROM_REGION32_BE(0x200000, "user1", 0) // PowerPC program roms
1092 	ROM_LOAD16_WORD_SWAP("713be01.27p", 0x000000, 0x200000, CRC(d84a7723) SHA1(f4e9e08591b7e5e8419266dbe744d56a185384ed) )
1093 
1094 	ROM_REGION32_BE(0x800000, "user2", 0) // Data roms
1095 	ROM_LOAD32_WORD_SWAP("713a04.16t", 0x000000, 0x200000, CRC(c994aaa8) SHA1(d82b9930a11e5384ad583684a27c95beec03cd5a) )
1096 	ROM_LOAD32_WORD_SWAP("713a05.14t", 0x000002, 0x200000, CRC(6f1e6802) SHA1(91f8a170327e9b4ee6a64aee0c106b981a317e69) )
1097 
1098 	ROM_REGION32_BE(0x800000, "user5", 0) // CG Board texture roms
1099 	ROM_LOAD32_WORD_SWAP( "713a13.8x",    0x000000, 0x400000, CRC(b795c66b) SHA1(6e50de0d5cc444ffaa0fec7ada8c07f643374bb2) )
1100 	ROM_LOAD32_WORD_SWAP( "713a14.16x",   0x000002, 0x400000, CRC(5275a629) SHA1(16fadef06975f0f3625cac8f84e2e77ed7d75e15) )
1101 
1102 	ROM_REGION(0x80000, "audiocpu", 0) // 68k program roms
1103 	ROM_LOAD16_WORD_SWAP( "713a08.7s", 0x000000, 0x080000, CRC(6a72a825) SHA1(abeac99c5343efacabcb0cdff6d34f9f967024db) )
1104 
1105 	ROM_REGION16_LE(0x1000000, "rfsnd", 0) // PCM sample roms
1106 	ROM_LOAD( "713a09.16p", 0x000000, 0x400000, CRC(058f250a) SHA1(63b8e60004ec49009633e86b4992c00083def9a8) )
1107 	ROM_LOAD( "713a10.14p", 0x400000, 0x400000, CRC(27f9833e) SHA1(1540f00d2571ecb81b914c553682b67fca94bbbd) )
1108 
1109 	ROM_REGION( 0x0000084, "laneeprom", 0 )
1110 	ROM_LOAD( "gc713jc.2g",   0x000000, 0x000084, NO_DUMP )
1111 
1112 	ROM_REGION(0x2000, "m48t58",0)
1113 	ROM_LOAD( "713jae_m48t58y.35d", 0x000000, 0x002000, CRC(5d8fbcb2) SHA1(74ad91544d2a200cf599a565005476623075e7d6) )
1114 ROM_END
1115 
1116 ROM_START(thrilldb)
1117 	ROM_REGION32_BE(0x200000, "user1", 0) // PowerPC program roms
1118 	ROM_LOAD16_WORD_SWAP("713bb01.27p", 0x000000, 0x200000, CRC(535fe4e8) SHA1(acd8194a4dafce289dbdfd874f0b799f25aeb73f) )
1119 
1120 	ROM_REGION32_BE(0x800000, "user2", 0) // Data roms
1121 	ROM_LOAD32_WORD_SWAP("713a04.16t", 0x000000, 0x200000, CRC(c994aaa8) SHA1(d82b9930a11e5384ad583684a27c95beec03cd5a) )
1122 	ROM_LOAD32_WORD_SWAP("713a05.14t", 0x000002, 0x200000, CRC(6f1e6802) SHA1(91f8a170327e9b4ee6a64aee0c106b981a317e69) )
1123 
1124 	ROM_REGION32_BE(0x800000, "user5", 0) // CG Board texture roms
1125 	ROM_LOAD32_WORD_SWAP( "713a13.8x",  0x000000, 0x400000, CRC(b795c66b) SHA1(6e50de0d5cc444ffaa0fec7ada8c07f643374bb2) )
1126 	ROM_LOAD32_WORD_SWAP( "713a14.16x", 0x000002, 0x400000, CRC(5275a629) SHA1(16fadef06975f0f3625cac8f84e2e77ed7d75e15) )
1127 
1128 	ROM_REGION(0x80000, "audiocpu", 0) // 68k program roms
1129 	ROM_LOAD16_WORD_SWAP( "713a08.7s", 0x000000, 0x080000, CRC(6a72a825) SHA1(abeac99c5343efacabcb0cdff6d34f9f967024db) )
1130 
1131 	ROM_REGION16_LE(0x1000000, "rfsnd", 0) // PCM sample roms
1132 	ROM_LOAD( "713a09.16p", 0x000000, 0x400000, CRC(058f250a) SHA1(63b8e60004ec49009633e86b4992c00083def9a8) )
1133 	ROM_LOAD( "713a10.14p", 0x400000, 0x400000, CRC(27f9833e) SHA1(1540f00d2571ecb81b914c553682b67fca94bbbd) )
1134 
1135 	ROM_REGION( 0x0000084, "laneeprom", 0 )
1136 	ROM_LOAD( "gc713jc.2g",   0x000000, 0x000084, NO_DUMP )
1137 
1138 	ROM_REGION(0x2000, "m48t58",0)
1139 	ROM_LOAD( "713jab_m48t58y.35d", 0x000000, 0x002000, CRC(5d8fbcb2) SHA1(74ad91544d2a200cf599a565005476623075e7d6) )
1140 ROM_END
1141 
1142 ROM_START(thrilldbe)
1143 	ROM_REGION32_BE(0x200000, "user1", 0) // PowerPC program roms
1144 	ROM_LOAD16_WORD_SWAP("713bb01.27p", 0x000000, 0x200000, CRC(535fe4e8) SHA1(acd8194a4dafce289dbdfd874f0b799f25aeb73f) )
1145 
1146 	ROM_REGION32_BE(0x800000, "user2", 0) // Data roms
1147 	ROM_LOAD32_WORD_SWAP("713a04.16t", 0x000000, 0x200000, CRC(c994aaa8) SHA1(d82b9930a11e5384ad583684a27c95beec03cd5a) )
1148 	ROM_LOAD32_WORD_SWAP("713a05.14t", 0x000002, 0x200000, CRC(6f1e6802) SHA1(91f8a170327e9b4ee6a64aee0c106b981a317e69) )
1149 
1150 	ROM_REGION32_BE(0x800000, "user5", 0) // CG Board texture roms
1151 	ROM_LOAD32_WORD_SWAP( "713a13.8x",  0x000000, 0x400000, CRC(b795c66b) SHA1(6e50de0d5cc444ffaa0fec7ada8c07f643374bb2) )
1152 	ROM_LOAD32_WORD_SWAP( "713a14.16x", 0x000002, 0x400000, CRC(5275a629) SHA1(16fadef06975f0f3625cac8f84e2e77ed7d75e15) )
1153 
1154 	ROM_REGION(0x80000, "audiocpu", 0) // 68k program roms
1155 	ROM_LOAD16_WORD_SWAP( "713a08.7s", 0x000000, 0x080000, CRC(6a72a825) SHA1(abeac99c5343efacabcb0cdff6d34f9f967024db) )
1156 
1157 	ROM_REGION16_LE(0x1000000, "rfsnd", 0) // PCM sample roms
1158 	ROM_LOAD( "713a09.16p", 0x000000, 0x400000, CRC(058f250a) SHA1(63b8e60004ec49009633e86b4992c00083def9a8) )
1159 	ROM_LOAD( "713a10.14p", 0x400000, 0x400000, CRC(27f9833e) SHA1(1540f00d2571ecb81b914c553682b67fca94bbbd) )
1160 
1161 	ROM_REGION( 0x0000084, "laneeprom", 0 )
1162 	ROM_LOAD( "gc713ec.2g",   0x000000, 0x000084, NO_DUMP )
1163 
1164 	ROM_REGION(0x2000, "m48t58",0)
1165 	ROM_LOAD( "713eaa_m48t58y.35d", 0x000000, 0x002000, CRC(056ea8fa) SHA1(23574e0c1d011dab8644f3d98763d4a2d11a05b3)  )
1166 ROM_END
1167 
1168 /*****************************************************************************/
1169 
1170 #define GAME_FLAGS (MACHINE_NOT_WORKING | MACHINE_IMPERFECT_GRAPHICS | MACHINE_IMPERFECT_SOUND | MACHINE_NODEVICE_LAN )
1171 
1172 GAME( 1998, racingj,    0,       nwktr,   nwktr, nwktr_state, init_racingj, ROT0, "Konami", "Racing Jam (JAC)",            GAME_FLAGS )
1173 GAME( 1998, racingj2,   racingj, nwktr,   nwktr, nwktr_state, init_racingj, ROT0, "Konami", "Racing Jam: Chapter 2 (EAE)", GAME_FLAGS )
1174 GAME( 1998, racingj2j,  racingj, nwktr,   nwktr, nwktr_state, init_racingj, ROT0, "Konami", "Racing Jam: Chapter 2 (JAE)", GAME_FLAGS )
1175 GAME( 1998, thrilld,    0,       thrilld, nwktr, nwktr_state, init_thrilld, ROT0, "Konami", "Thrill Drive (JAE)",          GAME_FLAGS )
1176 GAME( 1998, thrilldb,   thrilld, thrilld, nwktr, nwktr_state, init_thrilld, ROT0, "Konami", "Thrill Drive (JAB)",          GAME_FLAGS )
1177 GAME( 1998, thrilldbe,  thrilld, thrilld, nwktr, nwktr_state, init_thrilld, ROT0, "Konami", "Thrill Drive (EAB)",          GAME_FLAGS )
1178