/
konamigv.cpp
1461 lines (1170 loc) · 53.6 KB
/
konamigv.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:R. Belmont, smf
/***************************************************************************
Konami GV System (aka "Baby Phoenix") - Arcade PSX Hardware
===========================================================
Driver by R. Belmont & smf
***************************************************************************
Konami GV
Hardware Info by Guru
---------------------
Konami GV uses Playstation 1 based hardware.
Known Games
-----------
Game Description Mother Board Code Version Date Time
powyak96 Jikkyou Powerful Pro Yakyuu '96 GV999 GV017 JAPAN 1.03 96.05.27 18:00
hyperath Hyper Athlete ZV610 GV021 JAPAN 1.00 96.06.09 19:00
lacrazyc Let's Attack Crazy Cross ZV610 GV027 ASIA 1.10 96.01.18 12:00
susume Susume! Taisen Puzzle-Dama ZV610 GV027 JAPAN 1.20 96.03.04 12:00
btchamp Beat the Champ GV999 GV053 UAA01 ?
kdeadeye Dead Eye GV999 GV054 UAA01 ?
weddingr Wedding Rhapsody ? GX624 JAA 97.05.29 9:12
tmosh Tokimeki Memorial Oshiete Your Heart GV999 GQ673 JAA 97.03.14 ?
tmoshs Tokimeki Memorial Oshiete Your Heart Seal Version GV999 GE755 JAA 97.08.06 11:52
tmoshspa Tokimeki Memorial Oshiete Your Heart Seal Version Plus GV999 GE756 JAA 97.08.24 12:20
tmoshsp Tokimeki Memorial Oshiete Your Heart Seal Version Plus GV999 GE756 JAB 97.09.27 9:10
nagano98 Winter Olypmics in Nagano 98 GV999 GX720 EAA01 1.03 98.01.08 10:45
naganoj Hyper Olympic in Nagano GV999 GX720 JAA01 1.02 98.01.07 01:10
simpbowl The Simpsons Bowling GV999 GQ829 UAA ?
Notes:
The Tokimeki Memorial Oshiete Your Heart games use an extra PCB plugged in on top for controlling the printer and the sensors.
Additionally, there is a small PCB for connecting to a sensor... PCB number GE755-PWB(S)
The Simpsons Bowling uses an extra PCB plugged in on top containing flash ROMs and circuitry to control the trackball.
Some of the other games may also have extra PCBs.
Have seen two different CD-ROM drives:
- Sony CDU-76S (found in Hyper Athlete)
- Toshiba XM-5401B (found in Tokimeki Memorial Oshiete Your Heart)
PCB Layouts
-----------
ZV610 PWB301331
|---------------------------------------|
| 000180 056602 LM324 CN8|
|CN2 |
| |
| 999A01.7E CN6|
| CXD2922BQ |
| 10E KM416V256BLT-7|
| |
|J 12E |
|A CXD2923AR 058239 |
|M |
|M CXD8530BQ |
|A D482445LGW-A70 53CF96-2 |
| CXD8514Q S|
| D482445LGW-A70 C|
| 67.7376MHz S|
| 53.693175MHz I|
| 32MHz |
| 93C46 KM48V514BJ-6 KM48V514BJ-6 |
| KM48V514BJ-6 KM48V514BJ-6 |
| CN5 CN3 001231 |
|---------------------------------------|
GV999 PWB301949A
|---------------------------------------|
| 056602 LM324 CN8|
|CN2 |
|TEST_SW |
| 999A01.7E CN6|
|MC44200 CN4 CXD2925Q |
| 9E TC51V4260BJ-80|
| |
|J 12E |
|A 058239 |
|M 53.693175MHz |
|M CXD8530CQ |
|A 53CF96-2 |
| CXD8561Q S|
| KM4132G271Q-12 C|
| 67.7376MHz S|
| 53.693175MHz I|
| 32MHz |
| 93C46 KM48V514BJ-6 KM48V514BJ-6 |
| KM48V514BJ-6 KM48V514BJ-6 |
| CN5 CN3 001231 |
|---------------------------------------|
Notes:
- These two PCBs are functionally equivalent and can be exchanged between games and work fine (see CD-swapping note below).
- The Simpsons Bowling and Dead Eye use a GV999 with a daughtercard containing flash ROMs and CPLDs:
PWB402610
Xilinx XC3020A
Xilinx 1718DPC
74F244N (2 of these)
LVT245SS (2 of theses)
On The Simpsons Bowling, this also has one µPD4701AC and an empty space for a second.
- 000180 is used for driving the RGB output. It's a very thin piece of very brittle ceramic
containing a circuit, a LM1203 chip, some smt transistors/caps/resistors etc (let's just say
placing this thing on the edge of the PCB wasn't a good design choice!)
On GV999, it has been replaced by three transistors and a MC44200.
- 056602 seems to be some sort of A/D converter (another ceramic thing containing caps/resistors/transistors and a chip)
- CXD2922 and CXD2925 are SPU's.
- The BIOS on ZV610 and GV999 is identical. It's a 4M mask ROM, compatible with 27C040.
- The CD contains one MODE 1 data track and several Redbook audio tracks which are streamed to the speaker via CN8.
- The ZV and GV PCB's are virtually identical aside from some minor component shuffling and the RGB output mechanism.
However note that the GPU revision is different between the two boards and so are some of the other Sony IC's.
- CN8 used to connect redbook audio output from CD drive to PCB.
- CN6 used to connect power to CD drive.
- CN2 used for extra speaker connection for stereo output.
- CN3, CN5 used for connecting 3rd and 4th player controls.
- CN4 is present only on GV999 and is used to connect extra PCBs with additional functionality.
For example:
The Simpsons Bowling additional flash ROM & trackball control PCB.
Tokimeki Memorial Oshiete Your Heart printer and sensor control PCB.
- 001231, 058239 are PALCE16V8H PALs.
- 10E, 12E are unpopulated positions for 16M TSOP56 FLASHROMs (10E is 9E on GV999).
- If the CD is swapped to another GV game, the game will boot but will stop with an error '25C MBAD' (the EEPROM is 25C)
So the games can not be swapped by simply exchanging CDs because the EEPROM will not re-init itself if the CDROM is swapped.
This appears to be some form of mild protection to stop operators swapping CD's.
However it is possible to swap games to another PCB by exchanging the CD _AND_ the EEPROM from another PCB which belongs
to that same game. It won't work with a blank EEPROM or a different games' EEPROM.
Tokimeki Memorial Oshiete Your Heart control PCB Layout
-------------------------------------------------------
GQ673 PWB404691A
|------------------------|
|CN11 |
| 003673 |----------|
|CN10 74QST3383 LVT245 CN3 |
| CN4 |
|CN9 2SC2320 LS245 |
| 2SC2320 LS273 |
|CN8 2SC2320 HCT04 |
| 2SC2320 MB3516A |
|CN7 14.31818MHz |
| |
|CN6 2SC2320|
|---| uPC324 |---|
|CN5 2SC2320 ADC0838 CXA1585Q |
| PC817 VR 3.579545MHz |
|-------------------------------------------|
Notes: (all main parts shown)
This PCB is plugged into the Tokimeki Memorial Oshiete Your Heart main board into CN4
It provides additional functionality for the printer and sensor(s) and possibly other things.
CN10 & CN11 - TCS7927-54 4-pin mini DIN connectors, S-Video in and out for printer
CN9 - 6 pin connector
CN8 - 5 pin connector
CN7 - 7 pin connector, printer communication
CN6 - 3 pin connector
CN5 - 2 pin connector
CN3 - 4 pin power connector. Joins to CN6 on mainboard via a Y-splitter cable. The other end of the
Y cable is approximately 300mm long and joins to the GE755-PWB(S) PCB.
CN4 - 6 pin connector used to power the CDROM drive
003673 - PAL16V8D
74QST3383 - Quality Semiconductor Inc. High Speed CMOS Bus Exchange Switch
2SC2320 - NPN Transistor equivalent to 2SC945
MB3516A - Fujitsu MB3516A RGB Encoder
uPC324 - NEC uPC324 Low power quad operational amplifier
ADC0838 - Analog Devices ADC0838 8-Bit Serial I/O A/D Converter with Multiplexer Options
PC817 - Sharp PC817 Optocoupler
VR - 500 Ohm potentiometer
CXA1585Q - Sony CXA1585Q RGB Decoder
Tokimeki Memorial Oshiete Your Heart Sensor PCB
-----------------------------------------------
GQ673 PWB404691A
|----------------|
| LS14 E756S1 |
| uPC817 |
| CN1 CN2 CN3 |
|----------------|
Notes:
E756S1 - PAL16V8H
uPC817 - Sharp PC817 Optocoupler
CN1 - 4 pin power connector joining to GQ673 PCB CN3 and CN6 on mainboard via a Y-splitter cable.
CN1/CN2 - 2 pin connector
Notes:
The Tokimeki Memorial Oshiete Your Heart printer appears to be a model based on the Sony UP-1200 which is
a color video printer that takes S-Video as input.
https://www.ykuns-mechanical-club.com/tokimemo.html
https://www2.biglobe.ne.jp/~tell/keihin/tokimeki/tyheart/tyheart.html
***************************************************************************/
#include "emu.h"
#include "bus/nscsi/cd.h"
#include "cpu/psx/psx.h"
#include "machine/eepromser.h"
#include "machine/intelfsh.h"
#include "machine/mb89371.h"
#include "machine/ncr53c90.h"
#include "machine/upd4701.h"
#include "machine/ram.h"
#include "sound/cdda.h"
#include "sound/spu.h"
#include "video/psx.h"
#include "screen.h"
#include "speaker.h"
#include "cdrom.h"
#include "endianness.h"
namespace {
class konamigv_state : public driver_device
{
public:
konamigv_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_screen(*this, "screen")
, m_ncr53cf96(*this, "scsi:7:ncr53cf96")
, m_btc_trackball(*this, "upd%u", 1)
, m_maincpu(*this, "maincpu")
{
}
void kdeadeye(machine_config &config);
void btchamp(machine_config &config);
void konamigv(machine_config &config);
protected:
void konamigv_map(address_map &map);
virtual void machine_start() override;
virtual void machine_reset() override;
void btc_trackball_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
void scsi_dma_read(uint32_t *p_n_psxram, uint32_t n_address, int32_t n_size);
void scsi_dma_write(uint32_t *p_n_psxram, uint32_t n_address, int32_t n_size);
void scsi_drq(int state);
void btchamp_map(address_map &map);
void kdeadeye_map(address_map &map);
TIMER_CALLBACK_MEMBER(scsi_dma_transfer);
required_device<screen_device> m_screen;
required_device<ncr53cf96_device> m_ncr53cf96;
optional_device_array<upd4701_device, 2> m_btc_trackball;
required_device<cpu_device> m_maincpu;
uint32_t *m_dma_data_ptr;
uint32_t m_dma_offset;
int32_t m_dma_size;
bool m_dma_is_write;
bool m_dma_requested;
emu_timer *m_dma_timer;
};
class simpbowl_state : public konamigv_state
{
public:
simpbowl_state(const machine_config &mconfig, device_type type, const char *tag)
: konamigv_state(mconfig, type, tag)
, m_flash8(*this, "flash%u", 0)
{
}
void simpbowl(machine_config &config);
private:
virtual void machine_start() override;
uint16_t flash_r(offs_t offset);
void flash_w(offs_t offset, uint16_t data);
void simpbowl_map(address_map &map);
required_device_array<fujitsu_29f016a_device, 4> m_flash8;
uint32_t m_flash_address = 0;
};
class tokimeki_state : public konamigv_state
{
public:
tokimeki_state(const machine_config &mconfig, device_type type, const char *tag)
: konamigv_state(mconfig, type, tag)
, m_heartbeat(*this, "HEARTBEAT")
, m_gsr(*this, "GSR")
, m_printer_meta(*this, "PRINTER_META")
, m_device_val_start_state(0)
, m_printer_is_manual_layout(false)
{
}
void tmosh(machine_config &config);
void tmoshs_init();
void tmoshsp_init();
void heartbeat_pulse_w(int state);
uint16_t tokimeki_serial_r();
void tokimeki_serial_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
DECLARE_CUSTOM_INPUT_MEMBER(tokimeki_device_check_r);
void tokimeki_device_check_w(int state);
private:
enum
{
// This should actually be A6 sized paper (105mm x 148mm)
PRINTER_PAGE_WIDTH = 800,
PRINTER_PAGE_HEIGHT = 600,
};
virtual void machine_start() override;
virtual void machine_reset() override;
uint32_t printer_screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
void tmosh_map(address_map &map);
TIMER_CALLBACK_MEMBER(heartbeat_timer_tick);
TIMER_CALLBACK_MEMBER(printing_status_timeout);
TIMER_CALLBACK_MEMBER(printer_scan_video_frame);
required_ioport m_heartbeat;
required_ioport m_gsr;
required_ioport m_printer_meta;
uint16_t m_device_val_start_state;
uint16_t m_device_val;
uint8_t m_serial_val;
uint8_t m_serial_len;
uint8_t m_serial_clk;
uint8_t m_serial_sensor_id;
uint16_t m_serial_sensor_data;
uint8_t m_heartbeat_signal;
uint8_t m_printer_bit;
uint8_t m_printer_data[6];
uint8_t m_printer_curbit;
uint8_t m_printer_curbyte;
attotime m_printer_pulse_starttime;
uint8_t m_printer_is_printing;
uint32_t m_printer_current_image;
bool m_printer_is_manual_layout;
bool m_printer_page_is_dirty;
uint8_t m_printer_video_last_vblank_state;
bitmap_rgb32 m_page_bitmap;
emu_timer *m_heartbeat_timer;
emu_timer *m_printer_printing_status_timeout;
emu_timer *m_printer_video_frame_timer;
};
void konamigv_state::konamigv_map(address_map &map)
{
map(0x1f000000, 0x1f00001f).m(m_ncr53cf96, FUNC(ncr53cf96_device::map)).umask16(0x00ff);
map(0x1f100000, 0x1f100003).portr("P1");
map(0x1f100004, 0x1f100007).portr("P2");
map(0x1f100008, 0x1f10000b).portr("P3_P4");
map(0x1f180000, 0x1f180003).portw("EEPROMOUT");
map(0x1f680000, 0x1f68001f).rw("mb89371", FUNC(mb89371_device::read), FUNC(mb89371_device::write)).umask32(0x00ff00ff);
map(0x1f780000, 0x1f780003).nopw(); // watchdog?
}
void simpbowl_state::simpbowl_map(address_map &map)
{
konamigv_map(map);
map(0x1f680080, 0x1f68008f).rw(FUNC(simpbowl_state::flash_r), FUNC(simpbowl_state::flash_w));
map(0x1f6800c0, 0x1f6800c7).r("upd", FUNC(upd4701_device::read_xy)).umask32(0xff00ff00);
map(0x1f6800c9, 0x1f6800c9).r("upd", FUNC(upd4701_device::reset_xy_r));
}
void konamigv_state::btchamp_map(address_map &map)
{
konamigv_map(map);
map(0x1f380000, 0x1f3fffff).rw("flash", FUNC(intelfsh16_device::read), FUNC(intelfsh16_device::write));
map(0x1f680080, 0x1f680087).r(m_btc_trackball[0], FUNC(upd4701_device::read_xy)).umask32(0xff00ff00);
map(0x1f680080, 0x1f680087).r(m_btc_trackball[1], FUNC(upd4701_device::read_xy)).umask32(0x00ff00ff);
map(0x1f680088, 0x1f680089).w(FUNC(konamigv_state::btc_trackball_w));
map(0x1f6800e0, 0x1f6800e3).nopw();
}
void konamigv_state::kdeadeye_map(address_map &map)
{
konamigv_map(map);
map(0x1f380000, 0x1f3fffff).rw("flash", FUNC(intelfsh16_device::read), FUNC(intelfsh16_device::write));
map(0x1f680080, 0x1f680083).portr("GUNX1");
map(0x1f680090, 0x1f680093).portr("GUNY1");
map(0x1f6800a0, 0x1f6800a3).portr("GUNX2");
map(0x1f6800b0, 0x1f6800b3).portr("GUNY2");
map(0x1f6800c0, 0x1f6800c3).portr("BUTTONS");
map(0x1f6800e0, 0x1f6800e3).nopw();
}
void tokimeki_state::tmosh_map(address_map &map)
{
konamigv_map(map);
map(0x1f680080, 0x1f680081).r(FUNC(tokimeki_state::tokimeki_serial_r));
map(0x1f680090, 0x1f680091).w(FUNC(tokimeki_state::tokimeki_serial_w));
}
// SCSI
void konamigv_state::scsi_dma_read(uint32_t *p_n_psxram, uint32_t n_address, int32_t n_size)
{
m_dma_data_ptr = p_n_psxram;
m_dma_offset = n_address;
m_dma_size = n_size * 4;
m_dma_is_write = false;
m_dma_timer->adjust(attotime::from_usec(10));
}
void konamigv_state::scsi_dma_write(uint32_t *p_n_psxram, uint32_t n_address, int32_t n_size)
{
m_dma_data_ptr = p_n_psxram;
m_dma_offset = n_address;
m_dma_size = n_size * 4;
m_dma_is_write = true;
m_dma_timer->adjust(attotime::from_usec(10));
}
TIMER_CALLBACK_MEMBER(konamigv_state::scsi_dma_transfer)
{
if (m_dma_requested && m_dma_data_ptr != nullptr && m_dma_size > 0)
{
if (m_dma_is_write)
m_ncr53cf96->dma_w(util::little_endian_cast<const uint8_t>(m_dma_data_ptr)[m_dma_offset]);
else
util::little_endian_cast<uint8_t>(m_dma_data_ptr)[m_dma_offset] = m_ncr53cf96->dma_r();
m_dma_offset++;
m_dma_size--;
}
if (m_dma_requested && m_dma_size > 0)
m_dma_timer->adjust(attotime::from_usec(10));
}
void konamigv_state::scsi_drq(int state)
{
if (!m_dma_requested && state)
m_dma_timer->adjust(attotime::from_usec(10));
m_dma_requested = state;
}
void konamigv_state::machine_start()
{
m_dma_timer = timer_alloc(FUNC(konamigv_state::scsi_dma_transfer), this);
}
void konamigv_state::machine_reset()
{
m_dma_timer->adjust(attotime::never);
m_dma_data_ptr = nullptr;
m_dma_offset = 0;
m_dma_size = 0;
m_dma_requested = m_dma_is_write = false;
}
void simpbowl_state::machine_start()
{
konamigv_state::machine_start();
save_item(NAME(m_flash_address));
}
void tokimeki_state::machine_start()
{
konamigv_state::machine_start();
save_item(NAME(m_device_val));
save_item(NAME(m_serial_val));
save_item(NAME(m_serial_len));
save_item(NAME(m_serial_clk));
save_item(NAME(m_serial_sensor_id));
save_item(NAME(m_serial_sensor_data));
save_item(NAME(m_heartbeat_signal));
save_item(NAME(m_printer_bit));
save_item(NAME(m_printer_curbit));
save_item(NAME(m_printer_curbyte));
save_item(NAME(m_printer_is_printing));
save_item(NAME(m_printer_current_image));
save_item(NAME(m_printer_data));
save_item(NAME(m_printer_page_is_dirty));
save_item(NAME(m_printer_video_last_vblank_state));
save_item(NAME(m_page_bitmap));
m_heartbeat_timer = timer_alloc(FUNC(tokimeki_state::heartbeat_timer_tick), this);
m_heartbeat_timer->adjust(attotime::zero);
m_printer_printing_status_timeout = timer_alloc(FUNC(tokimeki_state::printing_status_timeout), this);
m_printer_video_frame_timer = timer_alloc(FUNC(tokimeki_state::printer_scan_video_frame), this);
m_page_bitmap.allocate(PRINTER_PAGE_WIDTH, PRINTER_PAGE_HEIGHT);
}
void tokimeki_state::machine_reset()
{
konamigv_state::machine_reset();
m_device_val = m_device_val_start_state;
m_serial_val = 0;
m_serial_len = 0;
m_serial_clk = 0;
m_serial_sensor_id = 0;
m_serial_sensor_data = 0;
m_heartbeat_signal = 1;
m_printer_bit = 0;
m_printer_curbit = 0;
m_printer_curbyte = 0;
m_printer_is_printing = 0;
m_printer_current_image = 0;
m_printer_video_last_vblank_state = 0;
std::fill(std::begin(m_printer_data), std::end(m_printer_data), 0);
m_page_bitmap.fill(0xffffffff);
m_printer_page_is_dirty = true;
}
void konamigv_state::konamigv(machine_config &config)
{
// basic machine hardware
CXD8530BQ(config, m_maincpu, XTAL(67'737'600));
m_maincpu->set_addrmap(AS_PROGRAM, &konamigv_state::konamigv_map);
m_maincpu->subdevice<psxdma_device>("dma")->install_read_handler(5, psxdma_device::read_delegate(&konamigv_state::scsi_dma_read, this));
m_maincpu->subdevice<psxdma_device>("dma")->install_write_handler(5, psxdma_device::write_delegate(&konamigv_state::scsi_dma_write, this));
m_maincpu->subdevice<ram_device>("ram")->set_default_size("2M");
MB89371(config, "mb89371", 0);
EEPROM_93C46_16BIT(config, "eeprom");
NSCSI_BUS(config, "scsi");
NSCSI_CONNECTOR(config, "scsi:4").option_set("cdrom", NSCSI_XM5401).machine_config(
[](device_t *device)
{
device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0);
device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0);
});
NSCSI_CONNECTOR(config, "scsi:7").option_set("ncr53cf96", NCR53CF96).clock(32_MHz_XTAL/2).machine_config(
[this](device_t *device)
{
ncr53cf96_device &adapter = downcast<ncr53cf96_device &>(*device);
adapter.irq_handler_cb().set(":maincpu:irq", FUNC(psxirq_device::intin10));
adapter.drq_handler_cb().set(*this, FUNC(konamigv_state::scsi_drq));
});
// video hardware
CXD8514Q(config, "gpu", XTAL(53'693'175), 0x100000, subdevice<psxcpu_device>("maincpu")).set_screen("screen");
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
// sound hardware
SPEAKER(config, "lspeaker").front_left();
SPEAKER(config, "rspeaker").front_right();
spu_device &spu(SPU(config, "spu", XTAL(67'737'600)/2, subdevice<psxcpu_device>("maincpu")));
spu.add_route(1, "lspeaker", 0.75); // to verify the channels, btchamp's "game sound test" in the sound test menu speaks the words left, right, center
spu.add_route(0, "rspeaker", 0.75);
}
static INPUT_PORTS_START( konamigv )
PORT_START("P1")
PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x00000004, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x00000008, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x00000010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
PORT_BIT( 0x00000020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
PORT_BIT( 0x00000080, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_SERVICE1 )
PORT_SERVICE_NO_TOGGLE( 0x00001000, IP_ACTIVE_LOW )
PORT_BIT( 0x00002000, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_READ_LINE_DEVICE_MEMBER( "eeprom", eeprom_serial_93cxx_device, do_read )
PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0xffff0000, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("P2")
PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x00000004, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x00000008, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x00000010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
PORT_BIT( 0x00000020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
PORT_BIT( 0x00000080, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x00001000, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0xffff0000, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("P3_P4")
PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(3)
PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(3)
PORT_BIT( 0x00000004, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(3)
PORT_BIT( 0x00000008, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(3)
PORT_BIT( 0x00000010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3)
PORT_BIT( 0x00000020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(3)
PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(3)
PORT_BIT( 0x00000080, IP_ACTIVE_LOW, IPT_START3 )
PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(4)
PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(4)
PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(4)
PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(4)
PORT_BIT( 0x00001000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(4)
PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(4)
PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(4)
PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_START4 )
PORT_BIT( 0xffff0000, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("EEPROMOUT")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, di_write)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, cs_write)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, clk_write)
INPUT_PORTS_END
// The Simpsons Bowling
uint16_t simpbowl_state::flash_r(offs_t offset)
{
if (offset == 4) // set odd address
{
m_flash_address |= 1;
}
if (offset == 0)
{
int chip = (m_flash_address >= 0x200000) ? 2 : 0;
int ret = ( m_flash8[chip]->read(m_flash_address & 0x1fffff) & 0xff ) |
( m_flash8[chip+1]->read(m_flash_address & 0x1fffff) << 8 );
m_flash_address++;
return ret;
}
return 0;
}
void simpbowl_state::flash_w(offs_t offset, uint16_t data)
{
int chip;
switch (offset)
{
case 0:
chip = (m_flash_address >= 0x200000) ? 2 : 0;
m_flash8[chip]->write(m_flash_address & 0x1fffff, data&0xff);
m_flash8[chip+1]->write(m_flash_address & 0x1fffff, (data>>8)&0xff);
break;
case 1:
m_flash_address = 0;
m_flash_address |= (data<<1);
break;
case 2:
m_flash_address &= 0xff00ff;
m_flash_address |= (data<<8);
break;
case 3:
m_flash_address &= 0x00ffff;
m_flash_address |= (data<<15);
break;
}
}
void simpbowl_state::simpbowl(machine_config &config)
{
konamigv(config);
m_maincpu->set_addrmap(AS_PROGRAM, &simpbowl_state::simpbowl_map);
FUJITSU_29F016A(config, "flash0");
FUJITSU_29F016A(config, "flash1");
FUJITSU_29F016A(config, "flash2");
FUJITSU_29F016A(config, "flash3");
upd4701_device &upd(UPD4701A(config, "upd"));
upd.set_portx_tag("TRACK0_X");
upd.set_porty_tag("TRACK0_Y");
}
static INPUT_PORTS_START( simpbowl )
PORT_INCLUDE( konamigv )
PORT_START("TRACK0_X")
PORT_BIT( 0xfff, 0x000, IPT_TRACKBALL_X ) PORT_SENSITIVITY(100) PORT_KEYDELTA(63) PORT_REVERSE PORT_PLAYER(1)
PORT_START("TRACK0_Y")
PORT_BIT( 0xfff, 0x000, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(63) PORT_PLAYER(1)
INPUT_PORTS_END
// Beat the Champ
void konamigv_state::btc_trackball_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
// osd_printf_debug( "w %08x %08x %08x %08x\n", m_maincpu->pc(), offset, data, mem_mask );
for (int i = 0; i < 2; i++)
{
m_btc_trackball[i]->cs_w(BIT(data, 1));
m_btc_trackball[i]->resetx_w(!BIT(data, 0));
m_btc_trackball[i]->resety_w(!BIT(data, 0));
}
}
void konamigv_state::btchamp(machine_config &config)
{
konamigv(config);
m_maincpu->set_addrmap(AS_PROGRAM, &konamigv_state::btchamp_map);
SHARP_LH28F400(config, "flash");
UPD4701A(config, m_btc_trackball[0]);
m_btc_trackball[0]->set_portx_tag("TRACK0_X");
m_btc_trackball[0]->set_porty_tag("TRACK0_Y");
UPD4701A(config, m_btc_trackball[1]);
m_btc_trackball[1]->set_portx_tag("TRACK1_X");
m_btc_trackball[1]->set_porty_tag("TRACK1_Y");
}
static INPUT_PORTS_START( btchamp )
PORT_INCLUDE( konamigv )
PORT_START("TRACK0_X")
PORT_BIT( 0xfff, 0x000, IPT_TRACKBALL_X ) PORT_SENSITIVITY(100) PORT_KEYDELTA(63) PORT_PLAYER(1)
PORT_START("TRACK0_Y")
PORT_BIT( 0xfff, 0x000, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(63) PORT_PLAYER(1)
PORT_START("TRACK1_X")
PORT_BIT( 0xfff, 0x000, IPT_TRACKBALL_X ) PORT_SENSITIVITY(100) PORT_KEYDELTA(63) PORT_PLAYER(2)
PORT_START("TRACK1_Y")
PORT_BIT( 0xfff, 0x000, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(63) PORT_PLAYER(2)
INPUT_PORTS_END
// Tokimeki Memorial games - has a heart rate sensor, GSR (galvanic skin response) sensor, and printer
TIMER_CALLBACK_MEMBER(tokimeki_state::heartbeat_timer_tick)
{
const auto heartrate = m_heartbeat->read() & 0xff;
if (heartrate > 0)
{
m_heartbeat_timer->adjust(attotime::from_msec(60'000 / (heartrate + 49)));
m_heartbeat_signal = 0;
}
else
{
// hand not on sensor, wait 100 ms for the heartbeat value to change again
m_heartbeat_timer->adjust(attotime::from_msec(100));
}
}
TIMER_CALLBACK_MEMBER(tokimeki_state::printing_status_timeout)
{
m_printer_is_printing = 0;
}
TIMER_CALLBACK_MEMBER(tokimeki_state::printer_scan_video_frame)
{
// only accept video frame when it's the start of the next vblank area
const int vblank = m_screen->vblank();
const bool is_next_vblank = vblank != m_printer_video_last_vblank_state && vblank != 0;
m_printer_video_last_vblank_state = vblank;
if (!is_next_vblank)
{
m_printer_video_frame_timer->adjust(attotime::from_nsec(500));
return;
}
if (m_printer_is_manual_layout)
{
// 4x4 image layout
// The game tells the printer to take a video still of each individual
// image that'll be printed on the sticker sheet instead of one only
// one picture for the entire sheet like the non-plus version.
// HACK: crop out some unwanted padding and garbage from the input image.
// The left side of image gets cropped off due to PSX gpu rendering issues.
// The actual image itself uses 4x4 pixels except for a few pixels
// around the edge of the image, so those few pixels are also cropped
// to allow for clean scaling without chunky pixels.
const int32_t crop_left = 1;
const int32_t crop_top = 40;
const int32_t crop_right = 19;
const int32_t crop_bottom = 16;
bitmap_rgb32 cropped(
m_screen->curbitmap().as_rgb32(),
{
crop_left,
m_screen->cliprect().max_x - crop_right,
crop_top,
m_screen->cliprect().max_y - crop_bottom,
}
);
// scale the individual screenshot down to roughly the right size
const int32_t inner_pad_x = 6, inner_pad_y = 5;
const int32_t width_margin = 163, height_margin = 161; // full size of padding on both sides
const int32_t dest_w = (PRINTER_PAGE_WIDTH - width_margin - (inner_pad_x * 3)) / 4;
const int32_t dest_h = (PRINTER_PAGE_HEIGHT - height_margin - (inner_pad_y * 3)) / 4;
const int32_t scale_w = (cropped.width() << 16) / dest_w;
const int32_t scale_h = (cropped.height() << 16) / dest_h;
bitmap_rgb32 scaled(dest_w, dest_h);
copyrozbitmap(
scaled,
scaled.cliprect(),
cropped,
0, 0,
scale_w, 0, 0, scale_h,
false
);
// render the cropped and scaled image to the printer page
const int x = (m_printer_current_image % 4) * (scaled.width() + inner_pad_x);
const int y = (m_printer_current_image / 4) * (scaled.height() + inner_pad_y);
copybitmap(m_page_bitmap, scaled, 0, 0, width_margin / 2 + x, height_margin / 2 + y, m_page_bitmap.cliprect());
m_printer_current_image++;
}
else
{
// center entire screen onto printer page
m_page_bitmap.fill(0xffffffff);
const int x = (PRINTER_PAGE_WIDTH - m_screen->width()) / 2;
const int y = (PRINTER_PAGE_HEIGHT - m_screen->height()) / 2;
copybitmap(m_page_bitmap, m_screen->curbitmap().as_rgb32(), 0, 0, x, y, m_page_bitmap.cliprect());
}
}
void tokimeki_state::heartbeat_pulse_w(int state)
{
if (state)
m_heartbeat_signal = 0;
}
uint16_t tokimeki_state::tokimeki_serial_r()
{
uint16_t r = m_heartbeat_signal << 2;
m_heartbeat_signal = 1;
if (m_serial_sensor_id != 0)
r |= BIT(m_serial_sensor_data, 8) << 3;
const auto printer_meta = m_printer_meta->read();
if (!BIT(printer_meta, 0))
r |= 0x20; // no paper loaded
if (!BIT(printer_meta, 1))
r |= 0x80; // printer is malfunctioning
r |= m_printer_is_printing << 6;
return r;
}
void tokimeki_state::tokimeki_serial_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
/*
0x20 = serial clock
0x10 = serial data
0x02 = sensors dest
0x80 = printer s-video in display flag? only shown during printer config menus
0x01 = printer data. the duration of the value being held 1 is used to determine the command or value
*/
const int printer_bit = BIT(data, 0);
if (printer_bit && !m_printer_bit)
{
m_printer_pulse_starttime = machine().time();
}
else if (!printer_bit && m_printer_bit)
{
/*
duration of the transition from 1->0->1 is used to figure out what is being sent/
the durations are clocked against the PS1's clock via GetRCnt(0xf2000002)
internally the values compared are 2400, 4800, and 9600 cycles
9600 = start of new data transfer
4800 = data bit 1
2400 = data bit 0
*/
const auto curtime = machine().time();
const auto ticks = (curtime - m_printer_pulse_starttime).as_ticks(m_maincpu->clock() / 16);
if (ticks >= 9000)
{
// start of data transfer
m_printer_curbit = 0;
}
else
{
// data bit transfer
const int bit = ticks >= 4000 && ticks <= 5600;
if (m_printer_curbit == 0)
m_printer_data[m_printer_curbyte] = 0;
m_printer_data[m_printer_curbyte] |= bit << m_printer_curbit;
m_printer_curbit++;
// game is programmed to always sends two bytes. first byte is 7 bits, second byte is hardcoded to be 0xf9
if ((m_printer_curbyte & 1) == 0 && m_printer_curbit == 7)
{
m_printer_curbyte++;
m_printer_curbit = 0;
}
else if ((m_printer_curbyte & 1) == 1 && m_printer_curbit == 8)
{
if (m_printer_data[m_printer_curbyte] != 0xf9)
logerror("tokimeki printer 2nd byte was expected to be f9, found %02x", m_printer_data[m_printer_curbyte]);
m_printer_curbyte++;
m_printer_curbit = 0;
}
}
if (m_printer_curbyte >= 6)
{
/*
All of the commands seem to correspond to physical buttons available on the machine.
The manual configuration option in the printer test menu appears to let you control
the printer's OSD via the cabinet controls and you can see it sending 64/65/66/67
depending on which direction you press on the joystick.
0x0b = sent before 0x63 -> 0x62 sequence when holding button to exit manual configuration menu. stop?
0x10 = memory in
0x11 = print
0x17 = source/memory?
0x62 = menu