/
segac2.cpp
2967 lines (2385 loc) · 127 KB
/
segac2.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:David Haywood, Aaron Giles
/***********************************************************************************************
Sega System C (System 14)/C2 Driver
driver by David Haywood and Aaron Giles
---------------------------------------
Sega's C2 was used between 1989 and 1994, the hardware being very similar to that
used by the Sega MegaDrive/Genesis Home Console Sega produced around the same time.
The Columns and Bloxeed (USA) manual call this system 'System 14' instead of system C/C2.
todo: fill in protection chip data
Year Game Developer Protection Chip Board Number
==== ==================== ================ =============== ===== =========
1989 Bloxeed Sega / Elorg n/a C
1989 Bloxeed (USA) Sega / Elorg 317-0140 C 171-5880B
1990 Columns Sega 317-0149 C 171-5880B
1990 Columns II Sega 317-0160 C
1990 Thunder Force AC Sega / Technosoft 317-0172 C2
1990 Borench Sega 317-0173 C2
1991 Twin Squash Sega 317-0193 C2
1991 Waku Waku Sonic Patrol Car Sega 317-0140 C2
1992 Ribbit! Sega 317-0178 C2
1992 Ribbit! (Japan) Sega 317-0178 C2
1992 Puyo Puyo Sega / Compile 317-0203 C2 171-5992A
1992 Tant-R (Japan) Sega 317-0211 C2
1992 Tant-R (Korea) Sega ? C2
1992 Waku Waku Marine Sega 317-0140 C2
1993 SegaSonic Popcorn Shop Sega 317-0140 C2
1993 SegaSonic Cosmo Fighter Sega 317-0140 C2
1994 PotoPoto (Japan) Sega 317-0218 C2
1994 Stack Columns (Japan) Sega 317-0219 C2
1994 Stack Columns (World) Sega 317-0223 C2
1994 Ichidant-R (Japan) Sega 317-0224 C2
1994 Ichidant-R (World) Sega ? C2
1994 Ichidant-R (Korea) Sega ? C2
1994 Puyo Puyo 2 Compile 317-0228 C2
1994 Zunzunkyou no Yabou Sega 317-0221 C2
1995 Print Club (Vol.1) Atlus ? C2
1995 Print Club (Vol.2) Atlus ? C2
1996 Print Club (Vol.4) Atlus ? C2
1996 Print Club (Vol.5) Atlus ? C2
Notes: Bloxeed doesn't read from the protection chip at all; all of the other games do.
Currently the protection chip is mostly understood, and needs a table of 256
4-bit values for each game. In all cases except for Poto Poto and Puyo Puyo 2,
the table is embedded in the code. Workarounds for the other 2 cases are
provided.
I'm assuming System-C was the Board without the uPD7759 chip and System-C2 was the
version of the board with it, this could be completely wrong but it doesn't really
matter anyway.
TODO: - Puyo Puyo ends up with a black screen after doing memory tests
- Battery-backed RAM needs to be figured out
- Correct ROM labels for: ssonicbr, ooparts, headonch
- Does ooparts actually use upd samples? PCB has the same rom as tfrceac
- Is the joystick hack for ooparts unofficial, or done by Sega for location test?
Thanks: (in no particular order) to any MameDev that helped me out .. (OG, Mish etc.)
Charles MacDonald for his C2Emu .. without it working out what were bugs in my code
and issues due to protection would have probably killed the driver long ago :p
Razoola & Antiriad .. for helping teach me some 68k ASM needed to work out just why
the games were crashing :)
Sega for producing some Fantastic Games...
The Japanese magazine that proudly previewed OOPArts as "FARTS"
and anyone else who knows they've contributed :)
***********************************************************************************************/
#include "emu.h"
#include "segaipt.h"
#include "cpu/m68000/m68000.h"
#include "machine/nvram.h"
#include "315_5296.h"
#include "sound/sn76496.h"
#include "sound/upd7759.h"
#include "sound/ymopn.h"
#include "video/315_5313.h"
#include "emupal.h"
#include "screen.h"
#include "speaker.h"
#define LOG_PROTECTION (1U << 1)
#define LOG_PALETTE (1U << 2)
#define VERBOSE (0)
#include "logmacro.h"
namespace {
#define XL1_CLOCK XTAL(640'000)
#define XL2_CLOCK XTAL(53'693'175)
typedef device_delegate<int (int in)> segac2_prot_delegate;
class segac2_state : public driver_device
{
public:
segac2_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_paletteram(*this, "paletteram")
, m_vdp(*this, "gen_vdp")
, m_screen(*this, "screen")
, m_upd_region(*this, "upd")
, m_upd7759(*this, "upd")
, m_ymsnd(*this, "ymsnd")
, m_palette(*this, "palette")
, m_io(*this, "io")
, m_prot_func(*this)
{ }
void segac2(machine_config &config);
void segac(machine_config &config);
void tfrceacjpb(machine_config &config);
void ribbit(machine_config &config);
void init_noprot();
void init_columns();
void init_columns2();
void init_tfrceac();
void init_tfrceacb();
void init_borench();
void init_twinsqua();
void init_ribbit();
void init_puyo();
void init_tantr();
void init_tantrkor();
void init_potopoto();
void init_stkclmns();
void init_stkclmnj();
void init_ichir();
void init_ichirk();
void init_ichirj();
void init_ichirjbl();
void init_puyopuy2();
void init_zunkyou();
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
int m_segac2_enable_display;
required_device<m68000_base_device> m_maincpu;
required_shared_ptr<uint16_t> m_paletteram;
required_device<sega315_5313_device> m_vdp;
required_device<screen_device> m_screen;
optional_memory_region m_upd_region;
optional_device<upd7759_device> m_upd7759;
required_device<ym3438_device> m_ymsnd;
required_device<palette_device> m_palette;
required_device<sega_315_5296_device> m_io;
/* protection-related tracking */
segac2_prot_delegate m_prot_func; /* emulation of protection chip */
uint8_t m_prot_write_buf; /* remembers what was written */
uint8_t m_prot_read_buf; /* remembers what was returned */
/* palette-related variables */
uint8_t m_segac2_alt_palette_mode;
uint8_t m_palbank;
uint8_t m_bg_palbase;
uint8_t m_sp_palbase;
/* sound-related variables */
uint8_t m_sound_banks; /* number of sound banks */
void set_prot_func(segac2_prot_delegate prot_func) { m_prot_func = prot_func; }
uint32_t screen_update_segac2_new(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
int m_segac2_bg_pal_lookup[4];
int m_segac2_sp_pal_lookup[4];
void recompute_palette_tables();
void vdp_sndirqline_callback_c2(int state);
void vdp_lv6irqline_callback_c2(int state);
void vdp_lv4irqline_callback_c2(int state);
IRQ_CALLBACK_MEMBER(int_callback);
uint8_t io_portc_r();
void io_portd_w(uint8_t data);
void io_porth_w(uint8_t data);
void segac2_upd7759_w(uint8_t data);
uint16_t palette_r(offs_t offset);
void palette_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
void control_w(uint8_t data);
uint8_t prot_r();
void prot_w(uint8_t data);
void counter_timer_w(uint8_t data);
uint16_t ichirjbl_prot_r();
void segac2_irq2_interrupt(int state);
int prot_func_dummy(int in);
int prot_func_columns(int in);
int prot_func_columns2(int in);
int prot_func_tfrceac(int in);
int prot_func_borench(int in);
int prot_func_ribbit(int in);
int prot_func_twinsqua(int in);
int prot_func_puyo(int in);
int prot_func_tantr(int in);
int prot_func_tantrkor(int in);
int prot_func_potopoto(int in);
int prot_func_stkclmnj(int in);
int prot_func_stkclmns(int in);
int prot_func_ichirj(int in);
int prot_func_ichir(int in);
int prot_func_ichirk(int in);
int prot_func_puyopuy2(int in);
int prot_func_zunkyou(int in);
void segac_map(address_map &map);
void segac2_map(address_map &map);
};
class wwmarine_state : public segac2_state
{
public:
wwmarine_state(const machine_config &mconfig, device_type type, const char *tag)
: segac2_state(mconfig, type, tag)
, m_wheel(*this, "WHEEL")
{ }
ioport_value read_wheel() { return m_wheel->read() | ((m_screen->frame_number() & 1) * 3); }
private:
required_ioport m_wheel;
};
class pclub_state : public segac2_state
{
public:
pclub_state(const machine_config &mconfig, device_type type, const char *tag)
: segac2_state(mconfig, type, tag)
{ }
static constexpr feature_type unemulated_features() { return feature::CAMERA | feature::PRINTER; }
void init_pclub();
void init_pclubj();
void init_pclubjv2();
void init_pclubjv4();
void init_pclubjv5();
private:
int m_cam_data = 0;
uint16_t printer_r();
void print_club_camera_w(uint16_t data);
int prot_func_pclub(int in);
int prot_func_pclubjv2(int in);
int prot_func_pclubjv4(int in);
int prot_func_pclubjv5(int in);
};
/******************************************************************************
Machine start/reset
******************************************************************************/
void segac2_state::machine_start()
{
save_item(NAME(m_prot_write_buf));
save_item(NAME(m_prot_read_buf));
// determine how many sound banks
if (m_upd_region != nullptr)
m_sound_banks = m_upd_region->bytes() / 0x20000;
else
m_sound_banks = 0;
// init the VDP
m_vdp->set_use_cram(0); // C2 uses its own palette ram
m_vdp->set_vdp_pal(false);
m_vdp->set_framerate(60);
m_vdp->set_total_scanlines(262);
m_vdp->stop_timers();
}
void segac2_state::machine_reset()
{
m_segac2_bg_pal_lookup[0] = 0x00;
m_segac2_bg_pal_lookup[1] = 0x10;
m_segac2_bg_pal_lookup[2] = 0x20;
m_segac2_bg_pal_lookup[3] = 0x30;
m_segac2_sp_pal_lookup[0] = 0x00;
m_segac2_sp_pal_lookup[1] = 0x10;
m_segac2_sp_pal_lookup[2] = 0x20;
m_segac2_sp_pal_lookup[3] = 0x30;
m_vdp->device_reset_old();
/* reset the protection */
m_prot_write_buf = 0;
m_prot_read_buf = 0;
m_segac2_alt_palette_mode = 0;
m_palbank = 0;
m_bg_palbase = 0;
m_sp_palbase = 0;
recompute_palette_tables();
}
/******************************************************************************
Sound handlers
*******************************************************************************
These handlers are responsible for communicating with the (generally)
8-bit sound chips. All accesses are via the low byte.
The Sega C/C2 system uses a YM3438 (compatible with the YM2612) for FM-
based music generation, and an SN76489 for PSG and noise effects. The
C2 board also appears to have a UPD7759 for sample playback.
******************************************************************************/
/* handle writes to the UPD7759 */
void segac2_state::segac2_upd7759_w(uint8_t data)
{
m_upd7759->port_w(data);
m_upd7759->start_w(0);
m_upd7759->start_w(1);
}
/******************************************************************************
Palette RAM Read / Write Handlers
*******************************************************************************
The following Read / Write Handlers are used when accessing Palette RAM.
The C2 Hardware appears to use 4 Banks of Colours 1 of which can be Mapped
to 0x8C0000 - 0x8C03FF at any given time by writes to 0x84000E (This same
address also looks to be used for things like Sample Banking)
Each Colour uses 15-bits (from a 16-bit word) in the Format
xBGRBBBB GGGGRRRR (x = unused, B = Blue, G = Green, R = Red)
As this works out the Palette RAM Stores 2048 from a Possible 4096 Colours
at any given time.
******************************************************************************/
/* handle reads from the paletteram */
uint16_t segac2_state::palette_r(offs_t offset)
{
offset &= 0x1ff;
if (m_segac2_alt_palette_mode)
offset = ((offset << 1) & 0x100) | ((offset << 2) & 0x80) | ((~offset >> 2) & 0x40) | ((offset >> 1) & 0x20) | (offset & 0x1f);
return m_paletteram[offset + m_palbank * 0x200];
}
/* handle writes to the paletteram */
void segac2_state::palette_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
int r, g, b, newword;
int tmpr, tmpg, tmpb;
/* adjust for the palette bank */
offset &= 0x1ff;
if (m_segac2_alt_palette_mode)
offset = ((offset << 1) & 0x100) | ((offset << 2) & 0x80) | ((~offset >> 2) & 0x40) | ((offset >> 1) & 0x20) | (offset & 0x1f);
offset += m_palbank * 0x200;
/* combine data */
COMBINE_DATA(&m_paletteram[offset]);
newword = m_paletteram[offset];
/* up to 8 bits */
r = ((newword << 1) & 0x1e) | ((newword >> 12) & 0x01);
g = ((newword >> 3) & 0x1e) | ((newword >> 13) & 0x01);
b = ((newword >> 7) & 0x1e) | ((newword >> 14) & 0x01);
/* set the color */
m_palette->set_pen_color(offset, pal5bit(r), pal5bit(g), pal5bit(b));
tmpr = r >> 1;
tmpg = g >> 1;
tmpb = b >> 1;
m_palette->set_pen_color(offset + 0x800, pal5bit(tmpr), pal5bit(tmpg), pal5bit(tmpb));
// how is it calculated on c2?
tmpr = tmpr | 0x10;
tmpg = tmpg | 0x10;
tmpb = tmpb | 0x10;
m_palette->set_pen_color(offset + 0x1000, pal5bit(tmpr), pal5bit(tmpg), pal5bit(tmpb));
}
/******************************************************************************
Palette Tables
*******************************************************************************
Both the background and sprites within the VDP have 4 possible palettes
to select from. External hardware on the C2 boards, controlled by the
EPM5032 chip and the I/O chip, allows for more complex palette selection.
The actual palette entry comes from:
Bits 10-9 = output from I/O port H
Bits 8-5 = output from EPM5032
Bits 4-0 = direct from the VDP
In order to compute bits 8-5, the EPM5032 gets the sprite/background
output line along with the two bits of palette info. For most games, the
two bits of palette info map straight through as follows:
Bits 10-9 = output from I/O port H
Bits 8 = sprite/background select
Bits 7-6 = palette selected by writing to prot_w
Bits 5-4 = direct from the VDP palette select
Bits 3-0 = direct from the VDP
However, because there are 4 bits completely controlled by the EPM5032,
it doesn't have to always map this way. An alternate palette mode can
be selected which alters the output palette by swizzling the color
RAM address bits.
******************************************************************************/
void segac2_state::recompute_palette_tables()
{
int i;
for (i = 0; i < 4; i++)
{
int bgpal = 0x000 + m_bg_palbase * 0x40 + i * 0x10;
int sppal = 0x100 + m_sp_palbase * 0x40 + i * 0x10;
if (!m_segac2_alt_palette_mode)
{
m_segac2_bg_pal_lookup[i] = 0x200 * m_palbank + bgpal;
m_segac2_sp_pal_lookup[i] = 0x200 * m_palbank + sppal;
}
else
{
m_segac2_bg_pal_lookup[i] = 0x200 * m_palbank + ((bgpal << 1) & 0x180) + ((~bgpal >> 2) & 0x40) + (bgpal & 0x30);
m_segac2_sp_pal_lookup[i] = 0x200 * m_palbank + ((~sppal << 2) & 0x100) + ((sppal << 2) & 0x80) + ((~sppal >> 2) & 0x40) + ((sppal >> 2) & 0x20) + (sppal & 0x10);
}
}
}
/******************************************************************************
Sega 315-5296 I/O chip
******************************************************************************/
uint8_t segac2_state::io_portc_r()
{
// D7 : From MB3773P pin 1. (/RESET output)
// D6 : From uPD7759 pin 18. (/BUSY output)
int busy = (m_upd7759 != nullptr) ? (m_upd7759->busy_r() << 6) : 0x40;
return 0xbf | busy;
}
void segac2_state::io_portd_w(uint8_t data)
{
/*
D7 : To pin 3 of JP15. (Watchdog clock control)
D6 : To MUTE input pin on TDA1518BQ amplifier.
D5 : To CN2 pin 10. (Unknown purpose)
D4 : To CN2 pin 11. (Unknown purpose)
D3 : To CN1 pin K. (Coin lockout 2)
D2 : To CN1 pin 9. (Coin lockout 1)
D1 : To CN1 pin J. (Coin meter 2)
D0 : To CN1 pin 8. (Coin meter 1)
*/
//machine().bookkeeping().coin_lockout_w(1, data & 0x08);
//machine().bookkeeping().coin_lockout_w(0, data & 0x04);
machine().bookkeeping().coin_counter_w(1, data & 0x02);
machine().bookkeeping().coin_counter_w(0, data & 0x01);
}
void segac2_state::io_porth_w(uint8_t data)
{
/*
D7 : To pin A19 of CN4
D6 : To pin B19 of CN4
D5 : ?
D4 : ?
D3 : To pin 31 of uPD7759 sample ROM (A18 on a 27C040)
D2 : To pin 30 of uPD7759 sample ROM (A17 on a 27C040)
D1 : To A10 of color RAM
D0 : To A9 of color RAM
*/
int newbank = data & 3;
if (newbank != m_palbank)
{
//m_screen->update_partial(m_screen->vpos() + 1);
m_palbank = newbank;
recompute_palette_tables();
}
if (m_sound_banks > 1)
{
newbank = (data >> 2) & (m_sound_banks - 1);
m_upd7759->set_rom_bank(newbank);
}
}
/******************************************************************************
Control Write Handler
*******************************************************************************
Seems to control some global states. The most important bit is the low
one, which enables/disables the display. This is used while tiles are
being modified in Bloxeed.
******************************************************************************/
void segac2_state::control_w(uint8_t data)
{
data &= 0x0f;
/* bit 0 controls display enable */
//segac2_enable_display(machine(), ~data & 1);
m_segac2_enable_display = ~data & 1;
/* bit 1 resets the protection */
if (!(data & 2))
m_prot_write_buf = m_prot_read_buf = 0;
/* bit 2 controls palette shuffling; only ribbit and twinsqua use this feature */
m_segac2_alt_palette_mode = ((~data & 4) >> 2);
recompute_palette_tables();
}
/******************************************************************************
Protection Read / Write Handlers
*******************************************************************************
The protection chip is fairly simple. Writes to it control the palette
banking for the sprites and backgrounds. The low 4 bits are also
remembered in a 2-stage FIFO buffer. A read from this chip should
return a value from a 256x4-bit table. The index into this table is
computed by taking the second-to-last value written in the upper 4 bits,
and the previously-fetched table value in the lower 4 bits.
******************************************************************************/
/* protection chip reads */
uint8_t segac2_state::prot_r()
{
LOGMASKED(LOG_PROTECTION, "%06X:protection r=%02X\n", m_maincpu->pcbase(), m_prot_read_buf);
return m_prot_read_buf | 0xf0;
}
/* protection chip writes */
void segac2_state::prot_w(uint8_t data)
{
int new_sp_palbase = (data >> 2) & 3;
int new_bg_palbase = data & 3;
int table_index;
/* compute the table index */
table_index = (m_prot_write_buf << 4) | m_prot_read_buf;
/* keep track of the last write for the next table lookup */
m_prot_write_buf = data & 0x0f;
/* determine the value to return, should a read occur */
m_prot_read_buf = m_prot_func(table_index);
LOGMASKED(LOG_PROTECTION, "%06X:protection w=%02X, new result=%02X\n", m_maincpu->pcbase(), data & 0x0f, m_prot_read_buf);
/* if the palette changed, force an update */
if (new_sp_palbase != m_sp_palbase || new_bg_palbase != m_bg_palbase)
{
//m_screen->update_partial(m_screen->vpos() + 1);
m_sp_palbase = new_sp_palbase;
m_bg_palbase = new_bg_palbase;
recompute_palette_tables();
if (m_screen) LOGMASKED(LOG_PALETTE, "Set palbank: %d/%d (scan=%d)\n", m_bg_palbase, m_sp_palbase, m_screen->vpos());
}
}
/******************************************************************************
Counter/timer I/O
*******************************************************************************
There appears to be a chip that is used to count coins and track time
played, or at the very least the current status of the game. All games
except Puyo Puyo 2 and Poto Poto access this in a mostly consistent
manner.
******************************************************************************/
void segac2_state::counter_timer_w(uint8_t data)
{
/*int value = data & 1;*/
switch (data & 0x1e)
{
case 0x00: /* player 1 start/stop */
case 0x02: /* player 2 start/stop */
case 0x04: /* ??? */
case 0x06: /* ??? */
case 0x08: /* player 1 game timer? */
case 0x0a: /* player 2 game timer? */
case 0x0c: /* ??? */
case 0x0e: /* ??? */
break;
case 0x10: /* coin counter */
// machine().bookkeeping().coin_counter_w(0,1);
// machine().bookkeeping().coin_counter_w(0,0);
break;
case 0x12: /* set coinage info -- followed by two 4-bit values */
break;
case 0x14: /* game timer? (see Tant-R) */
case 0x16: /* intro timer? (see Tant-R) */
case 0x18: /* ??? */
case 0x1a: /* ??? */
case 0x1c: /* ??? */
break;
case 0x1e: /* reset */
break;
}
}
/******************************************************************************
Print Club camera handling
*******************************************************************************
Just some fake stuff to get us to boot.
******************************************************************************/
uint16_t pclub_state::printer_r()
{
return m_cam_data;
}
void pclub_state::print_club_camera_w(uint16_t data)
{
m_cam_data = data;
}
/******************************************************************************
Memory Maps
*******************************************************************************
The System C/C2 68k Memory map is fairly similar to the Genesis in terms
of RAM, ROM, VDP access locations, although the differences between the
arcade system and the Genesis means its not same.
******************************************************************************/
void segac2_state::segac_map(address_map &map)
{
map(0x000000, 0x1fffff).rom();
map(0x800000, 0x800001).mirror(0x13fdfe).rw(FUNC(segac2_state::prot_r), FUNC(segac2_state::prot_w)).umask16(0x00ff);
map(0x800200, 0x800201).mirror(0x13fdfe).w(FUNC(segac2_state::control_w)).umask16(0x00ff);
map(0x840000, 0x84001f).mirror(0x13fee0).rw("io", FUNC(sega_315_5296_device::read), FUNC(sega_315_5296_device::write)).umask16(0x00ff);
map(0x840100, 0x840107).mirror(0x13fef8).rw(m_ymsnd, FUNC(ym3438_device::read), FUNC(ym3438_device::write)).umask16(0x00ff);
map(0x880100, 0x880101).mirror(0x13fefe).w(FUNC(segac2_state::counter_timer_w)).umask16(0x00ff);
map(0x8c0000, 0x8c0fff).mirror(0x13f000).rw(FUNC(segac2_state::palette_r), FUNC(segac2_state::palette_w)).share("paletteram");
map(0xc00000, 0xc0001f).mirror(0x18ff00).rw(m_vdp, FUNC(sega315_5313_device::vdp_r), FUNC(sega315_5313_device::vdp_w));
map(0xe00000, 0xe0ffff).mirror(0x1f0000).ram().share("nvram");
}
void segac2_state::segac2_map(address_map &map)
{
segac_map(map);
map(0x880000, 0x880001).mirror(0x13fefe).w(FUNC(segac2_state::segac2_upd7759_w)).umask16(0x00ff);
}
/******************************************************************************
Input Ports
*******************************************************************************
The input ports on the C2 games always consist of 1 Coin Port, 2 Player
Input ports and 2 Dipswitch Ports, 1 of those Dipswitch Ports being used
for coinage, the other for Game Options.
Most of the Games List the Dipswitches and Inputs in the Test Menus, adding
them is just a tedious task. I think Columnns & Bloxeed are Exceptions
and will need their Dipswitches working out by observation. The Coin Part
of the DSW's seems fairly common to all games.
******************************************************************************/
static INPUT_PORTS_START( systemc_generic )
PORT_START("P1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
PORT_START("P2")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
PORT_START("SERVICE")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_SERVICE_NO_TOGGLE( 0x04, IP_ACTIVE_LOW )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE1 )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("COINAGE")
SEGA_COINAGE_LOC(SW1)
PORT_START("DSW")
PORT_DIPUNUSED_DIPLOC( 0x01, IP_ACTIVE_LOW, "SW2:1" )
PORT_DIPUNUSED_DIPLOC( 0x02, IP_ACTIVE_LOW, "SW2:2" )
PORT_DIPUNUSED_DIPLOC( 0x04, IP_ACTIVE_LOW, "SW2:3" )
PORT_DIPUNUSED_DIPLOC( 0x08, IP_ACTIVE_LOW, "SW2:4" )
PORT_DIPUNUSED_DIPLOC( 0x10, IP_ACTIVE_LOW, "SW2:5" )
PORT_DIPUNUSED_DIPLOC( 0x20, IP_ACTIVE_LOW, "SW2:6" )
PORT_DIPUNUSED_DIPLOC( 0x40, IP_ACTIVE_LOW, "SW2:7" )
PORT_DIPUNUSED_DIPLOC( 0x80, IP_ACTIVE_LOW, "SW2:8" )
INPUT_PORTS_END
static INPUT_PORTS_START( columns )
PORT_INCLUDE( systemc_generic )
PORT_MODIFY("P1")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 2 Unused */
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 3 Unused */
PORT_MODIFY("P2")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 2 Unused */
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 3 Unused */
PORT_MODIFY("DSW")
//"SW2:1" unused
PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:2")
PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
//"SW2:3" unused
//"SW2:4" unused
/* The first level increase (from 0 to 1) is always after destroying
35 jewels. Then, the level gets 1 level more every : */
PORT_DIPNAME( 0x30, 0x30, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:5,6")
PORT_DIPSETTING( 0x00, DEF_STR( Easiest ) ) // 50 jewels
PORT_DIPSETTING( 0x10, DEF_STR( Easy ) ) // 40 jewels
PORT_DIPSETTING( 0x30, DEF_STR( Normal ) ) // 35 jewels
PORT_DIPSETTING( 0x20, DEF_STR( Hard ) ) // 25 jewels
//"SW2:7" unused
//"SW2:8" unused
INPUT_PORTS_END
static INPUT_PORTS_START( columnsu )
PORT_INCLUDE( systemc_generic )
PORT_MODIFY("P1")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 2 Unused */
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 3 Unused */
PORT_MODIFY("P2")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 2 Unused */
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 3 Unused */
PORT_MODIFY("DSW")
PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW2:1")
PORT_DIPSETTING( 0x01, DEF_STR( Upright ) )
PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) )
PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:2")
PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
//"SW2:3" unused
PORT_DIPNAME( 0x04, 0x00, "Background Music" ) PORT_DIPLOCATION("SW2:3") /* listed in the manual, ON by default */
PORT_DIPSETTING( 0x04, "BGM #1" )
PORT_DIPSETTING( 0x00, "BGM #2" )
/* The first level increase (from 0 to 1) is always after destroying
35 jewels. Then, the level gets 1 level more every : */
PORT_DIPNAME( 0x30, 0x30, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:5,6")
PORT_DIPSETTING( 0x00, DEF_STR( Easiest ) ) // 50 jewels
PORT_DIPSETTING( 0x10, DEF_STR( Easy ) ) // 40 jewels
PORT_DIPSETTING( 0x30, DEF_STR( Normal ) ) // 35 jewels
PORT_DIPSETTING( 0x20, DEF_STR( Hard ) ) // 25 jewels
//"SW2:7" unused
//"SW2:8" unused
INPUT_PORTS_END
static INPUT_PORTS_START( columns2 )
PORT_INCLUDE( systemc_generic )
PORT_MODIFY("P1")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 2 Unused */
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 3 Unused */
PORT_MODIFY("P2")
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 2 Unused */
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 3 Unused */
PORT_MODIFY("DSW")
PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW2:1")
PORT_DIPSETTING( 0x01, DEF_STR( Upright ) )
PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) )
PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:2")
PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x0c, 0x0c, "VS. Mode Credits/Match" ) PORT_DIPLOCATION("SW2:3,4")
PORT_DIPSETTING( 0x0c, "1" )
PORT_DIPSETTING( 0x08, "2" )
PORT_DIPSETTING( 0x04, "3" )
PORT_DIPSETTING( 0x00, "4" )
PORT_DIPNAME( 0x30, 0x30, "Flash Mode Difficulty" ) PORT_DIPLOCATION("SW2:5,6") // rising up height per a skull
PORT_DIPSETTING( 0x20, DEF_STR( Easy ) ) // 1
PORT_DIPSETTING( 0x30, DEF_STR( Normal ) ) // 2
PORT_DIPSETTING( 0x10, DEF_STR( Hard ) ) // 3
PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) ) // 4
//"SW2:7" unused
//"SW2:8" unused
INPUT_PORTS_END
static INPUT_PORTS_START( borench )
PORT_INCLUDE( systemc_generic )
PORT_MODIFY("P1")
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 3 Unused */
PORT_MODIFY("P2")
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) /* Button 3 Unused */
PORT_MODIFY("DSW")
PORT_DIPNAME( 0x01, 0x01, "Credits to Start" ) PORT_DIPLOCATION("SW2:1")
PORT_DIPSETTING( 0x01, "1" )
PORT_DIPSETTING( 0x00, "2" )
PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:2")
PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x0c, 0x0c, "Lives 1P Mode" ) PORT_DIPLOCATION("SW2:3,4")
PORT_DIPSETTING( 0x00, "1" )
PORT_DIPSETTING( 0x0c, "2" )
PORT_DIPSETTING( 0x08, "3" )
PORT_DIPSETTING( 0x04, "4" )
PORT_DIPNAME( 0x30, 0x30, "Lives 2P Mode" ) PORT_DIPLOCATION("SW2:5,6")
PORT_DIPSETTING( 0x00, "2" )
PORT_DIPSETTING( 0x30, "3" )
PORT_DIPSETTING( 0x20, "4" )
PORT_DIPSETTING( 0x10, "5" )
PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:7,8")
PORT_DIPSETTING( 0x80, DEF_STR( Easy ) )
PORT_DIPSETTING( 0xc0, DEF_STR( Medium ) )
PORT_DIPSETTING( 0x40, DEF_STR( Hard ) )
PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) )
INPUT_PORTS_END
static INPUT_PORTS_START( tfrceac )
PORT_INCLUDE( systemc_generic )
PORT_MODIFY("DSW")
PORT_DIPNAME( 0x01, 0x01, "Credits to Start" ) PORT_DIPLOCATION("SW2:1")
PORT_DIPSETTING( 0x01, "1" )
PORT_DIPSETTING( 0x00, "2" )
PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:2")
PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW2:3,4")
PORT_DIPSETTING( 0x00, "2" )
PORT_DIPSETTING( 0x0c, "3" )
PORT_DIPSETTING( 0x08, "4" )
PORT_DIPSETTING( 0x04, "5" )
PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW2:5,6")
PORT_DIPSETTING( 0x10, "10k, 70k, 150k" )
PORT_DIPSETTING( 0x30, "20k, 100k, 200k" )
PORT_DIPSETTING( 0x20, "40k, 150k, 300k" )
PORT_DIPSETTING( 0x00, DEF_STR( None ) )
PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:7,8")
PORT_DIPSETTING( 0x80, DEF_STR( Easy ) )
PORT_DIPSETTING( 0xc0, DEF_STR( Medium ) )
PORT_DIPSETTING( 0x40, DEF_STR( Hard ) )
PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) )
INPUT_PORTS_END
static INPUT_PORTS_START( twinsqua )
PORT_INCLUDE( systemc_generic )
PORT_MODIFY("P1")
PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(30) PORT_KEYDELTA(15) PORT_PLAYER(1)
PORT_MODIFY("P2")
PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(30) PORT_KEYDELTA(15) PORT_PLAYER(2)
PORT_MODIFY("SERVICE")
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
PORT_MODIFY("DSW")
PORT_DIPNAME( 0x01, 0x01, "Credits to Start" ) PORT_DIPLOCATION("SW2:1")
PORT_DIPSETTING( 0x01, "1" )
PORT_DIPSETTING( 0x00, "2" )
PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:2")
PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x04, 0x04, "Buy In" ) PORT_DIPLOCATION("SW2:3")
PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x18, 0x18, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:4,5")
PORT_DIPSETTING( 0x10, DEF_STR( Easy ) )
PORT_DIPSETTING( 0x18, DEF_STR( Medium ) )
PORT_DIPSETTING( 0x08, DEF_STR( Hard ) )
PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) )
PORT_DIPNAME( 0x20, 0x20, "Seat Type" ) PORT_DIPLOCATION("SW2:6") // Sega cabinet "MEGALO 50" has "MOVING SEAT"
PORT_DIPSETTING( 0x20, DEF_STR( Normal ) )
PORT_DIPSETTING( 0x00, "Moving" )
//"SW2:7" unused
//"SW2:8" unused
INPUT_PORTS_END
static INPUT_PORTS_START( soniccar )
PORT_INCLUDE( systemc_generic )
PORT_MODIFY("P1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) // siren
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) // jump
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) // turbo
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_RIGHT ) // 'winker' (a left/right joystick)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_LEFT )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_RIGHT ) // steering (it's a wheel on the control panel, but just seems to send left/right signals)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_LEFT )
PORT_MODIFY("P2")
PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_MODIFY("SERVICE")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_SERVICE_NO_TOGGLE( 0x04, IP_ACTIVE_LOW )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE1 )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON3 ) // accel
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_MODIFY("DSW")
PORT_DIPNAME( 0x03, 0x03, "Demo Sound Interval" ) PORT_DIPLOCATION("SW2:1,2")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x01, "Every 4 Minutes" )
PORT_DIPSETTING( 0x02, "Every 2 Minutes" )
PORT_DIPSETTING( 0x03, DEF_STR( On ) )
PORT_DIPNAME( 0x04, 0x04, "Lighting Time" ) PORT_DIPLOCATION("SW2:3")
PORT_DIPSETTING( 0x04, "Advertise & Playtime" )
PORT_DIPSETTING( 0x00, "Playtime Only" )
PORT_DIPNAME( 0x08, 0x08, "Light" ) PORT_DIPLOCATION("SW2:4")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x08, DEF_STR( On ) )
PORT_DIPNAME( 0x10, 0x10, "Screen Display" ) PORT_DIPLOCATION("SW2:5")
PORT_DIPSETTING( 0x10, "Insert 100-400 Yen" )
PORT_DIPSETTING( 0x00, "Insert Money" )
//"SW2:6" unused
//"SW2:7" unused
//"SW2:7" unused
INPUT_PORTS_END
static INPUT_PORTS_START( wwmarine )
PORT_INCLUDE( systemc_generic )
PORT_MODIFY("P1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) // Button 1