/
seattle.cpp
3056 lines (2492 loc) · 111 KB
/
seattle.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/*************************************************************************
Driver for Atari/Midway Phoenix/Seattle/Flagstaff hardware games
driver by Aaron Giles
Games supported:
* Wayne Gretzky's 3d Hockey [Phoenix, Atari, 100MHz, 4MB RAM, 1xTMU]
* Bio Freaks [Seattle, Midway, 150MHz, 8MB RAM, 1xTMU]
* CarnEvil [Seattle, Midway, 150MHz, 8MB RAM, 1xTMU]
* NFL Blitz [Seattle, Midway, 150MHz, 8MB RAM, 1xTMU]
* NFL Blitz 99 [Seattle, Midway, 150MHz, 8MB RAM, 1xTMU]
* NFL Blitz 2000 [Seattle, Midway, 150MHz, 8MB RAM, 1xTMU]
* Mace: The Dark Age [Seattle, Atari, 192MHz, 8MB RAM, 1xTMU]
* California Speed [Seattle + Widget, Atari, 150MHz, 8MB RAM, 1xTMU]
* Vapor TRX [Seattle + Widget, Atari, 192MHz, 8MB RAM, 1xTMU]
* Hyperdrive [Seattle + Widget, Midway, 192MHz, 8MB RAM, 1xTMU]
* San Francisco Rush [Flagstaff, Atari, 192MHz, 2xTMU]
* San Francisco Rush: The Rock [Flagstaff, Atari, 192MHz, 8MB RAM, 2xTMU]
Known bugs:
* Carnevil: lets you set the flash brightness; need to emulate that
***************************************************************************
Phoenix hardware main board:
* 100MHz R4700 main CPU (50MHz system clock)
* Galileo GT64010 system controller
* National Semiconductor PC87415 IDE controller
* 3dfx FBI with 2MB frame buffer
* 3dfx TMU with 4MB texture memory
* Midway I/O ASIC
* 4MB DRAM for main CPU
* 512KB boot ROM
* 16MHz ADSP 2115 audio CPU
* 4MB DRAM for audio CPU
* 32KB boot ROM
Seattle hardware main board:
* 144MHz/192MHz/ R5000 main CPU (system clock 48MHz)
* Galileo GT64010 system controller
* National Semiconductor PC87415 IDE controller
* 3dfx FBI with 2MB frame buffer
* 3dfx TMU with 4MB texture memory
* Midway I/O ASIC
* 8MB DRAM for main CPU
* 512KB boot ROM
* 16MHz ADSP 2115 audio CPU
* 4MB DRAM for audio CPU
* 32KB boot ROM
Flagstaff hardware main board:
* 192MHz R5000 main CPU (system clock 48MHz)
* Galileo GT64010 system controller
* National Semiconductor PC87415 IDE controller
* SMC91C94 ethernet controller
* ADC0848 8 x A-to-D converters
* 3dfx FBI with 2MB frame buffer
* 2 x 3dfx TMU with 4MB texture memory
* Midway I/O ASIC
* 8MB DRAM for main CPU
* 512KB boot ROM
* 33MHz TMS32C031 audio CPU
* 8MB ROM space for audio CPU
* 512KB boot ROM
Widget board:
* SMC91C94 ethernet controller
* ADC0848 8 x A-to-D converters
***************************************************************************
Blitz '99 board:
Seattle 5770-15206-08
1x R5000 CPU (heatsink covering part numbers)
1x Midway 5410-14589-00 IO chip
1x Midway 5410-14590-00 ??
1x Midway 5410-15349-00 Orbit 61142A ??
1x ADSP-2115
1x Midway security PIC Blitz 99 25" 481xxxxxx (U96)
1x mid sized QFP (Galileo?) has heatsink (u86)
1x mid sized QFP (PixelFX?) heatsink (u17)
1x mid sized QFP, smaller (TexelFX?) heatsink (u87)
12x v53c16258hk40 256Kx16 RAM (near Voodoo section)
1x PC87415VCG IDE controller
1x lh52256cn-70ll RAM (near Galileo)
1x 7can2 4k (unknown Texas Instruments SOIC)
2x IDT 7201 LA 35J (512x9 Async FIFO)
1x DS232AS serial port chip
1x Altera PLCC Seattle A-21859 (u50)
1x Altera PLCC PAD_C1 (u60)
3x IS61C256AH-15 (32Kx8 SRAM) near ADSP
1x TMS418160ADZ (1Meg x 16 RAM) near ADSP
4x TMS418160ADZ (1Meg x 16 RAM) near CPU
1x TVP3409-17OCFN (3dfx DAC?)
1xAD1866 audio DAC
1x Maxim max693acwe (watchdog) near 2325 battery and Midway IO chip
4MHz crystal attached to security PIC
14.31818MHz crystal near 3dfx DAC
16MHz crystal attached to ADSP
16.6667MHz crystal near Midway IO chip
33.3333MHz crystal near IDE chip and Galileo(PCI bus I assume)
50MHz crystal near CPU
Boot ROM-1.3
Sound ROM-1.02
Connectors:
P2 and P6 look like PCI slots, but with no connectors soldered in, near
3dfx/Galileo/IDE section.
P19 is for the Daisy Dukes widget board(used by Cal Speed), and maybe
the Carnevil gun board.
P28 is a large 120 pin connector that is not populated, right next to
the CPU.
P20 is a 10 pin connector labeled "factory test".
P1 is a 5 pin unpopulated connector marked "snd in" no idea what it
would be for.
P11 is a 5 pin connector marked "snd out" for line level stereo output.
P25 is a standard IDE connector marked "Disk Drive" P15 is a laptop
sized IDE connection right next to it.
P9 and P10 are 14 pin connectors marked "Player 3 I/O" and player 4
respectively.
P16 is a 6 pin marked "Aux in"
P3 is a 6 pin marked "Bill in"
P8 is a 14 pin marked "Aux Latched Outputs"
P22 is a 9 pin marked "serial port"
***************************************************************************
Interrupt summary:
__________
UART clear-to-send | | __________
-------(0x2000)--->| | Ethernet/Widget | |
| | ----(IRQ3/4/5)-->| |
UART data ready | | | |
-------(0x1000)--->| | | |
| | VSYNC | |
Main-to-sound empty| IOASIC | ----(IRQ3/4/5)-->| |
-------(0x0080)--->| | | |
| | | |
Sound-to-main full | | IDE Controller | CPU |
-------(0x0040)--->| | -------(IRQ2)--->| |
| | | |
Sound FIFO empty | | | |
-------(0x0008)--->| | IOASIC Summary | |
|__________|----------(IRQ1)--->| |
| |
__________ | |
Timer 3 | | Galileo Summary | |
-------(0x0800)--->| |----------(IRQ0)--->| |
| | |__________|
Timer 2 | |
-------(0x0400)--->| |
| |
Timer 1 | |
-------(0x0200)--->| |
| |
Timer 0 | |
-------(0x0100)--->| |
| Galileo |
DMA channel 3 | |
-------(0x0080)--->| |
| |
DMA channel 2 | |
-------(0x0040)--->| |
| |
DMA channel 1 | |
-------(0x0020)--->| |
| |
DMA channel 0 | |
-------(0x0010)--->| |
|__________|
**************************************************************************/
#include "emu.h"
#include "midwayic.h"
#include "cage.h"
#include "dcs.h"
#include "bus/ata/hdd.h"
#include "cpu/adsp2100/adsp2100.h"
#include "cpu/mips/mips3.h"
#include "machine/gt64xxx.h"
#include "machine/nvram.h"
#include "machine/pci-ide.h"
#include "machine/pci.h"
#include "machine/smc91c9x.h"
#include "video/voodoo_pci.h"
#include "screen.h"
#include "speaker.h"
#include "calspeed.lh"
#include "vaportrx.lh"
#include "hyprdriv.lh"
#include "sfrush.lh"
#define LOG_WIDGET (1U << 1)
#define VERBOSE (0)
#include "logmacro.h"
namespace {
/*************************************
*
* Core constants
*
*************************************/
#define SYSTEM_CLOCK 50000000
#define PCI_ID_GALILEO "pci:00.0"
#define PCI_ID_VIDEO "pci:08.0"
#define PCI_ID_IDE "pci:09.0"
// various board configurations
#define PHOENIX_CONFIG (0)
#define SEATTLE_CONFIG (1)
#define SEATTLE_WIDGET_CONFIG (2)
#define FLAGSTAFF_CONFIG (3)
// static interrupts
#define GALILEO_IRQ_NUM MIPS3_IRQ0
#define IOASIC_IRQ_NUM MIPS3_IRQ1
#define IDE_IRQ_NUM MIPS3_IRQ2
// configurable interrupts
#define ETHERNET_IRQ_SHIFT (1)
#define WIDGET_IRQ_SHIFT (1)
#define VBLANK_IRQ_SHIFT (7)
/*************************************
*
* Widget board constants
*
*************************************/
// Widget registers
#define WREG_ETHER_ADDR (0x00/4)
#define WREG_INTERRUPT (0x04/4)
#define WREG_OUTPUT (0x0C/4)
#define WREG_ANALOG (0x10/4)
#define WREG_ETHER_DATA (0x14/4)
// Widget interrupts
#define WINT_ETHERNET_SHIFT (2)
/*************************************
* Structures
*************************************/
class seattle_state : public driver_device
{
public:
seattle_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_nvram(*this, "nvram"),
m_maincpu(*this, "maincpu"),
m_galileo(*this, PCI_ID_GALILEO),
m_voodoo(*this, PCI_ID_VIDEO),
m_cage(*this, "cage"),
m_dcs(*this, "dcs"),
m_screen(*this, "screen"),
m_ethernet(*this, "ethernet"),
m_ioasic(*this, "ioasic"),
m_io_analog(*this, "AN%u", 0U),
m_io_p4_8way(*this, "8WAY_P4"),
m_io_49way_x(*this, "49WAYX_P%u", 1U),
m_io_49way_y(*this, "49WAYY_P%u", 1U),
m_io_gun_x(*this, "LIGHT%u_X", 0U),
m_io_gun_y(*this, "LIGHT%u_Y", 0U),
m_io_fake(*this, "FAKE"),
m_io_gearshift(*this, "GEAR"),
m_io_system(*this, "SYSTEM"),
m_io_dips(*this, "DIPS"),
m_wheel_driver(*this, "wheel"),
m_wheel_motor(*this, "wheel_motor"),
m_lamps(*this, "lamp%u", 0U),
m_leds(*this, "led%u", 0U)
{
}
void seattle_common(machine_config &config);
void phoenix(machine_config &config);
void seattle150(machine_config &config);
void seattle150_widget(machine_config &config);
void seattle200(machine_config &config);
void seattle200_widget(machine_config &config);
void flagstaff(machine_config &config);
void wg3dh(machine_config &config);
void sfrush(machine_config &config);
void hyprdriv(machine_config &config);
void carnevil(machine_config &config);
void blitz99(machine_config &config);
void blitz2k(machine_config &config);
void blitz(machine_config &config);
void biofreak(machine_config &config);
void sfrushrkw(machine_config &config);
void calspeed(machine_config &config);
void mace(machine_config &config);
void vaportrx(machine_config &config);
void sfrushrk(machine_config &config);
void init_sfrush();
void init_blitz2k();
void init_carnevil();
void init_biofreak();
void init_calspeed();
void init_sfrushrk();
void init_vaportrx();
void init_hyprdriv();
void init_blitz();
void init_wg3dh();
void init_mace();
void init_blitz99();
DECLARE_CUSTOM_INPUT_MEMBER(blitz_49way_r);
DECLARE_CUSTOM_INPUT_MEMBER(i40_r);
DECLARE_CUSTOM_INPUT_MEMBER(gearshift_r);
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
private:
required_device<nvram_device> m_nvram;
required_device<mips3_device> m_maincpu;
required_device<gt64010_device> m_galileo;
required_device<voodoo_1_pci_device> m_voodoo;
optional_device<atari_cage_seattle_device> m_cage;
optional_device<dcs_audio_device> m_dcs;
required_device<screen_device> m_screen;
optional_device<smc91c94_device> m_ethernet;
required_device<midway_ioasic_device> m_ioasic;
optional_ioport_array<8> m_io_analog;
optional_ioport m_io_p4_8way;
optional_ioport_array<4> m_io_49way_x;
optional_ioport_array<4> m_io_49way_y;
optional_ioport_array<2> m_io_gun_x;
optional_ioport_array<2> m_io_gun_y;
optional_ioport m_io_fake;
optional_ioport m_io_gearshift;
optional_ioport m_io_system;
optional_ioport m_io_dips;
output_finder<> m_wheel_driver;
output_finder<> m_wheel_motor;
output_finder<16> m_lamps;
output_finder<24> m_leds;
static const uint8_t translate49[7];
struct widget_data
{
// ethernet register address
uint8_t ethernet_addr;
// IRQ information
uint8_t irq_num;
uint8_t irq_mask;
};
widget_data m_widget;
uint32_t m_interrupt_enable;
uint32_t m_interrupt_config;
uint32_t m_asic_reset;
std::vector<uint32_t> m_nvram_data;
uint8_t m_board_config;
uint8_t m_ethernet_irq_num;
uint8_t m_ethernet_irq_state;
uint8_t m_vblank_irq_num;
uint8_t m_vblank_latch;
uint8_t m_vblank_state;
uint8_t m_pending_analog_read;
uint8_t m_status_leds;
uint32_t m_cmos_write_enabled;
uint16_t m_output_last;
uint8_t m_output_mode;
uint32_t m_i40_data;
uint32_t m_gear;
int8_t m_wheel_force;
int m_wheel_offset;
bool m_wheel_calibrated;
uint32_t interrupt_state_r();
uint32_t interrupt_state2_r();
uint32_t interrupt_config_r();
void interrupt_config_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
uint32_t seattle_interrupt_enable_r();
void seattle_interrupt_enable_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
void vblank_clear_w(uint32_t data);
uint32_t analog_port_r();
void analog_port_w(uint32_t data);
uint32_t carnevil_gun_r(offs_t offset);
void carnevil_gun_w(offs_t offset, uint32_t data);
void cmos_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
uint32_t cmos_r(offs_t offset);
void cmos_protect_w(uint32_t data);
uint32_t cmos_protect_r();
void seattle_watchdog_w(uint32_t data);
uint32_t asic_reset_r();
void asic_reset_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
void asic_fifo_w(uint32_t data);
uint32_t status_leds_r();
void status_leds_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
uint32_t ethernet_r(offs_t offset, uint32_t mem_mask = ~0);
void ethernet_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
uint32_t output_r();
void output_w(uint32_t data);
uint32_t widget_r(offs_t offset, uint32_t mem_mask = ~0);
void widget_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
void i40_w(uint32_t data);
void wheel_board_w(offs_t offset, uint32_t data);
void ide_interrupt(int state);
void vblank_assert(int state);
void ethernet_interrupt(int state);
void ioasic_irq(int state);
void update_vblank_irq();
void update_galileo_irqs();
void widget_reset();
void update_widget_irq();
void init_common(int config);
void seattle_cs0_map(address_map &map);
void seattle_cs1_map(address_map &map);
void seattle_cs2_map(address_map &map);
void seattle_cs3_map(address_map &map);
void widget_cs3_map(address_map &map);
void carnevil_cs3_map(address_map &map);
void flagstaff_cs3_map(address_map &map);
static void hdd_config(device_t *device);
};
/*************************************
*
* Machine init
*
*************************************/
void seattle_state::machine_start()
{
// set the fastest DRC options, but strict verification
m_maincpu->mips3drc_set_options(MIPS3DRC_FASTEST_OPTIONS | MIPS3DRC_STRICT_VERIFY);
// configure fast RAM regions
// m_maincpu->add_fastram(0x00000000, 0x007fffff, FALSE, m_rambase);
// m_maincpu->add_fastram(0x1fc00000, 0x1fc7ffff, TRUE, m_rombase);
save_item(NAME(m_widget.ethernet_addr));
save_item(NAME(m_widget.irq_num));
save_item(NAME(m_widget.irq_mask));
save_item(NAME(m_interrupt_enable));
save_item(NAME(m_interrupt_config));
save_item(NAME(m_asic_reset));
save_item(NAME(m_board_config));
save_item(NAME(m_ethernet_irq_num));
save_item(NAME(m_ethernet_irq_state));
save_item(NAME(m_vblank_irq_num));
save_item(NAME(m_vblank_latch));
save_item(NAME(m_vblank_state));
save_item(NAME(m_pending_analog_read));
save_item(NAME(m_status_leds));
save_item(NAME(m_cmos_write_enabled));
save_item(NAME(m_output_last));
save_item(NAME(m_output_mode));
save_item(NAME(m_i40_data));
save_item(NAME(m_gear));
save_item(NAME(m_wheel_calibrated));
m_wheel_driver.resolve();
m_wheel_motor.resolve();
m_lamps.resolve();
m_leds.resolve();
m_pending_analog_read = 0;
m_ethernet_irq_state = 0;
m_widget.ethernet_addr = 0;
m_widget.irq_num = 0;
m_widget.irq_mask = 0;
}
void seattle_state::machine_reset()
{
m_vblank_state = 0;
m_vblank_irq_num = 0;
m_interrupt_config = 0;
m_interrupt_enable = 0;
m_gear = 1;
m_wheel_force = 0;
m_wheel_offset = 0;
m_wheel_calibrated = false;
m_ethernet_irq_num = 0;
// reset either the DCS2 board or the CAGE board
if (m_dcs != nullptr)
{
m_dcs->reset_w(0);
m_dcs->reset_w(1);
}
else if (m_cage != nullptr)
{
m_cage->control_w(0);
m_cage->control_w(3);
}
if (m_board_config == SEATTLE_WIDGET_CONFIG)
widget_reset();
}
/*************************************
*
* Ethernet interrupts
*
*************************************/
void seattle_state::ethernet_interrupt(int state)
{
m_ethernet_irq_state = state;
if (m_board_config == FLAGSTAFF_CONFIG)
{
uint8_t assert = m_ethernet_irq_state && (m_interrupt_enable & (1 << ETHERNET_IRQ_SHIFT));
if (m_ethernet_irq_num != 0)
m_maincpu->set_input_line(m_ethernet_irq_num, assert ? ASSERT_LINE : CLEAR_LINE);
}
else if (m_board_config == SEATTLE_WIDGET_CONFIG)
update_widget_irq();
}
/*************************************
*
* I/O ASIC interrupts
*
*************************************/
void seattle_state::ioasic_irq(int state)
{
m_maincpu->set_input_line(IOASIC_IRQ_NUM, state);
}
/*************************************
*
* Configurable interrupts
*
*************************************/
uint32_t seattle_state::interrupt_state_r()
{
uint32_t result = 0;
result |= m_ethernet_irq_state << ETHERNET_IRQ_SHIFT;
result |= m_vblank_latch << VBLANK_IRQ_SHIFT;
return result;
}
uint32_t seattle_state::interrupt_state2_r()
{
uint32_t result = interrupt_state_r();
result |= m_vblank_state << 8;
return result;
}
uint32_t seattle_state::interrupt_config_r()
{
return m_interrupt_config;
}
void seattle_state::interrupt_config_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
int irq;
COMBINE_DATA(&m_interrupt_config);
//logerror("interrupt_config_w: m_interrupt_config=%08x\n", m_interrupt_config);
// VBLANK: clear anything pending on the old IRQ
if (m_vblank_irq_num != 0)
m_maincpu->set_input_line(m_vblank_irq_num, CLEAR_LINE);
// VBLANK: compute the new IRQ vector
irq = (m_interrupt_config >> (2 * VBLANK_IRQ_SHIFT)) & 3;
m_vblank_irq_num = (irq != 0) ? (2 + irq) : 0;
// Widget board case
if (m_board_config == SEATTLE_WIDGET_CONFIG)
{
// Widget: clear anything pending on the old IRQ
if (m_widget.irq_num != 0)
m_maincpu->set_input_line(m_widget.irq_num, CLEAR_LINE);
// Widget: compute the new IRQ vector
irq = (m_interrupt_config >> (2 * WIDGET_IRQ_SHIFT)) & 3;
m_widget.irq_num = (irq != 0) ? (2 + irq) : 0;
}
// Flagstaff board case
if (m_board_config == FLAGSTAFF_CONFIG)
{
// Ethernet: clear anything pending on the old IRQ
if (m_ethernet_irq_num != 0)
m_maincpu->set_input_line(m_ethernet_irq_num, CLEAR_LINE);
// Ethernet: compute the new IRQ vector
irq = (m_interrupt_config >> (2 * ETHERNET_IRQ_SHIFT)) & 3;
m_ethernet_irq_num = (irq != 0) ? (2 + irq) : 0;
}
// update the states
update_vblank_irq();
ethernet_interrupt(m_ethernet_irq_state);
}
uint32_t seattle_state::seattle_interrupt_enable_r()
{
return m_interrupt_enable;
}
void seattle_state::seattle_interrupt_enable_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
uint32_t old = m_interrupt_enable;
COMBINE_DATA(&m_interrupt_enable);
if (old != m_interrupt_enable)
{
if (m_vblank_latch)
update_vblank_irq();
if (m_ethernet_irq_state)
ethernet_interrupt(m_ethernet_irq_state);
//logerror("seattle_state::seattle_interrupt_enable_w = %08X m_interrupt_config=%08X\n", m_interrupt_enable, m_interrupt_config);
}
}
/*************************************
*
* VBLANK interrupts
*
*************************************/
void seattle_state::update_vblank_irq()
{
int state = CLEAR_LINE;
// skip if no interrupt configured
if (m_vblank_irq_num == 0)
return;
// if the VBLANK has been latched, and the interrupt is enabled, assert
if (m_vblank_latch && (m_interrupt_enable & (1 << VBLANK_IRQ_SHIFT))) {
state = ASSERT_LINE;
}
m_maincpu->set_input_line(m_vblank_irq_num, state);
//logerror("seattle_state::update_vblank_irq(%i)\n", state);
}
void seattle_state::vblank_clear_w(uint32_t data)
{
// clear the latch and update the IRQ
m_vblank_latch = 0;
update_vblank_irq();
}
void seattle_state::vblank_assert(int state)
{
// cache the raw state
m_vblank_state = state;
// latch on the correct polarity transition
if ((state && !(m_interrupt_enable & 0x100)) || (!state && (m_interrupt_enable & 0x100)))
{
m_vblank_latch = 1;
update_vblank_irq();
}
}
/*************************************
*
* Analog input handling (ADC0848)
*
*************************************/
uint32_t seattle_state::analog_port_r()
{
return m_pending_analog_read;
}
void seattle_state::analog_port_w(uint32_t data)
{
if (data < 8 || data > 15)
logerror("%08X:Unexpected analog port select = %08X\n", m_maincpu->pc(), data);
int index = data & 7;
uint8_t currValue = m_io_analog[index].read_safe(0);
if (!m_wheel_calibrated && ((m_wheel_force > 20) || (m_wheel_force < -20))) {
if (m_wheel_force > 0 && m_wheel_offset < 128)
m_wheel_offset++;
else if (m_wheel_offset > -128)
m_wheel_offset--;
int tmpVal = int(currValue) + m_wheel_offset;
if (tmpVal < m_io_analog[index]->field(0xff)->minval())
m_pending_analog_read = m_io_analog[index]->field(0xff)->minval();
else if (tmpVal > m_io_analog[index]->field(0xff)->maxval())
m_pending_analog_read = m_io_analog[index]->field(0xff)->maxval();
else
m_pending_analog_read = tmpVal;
}
else {
m_pending_analog_read = currValue;
}
// Declare calibration finished as soon as a SYSTEM button is hit
if (!m_wheel_calibrated && ((~m_io_system->read()) & 0xffff)) {
m_wheel_calibrated = true;
//osd_printf_info("wheel calibration complete system: %04x wheel: %02x\n", m_io_system->read(), currValue);
}
}
/*************************************
*
* Wheelboard output module
*
*************************************/
void seattle_state::wheel_board_w(offs_t offset, uint32_t data)
{
//logerror("wheel_board_w: data = %08X\n", data);
uint8_t arg = data & 0xFF;
if (!BIT(m_output_last, 11) && BIT(data, 11)) // output latch
{
if (BIT(data, 10))
{
uint8_t base = BIT(data, 8) << 3;
for (uint8_t bit = 0; bit < 8; bit++)
m_lamps[base | bit] = BIT(arg, bit);
}
else if (BIT(data, 9) || BIT(data, 8))
{
//logerror("%08X:wheel_board_w(%d) = %08X\n", m_maincpu->pc(), offset, data);
}
else
{
m_wheel_driver = arg; // target wheel angle. signed byte.
m_wheel_force = int8_t(arg);
}
}
m_output_last = data;
}
/*************************************
* 49 Way translation matrix
*************************************/
const uint8_t seattle_state::translate49[7] = { 0x8, 0xc, 0xe, 0xf, 0x3, 0x1, 0x0 };
/*************************************
* 2 player 49 Way Joystick on Blitz
*************************************/
CUSTOM_INPUT_MEMBER(seattle_state::blitz_49way_r)
{
return (translate49[m_io_49way_y[1]->read() >> 4] << 12) | (translate49[m_io_49way_x[1]->read() >> 4] << 8) |
(translate49[m_io_49way_y[0]->read() >> 4] << 4) | (translate49[m_io_49way_x[0]->read() >> 4] << 0);
}
/*************************************
* Optical 49 Way Joystick I40 Board
*************************************/
void seattle_state::i40_w(uint32_t data)
{
//printf("i40_w: data = %08x\n", data);
//logerror("i40_w: data = %08x\n", data);
m_i40_data = data;
}
CUSTOM_INPUT_MEMBER(seattle_state::i40_r)
{
if (m_io_dips->read() & 0x100) {
// 8 way joysticks
return m_io_p4_8way->read();
}
else {
// 49 way joysticks via i40 adapter board
int index = m_i40_data & 0xf;
uint8_t data = 0;
switch (index) {
case 0:
data = translate49[m_io_49way_x[0]->read() >> 4];
break;
case 1:
data = translate49[m_io_49way_y[0]->read() >> 4];
break;
case 2:
data = translate49[m_io_49way_x[1]->read() >> 4];
break;
case 3:
data = translate49[m_io_49way_y[1]->read() >> 4];
break;
case 4:
data = translate49[m_io_49way_x[2]->read() >> 4];
break;
case 5:
data = translate49[m_io_49way_y[2]->read() >> 4];
break;
case 6:
data = translate49[m_io_49way_x[3]->read() >> 4];
break;
case 7:
data = translate49[m_io_49way_y[3]->read() >> 4];
break;
case 10:
case 11:
case 12:
// I40 Detection
data = ~index & 0xf;
break;
default:
//logerror("%s: i40_r: select: %x index: %d data: %x\n", machine().describe_context(), m_i40_data, index, data);
break;
}
//logerror("%s: i40_r: select: %x index: %d data: %x\n", machine().describe_context(), m_i40_data, index, data);
//if (m_i40_data & 0x1000)
// printf("%s: i40_r: select: %x index: %d data: %x\n", machine().describe_context().c_str(), m_i40_data, index, data);
//m_i40_data &= ~0x1000;
return data;
}
}
/*************************************
*
* Gearshift (calspeed)
*
*************************************/
DECLARE_CUSTOM_INPUT_MEMBER(seattle_state::gearshift_r)
{
// Check for gear change and save gear selection
uint32_t gear = m_io_gearshift->read();
for (int i = 0; i < 4; i++)
{
if (gear & (1 << i))
m_gear = 1 << i;
}
return m_gear;
}
/*************************************
*
* CarnEvil gun handling
*
*************************************/
uint32_t seattle_state::carnevil_gun_r(offs_t offset)
{
uint32_t result = 0;
switch (offset)
{
case 0: // lower 8 bits of X
result = (m_io_gun_x[0]->read() << 4) & 0xff;
break;
case 1: // upper 4 bits of X
result = (m_io_gun_x[0]->read() >> 4) & 0x0f;
result |= (m_io_fake->read() & 0x03) << 4;
result |= 0x40;
break;
case 2: // lower 8 bits of Y
result = (m_io_gun_y[0]->read() << 2) & 0xff;
break;
case 3: // upper 4 bits of Y
result = (m_io_gun_y[0]->read() >> 6) & 0x03;
break;
case 4: // lower 8 bits of X
result = (m_io_gun_x[1]->read() << 4) & 0xff;
break;
case 5: // upper 4 bits of X
result = (m_io_gun_x[1]->read() >> 4) & 0x0f;
result |= (m_io_fake->read() & 0x30);
result |= 0x40;
break;
case 6: // lower 8 bits of Y
result = (m_io_gun_y[1]->read() << 2) & 0xff;
break;
case 7: // upper 4 bits of Y
result = (m_io_gun_y[1]->read() >> 6) & 0x03;
break;
}
return result;
}
void seattle_state::carnevil_gun_w(offs_t offset, uint32_t data)
{
//logerror("carnevil_gun_w(%d) = %02X\n", offset, data);
}
/*************************************
*
* Ethernet access
*
*************************************/
uint32_t seattle_state::ethernet_r(offs_t offset, uint32_t mem_mask)
{
uint32_t data = 0;
if (!(offset & 8))
data = m_ethernet->read(offset & 7, mem_mask & 0xffff);
else
data = m_ethernet->read(offset & 7, mem_mask & 0x00ff);
//logerror("ethernet_r: @%08x=%08x mask: %08x\n", offset, data, mem_mask);
return data;
}
void seattle_state::ethernet_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
//logerror("ethernet_w: @%08x=%08x mask: %08x\n", offset, data, mem_mask);
if (!(offset & 8))
m_ethernet->write(offset & 7, data & 0xffff, mem_mask | 0xffff);
else
m_ethernet->write(offset & 7, data & 0x00ff, mem_mask | 0x00ff);
}
/*************************************
*
* Widget board access
*
*************************************/
void seattle_state::widget_reset()
{
uint8_t saved_irq = m_widget.irq_num;
memset(&m_widget, 0, sizeof(m_widget));
m_widget.irq_num = saved_irq;
}
void seattle_state::update_widget_irq()
{
uint8_t state = m_ethernet_irq_state << WINT_ETHERNET_SHIFT;
uint8_t mask = m_widget.irq_mask;
uint8_t assert = ((mask & state) != 0) && (m_interrupt_enable & (1 << WIDGET_IRQ_SHIFT));
// update the IRQ state
if (m_widget.irq_num != 0)
m_maincpu->set_input_line(m_widget.irq_num, assert ? ASSERT_LINE : CLEAR_LINE);
}
uint32_t seattle_state::output_r()
{
logerror("%08X:output_r\n", m_maincpu->pc());
return 0;
}
void seattle_state::output_w(uint32_t data)
{
uint8_t arg = data & 0xFF;
if (!BIT(m_output_last, 11) && BIT(data, 11))
m_output_mode = arg;
m_output_last = data;
if (!BIT(data, 10))
{
switch (m_output_mode)
{
default:
logerror("%08X:output_w(%d) = %04X\n", m_maincpu->pc(), m_output_mode, data);
break;
case 0x04:
m_wheel_motor = arg; // wheel motor delta. signed byte.
m_wheel_force = int8_t(~arg);
//logerror("wheel_board_w: data = %08x op: %02x arg: %02x\n", data, op, arg);
break;
case 0x05:
for (uint8_t bit = 0; bit < 8; bit++)
m_lamps[bit] = BIT(arg, bit);