/
gaiden.cpp
1723 lines (1432 loc) · 78.8 KB
/
gaiden.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:Phil Stroffolino
/***************************************************************************
Ninja Gaiden memory map (preliminary)
000000-03ffff ROM
060000-063fff RAM
070000-070fff Video RAM (text layer)
072000-075fff VRAM (backgrounds)
076000-077fff Sprite RAM
078000-079fff Palette RAM
memory mapped ports:
read:
07a001 IN0
07a002 IN2
07a003 IN1
07a004 DWSB
07a005 DSWA
see the input_ports definition below for details on the input bits
write:
07a002-07a003 sprite layer Y offset
07a104-07a105 text layer Y scroll
07a108-07a109 text layer Y scroll offset
07a10c-07a10d text layer X scroll
07a204-07a205 front layer Y scroll
07a208-07a209 front layer Y scroll offset
07a20c-07a20d front layer X scroll
07a304-07a305 back layer Y scroll
07a308-07a309 back layer Y scroll offset
07a30c-07a30d back layer X scroll
unknown writes during boot sequence and/or game start:
07a000, 07a004, 07a006, 07a100, 07a110, 07a200, 07a210, 07a300, 07a310
Notes:
- The sprite Y size control is slightly different from gaiden/wildfang to
raiga. In the first two, size X and Y change together, while in the latter
they are changed independently. This is handled with a variable set in
DRIVER_INIT, but it might also be a selectable hardware feature, since
the two extra bits used by raiga are perfectly merged with the rest.
Raiga also uses more sprites than the others, but there's no way to tell
if hardware is more powerful or the extra sprites were just not needed
in the earlier games.
- The hardware supports blending sprites and background.
There are 3 copies of the palette;
- one for pixels that aren't blended
- one for pixels that are behind the object that will be blended
- one for the object that will be blended
Blending is performed by switching to the appropriate palettes for the
pixels behind the blended object and the object itself, and then adding
the RGB values.
- The location of the protection MCU (right next to the DIP switches, and
not populated on Ninja Gaiden) is marked “µPD8049” on the PCB. This has
found to actually be a 8749 (internal EPROM type) on Raiga and Tecmo
Knight/Wild Fang.
todo:
- make sure all of the protection accesses in raiga are handled correctly.
- work out how lower priority sprites are affected by blended sprites.
***************************************************************************/
/***************************************************************************
Strato Fighter (US version)
Tecmo, 1991
PCB Layout
----------
Top Board
---------
0210-A
MG-Y.VO
-----------------------------------------------
| MN50005XTA 4MHz DSW2 DSW1 |
| 6264 6264 8049 |
| IOP8 1.3S 2.4S |
|24MHz |
| |
|18.432MHz J|
| |
| 68000P10 A|
| |
| 6116 M|
| 6116 |
| 6116 M|
| |
| A|
| |
| 6264 YM2203 YM3014 |
| Z80 3.4B |
| 4MHz 6295 4.4A YM2203 YM3014 |
-----------------------------------------------
Bottom Board
------------
0210-B
MG-Y.VO
-----------------------------------------------
| TECMO-5 |
| ----------- |
| | TECMO-06| |
| ROM.M1 ROM.M3 | YM6048 | 6264 |
| ----------- 6264 |
| 4164 4164 4164 4164 |
| 4164 4164 4164 4164 |
| 4164 4164 4164 4164 |
| |
| |
| TECMO-3 TECMO-3 TECMO-3 |
| TECMO-4 TECMO-4 TECMO-4 |
| |
| |
| |
| 6264 6264 6116 6116 6264 |
| ROM.1B ROM.4B 6116 |
| ROM.7A |
-----------------------------------------------
Notes:
68k clock: 9.216 MHz (18.432 / 2)
Z80 clock: 4.000 MHz
YM2203 clock: 4.000 MHz
MSM6295 clock: 1.000 MHz (samplerate 7575Hz, i.e. / 132)
8049 clock: 4.000 MHz (separate XTAL)
IOP8 manufactured by Ricoh. Full part number: RICOH EPLIOP8BP (PAL or PIC?)
***************************************************************************/
#include "emu.h"
#include "gaiden.h"
#include "cpu/m68000/m68000.h"
#include "cpu/z80/z80.h"
#include "cpu/mcs48/mcs48.h"
#include "machine/gen_latch.h"
#include "machine/watchdog.h"
#include "sound/okim6295.h"
#include "sound/ymopm.h"
#include "sound/ymopn.h"
#include "speaker.h"
#include <algorithm>
void gaiden_state::irq_ack_w(uint16_t data)
{
m_maincpu->set_input_line(5, CLEAR_LINE);
}
void gaiden_state::drgnbowl_irq_ack_w(uint8_t data)
{
m_maincpu->set_input_line(5, CLEAR_LINE);
}
/* Wild Fang / Tecmo Knight has a simple protection. It writes codes to 0x07a804, */
/* and reads the answer from 0x07a007. The returned values contain the address of */
/* a function to jump to. */
static const int wildfang_jumppoints[] =
{
0x0c0c,0x0cac,0x0d42,0x0da2,0x0eea,0x112e,0x1300,0x13fa,
0x159a,0x1630,0x109a,0x1700,0x1750,0x1806,0x18d6,0x1a44,
0x1b52
};
void gaiden_state::wildfang_protection_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
if (ACCESSING_BITS_8_15)
{
data >>= 8;
// logerror("PC %06x: prot = %02x\n",m_maincpu->pc(),data);
switch (data & 0xf0)
{
case 0x00: /* init */
m_prot = 0x00;
break;
case 0x10: /* high 4 bits of jump code */
m_jumpcode = (data & 0x0f) << 4;
m_prot = 0x10;
break;
case 0x20: /* low 4 bits of jump code */
m_jumpcode |= data & 0x0f;
if (m_jumpcode >= std::size(wildfang_jumppoints))
{
logerror("unknown jumpcode %02x\n", m_jumpcode);
m_jumpcode = 0;
}
m_prot = 0x20;
break;
case 0x30: /* ask for bits 12-15 of function address */
m_prot = 0x40 | ((m_jumppoints[m_jumpcode] >> 12) & 0x0f);
break;
case 0x40: /* ask for bits 8-11 of function address */
m_prot = 0x50 | ((m_jumppoints[m_jumpcode] >> 8) & 0x0f);
break;
case 0x50: /* ask for bits 4-7 of function address */
m_prot = 0x60 | ((m_jumppoints[m_jumpcode] >> 4) & 0x0f);
break;
case 0x60: /* ask for bits 0-3 of function address */
m_prot = 0x70 | ((m_jumppoints[m_jumpcode] >> 0) & 0x0f);
break;
}
}
}
uint16_t gaiden_state::wildfang_protection_r()
{
// logerror("PC %06x: read prot %02x\n", m_maincpu->pc(), m_prot);
return m_prot;
}
/*
Raiga Protection
MCU read routine is at D9CE
startup codes
it reads 00/36/0e/11/33/34/2d, fetching some code copied to RAM,
and a value which is used as an offset to point to the code in RAM.
19/12/31/28 are read repeatedly, from the interrupt, and the returned
value changes, some kind of mode set command?
level codes
00 | score screen after level 1 (5457)
01 | score screen after level 2 (494e)
02 | score screen after level 3 (5f4b)
03 | score screen after level 4 (4149)
04 | score screen after level 5 (5345)
05 | score screen after level 6 + first loop end sequence (525f)
06 | score screen after second loop level 1 (4d49)
07 | score screen after second loop level 2 (5941)
08 | score screen after second loop level 3 (5241)
09 | score screen after second loop level 4 (5349)
0a | score screen after second loop level 5 (4d4f)
0b | score screen after second loop level 6 + final end sequence (4a49)
other game codes
13 | Game over (594f)
15 | at the start of second level attract mode (4e75)
1c | start of level 4 attract mode (4e75)
1e | after continue .. (5349)
23 | after entering hi-score (4e75)
25 | after attract level 1 (4849)
2b | after japan / wdud screen, to get back to 'tecmo presents' (524f)
also bonus life + when the boss appears but I think they use the
same commands as some of the above
*/
/* these are used during startup */
static const int raiga_jumppoints_00[0x100] =
{
0x6669, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1,0x4a46, -1,
-1,0x6704, -2, -1, -1, -1, -1, -1,
-1, -2, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-2, -1, -1, -1, -1,0x4e75, -1, -1,
-1, -2, -1,0x4e71,0x60fc, -1,0x7288, -1,
-1, -1, -1, -1, -1, -1, -1, -1
};
/* these are used the rest of the time */
static const int raiga_jumppoints_other[0x100] =
{
0x5457,0x494e,0x5f4b,0x4149,0x5345,0x525f,0x4d49,0x5941,
0x5241,0x5349,0x4d4f,0x4a49, -1, -1, -1, -1,
-1, -1, -2,0x594f, -1,0x4e75, -1, -1,
-1, -2, -1, -1,0x4e75, -1,0x5349, -1,
-1, -1, -1,0x4e75, -1,0x4849, -1, -1,
-2, -1, -1,0x524f, -1, -1, -1, -1,
-1, -2, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1
};
void gaiden_state::machine_reset()
{
m_prot = 0;
m_jumpcode = 0;
m_tx_scroll_x = 0;
m_tx_scroll_y = 0;
m_bg_scroll_x = 0;
m_bg_scroll_y = 0;
m_fg_scroll_x = 0;
m_fg_scroll_y = 0;
m_tx_offset_y = 0;
m_fg_offset_y = 0;
m_bg_offset_y = 0;
m_spr_offset_y = 0;
}
MACHINE_RESET_MEMBER(gaiden_state,raiga)
{
gaiden_state::machine_reset();
m_jumppoints = raiga_jumppoints_00;
}
void gaiden_state::machine_start()
{
save_item(NAME(m_prot));
save_item(NAME(m_jumpcode));
save_item(NAME(m_tx_scroll_x));
save_item(NAME(m_tx_scroll_y));
save_item(NAME(m_bg_scroll_x));
save_item(NAME(m_bg_scroll_y));
save_item(NAME(m_fg_scroll_x));
save_item(NAME(m_fg_scroll_y));
save_item(NAME(m_tx_offset_y));
save_item(NAME(m_fg_offset_y));
save_item(NAME(m_bg_offset_y));
save_item(NAME(m_spr_offset_y));
}
void gaiden_state::raiga_protection_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
if (ACCESSING_BITS_8_15)
{
data >>= 8;
// logerror("PC %06x: prot = %02x\n", m_maincpu->pc(), data);
switch (data & 0xf0)
{
case 0x00: /* init */
m_prot = 0x00;
break;
case 0x10: /* high 4 bits of jump code */
m_jumpcode = (data & 0x0f) << 4;
m_prot = 0x10;
break;
case 0x20: /* low 4 bits of jump code */
m_jumpcode |= data & 0x0f;
logerror("requested protection jumpcode %02x\n", m_jumpcode);
// m_jumpcode = 0;
if (m_jumppoints[m_jumpcode] == -2)
{
m_jumppoints = raiga_jumppoints_other;
}
if (m_jumppoints[m_jumpcode] == -1)
{
logerror("unknown jumpcode %02x\n", m_jumpcode);
popmessage("unknown jumpcode %02x", m_jumpcode);
m_jumpcode = 0;
}
m_prot = 0x20;
break;
case 0x30: /* ask for bits 12-15 of function address */
m_prot = 0x40 | ((m_jumppoints[m_jumpcode] >> 12) & 0x0f);
break;
case 0x40: /* ask for bits 8-11 of function address */
m_prot = 0x50 | ((m_jumppoints[m_jumpcode] >> 8) & 0x0f);
break;
case 0x50: /* ask for bits 4-7 of function address */
m_prot = 0x60 | ((m_jumppoints[m_jumpcode] >> 4) & 0x0f);
break;
case 0x60: /* ask for bits 0-3 of function address */
m_prot = 0x70 | ((m_jumppoints[m_jumpcode] >> 0) & 0x0f);
break;
}
}
}
uint16_t gaiden_state::raiga_protection_r()
{
// logerror("PC %06x: read prot %02x\n", m_maincpu->pc(), m_prot);
return m_prot;
}
void gaiden_state::gaiden_map(address_map &map)
{
map(0x000000, 0x03ffff).rom();
map(0x060000, 0x063fff).ram();
map(0x070000, 0x070fff).ram().w(FUNC(gaiden_state::tx_videoram_w)).share("videoram1");
map(0x072000, 0x073fff).ram().w(FUNC(gaiden_state::fg_videoram_w)).share("videoram2");
map(0x074000, 0x075fff).ram().w(FUNC(gaiden_state::bg_videoram_w)).share("videoram3");
map(0x076000, 0x077fff).ram().share("spriteram");
map(0x078000, 0x079fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0x07a000, 0x07a001).portr("SYSTEM");
map(0x07a002, 0x07a003).portr("P1_P2").w(FUNC(gaiden_state::gaiden_sproffsety_w));
map(0x07a004, 0x07a005).portr("DSW");
map(0x07a104, 0x07a105).w(FUNC(gaiden_state::gaiden_txscrolly_w));
map(0x07a108, 0x07a109).w(FUNC(gaiden_state::gaiden_txoffsety_w));
map(0x07a10c, 0x07a10d).w(FUNC(gaiden_state::gaiden_txscrollx_w));
map(0x07a204, 0x07a205).w(FUNC(gaiden_state::gaiden_fgscrolly_w));
map(0x07a208, 0x07a209).w(FUNC(gaiden_state::gaiden_fgoffsety_w));
map(0x07a20c, 0x07a20d).w(FUNC(gaiden_state::gaiden_fgscrollx_w));
map(0x07a304, 0x07a305).w(FUNC(gaiden_state::gaiden_bgscrolly_w));
map(0x07a308, 0x07a309).w(FUNC(gaiden_state::gaiden_bgoffsety_w));
map(0x07a30c, 0x07a30d).w(FUNC(gaiden_state::gaiden_bgscrollx_w));
map(0x07a800, 0x07a801).w("watchdog", FUNC(watchdog_timer_device::reset16_w));
// Ninja Gaiden writes only to the lower byte; Tecmo Knight and Strato Fighter write to the upper byte instead.
// It's not clear which 8 data lines are actually connected, but byte smearing is almost certainly involved.
map(0x07a802, 0x07a803).w("soundlatch", FUNC(generic_latch_8_device::write)).umask16(0x00ff).cswidth(16);
map(0x07a806, 0x07a807).w(FUNC(gaiden_state::irq_ack_w));
map(0x07a808, 0x07a809).w(FUNC(gaiden_state::gaiden_flip_w));
}
void gaiden_state::wildfang_map(address_map &map)
{
gaiden_map(map);
map(0x07a006, 0x07a007).r(FUNC(gaiden_state::wildfang_protection_r));
map(0x07a804, 0x07a805).w(FUNC(gaiden_state::wildfang_protection_w));
}
void gaiden_state::raiga_map(address_map &map)
{
gaiden_map(map);
map(0x07a006, 0x07a007).r(FUNC(gaiden_state::raiga_protection_r));
map(0x07a804, 0x07a805).w(FUNC(gaiden_state::raiga_protection_w));
}
void gaiden_state::drgnbowl_map(address_map &map)
{
map(0x000000, 0x03ffff).rom();
map(0x060000, 0x063fff).ram();
map(0x070000, 0x070fff).ram().w(FUNC(gaiden_state::tx_videoram_w)).share("videoram1");
map(0x072000, 0x073fff).ram().w(FUNC(gaiden_state::fg_videoram_w)).share("videoram2");
map(0x074000, 0x075fff).ram().w(FUNC(gaiden_state::bg_videoram_w)).share("videoram3");
map(0x076000, 0x077fff).ram().share("spriteram");
map(0x078000, 0x079fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0x07a000, 0x07a001).portr("SYSTEM");
map(0x07a002, 0x07a003).portr("P1_P2");
map(0x07a004, 0x07a005).portr("DSW");
map(0x07a00e, 0x07a00e).w("soundlatch", FUNC(generic_latch_8_device::write));
map(0x07e000, 0x07e000).w(FUNC(gaiden_state::drgnbowl_irq_ack_w));
map(0x07f000, 0x07f001).w(FUNC(gaiden_state::gaiden_bgscrolly_w));
map(0x07f002, 0x07f003).w(FUNC(gaiden_state::gaiden_bgscrollx_w));
map(0x07f004, 0x07f005).w(FUNC(gaiden_state::gaiden_fgscrolly_w));
map(0x07f006, 0x07f007).w(FUNC(gaiden_state::gaiden_fgscrollx_w));
}
void gaiden_state::sound_map(address_map &map)
{
map(0x0000, 0xdfff).rom();
map(0xe000, 0xefff).rom(); /* raiga only */
map(0xf000, 0xf7ff).ram();
map(0xf800, 0xf800).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write));
map(0xf810, 0xf811).w("ym1", FUNC(ym2203_device::write));
map(0xf820, 0xf821).w("ym2", FUNC(ym2203_device::write));
map(0xfc00, 0xfc00).noprw(); /* ?? */
map(0xfc20, 0xfc20).r("soundlatch", FUNC(generic_latch_8_device::read));
}
void gaiden_state::drgnbowl_sound_map(address_map &map)
{
map(0x0000, 0xf7ff).rom();
map(0xf800, 0xffff).ram();
}
void gaiden_state::drgnbowl_sound_port_map(address_map &map)
{
map.global_mask(0xff);
map(0x00, 0x01).rw("ymsnd", FUNC(ym2151_device::read), FUNC(ym2151_device::write));
map(0x80, 0x80).rw("oki", FUNC(okim6295_device::read), FUNC(okim6295_device::write));
map(0xc0, 0xc0).r("soundlatch", FUNC(generic_latch_8_device::read));
}
static INPUT_PORTS_START( common )
PORT_START("SYSTEM")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_START("P1_P2")
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) 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_BUTTON3 ) PORT_PLAYER(1)
PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) 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_BUTTON3 ) PORT_PLAYER(2)
PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_START("DSW")
PORT_DIPNAME( 0x00e0, 0x00e0, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SWA:3,2,1")
PORT_DIPSETTING( 0x0000, DEF_STR( 5C_1C ) )
PORT_DIPSETTING( 0x0080, DEF_STR( 4C_1C ) )
PORT_DIPSETTING( 0x0040, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x0020, 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( 0x00c0, DEF_STR( 1C_4C ) )
PORT_DIPNAME( 0x001c, 0x001c, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SWA:6,5,4")
PORT_DIPSETTING( 0x0000, DEF_STR( 5C_1C ) )
PORT_DIPSETTING( 0x0010, DEF_STR( 4C_1C ) )
PORT_DIPSETTING( 0x0008, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x0004, 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 ) )
PORT_DIPSETTING( 0x0018, DEF_STR( 1C_4C ) )
PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SWA:7")
PORT_DIPSETTING( 0x0002, DEF_STR( Off ) )
PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SWA:8")
PORT_DIPSETTING( 0x0000, DEF_STR( Off ) )
PORT_DIPSETTING( 0x0001, DEF_STR( On ) )
PORT_DIPNAME( 0xc000, 0xc000, DEF_STR( Lives ) ) PORT_DIPLOCATION("SWB:2,1")
PORT_DIPSETTING( 0x0000, "1" )
PORT_DIPSETTING( 0xc000, "2" )
PORT_DIPSETTING( 0x4000, "3" )
PORT_DIPSETTING( 0x8000, "4" )
PORT_DIPNAME( 0x3000, 0x3000, "Energy" ) PORT_DIPLOCATION("SWB:4,3")
PORT_DIPSETTING( 0x0000, "2" )
PORT_DIPSETTING( 0x3000, "3" )
PORT_DIPSETTING( 0x1000, "4" )
PORT_DIPSETTING( 0x2000, "5" )
PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SWB:6,5")
PORT_DIPSETTING( 0x0c00, DEF_STR( Normal ) )
PORT_DIPSETTING( 0x0400, "TBL 1" )
PORT_DIPSETTING( 0x0800, "TBL 2" )
PORT_DIPSETTING( 0x0000, "TBL 3" )
PORT_DIPUNUSED_DIPLOC( 0x0200, 0x0200, "SWB:7" )
PORT_DIPUNUSED_DIPLOC( 0x0100, 0x0100, "SWB:8" )
INPUT_PORTS_END
static INPUT_PORTS_START( drgnbowl )
PORT_INCLUDE( common )
PORT_MODIFY("DSW")
PORT_DIPUNUSED_DIPLOC( 0x0002, 0x0002, "SWA:7" ) /* No Flip Screen */
INPUT_PORTS_END
static INPUT_PORTS_START( wildfang )
PORT_INCLUDE( common )
PORT_MODIFY("DSW")
PORT_DIPNAME( 0xc000, 0xc000, DEF_STR( Lives ) ) PORT_DIPLOCATION("SWB:2,1")
PORT_DIPSETTING( 0x8000, "1" )
PORT_DIPSETTING( 0xc000, "2" )
PORT_DIPSETTING( 0x4000, "3" )
/* PORT_DIPSETTING( 0x0000, "2" ) */
/* When bit 0 is On, use bits 4 and 5 for difficulty */
PORT_DIPNAME( 0x3000, 0x3000, "Difficulty (Tecmo Knight)" ) PORT_DIPLOCATION("SWB:4,3")
PORT_DIPSETTING( 0x3000, DEF_STR( Easy ) )
PORT_DIPSETTING( 0x1000, DEF_STR( Normal ) )
PORT_DIPSETTING( 0x2000, DEF_STR( Hard ) )
PORT_DIPSETTING( 0x0000, DEF_STR( Hardest ) )
/* When bit 0 is 0ff, use bits 2 and 3 for difficulty */
PORT_DIPNAME( 0x0c00, 0x0c00, "Difficulty (Wild Fang)" ) PORT_DIPLOCATION("SWB:6,5")
PORT_DIPSETTING( 0x0c00, DEF_STR( Easy ) )
PORT_DIPSETTING( 0x0400, DEF_STR( Normal ) )
PORT_DIPSETTING( 0x0800, DEF_STR( Hard ) )
PORT_DIPSETTING( 0x0000, DEF_STR( Hardest ) )
PORT_DIPNAME( 0x0100, 0x0100, "Title" ) PORT_DIPLOCATION("SWB:8") // also affects Difficulty Table (see above)
PORT_DIPSETTING( 0x0100, "Wild Fang" )
PORT_DIPSETTING( 0x0000, "Tecmo Knight" )
INPUT_PORTS_END
static INPUT_PORTS_START( tknight )
PORT_INCLUDE( wildfang )
PORT_MODIFY("DSW")
PORT_DIPUNUSED_DIPLOC( 0x2000, 0x2000, "SWB:3" ) /* No separate difficulty option like parent set */
PORT_DIPUNUSED_DIPLOC( 0x1000, 0x1000, "SWB:4" ) /* No separate difficulty option like parent set */
PORT_DIPUNUSED_DIPLOC( 0x0100, 0x0100, "SWB:8" ) /* No title change option */
INPUT_PORTS_END
static INPUT_PORTS_START( raiga )
PORT_INCLUDE( common )
PORT_MODIFY("P1_P2") /* Only 2 Buttons */
PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
/* Dip Switches order fits the first screen */
PORT_MODIFY("DSW")
PORT_DIPNAME( 0x00f0, 0x00f0, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SWA:4,3,2,1")
PORT_DIPSETTING( 0x0000, DEF_STR( 5C_1C ) )
PORT_DIPSETTING( 0x0040, DEF_STR( 4C_1C ) )
PORT_DIPSETTING( 0x00a0, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x0010, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x0020, DEF_STR( 3C_2C ) )
PORT_DIPSETTING( 0x0080, DEF_STR( 4C_3C ) )
PORT_DIPSETTING( 0x00f0, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x00c0, DEF_STR( 3C_4C ) )
PORT_DIPSETTING( 0x00e0, DEF_STR( 2C_3C ) )
PORT_DIPSETTING( 0x0070, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x0060, DEF_STR( 2C_5C ) )
PORT_DIPSETTING( 0x00b0, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0x0030, DEF_STR( 1C_4C ) )
PORT_DIPSETTING( 0x00d0, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x0050, DEF_STR( 1C_6C ) )
PORT_DIPSETTING( 0x0090, DEF_STR( 1C_7C ) )
PORT_DIPNAME( 0x000f, 0x000f, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SWA:8,7,6,5")
PORT_DIPSETTING( 0x0000, DEF_STR( 5C_1C ) )
PORT_DIPSETTING( 0x0004, DEF_STR( 4C_1C ) )
PORT_DIPSETTING( 0x000a, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x0001, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x0002, DEF_STR( 3C_2C ) )
PORT_DIPSETTING( 0x0008, DEF_STR( 4C_3C ) )
PORT_DIPSETTING( 0x000f, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x000c, DEF_STR( 3C_4C ) )
PORT_DIPSETTING( 0x000e, DEF_STR( 2C_3C ) )
PORT_DIPSETTING( 0x0007, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x0006, DEF_STR( 2C_5C ) )
PORT_DIPSETTING( 0x000b, DEF_STR( 1C_3C ) )
PORT_DIPSETTING( 0x0003, DEF_STR( 1C_4C ) )
PORT_DIPSETTING( 0x000d, DEF_STR( 1C_5C ) )
PORT_DIPSETTING( 0x0005, DEF_STR( 1C_6C ) )
PORT_DIPSETTING( 0x0009, DEF_STR( 1C_7C ) )
PORT_DIPNAME( 0x8000, 0x0000, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SWB:1")
PORT_DIPSETTING( 0x8000, DEF_STR( Off ) )
PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
PORT_DIPUNUSED_DIPLOC( 0x4000, 0x4000, "SWB:2" )
PORT_DIPNAME( 0x3000, 0x1000, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SWB:4,3")
PORT_DIPSETTING( 0x3000, DEF_STR( Easy ) )
PORT_DIPSETTING( 0x1000, DEF_STR( Normal ) )
PORT_DIPSETTING( 0x2000, DEF_STR( Hard ) )
PORT_DIPSETTING( 0x0000, DEF_STR( Hardest ) )
PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SWB:6,5")
PORT_DIPSETTING( 0x0000, "2" )
PORT_DIPSETTING( 0x0c00, "3" )
PORT_DIPSETTING( 0x0400, "4" )
PORT_DIPSETTING( 0x0800, "5" )
PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SWB:8,7")
PORT_DIPSETTING( 0x0300, "50k 200k" )
PORT_DIPSETTING( 0x0100, "100k 300k" )
PORT_DIPSETTING( 0x0200, "50k only" )
PORT_DIPSETTING( 0x0000, DEF_STR( None ) )
INPUT_PORTS_END
static GFXDECODE_START( gfx_gaiden )
GFXDECODE_ENTRY( "txtiles", 0, gfx_8x8x4_packed_msb, 0x100, 16 ) /* tiles 8x8 */
GFXDECODE_ENTRY( "bgtiles", 0, gfx_8x8x4_row_2x2_group_packed_msb, 0x000, 0x100 ) /* tiles 16x16 */
GFXDECODE_ENTRY( "fgtiles", 0, gfx_8x8x4_row_2x2_group_packed_msb, 0x000, 0x100 ) /* tiles 16x16 (only colors 0x00-0x0f and 0x80-0x8f are used) */
GFXDECODE_END
static GFXDECODE_START( gfx_gaiden_spr )
GFXDECODE_ENTRY( "sprites", 0, gfx_8x8x4_packed_msb, 0x000, 0x100 ) /* sprites 8x8 (only colors 0x00-0x0f and 0x80-0x8f are used) */
GFXDECODE_END
static const gfx_layout mastninj_tile2layout =
{
16,16,
RGN_FRAC(1,1),
4,
{ 24,16,8,0 },
{ 0,1,2,3,4,5,6,7, 256,257,258,259,260,261,262,263 },
{ 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, 512+0*32, 512+1*32, 512+2*32, 512+3*32, 512+4*32, 512+5*32, 512+6*32, 512+7*32},
32*32
};
static const gfx_layout mastninj_spritelayout =
{
16,16, /* tile size */
RGN_FRAC(1,4), /* number of tiles */
4, /* 4 bits per pixel */
{ RGN_FRAC(0,4),RGN_FRAC(1,4),RGN_FRAC(2,4),RGN_FRAC(3,4) },
{ 0,1,2,3,4,5,6,7, 128+0,128+1,128+2,128+3,128+4,128+5,128+6,128+7 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
32*8 /* offset to next tile */
};
static GFXDECODE_START( gfx_mastninj )
GFXDECODE_ENTRY( "txtiles", 0, gfx_8x8x4_packed_msb, 0x000, 16 ) /* tiles 8x8 */
GFXDECODE_ENTRY( "bgtiles", 0, mastninj_tile2layout, 0x300, 16 ) /* tiles 16x16 */
GFXDECODE_ENTRY( "fgtiles", 0, mastninj_tile2layout, 0x200, 16 ) /* tiles 16x16 */
GFXDECODE_ENTRY( "sprites", 0, mastninj_spritelayout, 0x100, 16 ) /* sprites 16x16 */
GFXDECODE_END
static const gfx_layout drgnbowl_tile2layout =
{
16,16,
RGN_FRAC(1,8),
4,
{ RGN_FRAC(3,4),RGN_FRAC(2,4),RGN_FRAC(1,4),RGN_FRAC(0,4) },
{ STEP8(0,1), STEP8(8*8*2,1) },
{ STEP16(0,8) },
32*8
};
static const gfx_layout drgnbowl_spritelayout =
{
16,16,
RGN_FRAC(1,4),
4,
{ RGN_FRAC(0,4),RGN_FRAC(1,4),RGN_FRAC(2,4),RGN_FRAC(3,4) },
{ STEP8(0,1), STEP8(8*8*2,1) },
{ STEP16(0,8) },
32*8
};
static GFXDECODE_START( gfx_drgnbowl )
GFXDECODE_ENTRY( "txtiles", 0, gfx_8x8x4_packed_msb, 0, 16 ) /* tiles 8x8 */
GFXDECODE_ENTRY( "bgtiles", 0x00000, drgnbowl_tile2layout, 0x300, 16 ) /* tiles 16x16 */
GFXDECODE_ENTRY( "bgtiles", 0x20000, drgnbowl_tile2layout, 0x200, 16 ) /* tiles 16x16 */
GFXDECODE_ENTRY( "sprites", 0, drgnbowl_spritelayout, 0x100, 16 ) /* sprites 16x16 */
GFXDECODE_END
void gaiden_state::shadoww(machine_config &config)
{
/* basic machine hardware */
M68000(config, m_maincpu, 18432000/2); /* 9.216 MHz */
m_maincpu->set_addrmap(AS_PROGRAM, &gaiden_state::gaiden_map);
m_maincpu->set_vblank_int("screen", FUNC(gaiden_state::irq5_line_assert));
Z80(config, m_audiocpu, 4000000); /* 4 MHz */
m_audiocpu->set_addrmap(AS_PROGRAM, &gaiden_state::sound_map); /* IRQs are triggered by the YM2203 */
WATCHDOG_TIMER(config, "watchdog");
/* video hardware */
BUFFERED_SPRITERAM16(config, m_spriteram);
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_refresh_hz(59.17); /* verified on pcb */
m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0));
m_screen->set_size(32*8, 32*8);
m_screen->set_visarea(0*8, 32*8-1, 4*8, 32*8-1);
m_screen->set_screen_update(FUNC(gaiden_state::screen_update_gaiden));
GFXDECODE(config, m_gfxdecode, m_palette, gfx_gaiden);
PALETTE(config, m_palette).set_format(palette_device::xBGR_444, 4096);
TECMO_SPRITE(config, m_sprgen, 0, m_palette, gfx_gaiden_spr);
TECMO_MIXER(config, m_mixer, 0);
m_mixer->set_mixer_shifts(10,9,4);
m_mixer->set_blendcols( 0x0400 + 0x300, 0x0400 + 0x200, 0x0400 + 0x100, 0x0400 + 0x000 );
m_mixer->set_regularcols( 0x0000 + 0x300, 0x0000 + 0x200, 0x0000 + 0x100, 0x0000 + 0x000 );
m_mixer->set_blendsource( 0x0800 + 0x000, 0x0800 + 0x200);
m_mixer->set_revspritetile();
m_mixer->set_bgpen(0x000 + 0x200, 0x400 + 0x200);
MCFG_VIDEO_START_OVERRIDE(gaiden_state,gaiden)
/* sound hardware */
SPEAKER(config, "mono").front_center();
GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI);
ym2203_device &ym1(YM2203(config, "ym1", 4000000));
ym1.irq_handler().set_inputline(m_audiocpu, 0);
ym1.add_route(0, "mono", 0.15);
ym1.add_route(1, "mono", 0.15);
ym1.add_route(2, "mono", 0.15);
ym1.add_route(3, "mono", 0.60);
ym2203_device &ym2(YM2203(config, "ym2", 4000000));
ym2.add_route(0, "mono", 0.15);
ym2.add_route(1, "mono", 0.15);
ym2.add_route(2, "mono", 0.15);
ym2.add_route(3, "mono", 0.60);
okim6295_device &oki(OKIM6295(config, "oki", 1000000, okim6295_device::PIN7_HIGH));
oki.add_route(ALL_OUTPUTS, "mono", 0.20);
}
void gaiden_state::wildfang(machine_config &config)
{
shadoww(config);
m_maincpu->set_addrmap(AS_PROGRAM, &gaiden_state::wildfang_map);
I8749(config, "mcu", 4_MHz_XTAL).set_disable();
}
void gaiden_state::raiga(machine_config &config)
{
shadoww(config);
m_maincpu->set_addrmap(AS_PROGRAM, &gaiden_state::raiga_map);
I8749(config, "mcu", 4_MHz_XTAL).set_disable();
MCFG_MACHINE_RESET_OVERRIDE(gaiden_state,raiga)
MCFG_VIDEO_START_OVERRIDE(gaiden_state,raiga)
m_screen->set_screen_update(FUNC(gaiden_state::screen_update_raiga));
m_screen->screen_vblank().set(FUNC(gaiden_state::screen_vblank_raiga));
}
void gaiden_state::drgnbowl(machine_config &config)
{
/* basic machine hardware */
M68000(config, m_maincpu, 20000000/2); /* 10 MHz */
m_maincpu->set_addrmap(AS_PROGRAM, &gaiden_state::drgnbowl_map);
m_maincpu->set_vblank_int("screen", FUNC(gaiden_state::irq5_line_assert));
Z80(config, m_audiocpu, 12000000/2); /* 6 MHz */
m_audiocpu->set_addrmap(AS_PROGRAM, &gaiden_state::drgnbowl_sound_map);
m_audiocpu->set_addrmap(AS_IO, &gaiden_state::drgnbowl_sound_port_map);
/* video hardware */
BUFFERED_SPRITERAM16(config, m_spriteram);
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_refresh_hz(60);
m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0));
m_screen->set_size(32*8, 32*8);
m_screen->set_visarea(0*8, 32*8-1, 2*8, 30*8-1);
m_screen->set_screen_update(FUNC(gaiden_state::screen_update_drgnbowl));
m_screen->set_palette(m_palette);
GFXDECODE(config, m_gfxdecode, m_palette, gfx_drgnbowl);
PALETTE(config, m_palette).set_format(palette_device::xBGR_444, 4096);
/* NOT using Tecmo Sprite device - significant changes, maybe a clone of something else */
MCFG_VIDEO_START_OVERRIDE(gaiden_state,drgnbowl)
/* sound hardware */
SPEAKER(config, "mono").front_center();
GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_audiocpu, 0);
YM2151(config, "ymsnd", 4000000).add_route(ALL_OUTPUTS, "mono", 0.40);
OKIM6295(config, "oki", 1000000, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "mono", 0.50);
}
/*
Master Ninja
CPUs
QTY Type position function
1x MC68000P10 68000 main PCB main
1x Z8400HB1 ic36 main PCB sound
2x YM2203C ic31,ic32 main PCB sound
2x Y3014B c16,ic17 main PCB sound
2x LM324N ic2,ic6 main PCB sound
1x TDA2002 ic1 main PCB sound
Oscillators
1x oscillator 20.000 (xl2 main PCB)
1x blu resonator 400K (xl1 main PCB)
ROMs
QTY Type position status
6x AM27C512 1-6 main PCB dumped
32x AM27C512 8-39 ROMs PCB dumped
RAMs
QTY Type position
4x HY6264LP-10 ic25,ic28,ic61,ic62 main PCB
3x HY6116ALP-10 ic33,ic123,ic124 main PCB
1x HM6148P ic80 main PCB
1x MCM2018AN45 ic81 main PCB
4x HM6148P ic63-66 ROMs PCB
1x HY6116ALP-10 ic85 ROMs PCB
PLDs
QTY Type position status
2x TIBPAL16L8 ic15,ic54 main PCB read protected
1x GAL16L8 ic42 ROMs PCB read protected
Others
1x JAMMA edge connector
1x trimmer (volume)
2x 8x2 switches DIP
*/
void gaiden_state::mastninj_sound_map(address_map &map)
{
map(0x0000, 0x7fff).rom();
map(0x8000, 0xbfff).bankr("adpcm_bank");
map(0xc400, 0xc401).rw("ym1", FUNC(ym2203_device::read), FUNC(ym2203_device::write));
map(0xc800, 0xc801).rw("ym2", FUNC(ym2203_device::read), FUNC(ym2203_device::write));
map(0xcc00, 0xcc00).r("soundlatch", FUNC(generic_latch_8_device::read));
map(0xd000, 0xd000).w("adpcm_select2", FUNC(ls157_device::ba_w));
map(0xd400, 0xd400).w(FUNC(gaiden_state::adpcm_bankswitch_w));
map(0xd800, 0xd800).w("adpcm_select1", FUNC(ls157_device::ba_w));
map(0xf000, 0xf7ff).ram();
}
void gaiden_state::vck_flipflop_w(int state)
{
if (!state)
return;
m_adpcm_toggle = !m_adpcm_toggle;
m_adpcm_select[0]->select_w(m_adpcm_toggle);
m_adpcm_select[1]->select_w(m_adpcm_toggle);
m_audiocpu->set_input_line(INPUT_LINE_NMI, m_adpcm_toggle);
}
void gaiden_state::adpcm_bankswitch_w(uint8_t data)
{
m_msm[0]->reset_w(BIT(data, 3));
m_msm[1]->reset_w(BIT(data, 4));
m_adpcm_bank->set_entry(data & 7);
}
MACHINE_START_MEMBER(gaiden_state,mastninj)
{
gaiden_state::machine_start();
m_adpcm_bank->configure_entries(0, 8, memregion("audiocpu")->base(), 0x4000);
m_adpcm_bank->set_entry(0);
m_adpcm_toggle = 0;
save_item(NAME(m_adpcm_toggle));
}
void gaiden_state::mastninj_map(address_map &map)
{
map(0x000000, 0x03ffff).rom();
map(0x060000, 0x063fff).ram();
map(0x070000, 0x070fff).ram().w(FUNC(gaiden_state::tx_videoram_w)).share("videoram1");
map(0x072000, 0x073fff).ram().w(FUNC(gaiden_state::fg_videoram_w)).share("videoram2");
map(0x074000, 0x075fff).ram().w(FUNC(gaiden_state::bg_videoram_w)).share("videoram3");
map(0x076000, 0x077fff).ram().share("spriteram");
map(0x078000, 0x079fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
// map(0x078800, 0x079fff).ram();
map(0x07a000, 0x07a001).portr("SYSTEM");
map(0x07a002, 0x07a003).portr("P1_P2");
map(0x07a004, 0x07a005).portr("DSW");
// map(0x07a104, 0x07a105).w(FUNC(gaiden_state::gaiden_txscrolly_w));
// map(0x07a10c, 0x07a10d).w(FUNC(gaiden_state::gaiden_txscrollx_w));
map(0x07f000, 0x07f001).w(FUNC(gaiden_state::gaiden_bgscrolly_w));
map(0x07f002, 0x07f003).w(FUNC(gaiden_state::gaiden_bgscrollx_w));
map(0x07f004, 0x07f005).w(FUNC(gaiden_state::gaiden_fgscrolly_w));
map(0x07f006, 0x07f007).w(FUNC(gaiden_state::gaiden_fgscrollx_w));
map(0x07a800, 0x07a801).w("watchdog", FUNC(watchdog_timer_device::reset16_w));
// map(0x07a806, 0x07a807).nopw();
// map(0x07a808, 0x07a809).w(FUNC(gaiden_state::gaiden_flip_w));
map(0x07a00e, 0x07a00e).w("soundlatch", FUNC(generic_latch_8_device::write));
map(0x07e000, 0x07e000).w(FUNC(gaiden_state::drgnbowl_irq_ack_w));
}
void gaiden_state::mastninj(machine_config &config)
{
/* basic machine hardware */
M68000(config, m_maincpu, 10000000); /* 10 MHz? */
m_maincpu->set_addrmap(AS_PROGRAM, &gaiden_state::mastninj_map);
m_maincpu->set_vblank_int("screen", FUNC(gaiden_state::irq5_line_assert));
Z80(config, m_audiocpu, 4000000); /* ?? MHz */
m_audiocpu->set_addrmap(AS_PROGRAM, &gaiden_state::mastninj_sound_map);
MCFG_MACHINE_START_OVERRIDE(gaiden_state,mastninj)
WATCHDOG_TIMER(config, "watchdog");
/* video hardware */
BUFFERED_SPRITERAM16(config, m_spriteram);
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_refresh_hz(60);
m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0));
m_screen->set_size(32*8, 32*8);
m_screen->set_visarea(0*8, 32*8-1, 2*8, 30*8-1);
m_screen->set_screen_update(FUNC(gaiden_state::screen_update_drgnbowl));
m_screen->set_palette(m_palette);
GFXDECODE(config, m_gfxdecode, m_palette, gfx_mastninj);
PALETTE(config, m_palette).set_format(palette_device::xBGR_444, 4096);
/* NOT using Tecmo Sprite device - significant changes, maybe a clone of something else */
MCFG_VIDEO_START_OVERRIDE(gaiden_state,drgnbowl)