/
tumbleb.cpp
3920 lines (3253 loc) · 170 KB
/
tumbleb.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,Bryan McPhail
/***************************************************************************
the following run on hardware which is physically not the same as
Tumble Pop but works in a very similar way.
Tumblepop (c) 1991 Data East Corporation (Bootleg 1)
Tumblepop (c) 1991 Data East Corporation (Bootleg 2)
Jump Kids (c) 1993 Comad
Metal Saver (c) 1994 First Amusement
Magicball Fighting (c) 1994 SemiCom
Pang Pang (c) 1994 Dong Gue La Mi Ltd.
Super Trio[1] (c) 1994 GameAce
Fancy World (c) 1995 Unico
Hatch Catch (c) 1995 SemiCom
Cookie & Bibi[2] (c) 1995 SemiCom
Choky! Choky! (c) 1995 SemiCom
WonderLeague Star (c) 1995 Mijin (Korea Only) - SemiCom used the name Mijin up to 1995
WonderLeague '96 (c) 1996 SemiCom (Korea Only)
SD Fighters (c) 1996 SemiCom (Korea Only)
Carket Ball (c) 1996
Magic Purple (c) 1996 Unico
B.C. Story (c) 1997 SemiCom
MuHanSeungBu (c) 1997 SemiCom (Korea Only)
Date Quiz Go Go (c) 1998 SemiCom (Korea Only)
[1] has the same sprites as the bootlegs, not much else is the same tho
[2] test mode crashes the same way on the real board
cookbiba set doesn't crash, maybe it's newer? check the rest of the code
Bootleg sound is not quite correct yet (Nothing on bootleg 2).
** at least one of the bootlegs uses a protected PIC to drive the OKI **
If you reset the game while pressing START1 and START2, "VER 0.00 JAPAN"
is put into tile ram then MAME crashes !
Sometimes a garbage sprite gets left after the SemiCom logo in Hatch
Catch - other SemiCom games on different hw do this too, might just
be a bug in their code
Emulation by Bryan McPhail, mish@tendril.co.uk
Stephh's notes (based on the games M68000 code and some tests) :
1) 'tumbleb*' and 'jumpkids'
- I don't understand the interest of the "Remove Monsters" Dip Switch :
as I haven't found a way to "end" a level, I guess that it was used to
test the backgrounds and the "platforms".
- The "Edit Levels" Dip Switch allows you to add/delete monsters and
change their position.
Notes (for 'tumbleb*') :
* "worlds" and levels are 0-based (00-09 & 00-09) :
World Name
0 America
1 Brazil
2 Asia
3 Soviet
4 Europe
5 Egypt
6 Australia
7 Antartica
8 Stratosphere
9 Space
* As levels x-9 and 9-x are only constituted of a "big boss", you can't
edit them !
* All data is stored within the range 0x02b8c8-0x02d2c9, but it should be
extended to 0x02ebeb (and perhaps 0x02ffff). TO BE CONFIRMED !
* Once your levels are ready, turn the Dip Switch OFF and reset the game.
* Of course, there is no possibility to save the levels when you exit
MAME, nor the way to reload the default ones 8(
Additional notes (for 'jumpkids') :
* As there are only 9 "worlds", editing "world" 9 ("Space") might cause
unpredictable weird results !
* The "worlds" names are the same, but the background is different :
World Name Background
0 America Stadium
1 Brazil Beach
2 Asia Planet
3 Soviet Prehistoric Ages
4 Europe Castle
5 Egypt Pyramids
6 Australia Lunar base
7 Antartica Bridge
8 Stratosphere ???
9 Space DOES NOT EXIST !
As I'm not sure of the description of the background, feel free to
improve the previous list.
* All data is stored within the range 0x02776e-0x029207, but it should be
extended to 0x02ab29 (and perhaps 0x02ab49). TO BE CONFIRMED !
2) 'metlsavr'
- It is unknown what's the effect of DSW2-6 and DSW 2-7.
All that can be told is that they related somewhere to DSW 2-5 ("Language")
as they affect in game language (but not the one for explanations in "Test Mode").
In fact, some values are put to some RAM addresses, but I can't find what they do :
2-7 2-6 2-5 0x122eec 0x12021a In game language "Test Mode" explanations
OFF OFF OFF 0x00 0x00 English English
ON OFF OFF 0x00 0x01 English English
OFF ON OFF 0x00 0x01 English English
ON ON OFF 0x01 0x00 Korean English
OFF OFF OFF 0x01 0x00 Korean Korean
ON OFF OFF 0x01 0x01 Korean Korean
OFF ON OFF 0x01 0x01 Korean Korean
ON ON OFF 0x00 0x00 English Korean
If you have any clue, please let me know ...
3) 'pangpang'
- The game needs more investigation to get similar infos to "Tumble Pop" bootlegs/ripoffs.
4) 'htchctch'
- As I'm too bad at playing such game, I haven't been able to determine
what's the effect of DSW2-2 (which is called "Stage Skip" in "Test Mode"),
nor when it is supposed to be tested. Leftover from another game ?
- "Difficulty" and "Coinage" Dip Switches aren't visible in "Test Mode".
5) 'cookbib'
- Whatever is written in "Test Mode", Dip Switch bank 1 is unused, so DSW 1-1
(which is called "Stage Skip") might be a leftover from another game.
- "Difficulty" and "Coinage" Dip Switches aren't visible in "Test Mode".
6) 'wlstar'
- DSW 1-3 is read once (check code at 0x000eae), but the address
where the computed value is stored is NEVER read back !
I guess this might be a leftover from another game.
- DSW 2-8 determines the last inning if there is a draw after inning 9.
After inning 9, scores are checked to see if there us still a draw.
Once last inning is over, the game ends regardless of the score.
- The "VS CPU Game Ends" Dip Switch is used when you play a game against the CPU.
If CPU's score is +10 or +7 than player's score, the game ends.
- The "VS Game" Dip Switch affects single game against CPU or other player
(choices 2 and 3). Once the number of innings is achieved, the player(s)
is (are) proposed to continue, provided they get enough credits.
- The "Full 2 Players Game" determines how many credits are required
to enlighten the 4th choice (2 players 9 innings match).
7) 'wonld96'
- I can't determine what's the effect of DSW 1-7 to DSW 1-5 :(
All I can tell is that the computed value (from 0x0000 to 0x0007) is stored at 0x12279c.w
and it is compared with the contents of addresses 0x1207c6.w and 0x12153c.w .
- DSW 1-4 changes the color of the field, but I don't know if it has
some other effects. Please check this out and let me know.
- The "VS CPU Game Ends" Dip Switch is used when you play a game against the CPU.
If CPU's score is +10 or +7 than player's score, the game ends.
- The "VS Game" Dip Switch affects single game against CPU or other player
(choices 2 and 3). Once the number of innings is achieved, the player(s)
is (are) proposed to continue, provided they get enough credits.
- The "Full 2 Players Game" determines how many credits are required
to enlighten the 4th choice (2 players 9 innings match).
- DSW 2-1 should be "Demo Sounds", but there are NEVER demo sounds
due to code at 0x000fe6 ('beq $fea'). So I've marked it as "Unused".
8) 'fncywld'
- I'm not sure about the release date of this game :
* on the title screen, it ALWAYS displays 1996
* when "Language" Dip Switch is set to "English", there is a (c) 1996 "warning"
screen, but when it is set to "Korean", there is a (c) 1995 "warning" screen !
- I don't understand the interest of the "Remove Monsters" Dip Switch :
as I haven't found a way to "end" a level, I guess that it was used to
test the backgrounds and the "platforms".
- The "Edit Levels" Dip Switch allows you to add/delete monsters and
change their position.
This needs more investigation to get similar infos to "Tumble Pop" bootlegs/ripoffs.
9) 'bcstry*'
- DSW 2-6 and DSW 2-7 are read once (check code at 0x000628),
but the address where the computed value is stored is NEVER read back !
I guess this might be a leftover from another game.
- The "Event Selection" Dip Switch allows you to select your events by
pressing BUTTON1 when the moving "cursor" is on the event you want
- The "Control Type" Dip Switch only has an effect during the events :
it means that whatever the settings are, you need the joystick and buttons
to select your character, enter your initials and select your events.
- The "Debug Mode" Dip Switch (known as "Test Mode" ingame) allows you
to select your events by using the joystick then pressing BUTTON1.
This Dip Switch overrides "Event Selection" Dip Switch !
10) 'semibase'
- I'm completely unsure that there are 4 coin slots for this game,
but pressing ANY of the 4 COIN* buttons has the same effect :
credits are incremented depending on "Coinage" settings.
- "Free Play" Dip Switch is bogus : you can only start a VS computer game
unless you insert enough credits (see "Full 2 Players Game" Dip Switch).
- DSW 2-6 and DSW 2-7 are read once (check code at 0x002384),
but the address where the computed value is stored is NEVER read back !
I guess this might be a leftover from another game.
- DSW 2-4 is read once (check code at 0x002366), but the computed value
is the same (0x0009) whatever the settings are. So I've marked it as "Unused".
This Dip Switch was supposed to determine the last inning if there is a draw
after inning 9 un some other Semicom baseball games (eg: 'wlstar').
- The "VS CPU Game Ends" Dip Switch is used when you play a game against the CPU.
If CPU's score is +10 or +7 than player's score, the game ends.
- The "VS Game" Dip Switch affects single game against CPU or other player
(choices 2 and 3). Once the number of innings is achieved, the player(s)
is (are) proposed to continue, provided they get enough credits.
- The "Full 2 Players Game" determines how many credits are required
to enlighten the 4th choice (2 players 9 innings match).
11) 'dquizgo'
- "Free Play" Dip Switch is bogus : you can start a game without inserting a coin,
but you can't use any players joystick controls nor buttons. Ingame bug ?
- "Lives" Dip Switch isn't visible in "Test Mode".
- I'm unsure about the number of buttons for this game : there are 3 buttons in
"Test Mode", but as far as I can see only 1 seems needed when you play the game
and 2 buttons are required to exit some choices of "Test Mode".
MuHanSeungBu
------------
Unfinished Test Mode, Hangs with black screen, same as a real PCB.
Pang Pang
---------
You can't select anything except the first stage on the 'select a stage'
screen.
If you get a high score then your entry in the high-score table will be
corrupt.
There is a chance that both of these are bugs of the original game, it is
just a cheap hack of Tumble Pop afterall. The board doesn't work so it's
impossible to test.
The sound is driven by a read-protected PIC, as is the case with the
tumblepb2 bootleg. I've simulated the sound in tumbleb2 and am using
the same simulation code in pangpang, although pangpang has a few extra
sounds which are not mapped. As the board does not work the accuracy
of the sound simulation cannot be verified.
SD Fighters
-----------
"Time" and "Rounds to Win" Dip Switches aren't visible in "Test Mode".
***************************************************************************/
#include "emu.h"
#include "tumbleb.h"
#include "cpu/z80/z80.h"
#include "cpu/m68000/m68000.h"
#include "cpu/h6280/h6280.h"
#include "cpu/mcs51/mcs51.h" // for semicom mcu
#include "cpu/pic16c5x/pic16c5x.h"
#include "decocrpt.h"
#include "sound/okim6295.h"
#include "sound/ymopm.h"
#include "sound/ymopl.h"
#include "speaker.h"
#define TUMBLEP_HACK 0
/******************************************************************************/
void tumbleb_state::tumblepb_oki_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
if (mem_mask == 0xffff)
{
m_oki->write(data & 0xff);
//printf("tumbleb_oki_w %04x %04x\n", data, mem_mask);
}
else
{
m_oki->write((data >> 8) & 0xff);
//printf("tumbleb_oki_w %04x %04x\n", data, mem_mask);
}
/* STUFF IN OTHER BYTE TOO..*/
}
uint16_t tumbleb_state::tumblepb_prot_r()
{
return ~0;
}
/******************************************************************************/
uint16_t tumbleb_state::tumblepopb_controls_r(offs_t offset)
{
switch (offset << 1)
{
case 0:
return ioport("PLAYERS")->read();
case 2:
return ioport("DSW")->read();
case 8:
return ioport("SYSTEM")->read();
case 10: /* ? */
case 12:
return 0;
}
return -0;
}
/******************************************************************************/
/* Tumble Pop Bootleg Sound Simulation + Notes
tumblepb2 uses a PIC for the sound cpu, this is read protected, so we have to simulate it
1-11 are instruments
12 - enemy bounce off sides
13 - collect coin/item
14 - ??
15 - suck clown
16 - suck man
17 - power up item
18 - general suck
19 - another suck? or unused?
1a - world 1 clown boss bomb explode (maybe)..
1b - brazil boss, fire from ground
1c - pop?
1d - world 1 clown boss hit
1e - america, turtle spit
1f - man spitting fire
20 - france boss die (maybe) / antartica boss land
21 - france boss being hit
22 - taken too long
23 - used for brazil music?
24 - used for brazil music?
25 - egypt world genie boss sound
26 - final boss
27 - bag explode warning
28 - Let's Clean Up
29 - Tumble Pop! (between levels..)
2a - You Did It!
2b - Death
2c - france world boss arms / snowman fire in antartica
2d - space enemy fire
2e - egypt world genie appear
2f - coin
30 - france cannon fire
31 - giant vacuum? (i got this once on antartica..)
32 - world 1 clown boss bomb bounce
33 - end level
34 - end world?
*/
/* music
command 1 - stop?
4 - map screen
5 - america
6 - asia
7 - egypt
8 - antartica
9 - brazil
a - japan
b - australia
c - france
d - how to play
f - stage clear
10 - boss stage
12 - between levels
-- there are more tunes than we have music banks..
i guess some get repeated
*/
void tumbleb_state::tumbleb2_playmusic(okim6295_device *oki)
{
int status = oki->read();
if (m_music_is_playing)
{
if (!BIT(status, 3))
{
oki->write(0x80 | m_music_command);
oki->write(0x00 | 0x82);
}
}
}
INTERRUPT_GEN_MEMBER(tumbleb_state::tumbleb2_interrupt)
{
device.execute().set_input_line(6, HOLD_LINE);
tumbleb2_playmusic(m_oki);
}
static const int tumbleb_sound_lookup[256] = {
/*0 1 2 3 4 5 6 7 8 9 a b c d e f*/
0x00, -2, 0x00, 0x00, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 0x00, -2, /* 0 */
-2, 0x00, -2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, /* 2 */
0x19, 0x00, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 3 */
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 6 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 7 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* f */
};
/* we use channels 1,2,3 for sound effects, and channel 4 for music */
void tumbleb_state::tumbleb2_set_music_bank( int bank )
{
uint8_t *oki = memregion("oki")->base();
memcpy(&oki[0x38000], &oki[0x80000 + 0x38000 + 0x8000 * bank], 0x8000);
}
void tumbleb_state::tumbleb2_play_sound( okim6295_device *oki, int data )
{
int status = oki->read();
if (!BIT(status, 0))
{
oki->write(0x80 | data);
oki->write(0x00 | 0x12);
}
else if (!BIT(status, 1))
{
oki->write(0x80 | data);
oki->write(0x00 | 0x22);
}
else if (!BIT(status, 2))
{
oki->write(0x80 | data);
oki->write(0x00 | 0x42);
}
}
/* yay for terrible looped music .. there aren't even enough songs for all the levels */
// bank 0 - tune 1 = end of level
// bank 0 - tune 2 = end of stage?
// bank 1 = map screen
// bank 2 = asia
// bank 3 = antartica?
// bank 4 = south america
// bank 5 = australia
// bank 6 = america?? or europe?
// bank 7 = how to play?
// bank 8 = boss???
void tumbleb_state::process_tumbleb2_music_command( okim6295_device *oki, int data )
{
int status = oki->read();
if (data == 1) // stop?
{
if (BIT(status, 3))
{
oki->write(0x40); /* Stop playing music */
m_music_is_playing = 0;
}
}
else
{
if (m_music_is_playing != data)
{
m_music_is_playing = data;
oki->write(0x40); // stop the current music
switch (data)
{
case 0x04: // map screen
m_music_bank = 1;
m_music_command = 0x38;
break;
case 0x05: // america
m_music_bank = 6;
m_music_command = 0x38;
break;
case 0x06: // asia
m_music_bank = 2;
m_music_command = 0x38;
break;
case 0x07: // africa/egypt -- don't seem to have a tune for this one
m_music_bank = 4;
m_music_command = 0x38;
break;
case 0x08: // antartica
m_music_bank = 3;
m_music_command = 0x38;
break;
case 0x09: // brazil / south america
m_music_bank = 4;
m_music_command = 0x38;
break;
case 0x0a: // japan -- don't seem to have a tune
m_music_bank = 2;
m_music_command = 0x38;
break;
case 0x0b: // australia
m_music_bank = 5;
m_music_command = 0x38;
break;
case 0x0c: // france/europe
m_music_bank = 6;
m_music_command = 0x38;
break;
case 0x0d: // how to play
m_music_bank = 7;
m_music_command = 0x38;
break;
case 0x0f: // stage clear
m_music_bank = 0;
m_music_command = 0x33;
break;
case 0x10: // boss stage
m_music_bank = 8;
m_music_command = 0x38;
break;
case 0x12: // world clear
m_music_bank = 0;
m_music_command = 0x34;
break;
default: // anything else..
m_music_bank = 8;
m_music_command = 0x38;
break;
}
tumbleb2_set_music_bank(m_music_bank);
tumbleb2_playmusic(oki);
}
}
}
void tumbleb_state::tumbleb2_soundmcu_w(uint16_t data)
{
int sound = tumbleb_sound_lookup[data & 0xff];
if (sound == 0x00)
{
/* pangpang has more commands than tumbleb2, extra sounds */
//osd_printf_debug("Command %04x\n", data);
}
else if (sound == -2)
{
process_tumbleb2_music_command(m_oki, data);
}
else
{
tumbleb2_play_sound(m_oki, sound);
}
}
/******************************************************************************/
void tumbleb_state::tumblepopb_main_map(address_map &map)
{
map(0x000000, 0x07ffff).rom();
#if TUMBLEP_HACK
map(0x000000, 0x07ffff).writeonly(); /* To write levels modifications */
#endif
map(0x100000, 0x100001).rw(FUNC(tumbleb_state::tumblepb_prot_r), FUNC(tumbleb_state::tumblepb_oki_w));
map(0x120000, 0x123fff).ram().share("mainram");
map(0x140000, 0x1407ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0x160000, 0x1607ff).ram().share("spriteram"); /* Bootleg sprite buffer */
map(0x160800, 0x160807).nopw(); /* writes past the end of spriteram */
map(0x180000, 0x18000f).r(FUNC(tumbleb_state::tumblepopb_controls_r));
map(0x18000c, 0x18000d).nopw();
map(0x1a0000, 0x1a07ff).ram();
map(0x300000, 0x30000f).w(FUNC(tumbleb_state::tumblepb_control_0_w));
map(0x320000, 0x320fff).w(FUNC(tumbleb_state::tumblepb_pf1_data_w)).share("pf1_data");
map(0x322000, 0x322fff).w(FUNC(tumbleb_state::tumblepb_pf2_data_w)).share("pf2_data");
map(0x340000, 0x3401ff).nopw(); /* Unused row scroll */
map(0x340400, 0x34047f).nopw(); /* Unused col scroll */
map(0x342000, 0x3421ff).nopw();
map(0x342400, 0x34247f).nopw();
}
void tumbleb_state::tumblepopba_main_map(address_map &map)
{
map(0x000000, 0x07ffff).rom();
#if TUMBLEP_HACK
map(0x000000, 0x07ffff).writeonly(); /* To write levels modifications */
#endif
map(0x120000, 0x123fff).ram().share("mainram");
map(0x140000, 0x1407ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0x180000, 0x18000f).r(FUNC(tumbleb_state::tumblepopb_controls_r));
map(0x180005, 0x180005).lw8(NAME([this] (uint8_t data) { m_oki->set_rom_bank((data >> 4) & 0x03); })); // TODO: verify this
map(0x180007, 0x180007).w(m_oki, FUNC(okim6295_device::write));
map(0x1a0000, 0x1a07ff).ram().share("spriteram"); /* Bootleg sprite buffer */
map(0x1a1000, 0x1a1fff).ram(); // ?
map(0x200000, 0x200fff).ram(); // ?
//map(0x300000, 0x30000f).w(FUNC(tumbleb_state::tumblepb_control_0_w)); // 0x180000?
map(0x320000, 0x320fff).w(FUNC(tumbleb_state::tumblepb_pf1_data_w)).share("pf1_data");
map(0x322000, 0x322fff).w(FUNC(tumbleb_state::tumblepb_pf2_data_w)).share("pf2_data");
}
void tumbleb_pic_state::funkyjetb_map(address_map &map)
{
map(0x000000, 0x07ffff).rom();
map(0x120000, 0x1207ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0x140000, 0x143fff).ram().share("mainram");
map(0x160000, 0x1607ff).ram().share("spriteram");
map(0x1d0382, 0x1d0383).portr("DSW");
map(0x242102, 0x242103).portr("SYSTEM");
map(0x200000, 0x2007ff).ram(); // writes 0x180
map(0x300000, 0x30000f).w(FUNC(tumbleb_pic_state::tumblepb_control_0_w));
map(0x320000, 0x320fff).ram().w(FUNC(tumbleb_pic_state::tumblepb_pf1_data_w)).share("pf1_data");
map(0x322000, 0x322fff).ram().w(FUNC(tumbleb_pic_state::tumblepb_pf2_data_w)).share("pf2_data");
map(0x340000, 0x340bff).ram().share("pf1_rowscroll");
//map(0x342000, 0x342bff).ram().share("pf2_rowscroll");
}
void tumbleb_pic_state::funkyjetb_oki_map(address_map &map)
{
map(0x00000, 0x37fff).rom().region("oki", 0);
map(0x38000, 0x3ffff).bankr("okibank");
}
void tumbleb_state::unico_base_map(address_map &map)
{
map(0x100000, 0x100003).rw("ymsnd", FUNC(ym2151_device::read), FUNC(ym2151_device::write)).umask16(0x00ff);
map(0x100005, 0x100005).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write));
map(0x140000, 0x140fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0x160000, 0x1607ff).ram().share("spriteram"); /* sprites */
map(0x160800, 0x16080f).nopw(); /* goes slightly past the end of spriteram? */
map(0x180000, 0x18000f).r(FUNC(tumbleb_state::tumblepopb_controls_r));
map(0x18000c, 0x18000d).nopw();
map(0x1a0000, 0x1a07ff).ram();
map(0x300000, 0x30000f).w(FUNC(tumbleb_state::tumblepb_control_0_w));
map(0x320000, 0x321fff).ram().w(FUNC(tumbleb_state::fncywld_pf1_data_w)).share("pf1_data");
map(0x322000, 0x323fff).ram().w(FUNC(tumbleb_state::fncywld_pf2_data_w)).share("pf2_data");
map(0x340000, 0x3401ff).nopw(); /* Unused row scroll */
map(0x340400, 0x34047f).nopw(); /* Unused col scroll */
map(0x342000, 0x3421ff).nopw();
map(0x342400, 0x34247f).nopw();
}
void tumbleb_state::fncywld_main_map(address_map &map)
{
map(0x000000, 0x0fffff).rom();
map(0xff0000, 0xffffff).ram();
unico_base_map(map);
}
void tumbleb_state::magipur_main_map(address_map &map)
{
map(0x000000, 0x00ffff).ram().share("mainram");
map(0xf00000, 0xffffff).rom().region("maincpu", 0);
map(0x100010, 0x100011).nopw(); // TODO: what is this, fncywld doesn't write here, can't be related to the RAM/ROM arrangement as the writes happen well after boot
unico_base_map(map);
}
uint16_t tumbleb_state::semibase_unknown_r()
{
return machine().rand();
}
void tumbleb_state::htchctch_main_map(address_map &map)
{
map(0x000000, 0x0fffff).rom();
map(0x100000, 0x10000f).r(FUNC(tumbleb_state::semibase_unknown_r));
map(0x100000, 0x100001).w(FUNC(tumbleb_state::semicom_soundcmd_w));
map(0x100002, 0x100003).w(FUNC(tumbleb_state::bcstory_tilebank_w));
map(0x120000, 0x123fff).ram().share("mainram");
map(0x140000, 0x1407ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0x160000, 0x160fff).ram().share("spriteram"); /* Bootleg sprite buffer */
map(0x180000, 0x18000f).r(FUNC(tumbleb_state::tumblepopb_controls_r));
map(0x18000c, 0x18000d).nopw();
map(0x1a0000, 0x1a0fff).ram();
map(0x300000, 0x30000f).w(FUNC(tumbleb_state::tumblepb_control_0_w));
map(0x320000, 0x321fff).w(FUNC(tumbleb_state::tumblepb_pf1_data_w)).share("pf1_data");
map(0x322000, 0x322fff).w(FUNC(tumbleb_state::tumblepb_pf2_data_w)).share("pf2_data");
map(0x323000, 0x331fff).noprw(); // metal saver writes there when clearing the above tilemaps, flaw in the program routine
map(0x341000, 0x342fff).ram(); // Extra ram?
}
void tumbleb_state::jumpkids_sound_w(uint16_t data)
{
m_soundlatch->write(data & 0xff);
m_audiocpu->set_input_line(0, HOLD_LINE);
}
void tumbleb_state::suprtrio_main_map(address_map &map)
{
map(0x000000, 0x07ffff).rom();
map(0x700000, 0x700fff).ram().share("spriteram");
map(0xa00000, 0xa0000f).ram().share("control");
map(0xa20000, 0xa20fff).ram().w(FUNC(tumbleb_state::tumblepb_pf1_data_w)).share("pf1_data");
map(0xa22000, 0xa22fff).ram().w(FUNC(tumbleb_state::tumblepb_pf2_data_w)).share("pf2_data");
map(0xcf0000, 0xcf05ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0xe00000, 0xe00001).portr("PLAYERS").w(FUNC(tumbleb_state::suprtrio_tilebank_w));
map(0xe40000, 0xe40001).portr("SYSTEM");
map(0xe80002, 0xe80003).portr("DSW");
map(0xec0000, 0xec0001).w(FUNC(tumbleb_state::semicom_soundcmd_w));
map(0xee0001, 0xee0001).lw8(
NAME([this] (offs_t offset, u8 data) {
// writes here after bonus stages,
// expects bits 7-4 of SYSTEM port to read back same value.
// cfr. https://mametesters.org/view.php?id=7148
logerror("Write to prot latch %02x\n", data);
m_suprtrio_prot_latch = data & 0xf;
})
);
map(0xf00000, 0xf07fff).ram();
}
void tumbleb_state::pangpang_main_map(address_map &map)
{
map(0x000000, 0x07ffff).rom();
map(0x120000, 0x123fff).ram().share("mainram");
map(0x140000, 0x1407ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0x160000, 0x1607ff).ram().share("spriteram"); /* Bootleg sprite buffer */
map(0x160800, 0x160807).nopw(); // writes past the end of spriteram
map(0x180000, 0x18000f).r(FUNC(tumbleb_state::tumblepopb_controls_r));
map(0x1a0000, 0x1a07ff).ram();
map(0x300000, 0x30000f).w(FUNC(tumbleb_state::tumblepb_control_0_w));
map(0x320000, 0x321fff).ram().w(FUNC(tumbleb_state::pangpang_pf1_data_w)).share("pf1_data");
map(0x340000, 0x341fff).ram().w(FUNC(tumbleb_state::pangpang_pf2_data_w)).share("pf2_data");
}
/******************************************************************************/
void tumbleb_pic_state::oki_bank_w(uint8_t data)
{
m_okibank->set_entry(data & 0x0f);
}
uint8_t tumbleb_pic_state::pic_data_r()
{
return m_pic_data;
}
void tumbleb_pic_state::pic_data_w(uint8_t data)
{
m_pic_data = data;
}
void tumbleb_pic_state::pic_ctrl_w(uint8_t data)
{
if (!BIT(data, 2))
{
if (!BIT(data, 0))
m_pic_data = m_oki->read();
else if (!BIT(data, 1))
{
logerror("OKI write: %02X\n", m_pic_data);
m_oki->write(m_pic_data);
}
}
if (!BIT(data, 4))
m_pic_data = m_soundlatch->read();
if (!BIT(data, 5))
m_soundlatch->acknowledge_w();
}
void tumbleb_pic_state::driver_start()
{
m_pic_data = 0xff;
save_item(NAME(m_pic_data));
m_okibank->configure_entries(0, 16, memregion("oki")->base(), 0x8000);
}
/******************************************************************************/
void tumbleb_state::semicom_soundcmd_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
if (ACCESSING_BITS_0_7)
{
m_soundlatch->write(data & 0xff);
// needed for Super Trio which reads the sound with polling
// m_maincpu->spin_until_time(attotime::from_usec(100));
machine().scheduler().perfect_quantum(attotime::from_usec(20));
}
}
void tumbleb_state::oki_sound_bank_w(uint8_t data)
{
uint8_t *oki = memregion("oki")->base();
memcpy(&oki[0x30000], &oki[(data * 0x10000) + 0x40000], 0x10000);
}
void tumbleb_state::semicom_sound_map(address_map &map)
{
map(0x0000, 0xcfff).rom();
map(0xd000, 0xd7ff).ram();
map(0xf000, 0xf001).rw("ymsnd", FUNC(ym2151_device::read), FUNC(ym2151_device::write));
map(0xf002, 0xf002).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write));
//map(0xf006, 0xf006) ??
map(0xf008, 0xf008).r(m_soundlatch, FUNC(generic_latch_8_device::read));
map(0xf00e, 0xf00e).w(FUNC(tumbleb_state::oki_sound_bank_w));
}
void tumbleb_state::suprtrio_sound_map(address_map &map)
{
map(0x0000, 0xcfff).rom();
map(0xd000, 0xd7ff).ram();
map(0xf002, 0xf002).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write));
//map(0xf006, 0xf006) ??
map(0xf008, 0xf008).r(m_soundlatch, FUNC(generic_latch_8_device::read));
map(0xf00e, 0xf00e).w(FUNC(tumbleb_state::oki_sound_bank_w));
}
/* Jump Kids */
void tumbleb_state::jumpkids_main_map(address_map &map)
{
map(0x000000, 0x07ffff).rom();
map(0x100000, 0x100001).w(FUNC(tumbleb_state::jumpkids_sound_w));
map(0x120000, 0x123fff).ram().share("mainram");
map(0x140000, 0x1407ff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0x160000, 0x1607ff).ram().share("spriteram"); /* Bootleg sprite buffer */
map(0x160800, 0x160807).nopw(); /* writes past the end of spriteram */
map(0x180000, 0x18000f).r(FUNC(tumbleb_state::tumblepopb_controls_r));
map(0x18000c, 0x18000d).nopw();
map(0x1a0000, 0x1a07ff).ram();
map(0x300000, 0x30000f).w(FUNC(tumbleb_state::tumblepb_control_0_w));
map(0x320000, 0x320fff).w(FUNC(tumbleb_state::tumblepb_pf1_data_w)).share("pf1_data");
map(0x322000, 0x322fff).w(FUNC(tumbleb_state::tumblepb_pf2_data_w)).share("pf2_data");
map(0x340000, 0x3401ff).nopw(); /* Unused row scroll */
map(0x340400, 0x34047f).nopw(); /* Unused col scroll */
map(0x342000, 0x3421ff).nopw();
map(0x342400, 0x34247f).nopw();
}
void tumbleb_state::jumpkids_oki_bank_w(uint8_t data)
{
uint8_t* sound1 = memregion("oki")->base();
uint8_t* sound2 = memregion("oki2")->base();
int bank = data & 0x03;
memcpy(sound1 + 0x20000, sound2 + bank * 0x20000, 0x20000);
}
void tumbleb_state::jumpkids_sound_map(address_map &map)
{
map(0x0000, 0x0fff).rom();
map(0x8000, 0x87ff).ram();
map(0x9000, 0x9000).w(FUNC(tumbleb_state::jumpkids_oki_bank_w));
map(0x9800, 0x9800).rw(m_oki, FUNC(okim6295_device::read), FUNC(okim6295_device::write));
map(0xa000, 0xa000).r(m_soundlatch, FUNC(generic_latch_8_device::read));
}
/* Semicom AT89C52 MCU */
// probably not endian safe
void tumbleb_state::prot_p0_w(uint8_t data)
{
uint16_t word = m_mainram[(m_protbase/2) + m_semicom_prot_offset];
word = (word & 0xff00) | (data << 0);
m_mainram[(m_protbase/2) + m_semicom_prot_offset] = word;
}
// probably not endian safe
void tumbleb_state::prot_p1_w(uint8_t data)
{
uint16_t word = m_mainram[(m_protbase/2) + m_semicom_prot_offset];
word = (word & 0x00ff) | (data << 8);
m_mainram[(m_protbase/2) + m_semicom_prot_offset] = word;
}
void tumbleb_state::prot_p2_w(uint8_t data)
{
m_semicom_prot_offset = data;
}
/******************************************************************************/
static INPUT_PORTS_START( tumblepb )
PORT_START("PLAYERS")
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* button 3 - unused */
PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* button 3 - unused */
PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
PORT_START("SYSTEM")
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 )
PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_VBLANK("screen")
PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("DSW")
PORT_DIPNAME( 0x00e0, 0x00e0, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:1,2,3")
PORT_DIPSETTING( 0x0000, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x0080, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x00e0, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x0060, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x00a0, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0x0020, DEF_STR( 1C_4C ) )
PORT_DIPSETTING( 0x00c0, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x0040, DEF_STR( 1C_6C ) )
PORT_DIPNAME( 0x001c, 0x001c, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW1:4,5,6")
PORT_DIPSETTING( 0x0000, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x0010, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x001c, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x000c, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x0014, DEF_STR( 1C_3C ) )