-
Notifications
You must be signed in to change notification settings - Fork 36
/
BOOTCMFC.ASM
9333 lines (8511 loc) · 153 KB
/
BOOTCMFC.ASM
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
;
; Carnivore/Carnivore2 Cartridge's Boot Menu
; Copyright (c) 2015-2024 RBSC
; Portions (c) Grauw
; Portions (c) Spark/SDM
; Portions (c) Jordon aka KOD/SDM
; Version 2.53
;
; !COMPILATION OPTIONS!
SPC equ 0 ; 1 = only basic characters are used for UI (for Arabic and Korean computers)
; 0 = all characters are used for UI
MUS equ 0 ; Music selction for the Boot Menu
; 1 = Stamper, 0 = Aurora
; !COMPILATION OPTIONS!
; Variables
GETPNT equ #F3FA
PUTPNT equ #F3F8
CSRY equ #F3DC
CSRX equ #F3DD
CSRSW equ #FCA9
CSSTYL equ #FCAA
CSSYM equ #FBCC
SL0EXP equ #FCC1
SL1EXP equ #FCC2
SL2EXP equ #FCC3
SL3EXP equ #FCC4
KEYCLK equ #F3DB
FORCLR equ #F3E9
BAKCLR equ #F3EA
BDRCLR equ #F3EB
CHSETA equ #F920
CHSETS equ #F91F
SCR0WID equ #F3AE
SCRWID equ #F3B0
SCRHIGH equ #F3B1
SCRMOD equ #FCAF
; Boot Menu variable storage
SCRNUM equ #F560
SLASLTN equ #F561
SCRINFO equ #F562 ; 2 bytes!
DIRCNT equ #F564 ; 2 bytes!
DIRPAG equ #F566 ; 2 bytes!
CURPAG equ #F568 ; 2 bytes!
VDPVER equ #F56A
MASSLAV equ #F56B
PALNTSC equ #F56C
MASSLTN equ #F56D
XYPOS equ #F56E ; 2 bytes!
AUTOST equ #F570
MASSEXP equ #F571
PSGCFG equ #F572
SLASEXP equ #F573
ORGVR10 equ #F574
WARMBT equ #F575
MSXTYPE equ #F576
ERMSLT equ #F577
TURBOM equ #F578
MASSLTS equ #F579
SLASLTS equ #F57A
DUOSLCF equ #F57B
SLOTFAD equ #F57C
SPECRB equ #F57D
ARKOR equ #F57E
LASTU equ #F57F
; Variables for UI setup
SKIPFD equ #F580 ; 1 byte
SELITEM equ #F581 ; 1 byte
SORT equ #F582 ; 1 byte
EFF equ #F583 ; 1 byte
FMMON equ #F584 ; 1 byte
SPD equ #F585 ; 1 byte
FREQ equ #F586 ; 1 byte
DUALRST equ #F587 ; 1 byte
ASDELAY equ #F588 ; 1 byte
SLOT3R equ #F589 ; 1 byte
IOPORT equ #F58A ; 1 byte
; Colors for main menu screen -------------
; First value - foreground color
; Second value - foreground color palette
; Third value - background color
; Fourth value - background color palette
C2FCOLM equ 15
C2FPALM equ #F58B ; 2 bytes!
C2BCOLM equ 13
C2BPALM equ #F58D ; 2 bytes!
; Colors for help screen -------------
C2FCOLH equ 15
C2FPALH equ #F58F ; 2 bytes!
C2BCOLH equ 4
C2BPALH equ #F591 ; 2 bytes!
; Colors for volume screen -------------
C2FCOLV equ 15
C2FPALV equ #F593 ; 2 bytes!
C2BCOLV equ 12
C2BPALV equ #F595 ; 2 bytes!
; Colors for PSG setup screen -------------
C2FCOLP equ 15
C2FPALP equ #F597 ; 2 bytes!
C2BCOLP equ 6
C2BPALP equ #F599 ; 2 bytes!
SETXY equ #F59B ; 2 bytes!
MUSSTAT equ #F59D
MYHOOK equ #F59E ; 6 bytes!
ORGHOOK equ #F5A4 ; 6 bytes!
DIRPOS equ #F5AA ; 2 bytes!
BLINK equ #F5AC
SCROLL equ #F5AD
SCRTXT equ #F5AE ; 2 bytes!
SCRFDAT equ #F5B0 ; 2 bytes!
SPECRBS equ #F5B2
SCRSEM equ #F5B3
SYMSEM equ #F5B4
SCOLORS equ #F5B5 ; 3 bytes!
SORTBUF equ #F5B8 ; will use 64 characters for sorting!
VDPR10 equ #FFE8
KEYBUF equ #FBF0
; Card configuration registers
CardMDR equ #4F80
; Delays for fading and scroll effects
FDelay equ #0800
EDelay equ #0400
; Scroller semaphore value
SCRSEMV equ #4
; Delay for autostart, title and boot menu skip
ADelay equ 3
TDelay equ 1
SDelay equ 10
; Cursor (2 bytes)
CURS1 equ #94
CURS2 equ #95
; Delay for joystick (video frame based: assuming 60Hz for NTSC, 50Hz for PAL)
NTSC_dl equ 6
PAL_dl equ 5
R_Base equ #C010
L_STR equ 16
; Variables for music player
MUSINIT equ #C000
MUSPLAY equ #C005
MUSSTOP equ #C008
REGLORG equ MUSINIT+#05AB
;------------------------------------------
org #4000
db "AB" ; ROM Identeficator
dw Boot ; Start INIT
dw 0 ; STATEMENT
dw 0 ; DEVICE
dw 0 ; TEXT
db 0,0,0,0,0,0
Label db "CMFCCFRC"
db 0
BBVers db "v2.53" ; Version | also update it in the header!
db 0
Boot:
ld a,(#FBEC)
and %00000010 ; F5 - don't start boot menu
ret z
ld a,(CardMDR)
cp #38 ; Check for DefConfig
jr nz,Boot0
ld a,#85
ld (CardMDR+#09),a ; set 16kb for boot menu
ld hl,CardMDR+6 ; Current registers
ld de,DefCfg ; DefConfig values
ld bc,24
BootL:
ex hl,de
ld a,(hl) ; Compare DefConfig to current registers
ex hl,de
cpi
jr nz,Boot0
inc de
ld a,c
or a ; All 24 bytes match?
jr nz,BootL
ret z
Boot0:
call SltDet ; detect current slot
ld (ERMSLT),a ; save current slot
ld h,#80
call ENASLT ; Set slot 8000-BFFF the same on 4000-3FFF
ld hl,B2ON
ld de,CardMDR+#0C ; set Bank2
ld bc,6
ldir ; set cart, registers
call LocDetect ; detect Arabic or Korean MSX
call SetEnv ; set environment (screen, colors, fonts)
ld a,%10000111 ; check slot 3.1
call NetDetect ; detect network modules in Russian MSXs
jr z,NetHalt
ld a,%10001111 ; check slot 3.3
call NetDetect ; detect network modules in Russian MSXs
jr nz,Boot00
NetHalt:
ld hl,#0309
call POSIT
ld hl,Netmsg
call print_sp ; print halt msg
Halt: jr Halt
Boot00:
call DualReset ; check for dual reset
ld hl,#060B
ld (WARMBT),a ; 1 = cold boot
or a
jr z,SltCheck
Title:
ld hl,TitleScr
ld b,6
ld de,#0A09
Titlel1:
ex hl,de
call POSIT
inc l
ex hl,de
call print_sp ; print title lines
djnz Titlel1
ld hl,#180C
call POSIT
ld hl,BBVers
call print_sp ; print boot menu version
call InitTitle ; initialize title
ld hl,CardMDR+#2C
ld de,#190D
ld b,3
FirmVl:
ld a,(hl) ; get version
cp "0"
jr c,FirmVn ; smaller than 0?
cp "9"+1
jr nc,FirmVn
jr FirmVo
FirmVn:
ld a,"#" ; print unknown verison of firmware
FirmVo:
push af
ex hl,de
ld a,h
cp #1A
jr nz,FirmVs
inc h
FirmVs:
call POSIT
inc h
ex hl,de
inc hl
pop af
call CHPUT_VDP ; firmware version digit
djnz FirmVl
call AnimTitle ; animate title
ld hl,#0000
ld bc,TDelay*50 ; set delay for title
call AutoWait ; wait a few seconds
SltCheck:
ld a,#20
call EERD ; read slot 3 enable flag
ld (SLOT3R),a
ld a,(ERMSLT)
and %00000011
or a ; Won't work in slot 0! Unlikely to happen anyway...
jr z,NoSlt
cp 3 ; Won't work in slot 3!
jr nz,DrCheck
ld a,(SLOT3R)
or a ; disabled?
jr nz,DrCheck
ld hl,#0000
ld a,(hl)
cp 'C' ; subrom MSX2/2+?
jr z,NoSlt
inc hl
ld a,(hl)
cp 'D' ; subrom MSX2/2+?
jr z,NoSlt
ld hl,#4010
cp 'C' ; carnivore id?
jr nz,NoSlt
inc hl
ld a,(hl)
cp 'M' ; carnivore id?
jr nz,NoSlt
ld hl,SL3EXP ; slot expansion table
ld a,(hl) ; slot expanded?
cp #80
jr z,DrCheck ; unusable
NoSlt:
call CLS
ld hl,#0611
call POSIT
ld hl,Haltmsg
call print_sp ; print halt msg
Halt1: jr Halt1
DrCheck:
ld a,#18
call EERD ; read double reset flag
ld (DUALRST),a
cp 1
jr nz,Boot1 ; disabled?
ld a,(WARMBT) ; check for cold boot
or a
jp nz,#0000 ; reboot
Boot1:
if SPC=0
ld a,(ARKOR) ; Arabic or Korean?
or a
jr z,Boot2
call CLS
ld hl,#0309
call POSIT
ld hl,AltKormsg
call print_sp ; print incorrect Boot Menu message
call KILBUF
ld hl,#0000
ld bc,SDelay*50 ; set delay for boot menu skip
call AutoWait ; wait a few seconds
xor a
call RestEnv ; restore environment (font, colors, screen)
ld a,#38
ld (CardMDR),a ; set CardMDR for Defconfig
ld hl,DefCfg ; DefConfig values
ld de,CardMDR+6 ; current registers
ld bc,24
ldir
ret ; skip boot menu
endif
Boot2:
; set cart, register
ld hl,B2ON
ld de,CardMDR+#0C ; set Bank2
ld bc,6
ldir
ld a,#FF
ld (MASSLTS),a ; nothing selected for master slot
ld (SLASLTS),a ; nothing selected for slave slot
ld (MASSLAV),a ; slave slot not used as master's subslot
xor a
ld (MASSEXP),a ; master slot not expanded by default
ld (SLASEXP),a ; slave slot not expanded by default
ld (MUSSTAT),a ; music not playing
ld (LASTU),a ; last used entry
ld (SPECRB),a ; special reboot cfg
ld (SPECRBS),a ; special reboot subslot cfg
ld (SCROLL),a ; no scroller
ld (SCRSEM),a ; scroller semaphore
ld (SYMSEM),a ; symbol semaphore
ld a,%00010001
ld (DUOSLCF),a ; default master/slave slots configuration (subslots 32103210, first 4 bits - master)
ld a,(CardMDR+#29)
and %01111111 ; disable second cartridge
ld (CardMDR+#29),a
call SlotFilter ; identify usable slots
ld a,(SLASLTN)
cp #FF ; slave slot usable?
jr nz,Boot3
xor a
ld (MASSLAV),a ; enable slave slot emulation if no real slave slots are usable
ld a,#FF
ld (MASSEXP),a ; expand master slot by default
ld a,(DUOSLCF)
or %11110000 ; enable all devices of master slot
ld (DUOSLCF),a
Boot3:
; Load data (FMPAC/SCC/SCC+/PSG audio volume and other settings) from small EEPROM
ld a,1
call EERD ; read volume setting from EEPROM
ld b,a
and %11000000
cp %10000000 ; volume was set from boot menu? (bit 7 = 1, bit 6 = 0)
jr nz,TA_0A
ld a,b
ld (CardMDR+#22),a ; set the previously stored FMPAC/SCC/SCC+ volume
; Read 50/60Hz status from EEPROM
TA_0A:
call CLS
ld a,(VDPR10) ; read vdp register 10
ld (ORGVR10),a ; save original value
ld (PALNTSC),a ; save current mode
ld (FREQ),a ; save current mode
xor a
ld (SKIPFD),a ; skip fade disabled
ld (VDPVER),a ; VDP is v9918 by default
call DetVDP ; Detect actual VDP
ld (VDPVER),a ; save vdp verison (0=v9918, 1=v9938, 2=v9958)
or a
jr z,TA_0B ; don't use frequency change on MSX1
ld a,2
call EERD ; read PAL/NTSC setting from EEPROM
and %00000011
cp 3 ; illegal value?
jr z,TA_0B
cp 1 ; illegal value?
jr z,TA_0B
ld a,2
call EERD ; read PAL/NTSC setting from EEPROM
ld (FREQ),a ; save current mode
cp #FF ; ignore frequency?
jr z,TA_0AA
ld (PALNTSC),a ; save the value
TA_0AA:
ld b,a
ld a,9
ld c,a
call WRITVDP ; write to VDP register (set 50 or 60 HZ mode)
TA_0B:
ld a,DefFCol
ld (FORCLR),a
ld a,DefBCol
ld (BAKCLR),a
ld (BDRCLR),a
call CHCOLOR ; set screen colors (foreground=background)
ld a,3
call EERD ; read volume setting from EEPROM
ld (CardMDR+#24),a ; set the previously stored PSG volume
ld (PSGCFG),a
ld a,#1E
call EERD ; read Dual-PSG setting from EEPROM
cp #FF
jr nz,TA_0BA
xor a ; fix initial value (only 0 and 1 allowed)
TA_0BA:
ld (CardMDR+#30),a
ld hl,SORTD
ld de,SORT
ld bc,25
ldir ; reset all UI settings to defaults
ld a,#21
call EERD ; read port setting
cp #FF
jr nz,TA_0BAA
ld a,(ERMSLT)
and %00000011
ld b,a ; main slot number
ld a,#EF
add b ; autoset ID port based on slot
TA_0BAA:
cp #F0
jr z,TA_0BB
cp #F1
jr z,TA_0BB
cp #F2
jr z,TA_0BB
ld a,#F0
TA_0BB:
ld (IOPORT),a
ld (CardMDR+#35),a ; set new control port
ld a,#20
call EERD ; read slot 3 enable flag
ld (SLOT3R),a
ld a,#18
call EERD ; read double reset flag
ld (DUALRST),a
ld a,(#FBEB)
and %10000000 ; F3 - don't load UI settings
jr z,TA_0B3
ld a, (CardMDR+#22)
and %01111111
ld (CardMDR+#22),a ; enable FMPAC stereo by default
ld a,#19
call EERD ; read FMPAC mono flag
ld (FMMON),a
cp 1
jr nz,TA_0B0
ld a, (CardMDR+#22)
or %10000000
ld (CardMDR+#22),a ; enable FMPAC mono
TA_0B0:
ld a,#17
call EERD ; read custom flag from EEPROM
cp #42 ; custom settings?
jr nz,TA_0B3
ld a,2
call EERD ; read PAL/NTSC setting from EEPROM
ld (FREQ),a ; save current mode
ld a,4
call EERD ; read sorting flag
ld (SORT),a
ld a,5
call EERD ; read effects flag
ld (EFF),a
ld a,6
call EERD ; read key/joystick speed
cp 10 ; max value
jr nc,TA_0B1
ld (SPD),a
TA_0B1:
ld a,(VDPVER)
or a
jr z,TA_0B3 ; pallete operations for MSX1
ld a,7
ld hl,C2FPALM
TA_0B2:
push af
call EERD ; read palette from EEPROM
ld (hl),a
inc hl
pop af
inc a
cp #17
jr nz,TA_0B2
TA_0B3:
ld a,(VDPVER)
inc a
ld (MSXTYPE),a ; save MSX type
; Count all directory enrties and pages
DirCnt:
ld hl,0
ld (DIRCNT),hl ; zero dir entry count
ld d,0 ; first entry
ld a,1
ld (DIRPAG),a ; one page by default
ld (CURPAG),a ; 1st page to output first
DirC0:
call CalcDirPos ; calc dir entry point
jr nz,DirC1 ; normal entry?
inc d
ld a,d
or a ; 255+1 limit
jr z,DirC2
jr DirC0
DirC1: inc d
ld a,d
or a ; 255+1 limit
jr z,DirC2
ld hl,DIRCNT
inc (hl) ; add one entry
jr DirC0
DirC2: ld hl,DIRCNT
ld a,(hl)
ld hl,DIRPAG
DirC3:
cp L_STR ; number of strings on page
jr z,DSort ; last page?
jr c,DSort ; last page?
inc (hl) ; add one dir page
sub L_STR ; more dir pages?
jr DirC3
DSort:
call DirSort ; sort directory
Check_AS:
ld a,#FF
ld (AUTOST),a ; no autostart
ld a,#1F
call EERD ; read autostart delay
cp 10
jr c,Check_AS1
ld a,ADelay ; default value
Check_AS1:
ld (ASDELAY),a
ld a,#1C
call EERD ; check for autostart
ld (AUTOST),a ; save entry
ld d,a
cp #FF
jr z,Menu ; deselected autostart
call CalcDirPos
jr z,Menu ; empty record, go to menu
ld a,(#FBEC)
and %00001101 ; ESC, F4 no autostart
cp %00001101
jr nz,Menu
ld a,(ASDELAY)
or a
jr z,AutoWA22
ld b,a
add "0"
ld c,a
push bc
push bc
call CLS
ld hl,#030A
call POSIT
ld hl,AutoMSG
call print_sp ; print autostart message
ld hl,#150A
call POSIT
pop bc
ld a,c
call CHPUT_VDP ; output initial counter
call KILBUF
ld hl,#0000
pop bc
AutoWA2:
ld de,60 ; set delay for autostart in NTSC
ld a,(PALNTSC)
bit 1,a
jr z,AutoWA21
ld de,50 ; set delay for autostart for PAL
AutoWA21:
push hl
push de
push bc
push de
pop bc
call AutoWait ; wait a few seconds
jr nz,AutoWA3
ld hl,#150A
call POSIT
pop bc
dec c
ld a,c
push bc
call CHPUT_VDP ; output counter symbol
pop bc
pop de
pop hl
djnz AutoWA2
AutoWA22:
call CLS
jp RUN_CT ; not empty record, do autostart
AutoWA3:
pop bc
pop de
pop hl
ld a,#FF
ld (AUTOST),a ; no autostart
; Main Menu
; Search records (64b) max - 256
Menu:
ld a,1
ld (CardMDR+#0E),a ; set 2nd bank to directory map
ld a,(SORT)
or a
jr z,TA_07
push hl
ld hl,RAM_SORT+#03
ld a,(hl)
ld (CardMDR+#0F),a ; show RAM instead of flash for directory
pop hl
TA_07:
ld de,#0000
ld (DIRPOS),de ; positions (d=entry number, e=position on page)
; Set screen for menu
Menu1:
ld a,C2FCOLM
ld hl,#1701
call PALETTE
ld a,C2BCOLM
ld hl,#1701
call PALETTE
ld a,C2FCOLM
ld (FORCLR),a
ld a,C2BCOLM
ld (BAKCLR),a
ld (BDRCLR),a
call CHCOLOR ; set screen colors (foreground=background)
ld de,#1701
ld hl,#7707
ld b,C2FCOLM
ld c,#0D
call FadeOut ; fade out text
call CLS
ld de,#0000
ld hl,#1701
ld b,C2BCOLM
ld c,#0D
call FadeOut ; fade out background
ld hl,(C2BPALM)
ex de,hl
ld hl,#0000
ld b,C2BCOLM
ld c,#0D
call FadeIn ; fade in background
ld a,C2FCOLM
ld hl,(C2BPALM)
call PALETTE
ld hl,#0707
ld (XYPOS),hl ; default position for cursor
MusicScroll:
push hl
pop ix ; fix for music player
call MusicInit ; init music
call ScrollInit ; initialize data for scroller
call HookOn ; set hook and start music
ld a,#1B
call EERD ; read music status
ld (MUSSTAT),a
Pagep:
ld a,(VDPVER) ; detect if 9938 or later used, don't disable the screen
or a
jr nz,Pagep0
call DISDISP ; disable display
Pagep0:
ld a,C2FCOLM
ld (FORCLR),a
ld a,C2BCOLM
ld (BAKCLR),a
ld (BDRCLR),a
call CHCOLOR ; set screen colors (foreground=background)
call CLS
ld hl,#0101
call POSIT
if SPC=1
ld a,#20
ld (SCRHIGH),a
ld hl,MainScr ; print main screen messages
call print_sp
ld a,#18
ld (SCRHIGH),a
else
ld hl,MainScr ; print main screen messages
call print_sp
endif
call PrintInf ; print page number
call PrintFrq ; print frequency of the display (50/60)
call PrintVol ; print volumes
call PrintTur ; print turbo/r800/z80 mode
ld a,#1D
call EERD ; read scroller status
or a
jr z,Pagep0a
ld hl,#0104
call POSIT
ld hl,DynamicS
call print_sp ; print scroller placeholder
ld a,1
; Print autostarted entry
Pagep0a:
ld (SCROLL),a
ld hl,#1005
call POSIT
ld a,#1C
call EERD ; get autostart entry
cp #FF ; skip printing #FF
jr z,Pagep000
call hexout ; print autostart entry number
Pagep000:
ld a,(MASSLTS) ; selection for master slot
cp #FF
jr z,Pagep00
or a
jr nz,Pagep0000
ld hl,#2105
call POSIT
ld hl,Sccplsel
call print ; print ++ for SCC+ selection
jr Pagep00
Pagep0000:
push af
ld hl,#2105
call POSIT
pop af
call hexout ; print selection
Pagep00:
ld a,(SLASLTS) ; selection for slave slot
cp #FF
jr z,Pagep1
push af
ld hl,#2405
call POSIT
pop af
call hexout ; print selection
Pagep1:
ld de,(DIRPOS) ; positions (d=entry number, e=position on page)
ld e,0 ; set first string
ld (DIRPOS),de ; save new position
; print page ( 16 record )
sPrr1: call CalcDirPos ; calc dir entry point
jr nz,prStr ; valid dir entry?
nRec: inc d
ld a,d
or a
jp z,sPr0 ; done, last record
jr sPrr1
; Print directory entry
prStr:
;----str---------------------
; (ix , d) - record num , e - str num
; *(h,l, a b)
; set cursor position
ld h,3
ld a,e
add a,7
ld l,a
call POSIT
; record number
ld a,d
call hexout ; print entry number in hex
; set hl-point
push ix
pop hl
inc hl
inc hl
inc hl
inc hl
; mapper symbols
ld a,(hl)
cp 'K'
jr nz,sMap1
ld a,#B8
call CHPUT_VDP ; output Konami5 mapper symbol
ld a,#BE
jr sCur
sMap1:
cp 'k'
jr nz,sMap2
ld a,#B8
call CHPUT_VDP ; output Konami4 mapper symbol
ld a,#B3
jr sCur
sMap2:
cp 'A'
jr nz,sMap3
ld a,#B4
call CHPUT_VDP ; output ASCII16 mapper symbol
ld a,#BA
jr sCur
sMap3:
cp 'a'
jr nz,sMap4
ld a,#BB
call CHPUT_VDP ; output ASCII8 mapper symbol
ld a,#B9
jr sCur
sMap4:
cp 'C'
jr nz,sMap5
ld a,#BC
call CHPUT_VDP ; output configuration symbol
ld a,#BD
jr sCur
sMap5:
cp 'U'
jr nz,sMap6
ld a,#BF
call CHPUT_VDP ; output unknown mapper symbol
ld a,#B7
jr sCur
sMap6:
cp 'M'
jr nz,sMap7
ld a,#B5
call CHPUT_VDP ; output multirom mapper symbol
ld a,#B6
jr sCur
sMap7:
ld a,#B1
call CHPUT_VDP ; output unknown entry symbol
ld a,#B2
sCur:
call CHPUT_VDP
inc hl
; clear cursor area
ld a,' '
call CHPUT_VDP ; output space for cursor
ld a,' '
call CHPUT_VDP ; output space for cursor
; print record name
ld b,30
sPr: ld a,(hl)
call CHPUT_VDP ; output record name
inc hl
djnz sPr
inc d
ld a,d
or a
jr nz,sPr1 ; last found dir entry?
sPr0:
call PrintER ; print empty record
inc e
ld a,e ; last string on the page?
cp L_STR
jr c,sPr0
jr dRec
sPr1:
inc e
ld a,e ; last string on the page?
cp L_STR
jp c,sPrr1
dRec:
ld de,(DIRPOS) ; positions (d=entry number, e=position on page)
ld e,0 ; cursor at 0
ld (DIRPOS),de ; save new position
push af
ld a,(SKIPFD)
or a ; skip fade on page flip?
jr nz,dRec1
push de
ld hl,(C2FPALM)
ex de,hl
ld hl,(C2BPALM)
ld b,C2FCOLM
ld c,#0D
call FadeIn ; fade in text
pop de
dRec1:
xor a
ld (SKIPFD),a ; skip fade disabled
pop af
; set cursor pos on first entry
CH00:
ld a,(LASTU) ; last used entry