/
chihiro.cpp
2667 lines (2342 loc) · 116 KB
/
chihiro.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:Samuele Zannoli
/*
Chihiro is an Xbox-based arcade system from SEGA.
Games on this system include....
GD build date
yyyymmdd Game Manufacturer / Developer Media Number Key Chip
+-+----------+------------------------------------------------------+--------------------------+--------+------------+--------------|
|*| 20021029 | The House of the Dead III | Sega / Wow Entertainment | GDROM | GDX-0001 | 317-0348-COM |
| | 2003 | Crazy Taxi High Roller | Sega / Hitmaker | GDROM | GDX-0002 | 317-0353-COM |
| | 2003 | Crazy Taxi High Roller (Rev A) | Sega / Hitmaker | GDROM | GDX-0002A | 317-0353-COM |
|*| 20030224 | Crazy Taxi High Roller (Rev B) | Sega / Hitmaker | GDROM | GDX-0002B | 317-0353-COM |
| | 2003 | Virtua Cop 3 | Sega | GDROM | GDX-0003 | 317-0354-COM |
|*| 20030226 | Virtua Cop 3 (Rev A) | Sega | GDROM | GDX-0003A | 317-0354-COM |
| | 20030226 | Virtua Cop 3 (Rev A) | Sega | CF | MDA-G0010 | 317-0354-COM |
|*| 20030521 | Virtua Cop 3 (Rev B) | Sega | GDROM | GDX-0003B | 317-0354-COM |
| | 2003 | OutRun 2 | Sega | GDROM | GDX-0004 | 317-0372-COM |
|*| 20031017 | OutRun 2 (Rev A) | Sega | GDROM | GDX-0004A | 317-0372-COM |
| | 200312 | OutRun 2 (Rev A) | Sega | CF | MDA-G0011 | 317-0372-COM |
| | 20030911 | OutRun 2 prototype (Rev P) | Sega | GDROM | GDX-0004P | 317-0372-COM |
| | 2004 | Sega Golf Club Network Pro Tour | Sega | GDROM | GDX-0005 | |
| | 2004 | Sega Network Taisen Mahjong MJ 2 | Sega | GDROM | GDX-0006 | 317-0374-JPN |
| | 2004 | Sega Network Taisen Mahjong MJ 2 (Rev A) | Sega | GDROM | GDX-0006A | 317-0374-JPN |
| | 2004 | Sega Network Taisen Mahjong MJ 2 (Rev B) | Sega | GDROM | GDX-0006B | 317-0374-JPN |
|*| 20041102 | Sega Network Taisen Mahjong MJ 2 (Rev C) | Sega | GDROM | GDX-0006C | 317-0374-JPN |
| | 2004 | Sega Network Taisen Mahjong MJ 2 (Rev D) | Sega | GDROM | GDX-0006D | 317-0374-JPN |
| | 2005 | Sega Network Taisen Mahjong MJ 2 (Rev E) | Sega | GDROM | GDX-0006E | 317-0374-JPN |
|*| 2005 | Sega Network Taisen Mahjong MJ 2 (Rev F) | Sega | GDROM | GDX-0006F | 317-0374-JPN |
|*| 20050202 | Sega Network Taisen Mahjong MJ 2 (Rev G) | Sega | GDROM | GDX-0006G | 317-0374-JPN |
|*| 20031211 | Ollie King | Sega / Amusement Vision | GDROM | GDX-0007 | 317-0377-COM |
| | 2004 | Wangan Midnight Maximum Tune (Japan) | Namco | GDROM | GDX-0008 | 317-5101-JPN |
| | 2004 | Wangan Midnight Maximum Tune (Japan, Rev A) | Namco | GDROM | GDX-0008A | 317-5101-JPN |
|*| 20040610 | Wangan Midnight Maximum Tune (Japan, Rev B) | Namco | GDROM | GDX-0008B | 317-5101-JPN |
| | 2004 | Wangan Midnight Maximum Tune (Export) | Namco | GDROM | GDX-0009 | 317-5101-COM |
| | 2004 | Wangan Midnight Maximum Tune (Export, Rev A) | Namco | GDROM | GDX-0009A | 317-5101-COM |
|*| 20040610 | Wangan Midnight Maximum Tune (Export, Rev B) | Namco | GDROM | GDX-0009B | 317-5101-COM |
| | 2004 | Sega Golf Club Network Pro Tour 2005 | Sega | GDROM | GDX-0010 | ??? |
|*| 2004 | Sega Golf Club Network Pro Tour 2005 (Rev B) | Sega | GDROM | GDX-0010B | ??? |
|*| 2004 | Sega Golf Club Network Pro Tour 2005 (Rev C) | Sega | GDROM | GDX-0010C | ??? |
|*| 20040909 | OutRun 2 Special Tours (Japan) | Sega | GDROM | GDX-0011 | 317-0396-COM |
|*| 20041229 | OutRun 2 Special Tours (Japan, Rev A) | Sega | GDROM | GDX-0011A | 317-0396-COM |
|*| 20040914 | Ghost Squad | Sega | GDROM | GDX-0012 | 317-0398-COM |
|*| 20041209 | Ghost Squad (Rev A) | Sega | GDROM | GDX-0012A | 317-0398-COM |
| | 20041209 | Ghost Squad (Rev A) | Sega | CF | MDA-G0013 | 317-0398-COM |
|*| 20050208 | Gundam Battle Operating Simulator | Banpresto | GDROM | GDX-0013 | 317-0400-JPN |
|*| 20040910 | OutRun 2 Special Tours | Sega | GDROM | GDX-0014 | 317-0396-COM |
|*| 20041229 | OutRun 2 Special Tours (Rev A) | Sega | GDROM | GDX-0014A | 317-0396-COM |
| | 20041229 | OutRun 2 Special Tours (Rev A) | Sega | CF | MDA-G0012 | 317-0396-COM |
|*| 20050218 | Wangan Midnight Maximum Tune 2 (Japan) | Namco | GDROM | GDX-0015 | 317-5106-JPN |
|*| 20050908 | Wangan Midnight Maximum Tune 2 (Japan, Rev A) | Namco | GDROM | GDX-0015A | 317-5106-JPN |
|*| 20050218 | Wangan Midnight Maximum Tune 2 (Export) | Namco | GDROM | GDX-0016 | 317-5106-COM |
|*| 20050908 | Wangan Midnight Maximum Tune 2 (Export, Rev A) | Namco | GDROM | GDX-0016A | 317-5106-COM |
| | 2005 | Sega Network Taisen Mahjong MJ 3 | Sega | GDROM | GDX-0017 | 317-0414-JPN |
| | 2005 | Sega Network Taisen Mahjong MJ 3 (Rev A) | Sega | GDROM | GDX-0017A | 317-0414-JPN |
| | 2005 | Sega Network Taisen Mahjong MJ 3 (Rev B) | Sega | GDROM | GDX-0017B | 317-0414-JPN |
|*| 20051109 | Sega Network Taisen Mahjong MJ 3 (Rev C) | Sega | GDROM | GDX-0017C | 317-0414-JPN |
|*| 20060217 | Sega Network Taisen Mahjong MJ 3 (Rev D) | Sega | GDROM | GDX-0017D | 317-0414-JPN |
| | 2006 | Sega Network Taisen Mahjong MJ 3 (Rev E) | Sega | GDROM | GDX-0017E | 317-0414-JPN |
|*| 2006 | Sega Network Taisen Mahjong MJ 3 (Rev F) | Sega | GDROM | GDX-0017F | 317-0414-JPN |
| | 2005 | Sega Club Golf 2006: Next Tours | Sega | GDROM | GDX-0018 | |
|*| 20051107 | Sega Club Golf 2006: Next Tours (Rev A) | Sega | GDROM | GDX-0018A | 317-0428-JPN |
|*| 20050905 | Firmware Update For MJ 3 | Sega | GDROM | GDX-0019 | 317-0414-JPN |
| | 200? | Sega Club Golf 2006 | Sega | GDROM | GDX-0020 | |
| | 2006 | Sega Network Taisen Mahjong MJ 3 Evolution | Sega | GDROM | GDX-0021 | 317-0457-JPN |
|*| 20070217 | Sega Network Taisen Mahjong MJ 3 Evolution (Rev A) | Sega | GDROM | GDX-0021A | 317-0457-JPN |
|*| 20070525 | Sega Network Taisen Mahjong MJ 3 Evolution (Rev B) | Sega | GDROM | GDX-0021B | 317-0457-JPN |
| | 200? | Sega Network Taisen Mahjong MJ 3 Evo Test Ver | Sega | GDROM | GDX-0022 | |
|*| 20061222 | Sega Network Taisen Mahjong MJ 3 Evo Firmware Update | Sega | GDROM | GDX-0023 | 317-0457-JPN |
| | 2009 | Firmware Update For Compact Flash Box | Sega | GDROM | GDX-0024 | |
|*| 20090331 | Firmware Update For Compact Flash Box (Rev A) | Sega | GDROM | GDX-0024A | 317-0567-EXP |
|*| 20030226 | Chihiro Change Region GD USA | Sega | GDROM | 611-0028A | 317-0351-EXP |
|*| 200412 | Quest Of D Ver.1.01C | Sega | CDROM | CDV-10005C | 317-0376-JPN |
|*| 2005 | Sangokushi Taisen Ver.1.002 | Sega | DVDROM | CDV-10009D | |
|*| 2005 | Mobile Suit Gundam 0079 Card Builder | Banpresto | DVDROM | CDV-10010 | 317-0415-JPN |
|*| 2006 | Sangokushi Taisen 2 Ver.2.007 | Sega | DVDROM | CDV-10019A | |
|*| 2005 | Sangokushi Taisen | Sega | DVDROM | CDV-10022 | |
|*| 2006 | Sangokushi Taisen 2 Firmware Update | Sega | DVDROM | CDV-10023 | |
|*| 2006 | Mobile Suit Gundam 0079 Card Builder Ver.2.02 | Banpresto | DVDROM | CDV-10024B | 317-0415-JPN |
|*| 2006 | Sangokushi Taisen 2 Ver.2.100 | Sega | DVDROM | CDV-10029 | |
|*| 2007 | Mobile Suit Gundam 0083 Card Builder | Banpresto | DVDROM | CDV-10030 | 317-0484-JPN |
|*| 2008 | Sangokushi Taisen 3 | Sega | DVDROM | CDV-10036 | |
|*| 2008 | Sangokushi Taisen 3 Ver.J | Sega | DVDROM | CDV-10036J | |
|*| 2008 | Mobile Suit Gundam 0083 Card Builder Ver.2.10 | Bandai Namco - Banpresto | DVDROM | CDV-10037B | 317-0484-JPN |
|*| 2008 | Sangokushi Taisen 3 War Begins Ver.3.59 | Sega | DVDROM | CDV-10041 | |
|*| 2008 | Sangokushi Taisen 3 War Begins | Sega | DVDROM | CDV-10042 | |
+-+----------+------------------------------------------------------+--------------------------+--------+------------+--------------+
* denotes these games are archived.
Year Game (Unknown media) Manufacturer Number
+-+-----------------------------------------------------------+------------+------------+
| | 2004 | Quest Of D | Sega | CDV-10005 |
| | 2004 | Quest Of D | Sega | CDV-10005A |
| | 2004 | Quest Of D | Sega | CDV-10005B |
| | 2004 | Quest Of D 1.01D | Sega | CDV-10005D |
| | 2004 | Quest Of D 1.02 | Sega | CDV-10005E |
| | 2004 | Quest Of D Senko Habai | Sega | CDV-10005P |
| | 2004 | Quest Of D 1.10 | Sega | CDV-10006 |
| | 2004 | Quest Of D 1.10A | Sega | CDV-10006A |
| | 200? | Sangokushi Taisen | Sega | CDV-10009 |
| | 200? | Sangokushi Taisen 0.94 | Sega | CDV-10009A |
| | 200? | Sangokushi Taisen 1.00 | Sega | CDV-10009B |
| | 200? | Sangokushi Taisen 1.001 | Sega | CDV-10009C |
| | 200? | Sangokushi Taisen 1.002 | Sega | CDV-10009E |
| | 200? | Sangokushi Taisen 1.003 | Sega | CDV-10009F |
| | 200? | Sangokushi Taisen 1.003 | Sega | CDV-10009G |
| | 200? | Sangokushi Taisen 1.100 | Sega | CDV-10009H |
| | 200? | Sangokushi Taisen 1.003 | Sega | CDV-10009J |
| | 200? | Sangokushi Taisen 1.100 | Sega | CDV-10009K |
| | 200? | Sangokushi Taisen 1.110 | Sega | CDV-10009L |
| | 200? | Sangokushi Taisen 1.120 | Sega | CDV-10009M |
| | 200? | Sangokushi Taisen 1.120 | Sega | CDV-10009N |
| | 200? | Sangokushi Taisen 1.100 (kakinhenkou) | Sega | CDV-10009P |
| | 200? | Sangokushi Taisen 1.121 | Sega | CDV-10009Q |
| | 200? | Sangokushi Taisen 1.122 | Sega | CDV-10009R |
| | 200? | Mobile Suit Gundam 0079 Card Builder | Banpresto | CDV-10010A |
| | 200? | Quest Of D 1.20 | Sega | CDV-10012 |
| | 200? | Quest Of D 1.20A | Sega | CDV-10012A |
| | 200? | Sangokushi Taisen 1.00 (Asia) | Sega | CDV-10014 |
| | 200? | Sangokushi Taisen (Asia) | Sega | CDV-10014B |
| | 200? | Sangokushi Taisen (Asia) | Sega | CDV-10014C |
| | 200? | Quest Of D 1.21 | Sega | CDV-10016 |
| | 200? | Quest Of D: Gofu no Keisyousya 2.00 | Sega | CDV-10017 |
| | 200? | Quest Of D: Gofu no Keisyousya 2.01 | Sega | CDV-10017A |
| | 200? | Quest Of D: Gofu no Keisyousya 2.02 | Sega | CDV-10017B |
| | 200? | Quest Of D: Gofu no Keisyousya 2.02B | Sega | CDV-10017C |
| | 200? | Quest Of D: Gofu no Keisyousya 2.02C | Sega | CDV-10017D |
| | 200? | Sangokushi Taisen 2 | Sega | CDV-10019 |
| | 200? | Sangokushi Taisen 2 2.010 | Sega | CDV-10019B |
| | 200? | Mobile Suit Gundam 0079 Card Builder 2.00 | Banpresto | CDV-10024 |
| | 200? | Mobile Suit Gundam 0079 Card Builder 2.00 | Banpresto | CDV-10024A |
| | 200? | Quest Of D: Oukoku no Syugosya 3.00 | Sega | CDV-10026 |
| | 200? | Quest Of D: Oukoku no Syugosya 3.01 | Sega | CDV-10026A |
| | 200? | Quest Of D: Oukoku no Syugosya 3.01A | Sega | CDV-10026B |
| | 200? | Quest Of D: Oukoku no Syugosya 3.01B | Sega | CDV-10026C |
| | 200? | Quest Of D: Oukoku no Syugosya 3.02 | Sega | CDV-10026D |
| | 200? | Sangokushi Taisen 2 | Sega | CDV-10029A |
| | 200? | Mobile Suit Gundam 0083 Card Builder | Banpresto | CDV-10030A |
| | 200? | Sangokushi Taisen 2 (Asia) | Sega | CDV-10032 |
| | 200? | Sangokushi Taisen 2 (Asia) | Sega | CDV-10032A |
| | 200? | Sangokushi Taisen 2 (Asia) Check disc | Sega | CDV-10033 |
| | 200? | Sangokushi Taisen 2 (Asia) Firmware update | Sega | CDV-10034 |
| | 200? | Quest Of D: The Battle Kingdom | Sega | CDV-10035 |
| | 200? | Quest Of D: The Battle Kingdom | Sega | CDV-10035A |
| | 200? | Quest Of D: The Battle Kingdom | Sega | CDV-10035C |
| | 200? | Sangokushi Taisen 3 | Sega | CDV-10036A |
| | 200? | Sangokushi Taisen 3 | Sega | CDV-10036B |
| | 200? | Sangokushi Taisen 3 | Sega | CDV-10036D |
| | 200? | Sangokushi Taisen 3 | Sega | CDV-10036G |
| | 200? | Sangokushi Taisen 3 | Sega | CDV-10036H |
| | 200? | Sangokushi Taisen 3 | Sega | CDV-10036K |
| | 200? | Mobile Suit Gundam 0083 Card Builder 2.00 | Banpresto | CDV-10037 |
| | 200? | Mobile Suit Gundam 0083 Card Builder 2.02 | Banpresto | CDV-10037A |
| | 200? | Sangokushi Taisen 2 (Export) | Sega | CDV-10038 |
| | 200? | Sangokushi Taisen 2 (Export) | Sega | CDV-10038A |
| | 200? | Sangokushi Taisen 2 (Export) | Sega | CDV-10038B |
| | 200? | Sega Golf Club Network Pro Tour 2005 (DVD NMC TJP) | Sega | CDV-10039 |
| | 200? | Sangokushi Taisen 3 (Export) | Sega | CDV-10040 |
| | 200? | Sangokushi Taisen 3 (Export) | Sega | CDV-10040A |
+-+------+----------------------------------------------------+------------+------------+
A Chihiro system consists of several boards.
The system is in 2 separate metal boxes that fit together to form one box.
In order from top to bottom they are....
- Network board \
- Media board / Together in the top box
- Base board \
- Xbox board / Together in the bottom box
The 2 boxes join together via the Base Board upper connector and Media Board lower connector.
The Microsoft-manufactured XBox board is the lowest board. It's mostly the same as the V1 XBox retail
board with the exception that it has 128MB of RAM and a nVidia MCPX X2 chip. The retail XBox board has a
MCPX X3 chip. The board was probably released to Sega very early in development and the chip was updated
in the mass-produced retail version.
The Sega-manufactured base board is connected to the XBox board via a 40 pin 80-wire flat cable and a 16
pin 16-wire flat cable connects to the LPC header, plus a couple of thin multi-wire cables which join to the
XBox game controller ports (USB1.1) and front panel connector.
On the reverse side of that board are the power output connectors going to the XBox board and a 100 pin
connector where the media board plugs in. A CR2032 coin battery is also located there and next to it are 6
jumpers....
JP3S 2-3 \
JP4S 1-2 |
JP5S 1-2 |
JP6S 2-3 | These are connected to the USB chip on the other side of this board
JP7S 1-2 |
JP8S 2-3 /
A long connector on one edge connects to the filter board (power supply input etc) and on another edge are
connectors for VGA output, audio/video input (from a short cable coming from the A/V connector on the XBox board)
and a 14 pin connector which is unused. The base board handles JVS and video output.
The upper part contains a Sega-manufactured media board with a TSOP48 flash ROM containing an xbox .xbe loader
(this is the Chihiro logo you see when you power the Chihiro) and there's a connector for a Sega network board.
The network board is 100% the same as the one in the Triforce v3 with the same firmware also.
The system requires one of the various Sega JVS I/O boards to operate.
ROMs on the boards
------------------
Network Board : One ST 29W160ET 2M x8-bit TSOP48 Flash ROM stamped 'FPR24036' at location IC2
Media Board : One ST 29W160ET 2M x8-bit TSOP48 Flash ROM stamped 'FPR24042' at location IC8
As in Triforce, it consists of two versions in the same flash, the first MB of the flash has
an older version as backup, and the second MB has the current version, versions included are:
SegaBoot Ver.2.00.0 Build:Feb 7 2003 12:28:30
SegaBoot Ver.2.13.0 Build:Mar 3 2005 17:03:15
Base Board : Two Microchip 24LC64 64k Serial EEPROMs at locations IC32 and IC10
One Microchip 24LC24 2k Serial EEPROM at location IC11
The chip at IC32 seems to be a backup of the base board firmware without region or serial.
The chip at IC11 has an unknown purpose. It contains some strings. The interesting thing is that it
contains the string SBJE. If you go to the system info menu and press the service button 16 times in a row
a message will be displayed: GAME ID SBJE
The chip at IC10 contains the firmware of the Base Board, serial number and REGION of the whole system.
The region is located at offset 0x00001F10. 01 is JAPAN, 02 is USA, 03 is EXPORT. If you want to change
the region of your Chihiro unit just change this byte.
Alternatively, if you have a netboot PIC, plug that in and power up with it.
1) Enter the test menu (push the test button)
2) Go to the System Information menu.
3) Press the Service button 30 times in a row and a hidden menu will appear to change the region.
4) Once the region is changed, exit from the menus and after the Chihiro reboots, power off the system and
power on again.
Xbox Board : One Macronix 29F040TC-90 512k x8-bit TSOP32 Flash ROM at location U7D1
Board Layouts
=============
XBox Board
----------
|--------------------------------------------|
| LAN FAN1 A/V FAN2|
| |
| LF353 CONEXANT |
|DVD_PWR WM9709 XC25871-14 |
| |
| ICS_UA431317 |-------------------|
| LM358 |
| 27MHz PIC16LC63A |
|IDE BR24C02 |
| ICS_455R-02 |
| K4D263238D |
| 29F040.U7D1 *K4D263238D |
| |
| GPU CPU @733MHz |
| 16_PIN_CONN (WITH FAN) (SL5SN 733/128)|
| K4D263238D |
| *K4D263238D |
| |
| |
| K4D263238D K4D263238D |
| *K4D263238D *K4D263238D |
| NVIDIA |
| MCPX X2 |
| POWER_CONN |
| |
| |
| |
| GAME1/2 FRONT_PANEL GAME3/4 |
|----------------------------------------------------------------|
Notes:
* These parts located on the other side of the PCB
Some of the connectors are not used.
GAME1/2 - Connected to CN1 on Base Board. JST Part Number B12B-PHDSS
GAME3/4 - Connected to CN1 on Base Board. JST Part Number B12B-PHDSS
FRONT_PANEL - Connected to CN1 on Base Board. JST Part Number B10B-PHDSS
Base Board
----------
171-8204B
837-14280 SEGA 2002
Sticker: 837-14280-92
|----------------------------------------------------------------|
|*CN16S *CN14S *CN19S ADM3222 |
| CN8|
| 24LC64.IC32 |
|CN11 CN18 CN1 PC410 |
| LM1881 |
| SN65240 |
| SN65240 AN2131SC BA7623 |
| CN10|
| 12MHz BA7623 |
| *CR2032 |
| SUPERCAP |
| 32.768kHz |
|CN12 RV5C386A |
| 24LC024.IC11 M68AF127 CN9|
| 24LC64.IC10 AN2131QC |
| ADM3222 DS485 |
| 1.85MHz |
| 3771 CN5|
|-------------------------| CN15 |-----------------|
|--------------------|
Notes:
(* these parts on other side of the PCB)
RV5C386A - I2C Bus Serial Interface Real-Time Clock IC with Voltage Monitoring Function (SSOP10)
24LC64 - Microchip 24LC64 64K I2C Serial EEPROM (SOIC8) contains firmware for AN2131 chips
24LC024 - Microchip 24LC024 2K I2C Serial EEPROM (SOIC8) contain system/game configuration data
M68AF127B - ST Microelectronics 1Mbit (128K x8), 5V Asynchronous SRAM (SOP32) work ram for AN2131QC
AN2131QC - Cypress AN2131 EZ-USB-Family 8051-based High-Speed USB IC's (QFP80) firmware in IC10
AN2131SC / (QFP44) firmware in IC32
ADM3222 - Analog Devices ADM3222 High-Speed, +3.3V, 2-Channel RS232/V.28 Interface Device (SOIC20)
SN65240 - Texas Instruments SN65240 USB Port Transient Suppressor (SOIC8)
BA7623 - Rohm BA7623 75-Ohm driver IC with 3 internal circuits (SOIC8)
LM1881 - National LM1881 Video Sync Separator (SOIC8)
DS485 - National DS485 Low-Power RS-485/RS-422 Multipoint Transceiver (SOIC8)
3771 - Fujitsu MB3771 System Reset IC (SOIC8)
PC410 - Sharp PC410 Ultra-high Speed Response OPIC Photocoupler
CN1 - 22-pin multi-wire cable connector joining to XBox board (JST B22B-PHTSS)
CN5 - USB connector joining to JVS I/O board with standard USB cable
CN8 - A/V input connector (from XBox board via short A/V cable)
CN9 - VGA output connector
CN10 - 14 pin connector (purpose unknown, maybe another video connector)
CN11 - 16-pin flat cable connector joining to LPC connector on XBox board
CN12 - 40-pin IDE flat cable connector joining to IDE connector on XBox board
CN14S - 7-pin power output connector joining to XBox board
CN15 - 96-pin connector joining to filter board
CN16S - 2-pin connector joining to case fan on Chihiro lower section (next to XBox PCB)
CN18 - 10-pin multi-wire cable connector joining to XBox board
CN19S - 5-pin power output connector joining to XBox board
There are also many power-related components such as capacitors, mosfets and transistors.
Network Board
-------------
This board is identical to the network board used in Triforce games.
See src/mame/drivers/triforce.c
Media Board
-----------
171-8234C
837-14359-01 SEGA 2002
Sticker: 837-14359-91
|----------------------------------------------------------------|
| LED LED |
| FLASH.IC8 |
| LED CN12 CN11 |
| LED JP4-JP10 CN10|
| |
| |
| |----------| |
| |SEGA | |
| CN14S* |315-6355 | |
| | | |
| | | |
| MB3800* |----------| CN8|
| CY25560* |
| |
| CY23S09SC 49.25MHz |
| |
| CN4 (DIMM) |
| CN3 (DIMM) CN5|
| MM1433* |
| CN13 TPC8009 CN9 CN6 |
|----------------------------------------------------------------|
Notes:
* - These parts on other side of PCB
CN3/4 - 72 pin DIMM sockets
CN5 - GDROM data cable connector (SCSI mini-honda connection but signal/protocol is IDE)
CN6 - 40 pin flat cable connector (unused)
CN8 - 6 pin GDROM power connector
CN9 - 6 pin power connector (unused)
CN10 - Connector for small 90-degrees upright board where PIC plugs in. The upright board contains only a DIP18 socket and a 4MHz OSC.
CN11/12 - Network board connectors joining to Sega Network PCB
CN13 - Battery connector (maintains power to DIMM RAM)
CN14S - 100 pin connector joining to base board
JP4-10 - Jumpers. Settings are as follows (taken from Wangan Midnight Maximum Tune 2 (Japan, Rev A))
JP4 2-3
JP5 2-3. Sets DIMM RAM size. 1-2 = 1GB (2x 512M sticks), 2-3 = 512MB (1x 512M stick)
JP6 1-2
JP7 2-3
JP8 2-3
JP9 1-2
JP10 1-2
FLASH.IC8 - ST M29W160 16MBit Flash ROM stamped 'FPR24042' (TSOP48)
Filter Board
------------
839-1208-02
171-8205C SEGA 2002
|----------------------------------------------------------------|
| SP-DIF LED_STATUS2 LED_STATUS1 CN3 |
| |
| DIN1 LED_3.3V |
| LED_5V |
| DIPSW(8) LED_12V |
|CN6 CN5 CN4 SW2 SW1 CN2 CN1 |
|----------------------------------------------------------------|
Notes:
CN1 - 8-pin JVS power input connector
CN2 - 6-pin JVS power input connector
CN3 - Red/white RCA unamplified stereo audio output jacks
CN4 - 11-pin connector, has signals for 2 usb ports connected to the xbox board
CN5 - 8-pin connector, has signals for 2 rs232 ports
CN6 - 7-pin connector
SW1/2 - test/service buttons
DIN1 - 96-pin connector joining to Base Board
DIPSW - 8-position DIP switch. On this game (Wangan Midnight Maximum Tune 2 (Japan, Rev A)) DIPs 3, 4, 6, 7 & 8 are set ON. The others are OFF.
Dump info:
Network Board Dump : Ver1305.bin
Media Board dump : FPR21042_M29W160ET.bin
Base Board Dumps : ic10_g24lc64.bin ic11_24lc024.bin pc20_g24lc64.bin
Xbox Board Dump : chihiro_xbox_bios.bin
FPR21042_M29W160ET.bin :
As in Triforce, it consists of two versions in the same flash, the first MB of the flash has
an older version as backup, and the second MB has the current version, versions included are:
SegaBoot Ver.2.00.0 Build:Feb 7 2003 12:28:30
SegaBoot Ver.2.13.0 Build:Mar 3 2005 17:03:15
ic10_g24lc64.bin: This dump contains the firmware of the Base Board, serial number and REGION of the whole system
Region is located at Offset 0x00001F10 , 01 means JPN, 02 Means USA, 03 Means EXPORT, if you
want to change the region of your Chihiro Board, just change this byte.
Thanks to Alex, Mr Mudkips, and Philip Burke for this info.
*/
#include "emu.h"
#include "jvs13551.h"
#include "xbox_pci.h"
#include "xbox.h"
#include "machine/pci.h"
#include "machine/idectrl.h"
#include "bus/ata/hdd.h"
#include "cpu/i386/i386.h"
#include "machine/jvshost.h"
#include "naomigd.h"
#include "debug/debugcon.h"
#include "debugger.h"
#include <functional>
#define LOG_BASEBOARD (1U << 1)
#define LOG_EXTRA (1U << 2)
#define VERBOSE (0)
#include "logmacro.h"
/*
* Class declaration for jvs_master
*/
DECLARE_DEVICE_TYPE(JVS_MASTER, jvs_master)
class jvs_master : public jvs_host
{
public:
// construction/destruction
jvs_master(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
int get_sense_line();
void send_packet(int destination, int length, uint8_t *data);
int received_packet(uint8_t *buffer);
};
DEFINE_DEVICE_TYPE(JVS_MASTER, jvs_master, "jvs_master", "JVS MASTER")
jvs_master::jvs_master(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: jvs_host(mconfig, JVS_MASTER, tag, owner, clock)
{
}
int jvs_master::get_sense_line()
{
if (get_presence_line() == false)
return 50;
if (get_address_set_line() == true)
return 0;
return 25;
}
void jvs_master::send_packet(int destination, int length, uint8_t *data)
{
push((uint8_t)destination);
push((uint8_t)length);
length--;
while (length > 0)
{
push(*data);
data++;
length--;
}
commit_raw();
}
int jvs_master::received_packet(uint8_t *buffer)
{
uint32_t length;
const uint8_t *data;
get_raw_reply(data, length);
if (length > 0)
memcpy(buffer, data, length);
return (int)length;
}
/*
* Class declaration for ohci_hlean2131qc_device
*/
DECLARE_DEVICE_TYPE(OHCI_HLEAN2131QC, ohci_hlean2131qc_device)
class ohci_hlean2131qc_device : public device_t, public device_usb_ohci_function_interface
{
public:
ohci_hlean2131qc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
void initialize() override;
int handle_nonstandard_request(int endpoint, USBSetupPacket *setup) override;
int handle_bulk_pid(int endpoint, int pid, uint8_t *buffer, int size) override;
void set_region_base(uint8_t *data);
void set_region(const char *_region_tag, int _region_offset);
protected:
virtual void device_start() override;
private:
void process_jvs_packet();
static const USBStandardDeviceDescriptor devdesc;
static const USBStandardConfigurationDescriptor condesc;
static const USBStandardInterfaceDescriptor intdesc;
static const USBStandardEndpointDescriptor enddesc01;
static const USBStandardEndpointDescriptor enddesc02;
static const USBStandardEndpointDescriptor enddesc03;
static const USBStandardEndpointDescriptor enddesc04;
static const USBStandardEndpointDescriptor enddesc05;
static const USBStandardEndpointDescriptor enddesc81;
static const USBStandardEndpointDescriptor enddesc82;
static const USBStandardEndpointDescriptor enddesc83;
static const USBStandardEndpointDescriptor enddesc84;
static const USBStandardEndpointDescriptor enddesc85;
static const uint8_t strdesc0[];
static const uint8_t strdesc1[];
static const uint8_t strdesc2[];
int maximum_send;
const char *region_tag;
int region_offset;
uint8_t *region;
struct
{
uint8_t buffer_in[32768];
int buffer_in_expected;
uint8_t buffer_out[32768];
int buffer_out_used;
int buffer_out_packets;
} jvs;
required_device<jvs_master> m_jvs_master;
};
DEFINE_DEVICE_TYPE(OHCI_HLEAN2131QC, ohci_hlean2131qc_device, "ohci_hlean2131qc", "OHCI an2131qc HLE")
#define MCFG_OHCI_HLEAN2131QC_REGION(_region_tag, _region_offset) \
downcast<ohci_hlean2131qc_device *>(device)->set_region(_region_tag, _region_offset);
/*
* Class declaration for ohci_hlean2131sc_device
*/
DECLARE_DEVICE_TYPE(OHCI_HLEAN2131SC, ohci_hlean2131sc_device)
class ohci_hlean2131sc_device : public device_t, public device_usb_ohci_function_interface
{
public:
ohci_hlean2131sc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
void initialize() override;
int handle_nonstandard_request(int endpoint, USBSetupPacket *setup) override;
int handle_bulk_pid(int endpoint, int pid, uint8_t *buffer, int size) override;
void set_region_base(uint8_t *data);
void set_region(const char *_region_tag, int _region_offset);
protected:
virtual void device_start() override;
private:
void process_packet();
static const USBStandardDeviceDescriptor devdesc;
static const USBStandardConfigurationDescriptor condesc;
static const USBStandardInterfaceDescriptor intdesc;
static const USBStandardEndpointDescriptor enddesc01;
static const USBStandardEndpointDescriptor enddesc02;
static const USBStandardEndpointDescriptor enddesc03;
static const USBStandardEndpointDescriptor enddesc81;
static const USBStandardEndpointDescriptor enddesc82;
static const USBStandardEndpointDescriptor enddesc83;
static const uint8_t strdesc0[];
static const uint8_t strdesc1[];
static const uint8_t strdesc2[];
const char *region_tag;
int region_offset;
uint8_t *region;
uint8_t midi_rs232;
uint8_t response[256];
uint8_t packet[4];
int response_size;
int step;
};
DEFINE_DEVICE_TYPE(OHCI_HLEAN2131SC, ohci_hlean2131sc_device, "ohci_hlean2131sc", "OHCI an2131sc HLE")
#define MCFG_OHCI_HLEAN2131SC_REGION(_region_tag, _region_offset) \
downcast<ohci_hlean2131sc_device *>(device)->set_region(_region_tag, _region_offset);
/*
* Class declaration for chihiro_state
*/
class chihiro_state : public xbox_base_state
{
friend class ide_baseboard_device;
public:
chihiro_state(const machine_config &mconfig, device_type type, const char *tag)
: xbox_base_state(mconfig, type, tag)
, m_ide(*this, "ide1")
, m_dimmboard(*this, "rom_board")
, m_hack_index(-1)
, m_hack_counter(0)
, m_dimm_board_memory(nullptr)
, m_dimm_board_memory_size(0) { }
void chihirogd(machine_config &config);
void chihiro_base(machine_config &config);
private:
uint32_t mediaboard_r(offs_t offset, uint32_t mem_mask = ~0);
void mediaboard_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
virtual void machine_start() override;
void baseboard_ide_event(int type, uint8_t *read, uint8_t *write);
uint8_t *baseboard_ide_dimmboard(uint32_t lba);
void dword_write_le(uint8_t *addr, uint32_t d);
void word_write_le(uint8_t *addr, uint16_t d);
virtual void hack_eeprom() override;
virtual void hack_usb() override;
// devices
optional_device<bus_master_ide_controller_device> m_ide;
optional_device<naomi_gdrom_board> m_dimmboard;
int m_hack_index;
int m_hack_counter;
uint8_t *m_dimm_board_memory;
uint32_t m_dimm_board_memory_size;
static void an2131qc_configuration(device_t *device);
static void an2131sc_configuration(device_t *device);
void chihiro_map(address_map &map);
void chihiro_map_io(address_map &map);
void jamtable_disasm(address_space &space, uint32_t address, uint32_t size);
void jamtable_disasm_command(const std::vector<std::string_view> ¶ms);
void chihiro_help_command(const std::vector<std::string_view> ¶ms);
void debug_commands(const std::vector<std::string_view> ¶ms);
};
/* jamtable instructions for Chihiro (different from Xbox console)
St. Instr. Comment
0x01 POKEPCI PCICONF[OP2] := OP1
0x02 OUTB PORT[OP2] := OP1
0x03 POKE MEM[OP2] := OP1
0x04 BNE IF ACC <> OP2 THEN PC := PC + OP1
0x05 PEEKPCI ACC := PCICONF[OP2]
0x06 AND/OR ACC := (ACC & OP2) | OP1
0x07 BRA PC := PC + OP1
0x08 INB ACC := PORT[OP2]
0x09 PEEK ACC := MEM[OP2]
0xE1 (prefix) execute the instruction code in OP2 with OP2 := OP1, OP1 := ACC
0xEE END
*/
/* jamtable disassembler */
void chihiro_state::jamtable_disasm(address_space &space, uint32_t address, uint32_t size) // 0xff000080 == fff00080
{
debugger_console &con = machine().debugger().console();
offs_t addr = (offs_t)address;
address_space *tspace;
if (!space.device().memory().translate(space.spacenum(), device_memory_interface::TR_READ, addr, tspace))
{
con.printf("Address is unmapped.\n");
return;
}
while (1)
{
offs_t base = addr;
uint32_t opcode = tspace->read_byte(addr);
addr++;
uint32_t op1 = tspace->read_dword_unaligned(addr);
addr += 4;
uint32_t op2 = tspace->read_dword_unaligned(addr);
addr += 4;
std::string sop1;
std::string pcrel;
if (opcode == 0xe1)
{
opcode = op2 & 255;
op2 = op1;
sop1 = "ACC";
pcrel = "PC+ACC";
}
else
{
sop1 = util::string_format("%08X", op1);
pcrel = util::string_format("%08X", base + 9 + op1);
}
con.printf("%08X ", base);
// dl=instr ebx=par1 eax=par2
switch (opcode)
{
case 0x01:
// if ((op2 & 0xff) == 0x880) op1=op1 & 0xfffffffd
// out cf8,op2
// out cfc,op1
// out cf8,0
// cf8 (CONFIG_ADDRESS) format:
// 31 30 24 23 16 15 11 10 8 7 2 1 0
// +-+----------+------------+---------------+-----------------+-----------------+-+-+
// | | Reserved | Bus Number | Device Number | Function Number | Register Number |0|0|
// +-+----------+------------+---------------+-----------------+-----------------+-+-+
// 31 - Enable bit
con.printf("POKEPCI PCICONF[%08X]=%s\n", op2, sop1);
break;
case 0x02:
con.printf("OUTB PORT[%08X]=%s\n", op2, sop1);
break;
case 0x03:
con.printf("POKE MEM[%08X]=%s\n", op2, sop1);
break;
case 0x04:
con.printf("BNE IF ACC != %08X THEN PC=%s\n", op2, pcrel);
break;
case 0x05:
// out cf8,op2
// in acc,cfc
con.printf("PEEKPCI ACC=PCICONF[%08X]\n", op2);
break;
case 0x06:
con.printf("AND/OR ACC=(ACC & %08X) | %s\n", op2, sop1);
break;
case 0x07:
con.printf("BRA PC=%s\n", pcrel);
break;
case 0x08:
con.printf("INB ACC=PORT[%08X]\n", op2);
break;
case 0x09:
con.printf("PEEK ACC=MEM[%08X]\n", op2);
break;
case 0xee:
con.printf("END\n");
break;
default:
con.printf("NOP ????\n");
break;
}
if (opcode == 0xee)
break;
if (size <= 9)
break;
size -= 9;
}
}
void chihiro_state::jamtable_disasm_command(const std::vector<std::string_view> ¶ms)
{
address_space &space = m_maincpu->space();
uint64_t addr, size;
if (params.size() < 3)
return;
if (!machine().debugger().console().validate_number_parameter(params[1], addr))
return;
if (!machine().debugger().console().validate_number_parameter(params[2], size))
return;
jamtable_disasm(space, (uint32_t)addr, (uint32_t)size);
}
void chihiro_state::chihiro_help_command(const std::vector<std::string_view> ¶ms)
{
debugger_console &con = machine().debugger().console();
con.printf("Available Chihiro commands:\n");
con.printf(" chihiro jamdis,<start>,<size> -- Disassemble <size> bytes of JamTable instructions starting at <start>\n");
con.printf(" chihiro help -- this list\n");
}
void chihiro_state::debug_commands(const std::vector<std::string_view> ¶ms)
{
if (params.size() < 1)
return;
if (params[0] == "jamdis")
jamtable_disasm_command(params);
else
chihiro_help_command(params);
}
void chihiro_state::hack_eeprom()
{
// 8003b744,3b744=0x90 0x90
m_maincpu->space(AS_PROGRAM).write_byte(0x3b744, 0x90);
m_maincpu->space(AS_PROGRAM).write_byte(0x3b745, 0x90);
m_maincpu->space(AS_PROGRAM).write_byte(0x3b766, 0xc9);
m_maincpu->space(AS_PROGRAM).write_byte(0x3b767, 0xc3);
}
#define HACK_ITEMS 5
static const struct
{
const char *game_name;
struct {
uint32_t address;
uint8_t write_byte;
} modify[16];
} hacks[HACK_ITEMS] = { { "chihiro", { { 0, 0 } } },
{ "outr2", { { 0, 0 } } },
{ "crtaxihr", { { 0x14ada5/*11fda5*/, 0x90 }, { 0x14ada6/*11fda6*/, 0x90 }, { 0, 0 } } },
{ "ghostsqu", { { 0x78833/*4d833*/, 0x90 }, { 0x78834/*4d834*/, 0x90 }, { 0, 0 } } },
{ "vcop3", { { 0x61a23/*36a23*/, 0x90 }, { 0x61a24/*36a24*/, 0x90 }, { 0, 0 } } },
};
void chihiro_state::hack_usb()
{
int p;
if (m_hack_counter == 1)
p = m_hack_index; // need to patch the game
else
p = -1;
if (p >= 0) {
for (int a = 0; a < 16; a++) {
if (hacks[p].modify[a].address == 0)
break;
m_maincpu->space(0).write_byte(hacks[p].modify[a].address, hacks[p].modify[a].write_byte);
}
}
m_hack_counter++;
}
//**************************************************************************
// BASE BOARD USB
//**************************************************************************
//ic10
const USBStandardDeviceDescriptor ohci_hlean2131qc_device::devdesc = { 0x12,0x01,0x0100,0x60,0x00,0x00,0x40,0x0CA3,0x0002,0x0108,0x01,0x02,0x00,0x01 }; // class 0x60 subclass 0x00
const USBStandardConfigurationDescriptor ohci_hlean2131qc_device::condesc = { 0x09,0x02,0x0058,0x01,0x01,0x00,0x80,0x96 };
const USBStandardInterfaceDescriptor ohci_hlean2131qc_device::intdesc = { 0x09,0x04,0x00,0x00,0x0A,0xFF,0x00,0x00,0x00 };
const USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc01 = { 0x07,0x05,0x01,0x02,0x0040,0x00 };
const USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc02 = { 0x07,0x05,0x02,0x02,0x0040,0x00 };
const USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc03 = { 0x07,0x05,0x03,0x02,0x0040,0x00 };
const USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc04 = { 0x07,0x05,0x04,0x02,0x0040,0x00 };
const USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc05 = { 0x07,0x05,0x05,0x02,0x0040,0x00 };
const USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc81 = { 0x07,0x05,0x81,0x02,0x0040,0x00 };
const USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc82 = { 0x07,0x05,0x82,0x02,0x0040,0x00 };
const USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc83 = { 0x07,0x05,0x83,0x02,0x0040,0x00 };
const USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc84 = { 0x07,0x05,0x84,0x02,0x0040,0x00 };
const USBStandardEndpointDescriptor ohci_hlean2131qc_device::enddesc85 = { 0x07,0x05,0x85,0x02,0x0040,0x00 };
const uint8_t ohci_hlean2131qc_device::strdesc0[] = { 0x04,0x03,0x00,0x00 };
const uint8_t ohci_hlean2131qc_device::strdesc1[] = { 0x0A,0x03,0x53,0x00,0x45,0x00,0x47,0x00,0x41,0x00 };
const uint8_t ohci_hlean2131qc_device::strdesc2[] = { 0x0E,0x03,0x42,0x00,0x41,0x00,0x53,0x00,0x45,0x00,0x42,0x03,0xFF,0x0B };
ohci_hlean2131qc_device::ohci_hlean2131qc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, OHCI_HLEAN2131QC, tag, owner, clock)
, device_usb_ohci_function_interface(mconfig, *this)
, m_jvs_master(*this, "^^^^jvs_master")
{
maximum_send = 0;
region_tag = nullptr;
region_offset = 0;
region = nullptr;
jvs.buffer_in_expected = 0;
jvs.buffer_out_used = 0;
jvs.buffer_out_packets = 0;
}
void ohci_hlean2131qc_device::initialize()
{
device_usb_ohci_function_interface::initialize();
add_device_descriptor(devdesc);
add_configuration_descriptor(condesc);
add_interface_descriptor(intdesc);
// it is important to add the endpoints in the same order they are found in the device firmware
add_endpoint_descriptor(enddesc01);
add_endpoint_descriptor(enddesc02);
add_endpoint_descriptor(enddesc03);
add_endpoint_descriptor(enddesc04);
add_endpoint_descriptor(enddesc05);
add_endpoint_descriptor(enddesc81);
add_endpoint_descriptor(enddesc82);
add_endpoint_descriptor(enddesc83);
add_endpoint_descriptor(enddesc84);
add_endpoint_descriptor(enddesc85);
add_string_descriptor(strdesc0);
add_string_descriptor(strdesc1);
add_string_descriptor(strdesc2);
}
void ohci_hlean2131qc_device::set_region_base(uint8_t *data)
{
region = data;
}
void ohci_hlean2131qc_device::set_region(const char *_region_tag, int _region_offset)
{
region_tag = _region_tag;
region_offset = _region_offset;
}
int ohci_hlean2131qc_device::handle_nonstandard_request(int endpoint, USBSetupPacket *setup)
{
int sense;
LOGMASKED(LOG_EXTRA, "Control request to an2131qc: %x %x %x %x %x %x %x\n\r", endpoint, endpoints[endpoint].controldirection, setup->bmRequestType, setup->bRequest, setup->wValue, setup->wIndex, setup->wLength);
if (endpoint != 0)
return -1;
// default valuse for data stage
for (int n = 0; n < setup->wLength; n++)
endpoints[endpoint].buffer[n] = 0x50 ^ n;
sense = m_jvs_master->get_sense_line();
if (sense == 25)
sense = 3;
else
sense = 0; // need to check
// PINSA register, bits 0-2 connected do dip switches 1-3 on filter board, bit 4 to dip switch 4, bit 5 to dip switch 5, bits 6-7 to buttons 1-2 on filter board
// bits 4-1 value must be 10 xor 15, and bit 3 is ignored since its used as the CS pin of the chip
endpoints[endpoint].buffer[1] = 0x4b;
// PINSB register, bits 5-7 connected to 3 leds not mounted on pcb, bit 4 connected to re/de pins of max485, bits 2-3 used as uart pins, bits 0-1 give the status of the sense pin of the jvs connector
// if bits 0-1 are 11, the not all the connected jvs devices have been assigned an address yet
endpoints[endpoint].buffer[2] = 0x52 | sense;
// OUTB register
endpoints[endpoint].buffer[3] = 0x53;
// bRequest is a command value
if (setup->bRequest == 0x16)
{
// this command is used to read data from the first i2c serial eeprom connected to the chip
// setup->wValue = start address to read from
// setup->wIndex = number of bytes to read
// data will be transferred to the host using endpoint 1 (IN)
endpoints[1].remain = setup->wIndex & 255;
endpoints[1].position = region + setup->wValue; // usually wValue is 0x1f00
endpoints[endpoint].buffer[0] = 0;
}
else if (setup->bRequest == 0x17)
{
// this command is used to read data from the second i2c serial eeprom connected to the chip
// setup->wValue = start address to read from
// setup->wIndex = number of bytes to read
// data will be transferred to the host using endpoint 2 (IN)
endpoints[2].remain = setup->wIndex & 255;
endpoints[2].position = region + 0x2000 + setup->wValue;
endpoints[endpoint].buffer[0] = 0;
}
else if (setup->bRequest == 0x18)
{
// this command is used to read data from external memory (with respect to the internal 8051 cpu)
// setup->wValue = start address to read from
// setup->wIndex = number of bytes to read
// data will be transferred to the host using endpoint 3 (IN)
endpoints[endpoint].buffer[0] = 0;
}
else if (setup->bRequest == 0x19)
{
// this command is used to retreive the jvs packets that have been received in response to the ones of 0x20
// data for the packets will be transferred to the host using endpoint 4 (IN)
// the nuber of bytes to transfer is returned at bytes 4 and 5 in the data stage of this control transfer
// data transferred starts with a byte with value 0, then a byte with value the number of packets received, then a block of bytes for each packet
// the bytes for a packet start with the jvs node address of the sender, then a dummy one (must be 0), then a 16 bit number in little endian format that specifies how many bytes follow
// the bytes that follow contain the body of the packet as received from the jvs bus, from the 0xa0 byte to the checksum
endpoints[endpoint].buffer[0] = 0; // 0 if not busy
endpoints[endpoint].buffer[5] = jvs.buffer_out_used >> 8; // amount to transfer with endpoint 4
endpoints[endpoint].buffer[4] = (jvs.buffer_out_used & 0xff);
// the data to be sent is prepared in command 0x20
endpoints[4].remain = jvs.buffer_out_used;
endpoints[4].position = jvs.buffer_out;
jvs.buffer_out_used = 0;
endpoints[endpoint].buffer[0] = 0;
}
else if (setup->bRequest == 0x1c)
{
// this command is used to read from the RV5C386A chip
// setup->wValue = what to read
// setup->wIndex = number of bytes to read
// data will be transferred to the host using endpoint 5 (IN)
endpoints[endpoint].buffer[0] = 0;