-
Notifications
You must be signed in to change notification settings - Fork 82
/
mapit.src
145 lines (123 loc) · 3.14 KB
/
mapit.src
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
.messg "mapit"
.subttl "mapit"
.page
newmap
lda #0
sta track ; clr trk counter
lda dirtrk ; link to bam2
sta bam1 ; set trk links
lda #0 ; end trk link
sta bam2 ;
lda #2 ; link to bam2
sta bam1+1
lda #$ff ; sector end link
sta bam2+1
lda vernum
sta bam1+2
sta bam2+2
eor #$ff
sta bam1+3
sta bam2+3
lda dskid
sta bam1+4
sta bam2+4
lda dskid+1
sta bam1+5
sta bam2+5
lda iobyte
sta bam1+6 ; bit-7 iobyte verify, bit-6 crc check
sta bam2+6 ; *
lda #0
sta bam1+7 ; auto boot flag off
sta bam2+7 ; *
jsr setbp2 ; set pntrs
1$ ldy #bindx ; bam offset
2$ inc track ; next trk
lda track ; chk trk
cmp startrk ; allocate neccessary tracks
beq 4$ ; if track = starttrk then do not allocate
bcc 3$ ; if track < starttrk then allocate
cmp maxtrk
beq 3$ ; if track = maxtrk then allocate
bcc 4$ ; if track < maxtrk then do not allocate
3$ clc
.byte skip1
4$ sec
php ; save carry
lda #0 ; clear track map
sta t0
sta t1
sta t2
sta t3
sta t4
ldx numsec
txa
bcs 5$
lda #0
5$ sta (bmpnt),y
iny
6$ plp ; save carry
php ; & retrieve
rol t0 ; t0 t1 t2 ... t4
rol t1 ; 76543210 111111 22221111 ... 33333333
rol t2 ; 54321098 32109876 ... 98765432
rol t3
rol t4
dex
bne 6$
plp
8$ ; .x=0
lda t0,x
sta (bmpnt),y ; write out bit map
iny
inx
cpx #5
bcc 8$
tya ; done?
bne 2$
lda bmpnt+1
cmp #>bam2 ; both bams done?
beq 9$ ; yep...
inc bmpnt+1 ; do the next bam
bne 1$ ; bra
9$ lda #1
sta wbam ; set it dirty
lda #0
sta ndbl ; clr blk free
lda dirtrk
sta track
lda #0
sta sector ; allocate 3 sectors & directory sector
jsr wused ; 0
inc sector
jsr wused ; 1
inc sector
jsr wused ; 2
lda dirst
sta sector
jsr wused ; 3 usually
jmp nfcalc
.pag
mapout lda wbam ; is it dirty?
beq sb40 ; its clean
lda maxtrk ; verify bam first
sta cont ; set trk counter
jsr setbp2 ; set base adrr
sb10 lda #bindx ; bam offset
sb20 sta bmpnt ; lsb
jsr avck ; check this trk
dec cont ; do next trk
beq sb30 ; verify done
clc ; update bam pointer
lda bmpnt ;
adc #6 ; 6 byte per trk
bcc sb20 ; same bam
lda bmpnt+1
cmp #>bam2
beq sb30
inc bmpnt+1 ; do next bam
jmp sb10
sb30 jsr bamout ; wrt the bams
sb40 lda #0
sta wbam ; set it clean now!
rts