/
jalmah.c
executable file
·2478 lines (2172 loc) · 95.1 KB
/
jalmah.c
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:MAME
// copyright-holders:Angelo Salese
/*******************************************************************************************
MJ-8956 HW games (c) 1989 Jaleco / NMK / UPL
driver by Angelo Salese, based on early work by David Haywood
Special thanks to Uki and Yasu for the priority system explanation.
Similar to the NMK16 / Jaleco Mega System 1 boards but without sprites.
Notes(general):
-I think that the 0xf0000-0xfffff area is shared with the MCU because:
\-The first version of the MCU programs (daireika/mjzoomin) jump in that area.
Then the MCU upload a 68k code;the programs are likely to be the same for all the games,
for example if the program jumps to $f0020 it means a sample request.
\-Input ports located there.Program doesn't check these locations at P.O.S.T. and doesn't
give any work ram error.
\-Additionally all the games have a MCU protection which involves various RAM areas,
that controls mahjong panel inputs.Protection is simulated by
adding a value to these RAM areas according to what button is pressed.
TODO:
-Back layer pens looks ugly in some circumstances (i.e. suchipi when you win, mjzoomin when coined up),
static or controlled by something else?
-daireika: the ranking screen on the original pcb shows some hearts instead of the "0".
Some investigation indicates that the game reads area "fe100" onwards for these to be filled.
These are likely to be provided by one of the mcu snippets...
-kakumei/kakumei2:has weird text layer strings in test mode (like "#p control panel"),
unsure if this one is somehow related to the above daireika bug, it's a BTANB or something else.
-Check if urashima has a "mode 3" for the layer 0 tilemap;
-There could be timing issues caused by MCU simulation at $80004;
-Fix the sound banking, protection-related for the first version of the MCU
(should be somewhere on the work ram/shared ram)
-suchipi: I need a side-by-side to understand if the PAL shuffling is correct with the OKI bgm rom.
-urashima: might use three/four layers instead of two.It can be checked when you win
a match in particular circumstances because there's a write in the 94000-9bfff region;
-Massive clean-ups needed for the MCU snippet programs and the input-ports, also check if
the programs are actually into the m68k program itself (like hachamf/tdragon/ddealer);
Notes (1st MCU ver.):
-$f000e is bogus,maybe the program snippets can modify this value,or the MCU itself can
do that,returning the contents of D0 register seems enough for now...
Update: Improved it for the new mcu simulation,now it pulls all the values from 0x00 to
0x0f, it seems to be a MCU call snippet for the $f0000 work ram;
-$f030e is a mirror for $f000e in urashima.
-I need more space for MCU code...that's why I've used an extra jmp when entering
into mcu code,so we can debug the first version freely without being teased about
memory space.
BTW,the real HW is using a sort of bankswitch or I'm missing something?
-$f0020 is for the sound program,same for all games, for example mjzoomin hasn't any clear
write to $80040 area and the program jumps to $f0020 when there should be a sample.
============================================================================================
Debug cheats:
-(suchipi)
*
$fe87e: bonus timer,used as a count-down.
*
$f079a: finish match now
*
During gameplay,set $f0400 to 6 then set $f07d4 to 1 to advance to next
level.
*
$f06a6-$f06c0: Your tiles
$f06c6-$f06e0: COM tiles
---- ---- --xx ----: Defines kind
---- ---- ---- xxxx: Defines number
*
$f0434: priority number
============================================================================================
daireika 68k irq table vectors
lev 1 : 0x64 : 0000 049e -
lev 2 : 0x68 : 0000 04ae -
lev 3 : 0x6c : 0000 049e -
lev 4 : 0x70 : 0000 091a -
lev 5 : 0x74 : 0000 0924 -
lev 6 : 0x78 : 0000 092e -
lev 7 : 0x7c : 0000 0938 -
mjzoomin 68k irq table vectors
lev 1 : 0x64 : 0000 048a -
lev 2 : 0x68 : 0000 049a - vblank
lev 3 : 0x6c : 0000 048a -
lev 4 : 0x70 : 0000 09ba - "write to Text RAM" (?)
lev 5 : 0x74 : 0000 09c4 - "write to Text RAM" (?)
lev 6 : 0x78 : 0000 09ce - "write to Text RAM" (?)
lev 7 : 0x7c : 0000 09d8 - "write to Text RAM" (?)
kakumei/kakumei2/suchipi 68k irq table vectors
lev 1 : 0x64 : 0000 0506 - rte
lev 2 : 0x68 : 0000 050a - vblank
lev 3 : 0x6c : 0000 051c - rte
lev 4 : 0x70 : 0000 0520 - rte
lev 5 : 0x74 : 0000 0524 - rte
lev 6 : 0x78 : 0000 0524 - rte
lev 7 : 0x7c : 0000 0524 - rte
Board: MJ-8956
CPU: 68000-8
M50747 (not dumped)
Sound: M6295
OSC: 12.000MHz
4.000MHz
2009-04: Verified DipLocations and Default settings with manual (thanks to Uki)
*******************************************************************************************/
#include "emu.h"
#include "cpu/m68000/m68000.h"
#include "sound/okim6295.h"
class jalmah_state : public driver_device
{
public:
jalmah_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_sc0_vram(*this, "sc0_vram"),
m_sc1_vram(*this, "sc1_vram"),
m_sc2_vram(*this, "sc2_vram"),
m_sc3_vram(*this, "sc3_vram"),
m_jm_shared_ram(*this, "jshared_ram"),
m_jm_mcu_code(*this, "jmcu_code"),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette") { }
tilemap_t *m_sc0_tilemap_0;
tilemap_t *m_sc0_tilemap_1;
tilemap_t *m_sc0_tilemap_2;
tilemap_t *m_sc0_tilemap_3;
tilemap_t *m_sc1_tilemap_0;
tilemap_t *m_sc1_tilemap_1;
tilemap_t *m_sc1_tilemap_2;
tilemap_t *m_sc1_tilemap_3;
tilemap_t *m_sc2_tilemap_0;
tilemap_t *m_sc2_tilemap_1;
tilemap_t *m_sc2_tilemap_2;
tilemap_t *m_sc2_tilemap_3;
tilemap_t *m_sc3_tilemap_0;
tilemap_t *m_sc3_tilemap_2;
tilemap_t *m_sc3_tilemap_3;
required_shared_ptr<UINT16> m_sc0_vram;
optional_shared_ptr<UINT16> m_sc1_vram;
optional_shared_ptr<UINT16> m_sc2_vram;
required_shared_ptr<UINT16> m_sc3_vram;
UINT16 *m_jm_scrollram;
UINT16 *m_jm_vregs;
UINT16 m_sc0bank;
UINT16 m_pri;
UINT8 m_sc0_prin;
UINT8 m_sc1_prin;
UINT8 m_sc2_prin;
UINT8 m_sc3_prin;
required_shared_ptr<UINT16> m_jm_shared_ram;
required_shared_ptr<UINT16> m_jm_mcu_code;
UINT8 m_mcu_prg;
int m_respcount;
UINT8 m_test_mode;
UINT16 m_dma_old;
UINT16 m_prg_prot;
UINT8 m_oki_rom;
UINT8 m_oki_bank;
UINT8 m_oki_za;
DECLARE_WRITE16_MEMBER(sc0_vram_w);
DECLARE_WRITE16_MEMBER(sc3_vram_w);
DECLARE_WRITE16_MEMBER(sc1_vram_w);
DECLARE_WRITE16_MEMBER(sc2_vram_w);
DECLARE_WRITE16_MEMBER(jalmah_tilebank_w);
DECLARE_WRITE16_MEMBER(jalmah_scroll_w);
DECLARE_WRITE16_MEMBER(urashima_bank_w);
DECLARE_WRITE16_MEMBER(urashima_sc0_vram_w);
DECLARE_WRITE16_MEMBER(urashima_sc3_vram_w);
DECLARE_WRITE16_MEMBER(urashima_vregs_w);
DECLARE_WRITE16_MEMBER(urashima_dma_w);
DECLARE_WRITE16_MEMBER(jalmah_okirom_w);
DECLARE_WRITE16_MEMBER(jalmah_okibank_w);
DECLARE_WRITE16_MEMBER(jalmah_flip_screen_w);
DECLARE_READ16_MEMBER(urashima_mcu_r);
DECLARE_WRITE16_MEMBER(urashima_mcu_w);
DECLARE_READ16_MEMBER(daireika_mcu_r);
DECLARE_WRITE16_MEMBER(daireika_mcu_w);
DECLARE_READ16_MEMBER(mjzoomin_mcu_r);
DECLARE_WRITE16_MEMBER(mjzoomin_mcu_w);
DECLARE_READ16_MEMBER(kakumei_mcu_r);
DECLARE_READ16_MEMBER(suchipi_mcu_r);
DECLARE_DRIVER_INIT(suchipi);
DECLARE_DRIVER_INIT(kakumei);
DECLARE_DRIVER_INIT(urashima);
DECLARE_DRIVER_INIT(kakumei2);
DECLARE_DRIVER_INIT(daireika);
DECLARE_DRIVER_INIT(mjzoomin);
TILEMAP_MAPPER_MEMBER(range0_16x16);
TILEMAP_MAPPER_MEMBER(range1_16x16);
TILEMAP_MAPPER_MEMBER(range2_16x16);
TILEMAP_MAPPER_MEMBER(range3_16x16);
TILEMAP_MAPPER_MEMBER(range2_8x8);
TILEMAP_MAPPER_MEMBER(range3_8x8);
TILE_GET_INFO_MEMBER(get_sc0_tile_info);
TILE_GET_INFO_MEMBER(get_sc1_tile_info);
TILE_GET_INFO_MEMBER(get_sc2_tile_info);
TILE_GET_INFO_MEMBER(get_sc3_tile_info);
virtual void machine_reset();
virtual void video_start();
DECLARE_VIDEO_START(urashima);
UINT32 screen_update_jalmah(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
UINT32 screen_update_urashima(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
TIMER_DEVICE_CALLBACK_MEMBER(jalmah_mcu_sim);
void jalmah_priority_system();
void draw_sc0_layer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_sc1_layer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_sc2_layer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_sc3_layer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void daireika_palette_dma(UINT16 val);
void daireika_mcu_run();
void mjzoomin_mcu_run();
void urashima_mcu_run();
void second_mcu_run();
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
};
/******************************************************************************************
Video Hardware start
******************************************************************************************/
/*4096x512 tilemap*/
TILEMAP_MAPPER_MEMBER(jalmah_state::range0_16x16)
{
/* logical (col,row) -> memory offset */
return (row & 0x0f) + ((col & 0xff) << 4) + ((row & 0x70) << 8);
}
/*2048x1024 tilemap*/
TILEMAP_MAPPER_MEMBER(jalmah_state::range1_16x16)
{
/* logical (col,row) -> memory offset */
return (row & 0x0f) + ((col & 0x7f) << 4) + ((row & 0xf0) << 7);
}
/*1024x2048 tilemap*/
TILEMAP_MAPPER_MEMBER(jalmah_state::range2_16x16)
{
/* logical (col,row) -> memory offset */
return (row & 0x0f) + ((col & 0x3f) << 4) + ((row & 0x1f0) << 6);
}
/*512x4096 tilemap*/
TILEMAP_MAPPER_MEMBER(jalmah_state::range3_16x16)
{
/* logical (col,row) -> memory offset */
return (row & 0x0f) + ((col & 0x1f) << 4) + ((row & 0x3f0) << 5);
}
/*1024x512 tilemap*/
TILEMAP_MAPPER_MEMBER(jalmah_state::range2_8x8)
{
/* logical (col,row) -> memory offset */
return (row & 0x1f) + ((col & 0x7f) * 0x20) + ((row & 0x20) * 0x80);
}
/*512x1024 tilemap*/
TILEMAP_MAPPER_MEMBER(jalmah_state::range3_8x8)
{
return (row & 0x1f) + ((col & 0x3f) * 0x20) + ((row & 0x60) * 0x40);
}
TILE_GET_INFO_MEMBER(jalmah_state::get_sc0_tile_info)
{
int code = m_sc0_vram[tile_index];
SET_TILE_INFO_MEMBER(3,
(code & 0xfff) + ((m_sc0bank & 3) << 12),
code >> 12,
0);
}
TILE_GET_INFO_MEMBER(jalmah_state::get_sc1_tile_info)
{
int code = m_sc1_vram[tile_index];
SET_TILE_INFO_MEMBER(2,
code & 0xfff,
code >> 12,
0);
}
TILE_GET_INFO_MEMBER(jalmah_state::get_sc2_tile_info)
{
int code = m_sc2_vram[tile_index];
SET_TILE_INFO_MEMBER(1,
code & 0xfff,
code >> 12,
0);
}
TILE_GET_INFO_MEMBER(jalmah_state::get_sc3_tile_info)
{
int code = m_sc3_vram[tile_index];
SET_TILE_INFO_MEMBER(0,
code & 0xfff,
code >> 12,
0);
}
void jalmah_state::video_start()
{
m_sc0_tilemap_0 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc0_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range0_16x16),this),16,16,256,32);
m_sc0_tilemap_1 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc0_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range1_16x16),this),16,16,128,64);
m_sc0_tilemap_2 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc0_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range2_16x16),this),16,16,64,128);
m_sc0_tilemap_3 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc0_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range3_16x16),this),16,16,32,256);
m_sc1_tilemap_0 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc1_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range0_16x16),this),16,16,256,32);
m_sc1_tilemap_1 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc1_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range1_16x16),this),16,16,128,64);
m_sc1_tilemap_2 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc1_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range2_16x16),this),16,16,64,128);
m_sc1_tilemap_3 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc1_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range3_16x16),this),16,16,32,256);
m_sc2_tilemap_0 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc2_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range0_16x16),this),16,16,256,32);
m_sc2_tilemap_1 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc2_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range1_16x16),this),16,16,128,64);
m_sc2_tilemap_2 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc2_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range2_16x16),this),16,16,64,128);
m_sc2_tilemap_3 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc2_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range3_16x16),this),16,16,32,256);
m_sc3_tilemap_0 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc3_tile_info),this),TILEMAP_SCAN_COLS,8,8,256,32);
//m_sc3_tilemap_1 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc3_tile_info),this),TILEMAP_SCAN_COLS,8,8,256,32);
m_sc3_tilemap_2 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc3_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range2_8x8),this),8,8,128,64);
m_sc3_tilemap_3 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc3_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range3_8x8),this),8,8,64,128);
m_jm_scrollram = auto_alloc_array(machine(), UINT16, 0x80/2);
m_jm_vregs = auto_alloc_array(machine(), UINT16, 0x40/2);
m_sc0_tilemap_0->set_transparent_pen(15);
m_sc0_tilemap_1->set_transparent_pen(15);
m_sc0_tilemap_2->set_transparent_pen(15);
m_sc0_tilemap_3->set_transparent_pen(15);
m_sc1_tilemap_0->set_transparent_pen(15);
m_sc1_tilemap_1->set_transparent_pen(15);
m_sc1_tilemap_2->set_transparent_pen(15);
m_sc1_tilemap_3->set_transparent_pen(15);
m_sc2_tilemap_0->set_transparent_pen(15);
m_sc2_tilemap_1->set_transparent_pen(15);
m_sc2_tilemap_2->set_transparent_pen(15);
m_sc2_tilemap_3->set_transparent_pen(15);
m_sc3_tilemap_0->set_transparent_pen(15);
//m_sc3_tilemap_1->set_transparent_pen(15);
m_sc3_tilemap_2->set_transparent_pen(15);
m_sc3_tilemap_3->set_transparent_pen(15);
}
VIDEO_START_MEMBER(jalmah_state,urashima)
{
m_sc0_tilemap_0 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc0_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range0_16x16),this),16,16,256,32);
m_sc3_tilemap_0 = &machine().tilemap().create(m_gfxdecode, tilemap_get_info_delegate(FUNC(jalmah_state::get_sc3_tile_info),this),tilemap_mapper_delegate(FUNC(jalmah_state::range2_8x8),this),8,8,128,64);
m_jm_scrollram = auto_alloc_array(machine(), UINT16, 0x80/2);
m_jm_vregs = auto_alloc_array(machine(), UINT16, 0x40/2);
m_sc0_tilemap_0->set_transparent_pen(15);
m_sc3_tilemap_0->set_transparent_pen(15);
}
/***************************************************************************************
The priority system is a combination between one prom and the priority number.
The priority number is a pointer to an array of 16 bytes of the prom ( addresses bits 4-7
0x*0-0x*f). These 16 bytes are read and added and every number is directly hooked up
to the equivalent layer (i.e. read 0 == +1 for the layer 0, read 1 == +1 for the layer 1
etc.)
In the end the final results always are one bit assigned to each priority (i.e. most
priority = 8, then 4, 2 and finally 1).
***************************************************************************************/
void jalmah_state::jalmah_priority_system()
{
UINT8 *pri_rom = memregion("user1")->base();
UINT8 i;
UINT8 prinum[0x10];
m_sc0_prin = 0;
m_sc1_prin = 0;
m_sc2_prin = 0;
m_sc3_prin = 0;
for(i=0;i<0x10;i++)
{
prinum[i] = pri_rom[i+m_pri*0x10];
if(prinum[i] == 0) { m_sc0_prin++; }
if(prinum[i] == 1) { m_sc1_prin++; }
if(prinum[i] == 2) { m_sc2_prin++; }
if(prinum[i] == 3) { m_sc3_prin++; }
}
//popmessage("%02x %02x %02x %02x",m_sc0_prin,m_sc1_prin,m_sc2_prin,m_sc3_prin);
}
void jalmah_state::draw_sc0_layer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
switch(m_jm_vregs[0] & 3)
{
case 0: m_sc0_tilemap_0->draw(screen, bitmap, cliprect, 0,0); break;
case 1: m_sc0_tilemap_1->draw(screen, bitmap, cliprect, 0,0); break;
case 2: m_sc0_tilemap_2->draw(screen, bitmap, cliprect, 0,0); break;
case 3: m_sc0_tilemap_3->draw(screen, bitmap, cliprect, 0,0); break;
}
}
void jalmah_state::draw_sc1_layer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
switch(m_jm_vregs[1] & 3)
{
case 0: m_sc1_tilemap_0->draw(screen, bitmap, cliprect, 0,0); break;
case 1: m_sc1_tilemap_1->draw(screen, bitmap, cliprect, 0,0); break;
case 2: m_sc1_tilemap_2->draw(screen, bitmap, cliprect, 0,0); break;
case 3: m_sc1_tilemap_3->draw(screen, bitmap, cliprect, 0,0); break;
}
}
void jalmah_state::draw_sc2_layer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
switch(m_jm_vregs[2] & 3)
{
case 0: m_sc2_tilemap_0->draw(screen, bitmap, cliprect, 0,0); break;
case 1: m_sc2_tilemap_1->draw(screen, bitmap, cliprect, 0,0); break;
case 2: m_sc2_tilemap_2->draw(screen, bitmap, cliprect, 0,0); break;
case 3: m_sc2_tilemap_3->draw(screen, bitmap, cliprect, 0,0); break;
}
}
void jalmah_state::draw_sc3_layer(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
switch(m_jm_vregs[3] & 3)
{
case 0:
case 1: m_sc3_tilemap_0->draw(screen, bitmap, cliprect, 0,0); break;
case 2: m_sc3_tilemap_2->draw(screen, bitmap, cliprect, 0,0); break;
case 3: m_sc3_tilemap_3->draw(screen, bitmap, cliprect, 0,0); break;
}
}
UINT32 jalmah_state::screen_update_jalmah(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
UINT16 *jm_scrollram = m_jm_scrollram;
UINT8 cur_prin;
jalmah_priority_system();
m_sc0_tilemap_0->set_scrollx(0, jm_scrollram[0] & 0xfff);
m_sc0_tilemap_1->set_scrollx(0, jm_scrollram[0] & 0x7ff);
m_sc0_tilemap_2->set_scrollx(0, jm_scrollram[0] & 0x3ff);
m_sc0_tilemap_3->set_scrollx(0, jm_scrollram[0] & 0x1ff);
m_sc1_tilemap_0->set_scrollx(0, jm_scrollram[1] & 0xfff);
m_sc1_tilemap_1->set_scrollx(0, jm_scrollram[1] & 0x7ff);
m_sc1_tilemap_2->set_scrollx(0, jm_scrollram[1] & 0x3ff);
m_sc1_tilemap_3->set_scrollx(0, jm_scrollram[1] & 0x1ff);
m_sc2_tilemap_0->set_scrollx(0, jm_scrollram[2] & 0xfff);
m_sc2_tilemap_1->set_scrollx(0, jm_scrollram[2] & 0x7ff);
m_sc2_tilemap_2->set_scrollx(0, jm_scrollram[2] & 0x3ff);
m_sc2_tilemap_3->set_scrollx(0, jm_scrollram[2] & 0x1ff);
m_sc3_tilemap_0->set_scrollx(0, jm_scrollram[3] & 0x7ff);
// empty
m_sc3_tilemap_2->set_scrollx(0, jm_scrollram[3] & 0x3ff);
m_sc3_tilemap_3->set_scrollx(0, jm_scrollram[3] & 0x1ff);
m_sc0_tilemap_0->set_scrolly(0, jm_scrollram[4] & 0x1ff);
m_sc0_tilemap_1->set_scrolly(0, jm_scrollram[4] & 0x3ff);
m_sc0_tilemap_2->set_scrolly(0, jm_scrollram[4] & 0x7ff);
m_sc0_tilemap_3->set_scrolly(0, jm_scrollram[4] & 0xfff);
m_sc1_tilemap_0->set_scrolly(0, jm_scrollram[5] & 0x1ff);
m_sc1_tilemap_1->set_scrolly(0, jm_scrollram[5] & 0x3ff);
m_sc1_tilemap_2->set_scrolly(0, jm_scrollram[5] & 0x7ff);
m_sc1_tilemap_3->set_scrolly(0, jm_scrollram[5] & 0xfff);
m_sc2_tilemap_0->set_scrolly(0, jm_scrollram[6] & 0x1ff);
m_sc2_tilemap_1->set_scrolly(0, jm_scrollram[6] & 0x3ff);
m_sc2_tilemap_2->set_scrolly(0, jm_scrollram[6] & 0x7ff);
m_sc2_tilemap_3->set_scrolly(0, jm_scrollram[6] & 0xfff);
m_sc3_tilemap_0->set_scrolly(0, jm_scrollram[7] & 0xff);
// empty
m_sc3_tilemap_2->set_scrolly(0, jm_scrollram[7] & 0x1ff);
m_sc3_tilemap_3->set_scrolly(0, jm_scrollram[7] & 0x3ff);
bitmap.fill(m_palette->pen(0xff), cliprect); //selectable by a ram address?
for(cur_prin=1;cur_prin<=0x8;cur_prin<<=1)
{
if(cur_prin==m_sc0_prin) { draw_sc0_layer(screen,bitmap,cliprect); }
if(cur_prin==m_sc1_prin) { draw_sc1_layer(screen,bitmap,cliprect); }
if(cur_prin==m_sc2_prin) { draw_sc2_layer(screen,bitmap,cliprect); }
if(cur_prin==m_sc3_prin) { draw_sc3_layer(screen,bitmap,cliprect); }
}
return 0;
}
UINT32 jalmah_state::screen_update_urashima(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
UINT16 *jm_scrollram = m_jm_scrollram;
/*this game doesn't use the RANGE register at all.*/
m_sc0_tilemap_0->set_scrollx(0, jm_scrollram[0]);
m_sc3_tilemap_0->set_scrollx(0, jm_scrollram[3]);
m_sc0_tilemap_0->set_scrolly(0, jm_scrollram[4]);
m_sc3_tilemap_0->set_scrolly(0, jm_scrollram[7]);
bitmap.fill(m_palette->pen(0x1ff), cliprect);//selectable by a ram address?
if(m_jm_vregs[0] & 1) { m_sc0_tilemap_0->draw(screen, bitmap, cliprect, 0,0); }
if(m_jm_vregs[3] & 1) { m_sc3_tilemap_0->draw(screen, bitmap, cliprect, 0,0); }
return 0;
}
WRITE16_MEMBER(jalmah_state::sc0_vram_w)
{
COMBINE_DATA(&m_sc0_vram[offset]);
/*2048x256 tilemap*/
m_sc0_tilemap_0->mark_tile_dirty(offset);
/*1024x512 tilemap*/
m_sc0_tilemap_1->mark_tile_dirty(offset);
/*512x1024 tilemap*/
m_sc0_tilemap_2->mark_tile_dirty(offset);
/*256x2048 tilemap*/
m_sc0_tilemap_3->mark_tile_dirty(offset);
}
WRITE16_MEMBER(jalmah_state::sc3_vram_w)
{
COMBINE_DATA(&m_sc3_vram[offset]);
/*2048x256 tilemap*/
m_sc3_tilemap_0->mark_tile_dirty(offset);
/*1024x512 tilemap*/
m_sc3_tilemap_2->mark_tile_dirty(offset);
/*512x1024 tilemap*/
m_sc3_tilemap_3->mark_tile_dirty(offset);
}
WRITE16_MEMBER(jalmah_state::sc1_vram_w)
{
COMBINE_DATA(&m_sc1_vram[offset]);
/*2048x256 tilemap*/
m_sc1_tilemap_0->mark_tile_dirty(offset);
/*1024x512 tilemap*/
m_sc1_tilemap_1->mark_tile_dirty(offset);
/*512x1024 tilemap*/
m_sc1_tilemap_2->mark_tile_dirty(offset);
/*256x2048 tilemap*/
m_sc1_tilemap_3->mark_tile_dirty(offset);
}
WRITE16_MEMBER(jalmah_state::sc2_vram_w)
{
COMBINE_DATA(&m_sc2_vram[offset]);
/*2048x256 tilemap*/
m_sc2_tilemap_0->mark_tile_dirty(offset);
/*1024x512 tilemap*/
m_sc2_tilemap_1->mark_tile_dirty(offset);
/*512x1024 tilemap*/
m_sc2_tilemap_2->mark_tile_dirty(offset);
/*256x2048 tilemap*/
m_sc2_tilemap_3->mark_tile_dirty(offset);
}
WRITE16_MEMBER(jalmah_state::jalmah_tilebank_w)
{
/*
xxxx ---- fg bank (used by suchipi)
---- xxxx Priority number (trusted,see mjzoomin)
*/
//popmessage("Write to tilebank %02x",data);
if (ACCESSING_BITS_0_7)
{
if (m_sc0bank != ((data & 0xf0) >> 4))
{
m_sc0bank = (data & 0xf0) >> 4;
m_sc0_tilemap_0->mark_all_dirty();
m_sc0_tilemap_1->mark_all_dirty();
m_sc0_tilemap_2->mark_all_dirty();
m_sc0_tilemap_3->mark_all_dirty();
}
if (m_pri != (data & 0x0f))
m_pri = data & 0x0f;
}
}
WRITE16_MEMBER(jalmah_state::jalmah_scroll_w)
{
UINT16 *jm_scrollram = m_jm_scrollram;
UINT16 *jm_vregs = m_jm_vregs;
//logerror("[%04x]<-%04x\n",(offset+0x10)*2,data);
switch(offset+(0x10))
{
/*These 4 are just video regs,see mjzoomin test*/
/*
---x ---- Always on with layer 3, 8x8 tiles switch?
---- --xx RANGE registers
*/
case (0x24/2): jm_vregs[0] = data; break;
case (0x2c/2): jm_vregs[1] = data; break;
case (0x34/2): jm_vregs[2] = data; break;
case (0x3c/2): jm_vregs[3] = data; break;
case (0x20/2): jm_scrollram[0] = data; break;
case (0x28/2): jm_scrollram[1] = data; break;
case (0x30/2): jm_scrollram[2] = data; break;
case (0x38/2): jm_scrollram[3] = data; break;
case (0x22/2): jm_scrollram[4] = data; break;
case (0x2a/2): jm_scrollram[5] = data; break;
case (0x32/2): jm_scrollram[6] = data; break;
case (0x3a/2): jm_scrollram[7] = data; break;
//default: popmessage("[%04x]<-%04x",offset+0x10,data);
}
}
WRITE16_MEMBER(jalmah_state::urashima_bank_w)
{
if (ACCESSING_BITS_0_7)
{
if (m_sc0bank != (data & 0x0f))
{
m_sc0bank = (data & 0x0f);
m_sc0_tilemap_0->mark_all_dirty();
//m_sc0_tilemap_2->mark_all_dirty();
//m_sc0_tilemap_3->mark_all_dirty();
}
}
}
WRITE16_MEMBER(jalmah_state::urashima_sc0_vram_w)
{
COMBINE_DATA(&m_sc0_vram[offset]);
m_sc0_tilemap_0->mark_tile_dirty(offset);
}
WRITE16_MEMBER(jalmah_state::urashima_sc3_vram_w)
{
COMBINE_DATA(&m_sc3_vram[offset]);
m_sc3_tilemap_0->mark_tile_dirty(offset);
}
/*Urashima Mahjong uses a bigger (and mostly unused/wasted) video register ram.*/
WRITE16_MEMBER(jalmah_state::urashima_vregs_w)
{
UINT16 *jm_scrollram = m_jm_scrollram;
UINT16 *jm_vregs = m_jm_vregs;
//logerror("[%04x]<-%04x\n",(offset)*2,data);
switch(offset)
{
case 0x082/2: jm_vregs[0] = data; break; //sc0 plane enable
case 0x084/2: jm_scrollram[0] = data; break; //sc0 x offset
case 0x086/2: jm_scrollram[4] = data; break; //sc0 y offset
// case 0x182/2: jm_vregs[0] = data; break;
// case 0x184/2: jm_scrollram[0] = data; break;
// case 0x186/2: jm_scrollram[4] = data; break;
// case 0x382/2: jm_vregs[0] = data; break;
// case 0x384/2: jm_scrollram[0] = data; break;
// case 0x386/2: jm_scrollram[4] = data; break;
case 0x882/2: jm_vregs[3] = data; break; //sc3 plane enable
case 0x884/2: jm_scrollram[3] = data; break; //sc3 x offset
case 0x886/2: jm_scrollram[7] = data; break; //sc3 y offset
/*WRONG!*/
case 0x602/2: jm_vregs[0] = data; break;
case 0x604/2: jm_scrollram[0] = data; break;
case 0x606/2: jm_scrollram[4] = data; break;
case 0x77a/2: jm_vregs[0] = data; break; //sc0 plane enable,flip screen
case 0x77c/2: jm_scrollram[0] = data; break; //sc0 x offset,flip screen
case 0x77e/2: jm_scrollram[4] = data; break; //sc0 y offset,flip screen
case 0xf7a/2: jm_vregs[3] = data; break; //sc3 plane enable,flip screen
case 0xf7c/2: jm_scrollram[3] = data; break; //sc3 x offset,flip screen
case 0xf7e/2: jm_scrollram[7] = data; break; //sc3 y offset,flip screen
default: break;
}
//popmessage("%04x %04x %04x %04x %02x %02x",jm_scrollram[0],jm_scrollram[4],jm_scrollram[3],jm_scrollram[7],jm_vregs[0],jm_vregs[3]);
}
/******************************************************************************************
Protection file start
******************************************************************************************/
/*
MCU program number,different for each game(n.b. the numbering scheme is *mine*,do not
take it seriously...):
0x11 = daireika
0x12 = urashima
0x13 = mjzoomin
0x21 = kakumei
0x22 = kakumei2
0x23 = suchipi
xxxx ---- MCU program revision
---- xxxx MCU program number assignment for each game.
*/
#define DAIREIKA_MCU (0x11)
#define URASHIMA_MCU (0x12)
#define MJZOOMIN_MCU (0x13)
#define KAKUMEI_MCU (0x21)
#define KAKUMEI2_MCU (0x22)
#define SUCHIPI_MCU (0x23)
#define MCU_READ(tag, _bit_, _offset_, _retval_) \
if((0xffff - ioport(tag)->read()) & _bit_) { jm_shared_ram[_offset_] = _retval_; }
/*Funky "DMA" / protection thing*/
/*---- -x-- "DMA" execute.*/
/*---- ---x used too very often,I don't have any clue of what it is,it might just be the source or the destination address.*/
WRITE16_MEMBER(jalmah_state::urashima_dma_w)
{
if(data & 4)
{
UINT32 i;
for(i = 0; i < 0x200; i += 2)
space.write_word(0x88200 + i, space.read_word(0x88400 + i));
}
}
/*same as $f00c0 sub-routine,but with additional work-around,to remove from here...*/
void jalmah_state::daireika_palette_dma(UINT16 val)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
UINT32 index_1, index_2, src_addr, tmp_addr;
/*a0=301c0+jm_shared_ram[0x540/2] & 0xf00 */
/*a1=88000*/
src_addr = 0x301c0 + (val * 0x40);
// popmessage("%08x",src_addr);
for(index_1 = 0; index_1 < 0x200; index_1 += 0x20)
{
tmp_addr = src_addr;
src_addr = space.read_dword(src_addr);
for(index_2 = 0; index_2 < 0x20; index_2 += 2)
space.write_word(0x88000 + index_2 + index_1, space.read_word(src_addr + index_2));
src_addr = tmp_addr + 4;
}
}
/*RAM-based protection handlings*/
void jalmah_state::daireika_mcu_run()
{
UINT16 *jm_shared_ram = m_jm_shared_ram;
if(((jm_shared_ram[0x550/2] & 0xf00) == 0x700) && ((jm_shared_ram[0x540/2] & 0xf00) != m_dma_old))
{
m_dma_old = jm_shared_ram[0x540/2] & 0xf00;
daireika_palette_dma(((jm_shared_ram[0x540/2] & 0x0f00) >> 8));
}
if(m_test_mode) //service_mode
{
jm_shared_ram[0x000/2] = ioport("KEY0")->read();
jm_shared_ram[0x002/2] = ioport("KEY1")->read();
jm_shared_ram[0x004/2] = ioport("KEY2")->read();
jm_shared_ram[0x006/2] = ioport("KEY3")->read();
jm_shared_ram[0x008/2] = ioport("KEY4")->read();
jm_shared_ram[0x00a/2] = ioport("KEY5")->read();
}
else
{
jm_shared_ram[0x000/2] = 0x0000;
MCU_READ("KEY1", 0x0001, 0x000/2, 0x00); /*FF*/
MCU_READ("KEY2", 0x0400, 0x000/2, 0x01); /*A*/
MCU_READ("KEY2", 0x1000, 0x000/2, 0x02); /*B*/
MCU_READ("KEY2", 0x0200, 0x000/2, 0x03); /*C*/
MCU_READ("KEY2", 0x0800, 0x000/2, 0x04); /*D*/
MCU_READ("KEY2", 0x0004, 0x000/2, 0x05); /*E*/
MCU_READ("KEY2", 0x0010, 0x000/2, 0x06); /*F*/
MCU_READ("KEY2", 0x0002, 0x000/2, 0x07); /*G*/
MCU_READ("KEY2", 0x0008, 0x000/2, 0x08); /*H*/
MCU_READ("KEY1", 0x0400, 0x000/2, 0x09); /*I*/
MCU_READ("KEY1", 0x1000, 0x000/2, 0x0a); /*J*/
MCU_READ("KEY1", 0x0200, 0x000/2, 0x0b); /*K*/
MCU_READ("KEY1", 0x0800, 0x000/2, 0x0c); /*L*/
MCU_READ("KEY1", 0x0004, 0x000/2, 0x0d); /*M*/
MCU_READ("KEY1", 0x0010, 0x000/2, 0x0e); /*N*/
MCU_READ("KEY0", 0x0200, 0x000/2, 0x0f); /*RON (trusted)*/
MCU_READ("KEY0", 0x1000, 0x000/2, 0x10); /*REACH (trusted)*/
MCU_READ("KEY0", 0x0400, 0x000/2, 0x11); /*KAN */
MCU_READ("KEY1", 0x0008, 0x000/2, 0x12); /*PON */
MCU_READ("KEY1", 0x0002, 0x000/2, 0x13); /*CHI (trusted)*/
MCU_READ("KEY0", 0x0004, 0x000/2, 0x14); /*START1*/
}
m_prg_prot++;
if(m_prg_prot > 0x10) { m_prg_prot = 0; }
jm_shared_ram[0x00e/2] = m_prg_prot;
}
void jalmah_state::mjzoomin_mcu_run()
{
UINT16 *jm_shared_ram = m_jm_shared_ram;
if(m_test_mode) //service_mode
{
jm_shared_ram[0x000/2] = ioport("KEY0")->read();
jm_shared_ram[0x002/2] = ioport("KEY1")->read();
jm_shared_ram[0x004/2] = ioport("KEY2")->read();
jm_shared_ram[0x006/2] = ioport("KEY3")->read();
jm_shared_ram[0x008/2] = ioport("KEY4")->read();
jm_shared_ram[0x00a/2] = ioport("KEY5")->read();
}
else
{
jm_shared_ram[0x000/2] = 0x0000;
MCU_READ("KEY1", 0x0001, 0x000/2, 0x00); /*FF*/
MCU_READ("KEY2", 0x0400, 0x000/2, 0x01); /*A*/
MCU_READ("KEY2", 0x1000, 0x000/2, 0x02); /*B*/
MCU_READ("KEY2", 0x0200, 0x000/2, 0x03); /*C*/
MCU_READ("KEY2", 0x0800, 0x000/2, 0x04); /*D*/
MCU_READ("KEY2", 0x0004, 0x000/2, 0x05); /*E*/
MCU_READ("KEY2", 0x0010, 0x000/2, 0x06); /*F*/
MCU_READ("KEY2", 0x0002, 0x000/2, 0x07); /*G*/
MCU_READ("KEY2", 0x0008, 0x000/2, 0x08); /*H*/
MCU_READ("KEY1", 0x0400, 0x000/2, 0x09); /*I*/
MCU_READ("KEY1", 0x1000, 0x000/2, 0x0a); /*J*/
MCU_READ("KEY1", 0x0200, 0x000/2, 0x0b); /*K*/
MCU_READ("KEY1", 0x0800, 0x000/2, 0x0c); /*L*/
MCU_READ("KEY1", 0x0004, 0x000/2, 0x0d); /*M*/
MCU_READ("KEY1", 0x0010, 0x000/2, 0x0e); /*N*/
MCU_READ("KEY0", 0x0200, 0x000/2, 0x0f); /*RON (trusted)*/
MCU_READ("KEY0", 0x1000, 0x000/2, 0x10); /*REACH (trusted)*/
MCU_READ("KEY0", 0x0400, 0x000/2, 0x11); /*KAN */
MCU_READ("KEY1", 0x0008, 0x000/2, 0x12); /*PON */
MCU_READ("KEY1", 0x0002, 0x000/2, 0x13); /*CHI (trusted)*/
MCU_READ("KEY0", 0x0004, 0x000/2, 0x14); /*START1*/
}
jm_shared_ram[0x00c/2] = machine().rand() & 0xffff;
m_prg_prot++;
if(m_prg_prot > 0x10) { m_prg_prot = 0; }
jm_shared_ram[0x00e/2] = m_prg_prot;
}
void jalmah_state::urashima_mcu_run()
{
UINT16 *jm_shared_ram = m_jm_shared_ram;
if(m_test_mode) //service_mode
{
jm_shared_ram[0x300/2] = ioport("KEY0")->read();
jm_shared_ram[0x302/2] = ioport("KEY1")->read();
jm_shared_ram[0x304/2] = ioport("KEY2")->read();
jm_shared_ram[0x306/2] = ioport("KEY3")->read();
jm_shared_ram[0x308/2] = ioport("KEY4")->read();
jm_shared_ram[0x30a/2] = ioport("KEY5")->read();
}
else
{
jm_shared_ram[0x300/2] = 0x0000;
MCU_READ("KEY1", 0x0001, 0x300/2, 0x00); /*FF*/
MCU_READ("KEY2", 0x0400, 0x300/2, 0x01); /*A*/
MCU_READ("KEY2", 0x1000, 0x300/2, 0x02); /*B*/
MCU_READ("KEY2", 0x0200, 0x300/2, 0x03); /*C*/
MCU_READ("KEY2", 0x0800, 0x300/2, 0x04); /*D*/
MCU_READ("KEY2", 0x0004, 0x300/2, 0x05); /*E*/
MCU_READ("KEY2", 0x0010, 0x300/2, 0x06); /*F*/
MCU_READ("KEY2", 0x0002, 0x300/2, 0x07); /*G*/
MCU_READ("KEY2", 0x0008, 0x300/2, 0x08); /*H*/
MCU_READ("KEY1", 0x0400, 0x300/2, 0x09); /*I*/
MCU_READ("KEY1", 0x1000, 0x300/2, 0x0a); /*J*/
MCU_READ("KEY1", 0x0200, 0x300/2, 0x0b); /*K*/
MCU_READ("KEY1", 0x0800, 0x300/2, 0x0c); /*L*/
MCU_READ("KEY1", 0x0004, 0x300/2, 0x0d); /*M*/
MCU_READ("KEY1", 0x0010, 0x300/2, 0x0e); /*N*/
MCU_READ("KEY0", 0x0200, 0x300/2, 0x0f); /*RON (trusted)*/
MCU_READ("KEY0", 0x1000, 0x300/2, 0x10); /*REACH (trusted)*/
MCU_READ("KEY0", 0x0400, 0x300/2, 0x11); /*KAN */
MCU_READ("KEY1", 0x0008, 0x300/2, 0x12); /*PON */
MCU_READ("KEY1", 0x0002, 0x300/2, 0x13); /*CHI (trusted)*/
MCU_READ("KEY0", 0x0004, 0x300/2, 0x14); /*START1*/
}
jm_shared_ram[0x30c/2] = machine().rand() & 0xffff;
m_prg_prot++;
if(m_prg_prot > 0x10) { m_prg_prot = 0; }
jm_shared_ram[0x30e/2] = m_prg_prot;
}
void jalmah_state::second_mcu_run()
{
UINT16 *jm_shared_ram = m_jm_shared_ram;
if(m_test_mode) //service_mode
{
jm_shared_ram[0x200/2] = ioport("KEY0")->read();
jm_shared_ram[0x202/2] = ioport("KEY1")->read();
jm_shared_ram[0x204/2] = ioport("KEY2")->read();
}
else
{
jm_shared_ram[0x200/2] = 0x0000;
MCU_READ("KEY1", 0x0001, 0x200/2, 0x00); /*FF*/
MCU_READ("KEY2", 0x0400, 0x200/2, 0x01); /*A*/
MCU_READ("KEY2", 0x1000, 0x200/2, 0x02); /*B*/
MCU_READ("KEY2", 0x0200, 0x200/2, 0x03); /*C*/
MCU_READ("KEY2", 0x0800, 0x200/2, 0x04); /*D*/
MCU_READ("KEY2", 0x0004, 0x200/2, 0x05); /*E*/
MCU_READ("KEY2", 0x0010, 0x200/2, 0x06); /*F*/
MCU_READ("KEY2", 0x0002, 0x200/2, 0x07); /*G*/
MCU_READ("KEY2", 0x0008, 0x200/2, 0x08); /*H*/
MCU_READ("KEY1", 0x0400, 0x200/2, 0x09); /*I*/
MCU_READ("KEY1", 0x1000, 0x200/2, 0x0a); /*J*/
MCU_READ("KEY1", 0x0200, 0x200/2, 0x0b); /*K*/
MCU_READ("KEY1", 0x0800, 0x200/2, 0x0c); /*L*/
MCU_READ("KEY1", 0x0004, 0x200/2, 0x0d); /*M*/
MCU_READ("KEY1", 0x0010, 0x200/2, 0x0e); /*N*/
MCU_READ("KEY0", 0x0200, 0x200/2, 0x0f); /*RON*/
MCU_READ("KEY0", 0x1000, 0x200/2, 0x10); /*REACH*/
MCU_READ("KEY0", 0x0400, 0x200/2, 0x11); /*KAN*/
MCU_READ("KEY1", 0x0008, 0x200/2, 0x12); /*PON*/
MCU_READ("KEY1", 0x0002, 0x200/2, 0x13); /*CHI*/
MCU_READ("KEY0", 0x0004, 0x200/2, 0x14); /*START1*/
// MCU_READ("KEY0", 0x0004, 0x7b8/2, 0x03); /*START1(correct?) */
}
jm_shared_ram[0x20c/2] = machine().rand() & 0xffff; //kakumei2
}
TIMER_DEVICE_CALLBACK_MEMBER(jalmah_state::jalmah_mcu_sim)
{
switch(m_mcu_prg)
{
/*
#define DAIREIKA_MCU (0x11)
#define URASHIMA_MCU (0x12)
#define MJZOOMIN_MCU (0x13)
#define KAKUMEI_MCU (0x21)
#define KAKUMEI2_MCU (0x22)
#define SUCHIPI_MCU (0x23)
*/
case MJZOOMIN_MCU: mjzoomin_mcu_run(); break;
case DAIREIKA_MCU: daireika_mcu_run(); break;
case URASHIMA_MCU: urashima_mcu_run(); break;
case KAKUMEI_MCU:
case KAKUMEI2_MCU:
case SUCHIPI_MCU: second_mcu_run(); break;
}
}
/******************************************************************************************
Basic driver start
******************************************************************************************/
WRITE16_MEMBER(jalmah_state::jalmah_okirom_w)
{
if(ACCESSING_BITS_0_7)
{
UINT8 *oki = memregion("oki")->base();
m_oki_rom = data & 1;
/* ZA appears to be related to the banking, or maybe kakumei2 uses PAL shuffling and this is for something else? */
m_oki_za = (data & 2) ? 1 : 0;
memcpy(&oki[0x20000], &oki[(m_oki_rom * 0x80000) + ((m_oki_bank+m_oki_za) * 0x20000) + 0x40000], 0x20000);
}
//popmessage("PC=%06x %02x %02x %02x %08x",space.device().safe_pc(),m_oki_rom,m_oki_za,m_oki_bank,(m_oki_rom * 0x80000) + ((m_oki_bank+m_oki_za) * 0x20000) + 0x40000);
}
WRITE16_MEMBER(jalmah_state::jalmah_okibank_w)
{
if(ACCESSING_BITS_0_7)
{
UINT8 *oki = memregion("oki")->base();
m_oki_bank = data & 3;
memcpy(&oki[0x20000], &oki[(m_oki_rom * 0x80000) + ((m_oki_bank+m_oki_za) * 0x20000) + 0x40000], 0x20000);
}
//popmessage("PC=%06x %02x %02x %02x %08x",space.device().safe_pc(),m_oki_rom,m_oki_za,m_oki_bank,(m_oki_rom * 0x80000) + ((m_oki_bank+m_oki_za) * 0x20000) + 0x40000);
}
WRITE16_MEMBER(jalmah_state::jalmah_flip_screen_w)
{
/*---- ----x flip screen*/
flip_screen_set(data & 1);