/
init.mac
3603 lines (3284 loc) · 65.4 KB
/
init.mac
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
.z80
title INIT - MSXDOS and DISK BASIC initializer
;===== start add DOS2.50 (build type)
;
INCLUDE CONDASM.INC
INCLUDE CONST.INC
;
;===== end add DOS2.50
;
; Conditional assembly switch
;
NEW equ -1
BANKED equ -1
;===== start del DOS2.50 (include CONDASM.INC)
;HYBRID equ -1 ;DOS1/DOS2 hybrid system
;===== end del DOS2.50
;
; Some yummy ASCII control characters
;
BELL equ 07h
TAB equ 09h
LF equ 0Ah
CLS equ 0Ch
CR equ 0Dh
ESC equ 1Bh
;
; MSX specific constants
;
RDSLT equ 000Ch ;inter-slot read
WRSLT equ 0014h ;inter-slot write
CALSLT equ 001Ch ;inter-slot call
ENASLT equ 0024h ;enable slot
OUTDO equ 0018h ;output a character
DCOMPR equ 0020h ;compare HL with DE
ID_BYTE equ 002Bh
VERSION equ 002Dh
CHAR_16 equ 0034h
INTRPT equ 0038h ;hardware interrupt entry
CHGET equ 009Fh ;Get from console
CHPUT equ 00A2h
SNSMAT equ 0141h ;sense key matrix
PHYDIO equ 0144h ;physical disk read/write
KILBUF equ 0156h ;flush buffer
CALBAS equ 0159h ;call BASIC interpreter routine
CHGCPU equ 0180h
GETCPU equ 0183h
;
READYR equ 409Bh ;Warm start of BASIC
INILIN equ 4173h ;used to execute AUTOEXEC.BAS
if HYBRID
FCERR equ 475Ah ;
endif
CHKBRN equ 6EF4h
PRTTTL equ 7D29h
;
RAMLOW equ 0F380h ;Beginning of fixed work area for MSX
if HYBRID
USRTAB equ 0F39Ah ;!=FCERR ==> ROM appl. /w MSX-DOS2
endif
CNSDFG equ 0F3DEh ;Console display flag
CURLIN equ 0F41Ch ;Current line number
BUF equ 0F55Eh ;Line input buffer (used as scratch)
STKTOP equ 0F674h ;Pointer to bottom of stack
TXTTAB equ 0F676h ;Beginning of BASIC text
VARTAB equ 0F6C2h
STREND equ 0F6C6h ;End of variable storage
MAXFIL equ 0F85Fh ;Maximum file number
;
;; RS2IQ equ 0FAF5h
HOKVLD equ 0FB20h ;RS2IQ+43 Flag table for "hook valid"
DRVTBL equ 0FB21h ;RS2IQ+44 Table of disk driver slots
HOOKSAV equ 0FB29h ;RS2IQ+52 Table of disk driver interrupt
;
; Definition of hooks
;
H.TIMI equ 0FD9Fh ;hook at TIMI
H.RUNC equ 0FECBh ;hook at RUNC
H.CLEA equ 0FED0h ;hook at CLEARC
H.LOPD equ 0FED5h ;hook at LOPDEF
H.STKE equ 0FEDAh ;hook set by a auto-start cartridge
;
; Flags for disk system initialization
;
MAXSEC equ 0F6ABh ;AUTLIN, used to detect the maximum
; sector size within the disk system.
DISKID equ 0FD99h ;DEVICE, used to determine who is going
; to be the master.
PROCNM equ 0FD89h ;Used to avoid duplicate initialization
;
; Extended BIOS hooks.
;
public DISINT,ENAINT
FCALL equ 0FFCAh ;function call entry for devices
DISINT equ 0FFCFh ;Disable device driver interrupts
ENAINT equ 0FFD4h ;Enable device driver interrupts
;
; I/O ports.
;
PPI.AR equ 0A8h ;PPI Port A data read
PPI.AW equ 0A8h ;PPI Port A data write
;
; Disk system characteristics
;
MAXCARD equ 4 ;max number of cartridges
MAXDRV equ 8 ;max number of drives supported by disk
;system
BOOTAD equ 0C000h ;boot strap loader address
;
; Field definition of DPB
;
DRVNUM equ 0 ;drive number
SECSIZ equ 2 ;size of sector in bytes
FATSIZ equ 16 ;size of FAT in sectors
FAT equ 19 ;pointer to FAT
DPBSIZE equ 21 ;number of bytes per one DPB
SCANKEYS_RAM_BASE equ 0A100h
;
; MACROs
;
PRINTL macro NAME,VALUE
if2
.PRINTX % Size of NAME = VALUE bytes %
endif
endm
;
OUTCHR macro
rst OUTDO
endm
;
COMPAR macro
rst DCOMPR
endm
;
CALLDOS macro FUNC
ld c,FUNC
jp GO_DOS2
endm
;
ALIGN macro ADDR
if $-START gt ADDR-ORIGIN
error <Code overwraps at ADDR>
PRINTL <wrap at ADDR>,%($-START)-(ADDR-ORIGIN)
org ADDR-ORIGIN
else
PRINTL <hole at ADDR>,%(ADDR-ORIGIN)-($-START)
defs (ADDR-ORIGIN)-($-START),0C9h ;;fill with RET
endif
endm
;
ORIGIN equ 4100h ; ROM code starts here.
;
START:
;
subttl ROM header
if BANKED
include BANK.INC
endif
;
; Version and copyright strings.
;
_$DOSVER::
DOSV0::
defb "Nextor kernel version "
defb NXTVER##+"0", ".", NXTV_HI##+"0"
if 1
defb ".", NXTV_LO##+"0"
endif
INCLUDE betainfo.mac
defb 0
;
_$DSKBASIC::
defb "Nextor BASIC version ", BASVER##+"0"
defb ".", BASV_HI##+"0", BASV_LO##+"0"
INCLUDE betainfo.mac
defb 0
;
;===== start mod DOS2.50 (change Copyright string)
defb "Copyright (C) "
defb R_YEAR##/1000 mod 10 + "0"
defb R_YEAR##/ 100 mod 10 + "0"
defb R_YEAR##/ 10 mod 10 + "0"
defb R_YEAR## mod 10 + "0"
defb " Konamiman",0
;
defb R_DATE##/1000 mod 10 + "0"
defb R_DATE##/ 100 mod 10 + "0"
defb R_DATE##/ 10 mod 10 + "0"
defb R_DATE## mod 10 + "0"
defb 0
;
if 0
defb "Copyright (C) 2001-"
defb R_YEAR##/1000 mod 10 + "0"
defb R_YEAR##/ 100 mod 10 + "0"
defb R_YEAR##/ 10 mod 10 + "0"
defb R_YEAR## mod 10 + "0"
defb " Keiko Mizuo",0
endif
;===== end mod DOS2.50
;
;
BIOS_STAT::
ld hl,KCONST##
jr _GO_BIOS
;
BIOS_IN::
ld hl,KCONIN##
jr _GO_BIOS
;
BIOS_OUT::
ld c,a ;$OUT expects character in [A]
ld hl,KCONOUT##
;
_GO_BIOS:
jp GO_BIOS## ;Call the KBIOS in kernel page-0
;
;
subttl MSX-DOS1 compatible ROM entries (part 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; These are the MSX-DOS1 compatible BDOS function entries scatterred
; around 41EFh~55FFh in MSX-DOS version 1 ROM. They must be kept as
; defined because MSXDOS.SYS version 1 calls them directly.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;This routine will return NZ if the appropriate slot key is pressed.
;The slot keys are:
;UIOP for slots 0-0 to 0-3
;QWER for slots 1-0 to 1-3
;ASDF for slots 2-0 to 2-3
;ZXCV for slots 3-0 to 3-3
;For unexpanded slots, the key for subslot 0 applies (U, Q, A, Z)
DISABLE_KEY:
ld a,(BOOTKEYS##+2)
and 80h
ret nz ;"N" key pressed?
call GSLOT1##
and 00001111b
add a,a
ld e,a
ld d,0
ld hl,DISABLE_TBL
add hl,de
ld c,(hl) ;Offset of byte in boot keys area
inc hl
ld b,(hl) ;Mask in the boot keys byte
ld hl,BOOTKEYS##
ld e,c
ld d,0
add hl,de
ld a,(hl)
and b
ret
; 0: 76543210
; 1: FEDCBA98
; 2: NMLKJIHG
; 3: VUTSRQPO
; 4: ....ZYXW
DISABLE_TBL:
db 3, 01000000b ;0-0: U
db 3, 00000100b ;1-0: Q
db 1, 00000100b ;2-0: A
db 4, 00001000b ;3-0: Z
db 2, 00000100b ;0-1: I
db 4, 00000001b ;1-1: W
db 3, 00010000b ;2-1: S
db 4, 00000010b ;3-1: X
db 3, 00000001b ;0-2: O
db 1, 01000000b ;1-2: E
db 1, 00100000b ;2-2: D
db 1, 00010000b ;3-2: C
db 3, 00000010b ;0-3: P
db 3, 00001000b ;1-3: R
db 1, 10000000b ;2-3: F
db 3, 10000000b ;3-3: V
ALIGN 41E8h
jp PROMPT
ALIGN 41EFh-3
jp SCANKEYS
CPMVER: CALLDOS 0Ch ;Return CP/M version number
ALIGN 4200h
;--- BOOT KEY INVERTERS ---
;
; These two bytes have one bit assigned for each key that has meaning at boot time.
; If the bit for one key is set, then the meaning of the key is inverted.
;
; E.g. if the bit for the SHIFT key is set, then all MSX-DOS kernels will be
; disabled by default, but will be enabled if the SHIFT key is pressed
; during boot (the opposite of the normal behavior).
;
; This does NOT have effect when setting the boot keys in RAM
; (if boot keys are set in RAM, the keyboard is completely ignored).
;
; These bytes are fixed at offset 200h (starting at 0) in ROM.
; They should be changed in the ROM file before flashing in the hardware.
;
; Bits are assigned to keys as follows:
;
; 0: ..54321.
; 1: ..CS.... (C = CTRL, S = SHIFT)
;
; "." bits are currently unused and should always be 0 to ensure compatibility
; with possible future extensions.
KEYS_INV_0: db 00h
KEYS_INV_1: db 20h ;Invert CTRL by default (so internal FDDs get only one drive)
;
;=======================================================================
;
; This routine scans all the numeric and alphabetic keys,
; including the numeric keyboard.
;
; Input: A=0 for international keyboard, 1 for Russian keyboard
; Output: Keys in HLDEB (1 bit each, set if pressed):
;
; B: 76543210
; E: FEDCBA98
; D: NMLKJIHG
; L: VUTSRQPO
; H: ....ZYXW
;
; H holds also the status of CAPS, GRAPH, CTRL and SHIFT on bits 7,6,5,4
; respectively.
;
; (routine placed here to use a big hole in ROM - may need to be moved
; if the routine grows)
SK_ROW_0 equ 0
SK_ROW_1 equ 1
SK_ROW_2 equ 2
SK_ROW_3 equ 3
SK_ROW_4 equ 4
SK_ROW_5 equ 5
SK_ROW_6 equ 6
SK_ROW_9 equ 7
SK_ROW_10 equ 8
SK_B equ 9
SK_E equ 10
SK_D equ 11
SK_L equ 12
SK_H equ 13
SK_SIZE equ 14
SCANKEYS::
ld ix,-SK_SIZE
add ix,sp
ld sp,ix
push af
ld bc,0700h
push ix
pop hl
call SK_GET_ROWS
ld bc,0209h
call SK_GET_ROWS
pop af
or a
jr nz,SCANK_RUSSIAN
call SK_INTERNATIONAL
jr SCANK_DONE
SCANK_RUSSIAN:
call SK_RUSSIAN
SCANK_DONE:
ld b,(ix+SK_B)
ld e,(ix+SK_E)
ld d,(ix+SK_D)
ld l,(ix+SK_L)
ld h,(ix+SK_H)
ld ix,SK_SIZE
add ix,sp
ld sp,ix
ret
;* International keyboard layout version
;0: 76543210
;1: ......98
;2: BA......
;3: JIHGFEDC
;4: RQPONMLK
;5: ZYXWVUTS
;6: .... CAPS GRAPH CTRL SHIFT
;Numeric:
;9: 43210...
;10: ...98765
SK_INTERNATIONAL:
;* 0-7
ld a,(ix+SK_ROW_0) ;76543210
ld (ix+SK_B),a
;* 8-F
ld a,(ix+SK_ROW_1)
and 00000011b
ld b,a ;......89
ld a,(ix+SK_ROW_2) ;BA......
rrca
rrca
rrca
rrca
and 00001100b ;....BA..
or b
ld b,a ;....BA89
ld a,(ix+SK_ROW_3)
rlca
rlca
rlca
rlca
ld c,a ;FEDCJIHG
and 11110000b ;FEDC....
or b ;FEDCBA89
ld (ix+SK_E),a
;* G-N
ld a,c
and 00001111b ;....JIHG
ld b,a
ld a,(ix+SK_ROW_4)
rlca
rlca
rlca
rlca
ld c,a ;NMLKRQPO
and 11110000b ;NMLK....
or b ;NMLKJIHG
ld (ix+SK_D),a
;* O-V
ld a,c
and 00001111b ;....RQPO
ld b,a
ld a,(ix+SK_ROW_5)
rlca
rlca
rlca
rlca
ld c,a ;VUTSZYXW
and 11110000b ;VUTS....
or b ;VUTSRQPO
ld (ix+SK_L),a
;* W-Z
ld a,c
and 00001111b ;....ZYXW
ld (ix+SK_H),a
ld h,a
SK_COMMON:
;Input: H = (SK_H)
;* CAPS-GRAPH-CTRL-SHIFT
ld a,(ix+SK_ROW_6)
rlca
rlca
rlca
rlca
and 11110000b ;CAPS-GRAPH-CTRL-SHIFT-ZYXW
or h
ld (ix+SK_H),a
;* Numeric keyboard
ld a,(ix+SK_ROW_9) ;43210... from numeric keyboard
rrca
rrca
rrca
and 00011111b
ld b,a ;...43210 from numeric keyboard
ld a,(ix+SK_ROW_10) ;...98765 from numeric keyboard
rlca
rlca
rlca
rlca
rlca
ld c,a ;C = 765...98, we'll use it later
and 11100000b ;765..... from numeric keyboard
or b ;76543210 from numeric keyboard
or (ix+SK_B) ;76543210 from either the regular or the numeric keyboard
ld (ix+SK_B),a
ld a,c
and 00000011b ;......98 from numeric keyboard
or (ix+SK_E)
ld (ix+SK_E),a ;FEDCBA98, with 98 from either the regular or the numeric keyboard
ret
;* Russian keyboard layout version
;0: 654321.9
;1: V.H..087
;2: IF...B..
;3: O.RPAUWS
;4: KJZ.TXDL
;5: QN.CMGEY
;6: .... CAPS GRAPH CTRL SHIFT
;Numeric:
;9: 43210...
;10: ...98765
SK_RUSSIAN:
ld a,(ix+SK_ROW_0)
ld c,a
ld b,(ix+SK_ROW_1)
ld e,0
and 11111100b ;654321..
srl b ;Cy = 7
rra ;7654321.
srl a ;.7654321
srl c ;Cy = 9
rl e ;E = .......9
srl b ;Cy = 8
rl e ;E = ......98
srl b ;Cy = 0
rl a ;76543210
ld (ix+SK_B),a
ld (ix+SK_E),e
;I'm sorry but that's it, only 9 disk image files supported in Russian keyboards.
;Pull request implementing the (hellish) conversion of the rest of the keys will be welcome.
xor a
ld (ix+SK_D),a
ld (ix+SK_L),a
ld (ix+SK_H),a
ld h,a
jp SK_COMMON
;Input: HL = First work area address, B=Rows count, C=First row
;Output: HL = Last work area address used + 1
SK_GET_ROWS:
ld a,c
call SNSKEY
cpl
ld (hl),a
inc hl
inc c
djnz SK_GET_ROWS
ret
;A clone of the SNSMAT routine in main BIOS
SNSKEY:
push bc
ld c,a
di
in a,(0AAh)
and 0F0h
add a,c
out (0AAh),a
ei
in a,(0A9h)
pop bc
ret
SCEND::
NEWKEY EQU 0FBE5H
CAPST EQU 0FCABH
KANAST EQU 0FCACH
CLIKSW EQU 0F3DBH
KILBUF EQU 0156H
CHGET EQU 09FH
;Returns A=1 if we have a Russian keyboard, A=0 otherwise
CHECK_IS_RUSSIAN: ; in case of ZF
DI
CALL KILBUF
LD HL,(CAPST)
LD A,(CLIKSW)
PUSH AF
PUSH HL
XOR A
LD (KANAST),A ; KANA OFF
LD (CLIKSW),A ; Shut up!
DEC A
LD (CAPST),A ; CAPS ON
LD (NEWKEY+6),A ; No SHIFT, CTRL etc.
LD A,64
LD B,7
CALL 0D89H
POP HL
POP AF
LD (CLIKSW),A
LD (CAPST),HL
CALL CHGET
CP "J"
ld a,1
RET z
dec a
ret
;Read key status from RAM.
;Out: Z if status read ok, NZ if not
; BEDLH = same as SCANKEYS (if Z)
SCANKEYS_RAM:
ld b,a
ld hl,SCANKEYS_RAM_BASE
ld de,RAMKEYSIG
call STRCOMP
ld a,b
ret nz
push af
xor a
ld (SCANKEYS_RAM_BASE),a
ld a,(SCANKEYS_RAM_BASE+17) ;After signature, which is 17 bytes long including terminator
ld b,a
ld de,(SCANKEYS_RAM_BASE+18)
ld hl,(SCANKEYS_RAM_BASE+20)
pop af
ret
RAMKEYSIG: db "NEXTOR_BOOT_KEYS",0
ALIGN 436Ch
FDEL: CALLDOS 13h ;;Delete file (FCB)
;
INITVARS:
ld hl,0
ld (KER250##),hl
ld (KER250##+2),hl
ld hl,HOKVLD ;Initialize the extended BIOS entry
bit 0,(hl) ; if none had already done it.
jr nz,FCALLSET
set 0,(hl)
ld hl,FCALL
ld b,3*5
SETFCALL:
ld (hl),0C9h
inc hl
djnz SETFCALL
FCALLSET:
ret
ALIGN 4392h
FREN: CALLDOS 17h ;;Rename file (FCB)
;
ALIGN 4462h
FOPEN: CALLDOS 0Fh ;;Open file (FCB)
;
ALIGN 456Fh
FCLOSE: CALLDOS 10h ;;Close file (FCB)
;
ALIGN 461Dh
FMAKE: CALLDOS 16h ;;Create file (FCB)
;
ALIGN 46BAh
RDABS: CALLDOS 2Fh ;Absolute sector read
;
ALIGN 4720h
WRABS: CALLDOS 30h ;Absolute sector write
;
;--- Check if this slot's INIT has been executed already.
; This can happen when using a cartridge with a mapper that mirrors
; information on other pages.
; Returns normally if code not executed already for this slot,
; otherwise POPs and RETs.
;
; (This code placed here to recycle the empty space between BDOS entries)
CHK_DUP::
call GSLT1
pop hl
ld ix,PROCNM-1
cp (ix+1)
ret z
cp (ix+2)
ret z
cp (ix+3)
ret z
cp (ix+4)
ret z
push hl
ld b,a
xor a
chkslots:
inc ix
cp (ix)
jr nz,chkslots
ld (ix),b
ret
PRT_CRLF:
push af
ld a,CR
call $OUT
ld a,LF
call $OUT
pop af
ret
ALIGN 4775h
RDSEQ: CALLDOS 14h ;;Read sequential (FCB)
;
ALIGN 477Dh
WRSEQ: CALLDOS 15h ;;Write sequential (FCB)
;
ALIGN 4788h
RDRND: CALLDOS 21h ;;Read random (FCB)
;
ALIGN 4793h
WRRND: CALLDOS 22h ;;Write random (FCB)
;
SETF7:
ld hl,NEWF7
ld de,0F8DFh
ld bc,6
ldir
jp MEM_CHK
NEWF7: db "load",34,0
ALIGN 47B2h
RDBLK: CALLDOS 27h ;;Read random block (FCB)
;
ALIGN 47BEh
WRBLK: CALLDOS 26h ;;Write random block (FCB)
;
;
; Get base address of work area for this cartridge to [IX] and
; [HL]. preserves [DE].
;
public GETWRK
GETWRK:
call GET_SLTWRK_ENTRY
ld a,(hl)
inc hl
ld h,(hl)
ld l,a
push hl
pop ix
ret
ALIGN 47D1h
WRZER: CALLDOS 28h ;;Write random with zero fill (FCB)
;
subttl Initialize procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; There are about 2K bytes hole from here.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$$INIT::
public INIT
INIT:
di
ld hl,INIT2
push hl
xor a
;Bank switching code must go here
BSC::
ld (6000h),a
ret
ds 48-4
INIT2:
call CHK_DUP ;Will just POP and RET if slot already processed
call DO_KEYS_INIT
call DISABLE_KEY
ret nz
;
if 0 ;; If 0, will boot on MSX1 machine (with calendar clock problem).
ld a,(VERSION)
or a ;MSX1?
ret z ;yes
;
endif
call CHK_DRIVER ;Does not return if driver not present
call GET_DISKID_HL ;(This part removed to allow SHIFT+4)
ld a,(hl) ; (DISKID) ;Am I supposed to be the master?
or a
;===== start mod DOS2.50 (build type)
if STURBO
;;if HYBRID
;===== end mod DOS2.50
jp m,KILL_DISK
else
ret m ;Disk system had been disabled
endif
;
;===== start mod DOS2.50 (build type)
if STURBO
;;if HYBRID
;===== end mod DOS2.50
jp nz,VER_CHK ;Skip if I am not the first cartridge
else
jr nz,VER_CHK ;Skip if I am not the first cartridge
endif
;
; I am the first disk cartridge.
;
call INITVARS
ld a,CLS
call CHPUT
;
; I can be the master. Check if disk system can start up.
;
ld hl,(BOTTOM##) ;If somebody else has already allocated
ld de,0C000h+1 ; memory above BOTTOM (or the memory was
COMPAR ; less than 16K --- can't be for MSX2),
jr nc,KILL_DISK ; kill the disk system.
;
ld hl,(HIMEM##) ;If somebody else has already allocated
ld de,RAMLOW ; memory below RAMLOW (F380h),
COMPAR ; kill the disk system.
jr nz,KILL_DISK ;
;
ld a,(BOOTKEYS##+4)
and 00010000b
di
rrca
jr z,NOTKILL ;If SHIFT key is pressed, kill the disk system
;
KILL_DISK:
ld a,(DISKID)
cp 0FFh
jr nz,NOFFKILL ;Needed if the first kernel was MSX-DOS
xor a
NOFFKILL:
ld (PROCNM+8),a
ld b,a
ld a,-1 ;Kill the entire disk system.
ld (DISKID),a
ld a,b
inc a
jr nz,NOTKILL
;===== start mod DOS2.50 (build type)
if STURBO
ld a,(VERSION)
cp 3 ;MSXturboR?
ret c ;no
ld a,(BOOTKEYS##)
and 00000010b ;Scan "1" key
ld a,82h ;If "1" key is NOT being pressed
call z,CHGCPU ; switch to Super-Turbo mode.
endif
;;if HYBRID
;; xor a
;; call SNSMAT
;; bit 1,a
;; ld a,82h
;; call nz,CHGCPU
;;endif
;===== end mod DOS2.50
ret
;
NOTKILL:
call SETF7 ;MEM_CHK ;If enough memory was not available
jr nc,MEM_CHK_OK1
;ret c ; give DOS1 a chance to be the master.
ld a,1
ld (PROCNM+7),a
MEM_CHK_OK1:
;
ld hl,DATASIZE## ;Try to allocate fixed system work area
call ALLOC## ; just below RAMLOW.
ret c ;Be paranoid, this can't fail.
;
; I am the master.
;
ld bc,DATASIZE## ;clear disk system work area
INIWRK:
xor a
ld (hl),a
inc hl
dec bc
ld a,c
or b
jr nz,INIWRK
;
ld (MAXSEC),bc ;initialize maximum sector size
;
ld b,4*2+4*3 ;clear DRVTBL and HOOKSAV
ld hl,DRVTBL
CLEAR_HOOKSAV:
ld (hl),a
inc hl
djnz CLEAR_HOOKSAV
;
ld hl,HOOKBEG## ;initialize hook area for DOS
ld b,HOOKLEN##
INIHOOK:
ld (hl),0C9h
inc hl
djnz INIHOOK
;
ld hl,RSLREG## ;set RSLREG routine
ld (hl),0DBh ;instruction code for "IN A,(PPI.AR)"
inc hl
ld (hl),PPI.AR
inc hl
ld (hl),0C9h ;instruction code for "RET"
;
ld a,(BOOTKEYS##+4) ;Check CTRL key
and 00100000b
rrca
rrca
rrca
rrca
xor 2
ld (TARGET##),a
;
ld a,BELL ;tell user scanning is over
OUTCHR
jr OVERRIDE
;
VER_CHK:
;
; I am not the first. check to see if I can be the new master.
;
ld a,(IN_EMU##) ;If in disk emulation mode, disable myself
or a
ret nz
ld a,(NXT_VER##) ;If previous master is MSX-DOS (not Nextor) then I become master.
or a
jr z,MAST_OK
cp 16*NXTVER##+NXTV_HI## ;If old master is same or newer than I
jr nc,SLAVE ; become its slave.
;
MAST_OK:
call MEM_CHK ;Give up If there is not enough memory
;jp c,OLDDOS ;ret c
;I can't be new master, but can be the
; slave of current master when it is
; DOS2 or newer. Should do? [HF]
jr nc,MEM_CHK_OK2
ld a,1
ld (PROCNM+7),a
MEM_CHK_OK2: