/
firebeat.c
executable file
·2277 lines (1896 loc) · 71.4 KB
/
firebeat.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
/* Konami FireBeat
Driver by Ville Linde
Hardware overview:
GQ972 PWB(A2) 0000070609 Main board
-----------------------------------
OSC 64.00MHz
IBM PowerPC 403GCX at 64MHz
(2x) Konami 0000057714 (2D object processor)
Yamaha YMZ280B (ADPCM sound chip)
Epson RTC65271 RTC/NVRAM
National Semiconductor PC16552DV (dual UART)
GQ974 PWB(A2) 0000070140 Extend board
-------------------------------------
ADC0808CCN
FDC37C665GT (floppy disk controller)
National Semiconductor PC16552DV (dual UART)
ADM223LJR (RS-232 driver/receiver)
GQ971 PWB(A2) 0000070254 SPU
----------------------------
Motorola MC68HC000FN16 at 16MHz (?)
Xilinx XC9572 CPLD
Ricoh RF5c400 sound chip
GQ971 PWB(B2) 0000067784 Backplane
----------------------------------
3x PCB Slots with 2x DIN96S connectors (for main and extend PCBs)
40-pin ATA connector for each slot
GQ986 PWB(A1) 0000073015 Backplane
----------------------------------
2x PCB Slots with 2x DIN96S connectors (for main and extend PCBs)
40-pin ATA connector for each slot
GQ972 PWB(D2) Controller interface on Beatmania III (?)
GQ972 PWB(G1) Sound Amp (?)
GQ971 PWB(C) Sound Amp
Hardware configurations:
Beatmania III
-------------
GQ971 Backplane
GQ972 Main Board
GQ974 Extend Board
GQ971 SPU
GQ972 Controller Interface
GQ972 Sound Amp
Hard drive in Slot 1
DVD drive in Slot 2
Keyboardmania
-------------
GQ971 Backplane
GQ972 Main Board
GQ974 Extend Board
Yamaha XT446 board (for keyboard sounds) (the board layout matches the Yamaha MU100 Tone Generator)
GQ971 Sound Amp
CD-ROM drive in Slot 1
CD-ROM drive in Slot 2
ParaParaParadise
----------------
GQ986 Backplane
GQ972 Main Board
2x CD-ROM drive in Slot 1
Games that run on this hardware:
BIOS Game ID Year Game
------------------------------------------------------------------
GQ972 GQ972 2000 Beatmania III
GQ972(?) ? 2001 Beatmania III Append 6th Mix
GQ972(?) ? 2002 Beatmania III Append 7th Mix
GQ972(?) ? 2000 Beatmania III Append Core Remix
GQ972(?) ? 2003 Beatmania III The Final
GQ974 GQ974 2000 Keyboardmania
GQ974 GCA01 2000 Keyboardmania 2nd Mix
GQ974 GCA12 2001 Keyboardmania 3rd Mix
GQ977 GQ977 2000 Para Para Paradise
GQ977 GQ977 2000 Para Para Dancing
GQ977 GC977 2000 Para Para Paradise 1.1
GQ977 GQA11 2000 Para Para Paradise 1st Mix+
GQA02(?) ? 2000 Pop'n Music 4
??? ? 2000 Pop'n Music 5
??? ? 2001 Pop'n Music 6
GQA02 GCB00 2001 Pop'n Music 7
??? ? 2002 Pop'n Music 8
??? ? 2000 Pop'n Music Animelo
??? ? 2001 Pop'n Music Animelo 2
??? ? 2001 Pop'n Music Mickey Tunes
TODO:
- The display list pointer setting in the graphics chip is not understood. Currently
it has to be changed manually. (BIOS = 0x200000, PPP bootup = 0x1D0800, ingame = 0x0000, 0x8000 & 0x10000)
- Keyboardmania 3rd mix is missing some graphics in the ingame. Most notably the backgrounds.
The display list objects seem to be there, but the address is wrong (0x14c400, instead of the correct address)
- The external Yamaha MIDI sound board is not emulated (no keyboard sounds).
- Notes on how the video is supposed to work from Ville / Ian Patterson:
There are four "display contexts" that are set up via registers 20-4E. They are
basically just raw framebuffers. 40-4E sets the base framebuffer pointer, 30-3E
sets the size, 20-2E may set the minimum x and y coordinates but I haven't seen
them set to something other than 0 yet. One context is set as the one the RAMDAC
outputs to the monitor (not sure how this is selected yet, probably the lower
bits of register 12). Thestartup test in the popn BIOS checks all of VRAM, so
it moves the currentdisplay address around so you don't see crazy colors, which
is very helpful in figuring out how this part works.
The other new part is that there are two VRAM write ports, managed by registers
60+68+70 and 64+6A+74, with status read from the lower bits of reg 7A. Each context
can either write to VRAM as currently emulated, or the port can be switched in to
"immediate mode" via registers 68/6A. Immedate mode can be used to run GCU commands
at any point during the frame. It's mainly used to call display lists, which is where
the display list addresses come from. Some games use it to send other commands, so
it appears to be a 4-dword FIFO or something along those lines.
*/
#include "emu.h"
#include "cpu/m68000/m68000.h"
#include "cpu/powerpc/ppc.h"
#include "machine/ataintf.h"
#include "machine/intelfsh.h"
#include "machine/rtc65271.h"
#include "machine/ins8250.h"
#include "machine/midikbd.h"
#include "sound/ymz280b.h"
#include "sound/cdda.h"
#include "firebeat.lh"
struct GCU_REGS
{
UINT32 *vram;
UINT32 vram_read_address;
UINT32 vram_write_fifo_address;
UINT32 visible_area;
};
struct IBUTTON_SUBKEY
{
UINT8 identifier[8];
UINT8 password[8];
UINT8 data[0x30];
};
struct IBUTTON
{
IBUTTON_SUBKEY subkey[3];
};
class firebeat_state : public driver_device
{
public:
firebeat_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_work_ram(*this, "work_ram"),
m_flash_main(*this, "flash_main"),
m_flash_snd1(*this, "flash_snd1"),
m_flash_snd2(*this, "flash_snd2"),
m_duart_midi(*this, "duart_midi"),
m_duart_com(*this, "duart_com"),
m_kbd0(*this, "kbd0"),
m_kbd1(*this, "kbd1"),
m_ata(*this, "ata")
{ }
required_device<ppc4xx_device> m_maincpu;
required_shared_ptr<UINT32> m_work_ram;
required_device<fujitsu_29f016a_device> m_flash_main;
required_device<fujitsu_29f016a_device> m_flash_snd1;
required_device<fujitsu_29f016a_device> m_flash_snd2;
optional_device<pc16552_device> m_duart_midi;
required_device<pc16552_device> m_duart_com;
optional_device<midi_keyboard_device> m_kbd0;
optional_device<midi_keyboard_device> m_kbd1;
required_device<ata_interface_device> m_ata;
UINT8 m_extend_board_irq_enable;
UINT8 m_extend_board_irq_active;
// emu_timer *m_keyboard_timer;
GCU_REGS m_gcu[2];
int m_tick;
int m_layer;
int m_cab_data_ptr;
const int * m_cur_cab_data;
// int m_keyboard_state[2];
UINT8 m_spu_shared_ram[0x400];
IBUTTON m_ibutton;
int m_ibutton_state;
int m_ibutton_read_subkey_ptr;
UINT8 m_ibutton_subkey_data[0x40];
DECLARE_READ8_MEMBER(soundram_r);
DECLARE_DRIVER_INIT(ppd);
DECLARE_DRIVER_INIT(kbm);
DECLARE_DRIVER_INIT(ppp);
DECLARE_MACHINE_START(firebeat);
DECLARE_MACHINE_RESET(firebeat);
DECLARE_VIDEO_START(firebeat);
UINT32 screen_update_firebeat_0(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
UINT32 screen_update_firebeat_1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
INTERRUPT_GEN_MEMBER(firebeat_interrupt);
DECLARE_READ32_MEMBER(gcu0_r);
DECLARE_WRITE32_MEMBER(gcu0_w);
DECLARE_READ32_MEMBER(gcu1_r);
DECLARE_WRITE32_MEMBER(gcu1_w);
DECLARE_READ32_MEMBER(input_r);
DECLARE_READ32_MEMBER(sensor_r );
DECLARE_READ32_MEMBER(flashram_r);
DECLARE_WRITE32_MEMBER(flashram_w);
DECLARE_READ32_MEMBER(soundflash_r);
DECLARE_WRITE32_MEMBER(soundflash_w);
DECLARE_WRITE_LINE_MEMBER(ata_interrupt);
DECLARE_READ32_MEMBER(ata_command_r);
DECLARE_WRITE32_MEMBER(ata_command_w);
DECLARE_READ32_MEMBER(ata_control_r);
DECLARE_WRITE32_MEMBER(ata_control_w);
// DECLARE_READ32_MEMBER(comm_uart_r);
// DECLARE_WRITE32_MEMBER(comm_uart_w);
DECLARE_READ32_MEMBER(cabinet_r);
DECLARE_READ32_MEMBER(keyboard_wheel_r);
DECLARE_READ8_MEMBER(midi_uart_r);
DECLARE_WRITE8_MEMBER(midi_uart_w);
DECLARE_READ32_MEMBER(extend_board_irq_r);
DECLARE_WRITE32_MEMBER(extend_board_irq_w);
DECLARE_WRITE32_MEMBER(lamp_output_w);
DECLARE_WRITE32_MEMBER(lamp_output_kbm_w);
DECLARE_WRITE32_MEMBER(lamp_output_ppp_w);
DECLARE_WRITE32_MEMBER(lamp_output2_w);
DECLARE_WRITE32_MEMBER(lamp_output2_ppp_w);
DECLARE_WRITE32_MEMBER(lamp_output3_w);
DECLARE_WRITE32_MEMBER(lamp_output3_ppp_w);
DECLARE_READ32_MEMBER(ppc_spu_share_r);
DECLARE_WRITE32_MEMBER(ppc_spu_share_w);
DECLARE_READ16_MEMBER(spu_unk_r);
// TIMER_CALLBACK_MEMBER(keyboard_timer_callback);
void gcu_draw_object(bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, UINT32 *cmd);
void gcu_fill_rect(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 *cmd);
void gcu_draw_character(bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, UINT32 *cmd);
void gcu_exec_display_list(bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, UINT32 address);
UINT32 update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip);
UINT32 GCU_r(int chip, UINT32 offset, UINT32 mem_mask);
void GCU_w(int chip, UINT32 offset, UINT32 data, UINT32 mem_mask);
void set_ibutton(UINT8 *data);
int ibutton_w(UINT8 data);
DECLARE_WRITE8_MEMBER(security_w);
void init_lights(write32_delegate out1, write32_delegate out2, write32_delegate out3);
void init_firebeat();
void init_keyboard();
DECLARE_WRITE_LINE_MEMBER(sound_irq_callback);
DECLARE_WRITE_LINE_MEMBER(midi_uart_ch0_irq_callback);
DECLARE_WRITE_LINE_MEMBER(midi_uart_ch1_irq_callback);
};
VIDEO_START_MEMBER(firebeat_state,firebeat)
{
m_gcu[0].vram = auto_alloc_array(machine(), UINT32, 0x2000000/4);
m_gcu[1].vram = auto_alloc_array(machine(), UINT32, 0x2000000/4);
memset(m_gcu[0].vram, 0, 0x2000000);
memset(m_gcu[1].vram, 0, 0x2000000);
}
void firebeat_state::gcu_draw_object(bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, UINT32 *cmd)
{
// 0x00: xxx----- -------- -------- -------- command type
// 0x00: -------- xxxxxxxx xxxxxxxx xxxxxxxx object data address in vram
// 0x01: -------- -------- ------xx xxxxxxxx object x
// 0x01: -------- ----xxxx xxxxxx-- -------- object y
// 0x01: -----x-- -------- -------- -------- object x flip
// 0x01: ----x--- -------- -------- -------- object y flip
// 0x01: ---x---- -------- -------- -------- object alpha enable (?)
// 0x02: -------- -------- ------xx xxxxxxxx object width
// 0x02: -------- -----xxx xxxxxx-- -------- object x scale
// 0x03: -------- -------- ------xx xxxxxxxx object height
// 0x03: -------- -----xxx xxxxxx-- -------- object y scale
int x = cmd[1] & 0x3ff;
int y = (cmd[1] >> 10) & 0x3ff;
int width = (cmd[2] & 0x3ff) + 1;
int height = (cmd[3] & 0x3ff) + 1;
int xscale = (cmd[2] >> 10) & 0x1ff;
int yscale = (cmd[3] >> 10) & 0x1ff;
int xflip = (cmd[1] & 0x04000000) ? 1 : 0;
int yflip = (cmd[1] & 0x08000000) ? 1 : 0;
int alpha_enable = (cmd[1] & 0x10000000) ? 1 : 0;
UINT32 address = cmd[0] & 0xffffff;
int alpha_level = (cmd[2] >> 27) & 0x1f;
int i, j;
int u, v;
UINT16 *vr = (UINT16*)m_gcu[chip].vram;
if (xscale == 0 || yscale == 0)
{
xscale = 0x40;
yscale = 0x40;
return;
}
//if ((cmd[2] >> 24) != 0x84 && (cmd[2] >> 24) != 0x04 && (cmd[2] >> 24) != 0x00)
// printf("Unknown value = %d, %d\n", (cmd[2] >> 27) & 0x1f, (cmd[2] >> 22) & 0x1f);
width = (((width * 65536) / xscale) * 64) / 65536;
height = (((height * 65536) / yscale) * 64) / 65536;
if (y > cliprect.max_y || x > cliprect.max_x) {
return;
}
if ((y+height) > cliprect.max_y) {
height = cliprect.max_y - y;
}
if ((x+width) > cliprect.max_x) {
width = cliprect.max_x - x;
}
v = 0;
for (j=0; j < height; j++)
{
int xi;
int index;
UINT16 *d = &bitmap.pix16(j+y, x);
//int index = address + ((v >> 6) * 1024);
if (yflip)
{
index = address + ((height - 1 - (v >> 6)) * 1024);
}
else
{
index = address + ((v >> 6) * 1024);
}
if (xflip)
{
d += width;
xi = -1;
}
else
{
xi = 1;
}
u = 0;
for (i=0; i < width; i++)
{
UINT16 pix = vr[((index + (u >> 6)) ^ 1) & 0xffffff];
if (alpha_enable)
{
if (pix & 0x8000)
{
if ((pix & 0x7fff) != 0)
{
//*d = pix & 0x7fff;
UINT16 srcpix = *d;
/*
UINT32 r = pix & 0x7c00;
UINT32 g = pix & 0x03e0;
UINT32 b = pix & 0x001f;
UINT32 sr = srcpix & 0x7c00;
UINT32 sg = srcpix & 0x03e0;
UINT32 sb = srcpix & 0x001f;
sr += r;
sg += g;
sb += b;
if (sr > 0x7c00) sr = 0x7c00;
if (sg > 0x03e0) sg = 0x03e0;
if (sb > 0x001f) sb = 0x001f;
*d = sr | sg | sb;
*/
UINT32 sr = (srcpix >> 10) & 0x1f;
UINT32 sg = (srcpix >> 5) & 0x1f;
UINT32 sb = (srcpix >> 0) & 0x1f;
UINT32 r = (pix >> 10) & 0x1f;
UINT32 g = (pix >> 5) & 0x1f;
UINT32 b = (pix >> 0) & 0x1f;
sr += (r * alpha_level) >> 4;
sg += (g * alpha_level) >> 4;
sb += (b * alpha_level) >> 4;
if (sr > 0x1f) sr = 0x1f;
if (sg > 0x1f) sg = 0x1f;
if (sb > 0x1f) sb = 0x1f;
*d = (sr << 10) | (sg << 5) | sb;
}
}
}
else
{
if (pix & 0x8000)
{
*d = pix & 0x7fff;
}
}
if ((cmd[0] & 0x10000000) == 0)
*d = 0x7fff;
d += xi;
u += xscale;
}
v += yscale;
}
}
void firebeat_state::gcu_fill_rect(bitmap_ind16 &bitmap, const rectangle &cliprect, UINT32 *cmd)
{
int i, j;
int x1, y1, x2, y2;
int x = cmd[1] & 0x3ff;
int y = (cmd[1] >> 10) & 0x3ff;
int width = (cmd[0] & 0x3ff) + 1;
int height = ((cmd[0] >> 10) & 0x3ff) + 1;
UINT16 color[4];
color[0] = (cmd[2] >> 16);
color[1] = (cmd[2] >> 0);
color[2] = (cmd[3] >> 16);
color[3] = (cmd[3] >> 0);
x1 = x;
x2 = x + width;
y1 = y;
y2 = y + height;
if ((color[0] & 0x8000) == 0 && (color[1] & 0x8000) == 0 && (color[2] & 0x8000) == 0 && (color[3] & 0x8000) == 0)
{
// optimization, nothing to fill
return;
}
// clip
if (x1 < cliprect.min_x) x1 = cliprect.min_x;
if (y1 < cliprect.min_y) y1 = cliprect.min_y;
if (x2 > cliprect.max_x) x2 = cliprect.max_x;
if (y2 > cliprect.max_y) y2 = cliprect.max_y;
for (j=y1; j < y2; j++)
{
UINT16 *d = &bitmap.pix16(j);
for (i=x1; i < x2; i++)
{
if (color[i&3] & 0x8000)
{
d[i] = color[i&3] & 0x7fff;
}
}
}
}
void firebeat_state::gcu_draw_character(bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, UINT32 *cmd)
{
// 0x00: xxx----- -------- -------- -------- command type
// 0x00: -------- xxxxxxxx xxxxxxxx xxxxxxxx character data address in vram
// 0x01: -------- -------- ------xx xxxxxxxx character x
// 0x01: -------- ----xxxx xxxxxx-- -------- character y
// 0x02: xxxxxxxx xxxxxxxx -------- -------- color 0
// 0x02: -------- -------- xxxxxxxx xxxxxxxx color 1
// 0x03: xxxxxxxx xxxxxxxx -------- -------- color 2
// 0x03: -------- -------- xxxxxxxx xxxxxxxx color 3
int i, j;
int x = cmd[1] & 0x3ff;
int y = (cmd[1] >> 10) & 0x3ff;
UINT32 address = cmd[0] & 0xffffff;
UINT16 color[4];
UINT16 *vr = (UINT16*)m_gcu[chip].vram;
color[0] = (cmd[2] >> 16) & 0xffff;
color[1] = (cmd[2] >> 0) & 0xffff;
color[2] = (cmd[3] >> 16) & 0xffff;
color[3] = (cmd[3] >> 0) & 0xffff;
if (y > cliprect.max_y || x > cliprect.max_x) {
return;
}
for (j=0; j < 8; j++)
{
UINT16 *d = &bitmap.pix16(y+j, x);
UINT16 line = vr[address^1];
address += 4;
for (i=0; i < 8; i++)
{
int pix = (line >> ((7-i) * 2)) & 3;
d[i] = color[pix];
}
}
}
void firebeat_state::gcu_exec_display_list(bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, UINT32 address)
{
int counter = 0;
int end = 0;
int i = address / 4;
if (i < 0) i = 0;
while (!end && counter < 0x1000 && i < (0x2000000/4))
{
int command;
UINT32 cmd[4];
cmd[0] = m_gcu[chip].vram[i+0];
cmd[1] = m_gcu[chip].vram[i+1];
cmd[2] = m_gcu[chip].vram[i+2];
cmd[3] = m_gcu[chip].vram[i+3];
command = (cmd[0] >> 29) & 0x7;
switch (command)
{
case 0x0: // ???
{
break;
}
case 0x1: // Branch
{
gcu_exec_display_list(bitmap, cliprect, chip, cmd[0] & 0xffffff);
break;
}
case 0x2: // End of display list
{
end = 1;
break;
}
case 0x3: // ???
{
break;
}
case 0x4: // Fill rectangle
{
gcu_fill_rect(bitmap, cliprect, cmd);
break;
}
case 0x5: // Draw object
{
gcu_draw_object(bitmap, cliprect, chip, cmd);
break;
}
case 0x7: // Draw 8x8 Character (2-bits per pixel)
{
gcu_draw_character(bitmap, cliprect, chip, cmd);
break;
}
default:
//printf("Unknown command %08X %08X %08X %08X at %08X\n", cmd[0], cmd[1], cmd[2], cmd[3], i*4);
break;
}
i += 4;
counter++;
};
}
UINT32 firebeat_state::update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip)
{
bitmap.fill(0, cliprect);
if ((core_strnicmp(machine().system().name, "popn", 4) == 0) || (core_strnicmp(machine().system().name, "bm3", 3) == 0))
{
gcu_exec_display_list( bitmap, cliprect, chip, 0x1f80000);
}
else
{
if (m_layer >= 2)
{
gcu_exec_display_list(bitmap, cliprect, chip, 0x8000);
gcu_exec_display_list(bitmap, cliprect, chip, 0x0000);
gcu_exec_display_list(bitmap, cliprect, chip, 0x10000);
}
else if (m_layer == 0)
{
gcu_exec_display_list(bitmap, cliprect, chip, 0x200000);
//gcu_exec_display_list(bitmap, cliprect, chip, 0x186040);
}
else if (m_layer == 1)
{
gcu_exec_display_list(bitmap, cliprect, chip, 0x1d0800);
gcu_exec_display_list(bitmap, cliprect, chip, 0x1a9440);
}
}
m_tick++;
if (m_tick >= 5)
{
m_tick = 0;
if (machine().input().code_pressed(KEYCODE_0))
{
m_layer++;
if (m_layer > 2)
{
m_layer = 0;
}
}
/*
if (machine().input().code_pressed_once(KEYCODE_9))
{
FILE *file = fopen("vram0.bin", "wb");
int i;
for (i=0; i < 0x2000000/4; i++)
{
fputc((m_gcu[0].vram[i] >> 24) & 0xff, file);
fputc((m_gcu[0].vram[i] >> 16) & 0xff, file);
fputc((m_gcu[0].vram[i] >> 8) & 0xff, file);
fputc((m_gcu[0].vram[i] >> 0) & 0xff, file);
}
fclose(file);
file = fopen("vram1.bin", "wb");
for (i=0; i < 0x2000000/4; i++)
{
fputc((m_gcu[1].vram[i] >> 24) & 0xff, file);
fputc((m_gcu[1].vram[i] >> 16) & 0xff, file);
fputc((m_gcu[1].vram[i] >> 8) & 0xff, file);
fputc((m_gcu[1].vram[i] >> 0) & 0xff, file);
}
fclose(file);
}
*/
}
return 0;
}
UINT32 firebeat_state::screen_update_firebeat_0(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ return update_screen(screen, bitmap, cliprect, 0); }
UINT32 firebeat_state::screen_update_firebeat_1(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect){ return update_screen(screen, bitmap, cliprect, 1); }
UINT32 firebeat_state::GCU_r(int chip, UINT32 offset, UINT32 mem_mask)
{
int reg = offset * 4;
/* VRAM Read */
if (reg >= 0x80 && reg < 0x100)
{
return m_gcu[chip].vram[m_gcu[chip].vram_read_address + ((reg/4) - 0x20)];
}
switch(reg)
{
case 0x78: /* GCU Status */
/* ppd checks bits 0x0041 of the upper halfword on interrupt */
return 0xffff0005;
default:
break;
}
return 0xffffffff;
}
void firebeat_state::GCU_w(int chip, UINT32 offset, UINT32 data, UINT32 mem_mask)
{
int reg = offset * 4;
if (reg != 0x70 && chip == 0)
{
//printf("%s:gcu%d_w: %08X, %08X, %08X at %08X\n", machine().describe_context(), chip, data, offset, mem_mask);
//logerror("%s:gcu%d_w: %08X, %08X, %08X at %08X\n", cmachine->describe_context(), hip, data, offset, mem_mask);
}
switch(reg)
{
case 0x10: /* ??? */
/* IRQ clear/enable; ppd writes bit off then on in response to interrupt */
/* it enables bits 0x41, but 0x01 seems to be the one it cares about */
if (ACCESSING_BITS_16_31 && (data & 0x0001) == 0)
m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
break;
case 0x30:
//case 0x34:
//case 0x38:
//case 0x3c:
{
COMBINE_DATA( &m_gcu[chip].visible_area );
if (ACCESSING_BITS_0_15)
{
screen_device_iterator iter(machine().root_device());
screen_device *screen = iter.byindex(chip);
if (screen != NULL)
{
rectangle visarea = screen->visible_area();
int width, height;
width = (m_gcu[chip].visible_area & 0xffff);
height = (m_gcu[chip].visible_area >> 16) & 0xffff;
visarea.max_x = width-1;
visarea.max_y = height-1;
screen->configure(visarea.max_x + 1, visarea.max_y + 1, visarea, screen->frame_period().attoseconds);
}
}
break;
}
case 0x40: /* framebuffer config */
// HACK: switch display lists at the right times for the ParaParaParadise games until we
// do the video emulation properly
if (core_strnicmp(machine().system().name, "pp", 2) == 0)
{
switch (data)
{
case 0x00080000: // post
m_layer = 0;
break;
case 0x00008400: // startup tests
if (m_layer != 2)
{
m_layer = 1;
}
break;
case 0x00068400: // game & svc menu
m_layer = 2;
break;
}
}
else if (core_strnicmp(machine().system().name, "kbm", 3) == 0)
{
switch (data)
{
case 0x00080000: // post
m_layer = 0;
break;
case 0x0000c400: // game & svn menu
m_layer = 2;
break;
}
}
break;
//case 0x44: /* ??? */
// break;
case 0x5c: /* VRAM Read Address */
m_gcu[chip].vram_read_address = (data & 0xffffff) / 2;
break;
case 0x60: /* VRAM FIFO Write Address */
m_gcu[chip].vram_write_fifo_address = (data & 0xffffff) / 2;
// printf("gcu%d_w: %08X, %08X, %08X\n", chip, data, offset, mem_mask);
break;
case 0x68: /* Unknown */
{
break;
}
case 0x70: /* VRAM FIFO Write */
m_gcu[chip].vram[m_gcu[chip].vram_write_fifo_address] = data;
m_gcu[chip].vram_write_fifo_address++;
break;
default:
// printf("gcu%d_w: %08X, %08X, %08X\n", chip, data, offset, mem_mask);
break;
}
}
READ32_MEMBER(firebeat_state::gcu0_r)
{
return GCU_r(0, offset, mem_mask);
}
WRITE32_MEMBER(firebeat_state::gcu0_w)
{
GCU_w(0, offset, data, mem_mask);
}
READ32_MEMBER(firebeat_state::gcu1_r)
{
return GCU_r(1, offset, mem_mask);
}
WRITE32_MEMBER(firebeat_state::gcu1_w)
{
GCU_w(1, offset, data, mem_mask);
}
/*****************************************************************************/
READ32_MEMBER(firebeat_state::input_r)
{
UINT32 r = 0;
if (ACCESSING_BITS_24_31)
{
r |= (ioport("IN0")->read() & 0xff) << 24;
}
if (ACCESSING_BITS_8_15)
{
r |= (ioport("IN1")->read() & 0xff) << 8;
}
if (ACCESSING_BITS_0_7)
{
r |= (ioport("IN2")->read() & 0xff);
}
return r;
}
READ32_MEMBER(firebeat_state::sensor_r )
{
if (offset == 0)
{
return ioport("SENSOR1")->read() | 0x01000100;
}
else
{
return ioport("SENSOR2")->read() | 0x01000100;
}
}
READ32_MEMBER(firebeat_state::flashram_r)
{
UINT32 r = 0;
if (ACCESSING_BITS_24_31)
{
r |= (m_flash_main->read((offset*4)+0) & 0xff) << 24;
}
if (ACCESSING_BITS_16_23)
{
r |= (m_flash_main->read((offset*4)+1) & 0xff) << 16;
}
if (ACCESSING_BITS_8_15)
{
r |= (m_flash_main->read((offset*4)+2) & 0xff) << 8;
}
if (ACCESSING_BITS_0_7)
{
r |= (m_flash_main->read((offset*4)+3) & 0xff) << 0;
}
return r;
}
WRITE32_MEMBER(firebeat_state::flashram_w)
{
if (ACCESSING_BITS_24_31)
{
m_flash_main->write((offset*4)+0, (data >> 24) & 0xff);
}
if (ACCESSING_BITS_16_23)
{
m_flash_main->write((offset*4)+1, (data >> 16) & 0xff);
}
if (ACCESSING_BITS_8_15)
{
m_flash_main->write((offset*4)+2, (data >> 8) & 0xff);
}
if (ACCESSING_BITS_0_7)
{
m_flash_main->write((offset*4)+3, (data >> 0) & 0xff);
}
}
READ32_MEMBER(firebeat_state::soundflash_r)
{
UINT32 r = 0;
fujitsu_29f016a_device *chip;
if (offset < 0x200000/4)
{
chip = m_flash_snd1;
}
else
{
chip = m_flash_snd2;
}
offset &= 0x7ffff;
if (ACCESSING_BITS_24_31)
{
r |= (chip->read((offset*4)+0) & 0xff) << 24;
}
if (ACCESSING_BITS_16_23)
{
r |= (chip->read((offset*4)+1) & 0xff) << 16;
}
if (ACCESSING_BITS_8_15)
{
r |= (chip->read((offset*4)+2) & 0xff) << 8;
}
if (ACCESSING_BITS_0_7)
{
r |= (chip->read((offset*4)+3) & 0xff) << 0;
}
return r;
}
WRITE32_MEMBER(firebeat_state::soundflash_w)
{
fujitsu_29f016a_device *chip;
if (offset < 0x200000/4)
{
chip = m_flash_snd1;
}
else
{
chip = m_flash_snd2;
}
offset &= 0x7ffff;
if (ACCESSING_BITS_24_31)
{
chip->write((offset*4)+0, (data >> 24) & 0xff);
}
if (ACCESSING_BITS_16_23)
{
chip->write((offset*4)+1, (data >> 16) & 0xff);
}
if (ACCESSING_BITS_8_15)
{
chip->write((offset*4)+2, (data >> 8) & 0xff);
}
if (ACCESSING_BITS_0_7)
{
chip->write((offset*4)+3, (data >> 0) & 0xff);
}
}
/*****************************************************************************/
/* ATA Interface */
#define BYTESWAP16(x) ((((x) >> 8) & 0xff) | (((x) << 8) & 0xff00))
READ32_MEMBER(firebeat_state::ata_command_r )
{
UINT16 r;
// printf("ata_command_r: %08X, %08X\n", offset, mem_mask);
if (ACCESSING_BITS_16_31)
{
r = m_ata->read_cs0(space, offset*2, BYTESWAP16((mem_mask >> 16) & 0xffff));
return BYTESWAP16(r) << 16;
}
else
{
r = m_ata->read_cs0(space, (offset*2) + 1, BYTESWAP16((mem_mask >> 0) & 0xffff));
return BYTESWAP16(r) << 0;
}
}