Subversion Repositories MB01 Project

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 - 1
  Tue Jul 17 11:00:20 2018                                                                                               Page    1
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9
          2500 A.D. 65816 Macro Assembler #26960 - Version 5.02g
10
          -----------------------------------------------------
11
 
12
                       Input  Filename : src\F9\fsstart.asm
13
                       Output Filename : obj\F9\fsstart.obj
14
                       Listing Has Been Relocated
15
 
16
 
17
 2582                        	.LIST		on
18
 2583
19
 2584  F8FFB1                		.INCLUDE inc\dirp00.inc
20
 2585                        	;----------------------------------------------------------
21
 2586                        	; DIRP00.ASM
22
 2587                        	; PROGETTO: B1601
23
 2588                        	;
24
 2589                        	; Variabili in Direct Page $00
25
 2590                        	;----------------------------------------------------------
26
 2591
27
 2592                        	; sezione COMMON -- questo permette di includere il file in piu' file
28
 2593
29
 2594                        	.LIST on
30
 2595
31
 2596                        	DIRP00:	.SECTION page0, ref_only, common	;Direct-Page 00
32
 2597
33
 2598  000000                		.ABSOLUTE		;; inizia sempre da $00
34
 2599  000000                		.ORG		0x00
35
 2600  000000
36
 2601  000000  0000          	JiffyClk	.DW			; contatore 10ms 32 bit
37
 2602  000002  0000          			.DW
38
 2603  000004                	SysTmr		.DS	SYSTMRCNT	; system timer 0 (10ms)
39
 2604  000008                	SysTMF		.DS	SYSTMRCNT	; flag timer (80 -> start)
40
 2605  00000C  00            	Bnk0Flag	.DB			; <7>: flag test RAM banco 0 ok
41
 2606                        						; <6>: flag warm reset
42
 2607  00000D  00            	RTCFlag		.DB
43
 2608
44
 2609  00000E                	diskstat	.DS	2	; flag device on ata bus #0 & #1
45
 2610                        					; <7>: device ready
46
 2611                        					; <6>: compact flash device (C.F.)
47
 2612                        					; <5>: device identification ok
48
 2613                        					; <4>: MBR loaded
49
 2614                        					; <3>: valid signature in MBR
50
 2615                        					; <2>: first partition found&active
51
 2616                        					; <1>:
52
 2617                        					; <0>: valid partition flag
53
 2618
54
 2619                        					; <7>: device ready
55
 2620                        					; <6>: USB device
56
 2621                        					; <5>: compact flash device (C.F.)
57
 2622                        					; <4>: device identification ok
58
 2623                        					; <3>: MBR loaded
59
 2624                        					; <2>: first partition found&active
60
 2625                        					; <1>: always 1
61
 2626                        					; <0>: valid partition flag
62
 2627  000010
63
  Tue Jul 17 11:00:20 2018                                                                                               Page    2
64
 
65
 
66
 
67
 
68
 2628
69
 2629          00000E        	atadev		.EQU	diskstat
70
 2630
71
 2631  000010                	usbdev		.DS	2	; flag flash disk on usb bus #0
72
 2632                        					; <7>: device plugged and ready
73
 2633                        					; <6>: always 1
74
 2634                        					; <5>: device identification ok
75
 2635                        					; <4>: MBR loaded
76
 2636                        					; <3>: valid signature in MBR
77
 2637                        					; <2>: first partition found&active
78
 2638                        					; <1>:
79
 2639                        					; <0>: valid partition flag
80
 2640
81
 2641  000012                	diskmax		.DS	16	; disk max. sector's
82
 2642          000012        	atasec		.EQU	diskmax
83
 2643          00001A        	usbsec		.EQU	diskmax+8
84
 2644
85
 2645
86
 2646  000022                	atambr		.DS	8	; data for first partition found in mbr
87
 2647                        					; first 3 bytes for start sector of partition
88
 2648                        					; last byte for partition type
89
 2649  00002A                	usbmbr		.DS	8
90
 2650
91
 2651  000032                	ataprt		.DS	8	; total sec's of first partition
92
 2652  00003A                	usbprt		.DS	8	; total sec's of first partition
93
 2653
94
 2654
95
 2655  000042  00            	usb0ch		.DB	; usb0 (ch375/ch376) flag
96
 2656                        				; <7>: module on
97
 2657                        				; <6>: ch376 flag
98
 2658                        				; <5:0>: chip version
99
 2659
100
 2660  000043  00            	usb0st		.DB	; usb0 status
101
 2661                        				; <7>: usb0 host mode ok
102
 2662                        				; <6>: flash disk attached flag
103
 2663                        				; <5>: usb device attached
104
 2664
105
 2665  000044  00            	fdcdrv		.DB		; phisycal drive status (drive #0)
106
 2666                        					; <7>: disk format established in bit 0&1
107
 2667                        					; <6>: double step seek done
108
 2668                        					; <5>: trust format bit's (set after ok r/w)
109
 2669                        					; <4>: write protect bit (if disk in drive)
110
 2670                        					; <3>: don't care
111
 2671                        					; <2>: don't care
112
 2672                        					; <1>: HD disk if set else DD disk
113
 2673                        					; <0>: CBM format if set else IBM format
114
 2674
115
 2675  000045  00            	vdrive		.DB		; virtual drive status (ram disk, drive #1)
116
 2676                        					; <7>: disk format established in bit 0&1
117
 2677                        					; <6>: change disk simulation (after format)
118
 2678                        					; <5>: don't care
119
 2679                        					; <4>: write protect bit (under sw control)
120
 2680                        					; <3>: don't care
121
 2681                        					; <2>: don't care
122
 2682                        					; <1>: HD disk if set else DD disk
123
 2683                        					; <0>: CBM format if set else IBM format
124
 2684
125
  Tue Jul 17 11:00:20 2018                                                                                               Page    3
126
 
127
 
128
 
129
 
130
 2685  000046  00            	fdcctl		.DB		; fdc controller status
131
 2686                        					; <7>: drive is attached
132
 2687                        					; <6>: drive need recalibration (restore)
133
 2688                        					; <5>: FDC controller ok
134
 2689                        					; <4>: motor on
135
 2690                        					; <3>: dma is active
136
 2691                        					; <2>: dma chip ok (post routine)
137
 2692                        					; <1>: clock rate (1=HD,0=DD)
138
 2693                        					; <0>: disk ready
139
 2694
140
 2695  000047  00            	fdctrk		.DB		; fd: current seek track
141
 2696  000048  00            	fdcerr		.DB		; fd: last error code
142
 2697  000049  00            	ataerr		.DB		; ata: last error code
143
 2698  00004A  00            	ataxer		.DB		; ata: last extended error code
144
 2699
145
 2700  00004B  00            	CtrlBrk		.DB		; flag CTRL+BREAK (NMI)
146
 2701
147
 2702  00004C  0000          	MemTop		.DW		; top memoria RAM
148
 2703  00004E  00            			.DB		; banco top mem
149
 2704
150
 2705  00004F  00            	DflTxtIn	.DB		; device di default text input
151
 2706  000050  00            	DflTxtOut	.DB		; device di default text output
152
 2707
153
 2708  000051                	COPPtr		LP		; long pointer for COP decoding
154
 2709  000054  00            	COPIdx		.DB		; COP signature/index
155
 2710
156
 2711  000055  00            	BiosEnt		.DB		; flag accesso a bios setup
157
 2712
158
 2713                        	; variabili utilizzate da ACIA
159
 2714  000056                	spwrk		.DS	$30
160
 2715
161
 2716                        	; bios mem
162
 2717  000086  0000          	nsize		.DW	; dimensione blocco da allocare
163
 2718                        	;bsize		.DW	; dimensione vera blocco free
164
 2719  000088  0000          	splitsz		.DW	; dimensione blocco splittato
165
 2720  00008A  0000          	bfree		.DW	; puntatore blocco free
166
 2721  00008C  0000          	hdrptr		.DW	; puntatore header heap
167
 2722
168
 2723  00008E  0000          	pbrklv		.DW	; current break level of current process
169
 2724  000090  0000          	pbrkmin		.DW	; minimum breal level of current process
170
 2725  000092  0000          	pbrkmax		.DW	; maximum breal level of current process
171
 2726  000094
172
 2727                        	; bios temp. work area
173
 2728  000094                	bwrktmp		.DS	$28
174
 2729
175
 2730  0000BC  00            	coptmp		.DB	; temp. used while cop
176
 2731
177
 2732  0000BD  00            	tstser		.DB	; check ser/usb test board post
178
 2733                        				; <7>: VIA2 ok
179
 2734                        				; <6>: PICRAM ok
180
 2735                        				; <1>: UART 16C550 ok
181
 2736                        				; <0>: R65C51 ok
182
 2737
183
 2738
184
 2739                        	;crc16		.DW
185
 2740
186
 2741  0000BD                		.RELATIVE
187
  Tue Jul 17 11:00:20 2018                                                                                               Page    4
188
 
189
 
190
 
191
 
192
 2742
193
 2743                        		.ENDS
194
 2744
195
 2745          [01]          	.IFDEF		_ACIA_INC_
196
 2746                        		.INCLUDE INC\SP.INC
197
 2747          [00]          	.ENDIF
198
 2748
199
 2762                        	.LIST on
200
 2763
201
 2764          000060        	KBDBUFLEN	.EQU	96		; dimensione buffer di tastiera
202
 2765
203
 2766                        	DIRP01:	.SECTION page0, ref_only, common	;Direct-Page 01
204
 2767
205
 2768  000000                		.ABSOLUTE		;; inizia sempre da $00
206
 2769  000000                		.ORG		0x00
207
 2770
208
 2771  000000
209
 2772  000000                	KbdBuf		.DS	KBDBUFLEN	; buffer della tastiera
210
 2773  000060  00            	KbdITail	.DB			; coda buffer tastiera
211
 2774  000061  00            	KbdIHead	.DB			; testa buffer tastiera
212
 2775  000062  00            	KbdCnt		.DB			; numero bytes nel buffer
213
 2776  000063  00            	KbdShift	.DB
214
 2777  000064  00            	KbdFlag		.DB
215
 2778  000065  00            	KbdToggle	.DB
216
 2779  000066  00            	KbdSt		.DB			; status tastiera dopo reset
217
 2780  000067  00            	PS2Ctl		.DB			; flag controller PS2 keyboard
218
 2781
219
 2782  000068  00            	LCDFlag		.DB
220
 2783  000069  00            	LCDTmp		.DB
221
 2784  00006A  0000          	LCDVal		.DW
222
 2785
223
 2786  00006C  00            	VBBFlag		.DB		; flag video board
224
 2787  00006D  00            	VBBRam		.DB		; flag video RAM
225
 2788
226
 2789  00006E  00            	ScnLinTmp	.DB
227
 2790  00006F  00            	ScnChBase	.DB		; base video ram VDC
228
 2791  000070  00            	ScnAttBase	.DB		; base ram attributi VDC
229
 2792  000071  00            	ScnCursMode	.DB		; VDC cursore default
230
 2793  000072  00            	ScnSaveAttr	.DB
231
 2794  000073  00            	ScnInsert	.DB
232
 2795  000074  00            	ScnAutoIns	.DB		; bit 7 -> autoins - bit 6 -> modo input
233
 2796  000075  00            	ScnScroll	.DB
234
 2797  000076  00            	ScnMaxRow	.DB		; max. righe finestra (-1)
235
 2798  000077  00            	ScnMaxCols	.DB		; max. colonne finestra (-1)
236
 2799
237
 2800  000078                	ScnMapTabs1	.DS	10
238
 2801  000082                	ScnMapTabs2	.DS	4
239
 2802  000086
240
 2803  000086  0000          	ScnPtr		.DW		; puntatore video ram linea corrente
241
 2804  000088  00            			.DB
242
 2805
243
 2806  000089  00            	ScnFiltLen	.DB		; lunghezza set caratteri filtro
244
 2807
245
 2808  00008A  0000          	ScnAtPtr	.DW		; puntatore attributi ram linea corrente
246
 2809  00008C  00            			.DB
247
 2810
248
 2811  00008D  00            	ScnTmpx		.DB		; temporaneo: durante put char
249
  Tue Jul 17 11:00:20 2018                                                                                               Page    5
250
 
251
 
252
 
253
 
254
 2812  00008E
255
 2813  00008E  00            	ScnTop		.DB		; riga superiore finestra
256
 2814  00008F  00            	ScnLeft		.DB		; colonna sinistra finestra
257
 2815  000090  00            	ScnBottom	.DB		; riga inferiore finestra
258
 2816  000091  00            	ScnRight	.DB		; colonna destra finestra
259
 2817  000092  00            	ScnAttr		.DB		; attributo default
260
 2818  000093  00            	ScnAttr2	.DB		; attributo alternativo
261
 2819  000094  00            	ScnRow		.DB		; riga cursore
262
 2820  000095  00            	ScnCol		.DB		; colonna cursore
263
 2821  000096  00            	ScnRowStart	.DB		; riga di start input
264
 2822  000097  00            	ScnInput	.DB		; riga di fine input
265
 2823  000098  00            	ScnColStart	.DB		; colonna di start input
266
 2824  000099  00            	ScnSaveX	.DB
267
 2825  00009A  00            	ScnSaveY	.DB
268
 2826  00009B  00            	ScnTmpL		.DB
269
 2827  00009C  00            	ScnTmpH		.DB
270
 2828  00009D  00            	ScnSaveRow	.DB
271
 2829  00009E  00            	ScnSaveCol	.DB
272
 2830  00009F  00            	ScnCurChr	.DB
273
 2831  0000A0  00            	ScnLstChr	.DB
274
 2832  0000A1  00            	ScnCR		.DB
275
 2833  0000A2  0000          	ScnPrm		.DW		; puntatore long utilizzato da print imm
276
 2834  0000A4  00            			.DB		; banco puntatore ScnPrm
277
 2835  0000A5  00            	ScnMode		.DB		; flag modo schermo
278
 2836
279
 2837  0000A6                	ScnPtr1		LP
280
 2838
281
 2839  0000A9  00            	ScnDefCol	.DB		; default foreground color
282
 2840
283
 2841  0000AA                	ScnPtr2		LP
284
 2842
285
 2843  0000AD  00            	ScnDefBkgCol	.DB		; default background color
286
 2844  0000AE  00            	ScnInpRow	.DB		; modo input line: riga start input
287
 2845  0000AF  00            	ScnInpCol	.DB		; modo input line: colonna start input
288
 2846  0000B0  00            	ScnLstRow	.DB		; modo input line: riga stop input
289
 2847  0000B1  00            	ScnLstCol	.DB		; modo input line: colonna stop input
290
 2848  0000B2  00            	ScnFlag		.DB		; Bit 7: input line - Bit 6: input riga unica
291
 2849  0000B3  00            	ScnMask		.DB		; flag tasti funzione editor di linea
292
 2850  0000B4  00            	ScnFilt		.DB		; filtro tasti editor di linea
293
 2851  0000B5  00            	ScnCntrl	.DB		; flag ASCII/CONTROL
294
 2852                        	;DflTxtIn	.DB		; device di default text input
295
 2853                        	;DflTxtOut	.DB		; device di default text output
296
 2854  0000B6
297
 2855          000047        	SCNCLRLEN	.EQU	($ - ScnLinTmp - 1)
298
 2856
299
 2857                        	;SCNCLRLEN	.EQU	(DflTxtOut - ScnLinTmp)
300
 2858
301
 2859                        	; variabili monitor
302
 2860  0000B6  00            	SMAddrL		.DB	; address low/high
303
 2861  0000B7  00            	SMAddrH		.DB
304
 2862  0000B8  00            	SMAddrK		.DB	; address bank
305
 2863  0000B9  00            	SMFlag32	.DB	; flag parametro 32 bit
306
 2864  0000BA  00            	SMTmpL		.DB	; temp. low/high
307
 2865  0000BB  00            	SMTmpH		.DB
308
 2866  0000BC  00            	SMTmpK		.DB	; temp. bank
309
 2867  0000BD  00            	SMTmpKK		.DB	; high byte param. 32 bit
310
 2868  0000BE  00            	SMSizeL		.DB	; size low/high
311
  Tue Jul 17 11:00:20 2018                                                                                               Page    6
312
 
313
 
314
 
315
 
316
 2869  0000BF  00            	SMSizeH		.DB
317
 2870  0000C0  00            	SMSizeK		.DB	; size bank
318
 2871  0000C1  00            	SMXAddrL	.DB	; address low/high XM
319
 2872  0000C2  00            	SMXAddrH	.DB
320
 2873  0000C3  00            	SMXAddrK	.DB	; address bank XM
321
 2874  0000C4  00            	SMbndx		.DB	; indice input buffer
322
 2875  0000C5  00            	SMnprm		.DB	; numero parametri riga di comando
323
 2876  0000C6  00            	SMdumb		.DB
324
 2877  0000C7  00            	SMkr		.DB
325
 2878  0000C8  0000          	SMpc		.DW
326
 2879  0000CA  00            	SMsr		.DB
327
 2880  0000CB  00            	SMbr		.DB
328
 2881  0000CC  0000          	SMdp		.DW
329
 2882  0000CE  0000          	SMac		.DW
330
 2883  0000D0  0000          	SMxr		.DW
331
 2884  0000D2  0000          	SMyr		.DW
332
 2885  0000D4  0000          	SMsp		.DW
333
 2886
334
 2887  0000D6  00            	SMAuxL		.DB
335
 2888  0000D7  00            	SMAuxH		.DB
336
 2889
337
 2890  0000D8  00            	asmlong		.DB	; flag for CPU in 16 mode
338
 2891                        				; <7> -> A/M in 16 bit mode
339
 2892                        				; <6> -> X/Y in 16 bit mode
340
 2893  0000D9  00            	asmcpu		.DB	; <7> -> 8 bit family
341
 2894                        				; <6> -> 65C02 cmos version
342
 2895
343
 2896  0000DA  00            	SMctx		.DB	; context (if = $00 no quit command)
344
 2897  0000DB                	SMrsm		LP	; long pointer to resume caller context
345
 2898
346
 2899  0000DE  00            	rtcadr		.DB	; rtc internal ram address
347
 2900  0000DF  00            	rtcbnk		.DB	; RTC internal bank ram
348
 2901  0000E0  00            	cmdlin		.DB	;
349
 2902  0000E1  00            	SMesc		.DB
350
 2903
351
 2904  0000E2                	SMXTmp:		.DS	26	; 26 bytes tmp
352
 2905
353
 2906          0000E2        	SMTmp2		.EQU	SMXTmp
354
 2907          0000E4        	SMTmp3		.EQU	SMXTmp+2
355
 2908          0000E6        	SMdwTmp1	.EQU	SMXTmp+4
356
 2909          0000EA        	SMdwTmp2	.EQU	SMXTmp+8
357
 2910          0000EE        	SMFsrc		.EQU	SMXTmp+12	; source bank for flash update
358
 2911          0000EF        	SMFflag		.EQU	SMXTmp+13	; flag file for flash update
359
 2912          0000F0        	SMXPos2		.EQU	SMXTmp+14
360
 2913          0000F1        	SMYPos2		.EQU	SMXTmp+15
361
 2914          0000F2        	SMXPos3		.EQU	SMXTmp+16
362
 2915          0000F3        	SMYPos3		.EQU	SMXTmp+17
363
 2916                        	;SMAuxL		.EQU	SMXTmp+18
364
 2917                        	;SMAuxH		.EQU	SMXTmp+19
365
 2918          0000F6        	SMXPos		.EQU	SMXTmp+20
366
 2919          0000F7        	SMYPos		.EQU	SMXTmp+21
367
 2920          0000F8        	SMdwTmp3	.EQU	SMXTmp+22
368
 2921
369
 2922          0000E2        	atcmd		.EQU	SMXTmp		; save @ command
370
 2923          0000E3        	atnum		.EQU	SMXTmp+1	; @ command index
371
 2924          0000E4        	atflag		.EQU	SMXTmp+2	; @ L,S,V,R,W start address flag
372
 2925          0000E5        	atbnk		.EQU	SMXTmp+3	; @ L,S,V,R,W bank
373
  Tue Jul 17 11:00:20 2018                                                                                               Page    7
374
 
375
 
376
 
377
 
378
 2926          0000E6        	atstr		.EQU	SMXTmp+4	; @ command string start (word)
379
 2927          0000E8        	atstart		.EQU	SMXTmp+6	; @ L,S,V,R,W start address (word)
380
 2928          0000EA        	atend		.EQU	SMXTmp+8	; @ S,W end address (word)
381
 2929          0000EC        	atbuf		.EQU	SMXTmp+10	; @ local buffer pointer (word)
382
 2930          0000EE        	atipb		.EQU	SMXTmp+12	; @ bank of input buffer
383
 2931          0000EF        	atdir		.EQU	SMXTmp+13	; @ load dir flag
384
 2932          0000F0        	atptr		.EQU	SMXTmp+14	; @ load dir pointer (word)
385
 2933          0000F2        	atsiz		.EQU	SMXTmp+16	; @ buffer size (word)
386
 2934          0000F5        	atlp		.EQU	SMXTmp+19	; @ long pointer
387
 2935          0000F8        	atsa		.EQU	SMXTmp+22	; @ sa
388
 2936
389
 2937          0000E2        	btmpx		.EQU	SMXTmp		; asc2bin conversion
390
 2938          0000E3        	brtcsec		.EQU	SMXTmp+1
391
 2939          0000E4        	brtcmin		.EQU	SMXTmp+2
392
 2940          0000E5        	brtchour	.EQU	SMXTmp+3
393
 2941          0000E6        	brtcday		.EQU	SMXTmp+4
394
 2942          0000E7        	brtcmonth	.EQU	SMXTmp+5
395
 2943          0000E8        	brtcyear	.EQU	SMXTmp+6
396
 2944          0000E9        	brtcct		.EQU	SMXTmp+7
397
 2945
398
 2946
399
 2947  0000FC                		.RELATIVE
400
 2948
401
 2949                        		.ENDS
402
 2950
403
 2958                        		.LIST on
404
 2959
405
 2960  F8FFB1                		.INCLUDE INC\LDT.INC
406
 2961                        	; LDT.INC
407
 2962
408
 2963          [02]          	.IFNDEF		__LDT_INC__
409
 2964          000001        	__LDT_INC__	.SET	1
410
 2965
411
 2966                        	.LIST on
412
 2967                        	;---------------------------------------------------------------------------
413
 2968                        	; Logical Drive Table (LDT) -- page 0 offset's
414
 2969                        	;---------------------------------------------------------------------------
415
 2970
416
 2971  F8FFB1                	 STRUCT		LDT
417
 2972                        	_LDT	.SECTION page0,common,ref_only,offset 0	;LDT Struct
418
 2973                        			;.ABSOLUTE
419
 2974                        			;.ORG	0
420
 2975                        		.MNLIST
421
 2976  000000  00            	ldt_fg1		.DB		; logical volume flag's
422
 2977                        					; <7>: device ready (fdc drive or ata device)
423
 2978                        					; <6>: if=1->HD/CF else->FD
424
 2979                        					; <1:0>: phisycal device number
425
 2980
426
 2981  000001  00            	ldt_fg2		.DB		; <7>: valid volume (fat volume or cbm disk)
427
 2982                        					; <6>: if=1->FAT else->CBM (FD only)
428
 2983                        					; <5>: disk format checked
429
 2984                        					; <1:0>: disk format (fdc only)
430
 2985
431
 2986  000002  0000          	ldt_root	.DW		; lba of root dir
432
 2987  000004  0000          	ldt_fat1	.DW		; lba of fat1 table
433
 2988  000006  0000          	ldt_fat2	.DW		; lba of fat2 table
434
 2989  000008  0000          	ldt_cls		.DW		; lba of first data cluster
435
  Tue Jul 17 11:00:20 2018                                                                                               Page    8
436
 
437
 
438
 
439
 
440
 2990  00000A  0000          	ldt_max		.DW		; max usable cluster + 1
441
 2991  00000C  0000          	ldt_rent	.DW		; root dir. max. entries
442
 2992  00000E  0000          	ldt_cent	.DW		; max. entries in dir. cluster
443
 2993  000010  0000          	ldt_eoc		.DW		; end of cluster chain marker
444
 2994  000012  0000          	ldt_free	.DW		; count of free cluster's
445
 2995  000014  0000          	ldt_nxt		.DW		; next free cluster
446
 2996  000016  0000          	ldt_fsiz	.DW		; fat table size
447
 2997
448
 2998  000018  00            	ldt_csiz	.DB		; cluster size (1,2,4,8,16,32,64)
449
 2999  000019  00            	ldt_cshf	.DB		; cluster shift (0,1,2,3,4,5,6)
450
 3000  00001A  00            	ldt_rsiz	.DB		; root dir. size (sector's)
451
 3001  00001B  00            	ldt_mcls	.DB		; mask for clust. module: 00,01,03,07,0F,1F,3F
452
 3002  00001C  0000          	ldt_cdlp	.DW		; current working dir list pointer
453
 3003  00001E  0000          	ldt_cdcls	.DW		; current working dir start cluster
454
 3004  000020  00            	ldt_cdlvl	.DB		; current working dir level count
455
 3005
456
 3006  000021  00            	ldt_ptype	.DB
457
 3007  000022  0000 0000     	ldt_pstart	.LWORD
458
 3008  000026  0000 0000     	ldt_psize	.LWORD
459
 3009
460
 3010          000022        	ldt_fp		.EQU	ldt_pstart	; fat table buffer long pointer
461
 3011          000025        	ldt_fbuf	.EQU	ldt_pstart+3		; fat table: x-mem base bank/dma buffer
462
 3012
463
 3013          000026        	ldt_pbr		.EQU	ldt_psize		; long pointer to PBR cache buffer
464
 3014          000029        	ldt_fmt		.EQU	ldt_psize+3
465
 3015
466
 3016  00002A                	 ESTRUCT	LDT
467
 3017  00002A                	LDTSIZE	.DS	0
468
 3018                        			;.RELATIVE
469
 3019                        			.ENDS
470
 3020                        		.MNLIST
471
 3021
472
 3022          [01]          	.ENDIF
473
 3023
474
 3024
475
 3025          000100        	CLSBUF		.EQU	$100	; dma buffer of cluster cache
476
 3026          000040        	CLSMAXSIZ	.EQU	64	; max. size of cluster in sector's
477
 3027
478
 3028                        	;---------------------------------------------------------------------------
479
 3029                        	; FAT Working Segment
480
 3030                        	;---------------------------------------------------------------------------
481
 3031
482
 3032          010000        	FATSEG		.EQU	$010000
483
 3033          000001        	FATBNK		.EQU	.SEG.FATSEG	; FAT working bank
484
 3034
485
 3035          010000        	FS		.SET	FATSEG
486
 3036          01FFFF        	FE		.SET	FATSEG + $FFFF
487
 3037          018C00        	FO		.SET	$018C00
488
 3038
489
 3039                        	_FATS:	.SECTION ref_only, common, offset FO, range FS FE ;FAT Segment
490
 3040  018C00                	_FATS_START	.DS	0
491
 3041
492
 3042  018C00                	_pbr0		.DS	512
493
 3043  018E00                	_pbr1		.DS	512
494
 3044  019000                	_pbr2		.DS	512
495
 3045  019200                	_pbr3		.DS	512
496
 3046
497
  Tue Jul 17 11:00:20 2018                                                                                               Page    9
498
 
499
 
500
 
501
 
502
 3047  019400                	_FATS_END	.DS	0
503
 3048          000800        	FATSSIZ		.EQU	(_FATS_END - _FATS_START)
504
 3049                        	.ENDS
505
 3050
506
 3051                        	;---------------------------------------------------------------------------
507
 3052                        	; direct page for LDT tables (P0LDT direct page)
508
 3053                        	;---------------------------------------------------------------------------
509
 3054
510
 3055                        	_DPLDT:	.SECTION page0, common, ref_only, offset 0	;LDT D.P.
511
 3056
512
 3057  000000                	ldt0		.DS	LDTSIZE
513
 3058  00002A                	ldt1		.DS	LDTSIZE
514
 3059  000054                	ldt2		.DS	LDTSIZE
515
 3060  00007E                	ldt3		.DS	LDTSIZE
516
 3061  0000A8                	ldt4		.DS	LDTSIZE
517
 3062  0000D2                	ldt5		.DS	LDTSIZE
518
 3063
519
 3064  0000FC                	_DPLDT_END	.DS	0
520
 3065
521
 3066                        	.ENDS
522
 3067
523
 3068
524
 3069                        	;---------------------------------------------------------------------------
525
 3070                        	; FAT var's direct page (P0FAT direct page)
526
 3071                        	;---------------------------------------------------------------------------
527
 3072
528
 3073                        	_DPFAT:	.SECTION page0, common, ref_only, offset 0	;FAT D.P.
529
 3074
530
 3075  000000  00            	ldtfg1		.DB		; logical volume flag's
531
 3076                        					; <7>: device ready (fdc drive or ata device)
532
 3077                        					; <6>: if=1->HD/CF else->FD
533
 3078                        					; <0>: phisycal device number
534
 3079
535
 3080  000001  00            	ldtfg2		.DB		; <7>: valid volume (fat volume or cbm disk)
536
 3081                        					; <6>: if=1->FAT else->CBM (FD only)
537
 3082                        					; <5>: disk format checked
538
 3083                        					; <1:0>: disk format (fdc only)
539
 3084
540
 3085  000002  0000          	ldtroot		.DW		; lba of root dir
541
 3086  000004  0000          	ldtfat1		.DW		; lba of fat1 table
542
 3087  000006  0000          	ldtfat2		.DW		; lba of fat2 table
543
 3088  000008  0000          	ldtcls		.DW		; lba of first data cluster
544
 3089  00000A  0000          	ldtmax		.DW		; max usable cluster + 1
545
 3090  00000C  0000          	ldtrent		.DW		; root dir. max. entries
546
 3091  00000E  0000          	ldtcent		.DW		; max. entries in dir. cluster
547
 3092  000010  0000          	ldteoc		.DW		; end of cluster chain marker
548
 3093  000012  0000          	ldtfree		.DW		; count of free cluster's
549
 3094  000014  0000          	ldtnxt		.DW		; next free cluster
550
 3095  000016  0000          	ldtfsiz		.DW		; fat table size
551
 3096
552
 3097  000018  00            	ldtcsiz		.DB		; cluster size (1,2,4,8,16,32,64)
553
 3098  000019  00            	ldtcshf		.DB		; cluster shift (0,1,2,3,4,5,6)
554
 3099  00001A  00            	ldtrsiz		.DB		; root dir. size (sector's)
555
 3100  00001B  00            	ldtmcls		.DB		; mask for clust. module: 00,01,03,07,0F,1F,3F
556
 3101  00001C  0000          	ldtcdlp		.DW		; current working dir list pointer
557
 3102  00001E  0000          	ldtcdcls	.DW		; current working dir start cluster
558
 3103  000020  00            	ldtcdlvl	.DB		; current working dir level count
559
  Tue Jul 17 11:00:20 2018                                                                                               Page   10
560
 
561
 
562
 
563
 
564
 3104
565
 3105                        	; ---------------------------
566
 3106
567
 3107  000021  00            	curldt		.DB		; pointer to current LDT
568
 3108  000022                	ldtp		.DS	6	; LDT's pointer
569
 3109  000028  00            	defdrv		.DB		; default logical drive
570
 3110  000029  00            	curdrv		.DB		; current logical drive
571
 3111
572
 3112  00002A  0000 0000     	lba		.LWORD		; current lba
573
 3113  00002E  0000          	wseccnt		.DW		; sector count
574
 3114
575
 3115  000030  00            	defhsec		.DB		; default hidden sector's in fdisk
576
 3116  000031  00            	pdrive		.DB		; phisycal drive number (temp.)
577
 3117
578
 3118  000032                	_fattmp		.DS	48
579
 3119
580
 3120                        	.ENDS
581
 3121
582
 3127                        	.LIST on
583
 3128
584
 3129                        	_FATTMP:	.SECTION page0, ref_only, offset _fattmp
585
 3130          000032        	FATTMP_START	.EQU	$
586
 3131
587
 3132  000032  0000 0000     	hidsec		.LWORD		; hidden sectors
588
 3133  000036  0000 0000     	totsec		.LWORD		; partition size in sector's
589
 3134  00003A  0000 0000     	maxsec		.LWORD		; device max sector's count
590
 3135  00003E  0000          	freecnt		.DW		; free cluster's count
591
 3136          00003E        	mbrflag		.EQU	freecnt	; mbr partition flag (low 8 bits only)
592
 3137  000040  0000          	nextfree	.DW		; next free cluster
593
 3138  000042  0000          	maxcls		.DW		; last usable cluster+1
594
 3139          000042        	mbrtype		.EQU	maxcls	; mbr partition type (low 8 bits only)
595
 3140  000044  0000          	fatsize		.DW		; FAT16 fat table size
596
 3141  000046  0000          	clscnt		.DW		; cluster's count #
597
 3142  000048  0000          	ncnt		.DW		; generic counter
598
 3143
599
 3144  00004A  00            	ldrv		.DB		; temp.: logical drive
600
 3145  00004B  00            	ldttmp		.DB		; temp.: LDT pointer
601
 3146  00004C  00            	pdev		.DB		; temp.: phisycal drive
602
 3147
603
 3148          00001B        	FATTMP_SIZ	.EQU	($ - FATTMP_START)
604
 3149                        		.ENDS
605
 3150
606
 3151
607
 3152                        	;---------------------------------------------------------------------------
608
 3153                        	; code segment -- bank $F9
609
 3154                        	;---------------------------------------------------------------------------
610
 3155
611
 3156                        		.CODEF9
612
 3157
613
 3158                        	.comment @
614
 3159                        	; getfreecnt - compute free cluster's count scanning fat table
615
 3160                        	; in:	X = logical drive
616
 3161                        	; out:	LDT of logical drive is updated
617
 3162                        	;	CF = 1 if error
618
 3163                        	;
619
 3164                        	; fat table is loaded in dma buffer # $100, devoted to cluster cache and
620
 3165                        	; limited to 64 sectors
621
  Tue Jul 17 11:00:20 2018                                                                                               Page   11
622
 
623
 
624
 
625
 
626
 3166                        	;
627
 3167                        	getfreecnt:
628
 3168                        		stx	ldrv		; logical drive
629
 3169                        		ldy	ldtp,x		; LDT pointer
630
 3170                        		sty	ldttmp		; save LDT pointer
631
 3171                        		stz	tlp		; init dma buffer pointer
632
 3172                        		stz	tlp+1
633
 3173                        		lda	#DMABNK
634
 3174                        		sta	tlp+2
635
 3175                        		lda	!P0LDT+ldt_fg1,y
636
 3176                        		and	#00000011B
637
 3177                        		sta	pdrive		; phisycal drive
638
 3178                        		ACC16
639
 3179                        		lda	!P0LDT+ldt_fat1,y
640
 3180                        		sta	lba		; start sector of fat 1 table
641
 3181                        		stz	lba+2
642
 3182                        		stz	freecnt		; count of free clusters
643
 3183                        		stz	nxtfree		; free next cluster
644
 3184                        		stz	clscnt		; cluster numbering
645
 3185                        		lda	!P0LDT+ldt_max,y
646
 3186                        		sta	maxcls		; max. cluster number + 1
647
 3187                        		lda	!P0LDT+ldt_fsiz,y
648
 3188                        		sta	fatsize		; store fat table size
649
 3189
650
 3190                        	?lp:	lda	fatsize
651
 3191                        		cmp	#CLSMAXSIZ
652
 3192                        		bcc	?less
653
 3193                        		lda	#CLSMAXSIZ
654
 3194                        	?less:	sta	wseccnt		; sectors count #
655
 3195                        		ACC08
656
 3196                        		lda	pdrive		; phisycal device #
657
 3197                        		pha
658
 3198                        		pei	(lba+2)		; start sector
659
 3199                        		pei	(lba)
660
 3200                        		lda	seccnt		; sector's count
661
 3201                        		pha
662
 3202                        		pea	#CLSBUF		; dma cliuster buffer
663
 3203                        		DISKRD			; read dik sector
664
 3204                        		bcs	??		; error (Y = error code)
665
 3205
666
 3206                        		ldy	#0
667
 3207                        		CPU16
668
 3208                        		lda	wseccnt
669
 3209                        		xba
670
 3210                        		asl	a		; bytes count #
671
 3211                        		sta	ncnt
672
 3212                        		ldx	clscnt		; X = current cluster number
673
 3213                        	?lpf:	lda	[tlp],y		; scan fat table
674
 3214                        		bne	?nxt		; not free
675
 3215                        		inc	freecnt		; update free cluster's count
676
 3216                        		lda	nxtfree		; already set?
677
 3217                        		bne	?nxt		; yes
678
 3218                        		stx	nxtfree		; set first free cluster
679
 3219                        	?nxt:	inx			; update cluster number
680
 3220                        		iny
681
 3221                        		iny
682
 3222                        		cpx	maxcls		; end of table?
683
  Tue Jul 17 11:00:20 2018                                                                                               Page   12
684
 
685
 
686
 
687
 
688
 3223                        		bcs	?done		; yes
689
 3224                        		cpy	ncnt		; end of partial table?
690
 3225                        		bcc	?lpf		; no
691
 3226                        		stx	cluster		; save current cluster number
692
 3227                        		INDEX08
693
 3228                        		lda	fatsize
694
 3229                        		sec
695
 3230                        		sbc	wseccnt
696
 3231                        		beq	?done		; end
697
 3232                        		sta	fatsize
698
 3233                        		clc
699
 3234                        		lda	lba
700
 3235                        		adc	wseccnt
701
 3236                        		bcc	?lp
702
 3237                        		inc	lba+2
703
 3238                        		bra	?lp
704
 3239                        	?done:	CPU08
705
 3240                        		clc
706
 3241                        	?err:	ACC16
707
 3242                        		ldy	ldttmp		; LDT pointer
708
 3243                        		lda	freecnt
709
 3244                        		sta	!P0LDT+ldt_free,y
710
 3245                        		lda	nxtfree
711
 3246                        		sta	!P0LDT+ldt_nxt,y
712
 3247                        		ACC08
713
 3248                        		rts
714
 3249                        	@
715
 3250
716
 3251                        	.comment @
717
 3252                        	; load & check disk mbr
718
 3253                        	mbrld:
719
 3254                        		lda	pdev		; phisycal device #
720
 3255                        		pha
721
 3256                        		pea	#0		; load sector #0
722
 3257                        		pea	#0
723
 3258                        		lda	#1		; load 1 sector
724
 3259                        		pha
725
 3260                        		pea	#$0100		; dma buffer #256
726
 3261                        		DISKRD			; read dik sector
727
 3262                        		bcs	??		; error (Y = error code)
728
 3263
729
 3264                        		lda	#$10		; set bit mbr loaded
730
 3265                        		sta	tmp
731
 3266                        		CPU16
732
 3267                        		ldy	#$01FE		; signature pointer
733
 3268                        		lda	[bufp],y
734
 3269                        		sta	mbrsgn		; mbr signature
735
 3270                        		ldy	#$01C2		; partition type pointer
736
 3271                        		lda	[bufp],y
737
 3272                        		sta	wtmp		; partition type
738
 3273                        		ldy	#$01C6		; partition start pointer
739
 3274                        		lda	[bufp],y
740
 3275                        		sta	nlba		; partition start
741
 3276                        		iny
742
 3277                        		iny
743
 3278                        		lda	[bufp],y
744
 3279                        		sta	nlba+2
745
  Tue Jul 17 11:00:20 2018                                                                                               Page   13
746
 
747
 
748
 
749
 
750
 3280                        		ldy	#$01BE		; partition flag pointer
751
 3281                        		lda	[bufp],y
752
 3282                        		sta	mbrfg		; partition flag
753
 3283                        		lda	mbrsgn
754
 3284                        		cmp	#$AA55
755
 3285                        		CPU08
756
 3286                        		bne	?20		; invalid mbr signature
757
 3287                        		lda	#$18		; add valid mbr signature flag
758
 3288                        		sta	tmp
759
 3289                        		lda	mbrfg		; must be $80 or 0
760
 3290                        		beq	?vv
761
 3291                        		bpl	?20		; first partition invalid
762
 3292                        	?vv:	lda	#$1C		; add active partition flag
763
 3293                        		sta	tmp
764
 3294                        		lda	drive
765
 3295                        		asl	a
766
 3296                        		asl	a
767
 3297                        		tax			; index for access to atambr var
768
 3298                        		lda	wtmp		; partition type
769
 3299                        		tay
770
 3300                        		sta	atambr+3,x	; store partition type
771
 3301                        		lda	nlba+2		; store partition start
772
 3302                        		sta	atambr+2,x
773
 3303                        		lda	nlba+1
774
 3304                        		sta	atambr+1,x
775
 3305                        		lda	nlba
776
 3306                        		sta	atambr,x
777
 3307                        		lda	nlba+3		; must be 0
778
 3308                        		bne	?20
779
 3309                        		cpy	#$06		; just FAT16 type
780
 3310                        		beq	?10
781
 3311                        		cpy	#$04		; FAT 16 for disk less than 32Mb
782
 3312                        		beq	?10
783
 3313                        		cpy	#$0E
784
 3314                        		bne	?20
785
 3315                        	?10:	CPU16
786
 3316                        		ldy	#$01CA		; partition sec's count pointer
787
 3317                        		lda	[bufp],y
788
 3318                        		sta	ataprt,x
789
 3319                        		iny
790
 3320                        		iny
791
 3321                        		lda	[bufp],y
792
 3322                        		sta	ataprt+2,x
793
 3323                        		CPU08
794
 3324                        		lda	#$1D		; add valid partition type
795
 3325                        		sta	tmp
796
 3326                        	?20:	ldx	drive		; update device flag
797
 3327                        		lda	atadev,x
798
 3328                        		ora	tmp
799
 3329                        		sta	atadev,x
800
 3330                        		clc
801
 3331                        	?30:	rts
802
 3332
803
 3333                        	; load & check pbr
804
 3334                        		lda	pdev		; phisycal device #
805
 3335                        		pha
806
 3336                        		pei	(lba+2)		; load pbr sector
807
  Tue Jul 17 11:00:20 2018                                                                                               Page   14
808
 
809
 
810
 
811
 
812
 3337                        		pea	(lba)
813
 3338                        		lda	#1		; load 1 sector
814
 3339                        		pha
815
 3340                        		pea	#$0100		; dma buffer #256
816
 3341                        		DISKRD			; read dik sector
817
 3342                        		bcs	??		; error (Y = error code)
818
 3343
819
 3344                        		lda	pdev		; phisycal drive
820
 3345                        		asl	a
821
 3346                        		asl	a
822
 3347                        		asl	a
823
 3348                        		tax
824
 3349                        		ACC16
825
 3350                        		lda	!atambr,x	; partition start
826
 3351                        		sta	hidsec		; this is also hidden sectors count
827
 3352                        		lda	!atambr+2,x
828
 3353                        		and	#$00FF
829
 3354                        		sta	hidsec+2
830
 3355                        		lda	!ataprt,x	; total partition sector's
831
 3356                        		sta	totsec
832
 3357                        		lda	!ataprt+2,x
833
 3358                        		sta	totsec+2
834
 3359                        		ldx	ldtcur		; LDT ptr
835
 3360
836
 3361                        	; entry point to check usb #0 disk
837
 3362                        	chk16c:
838
 3363                        		ACC16
839
 3364                        		ldx	pbrp+1
840
 3365                        		inx
841
 3366                        		stx	pbrp+1
842
 3367                        		lda	#MAXF16
843
 3368                        		sta	maxcnt
844
 3369                        		ldy	#$FE		; pointer to pbr signature
845
 3370                        		lda	[pbrp],y
846
 3371                        		cmp	#$AA55
847
 3372                        		bne	?10		; signature error
848
 3373                        		dex
849
 3374                        		stx	pbrp+1
850
 3375                        		ldy	#$0B		; pointer to bytes per sector
851
 3376                        		lda	[pbrp],y
852
 3377                        		cmp	#$0200		; must be always 512 bytes per sector
853
 3378                        		bne	?10		; error
854
 3379                        		ldy	#$1C		; pointer to hidden sector's count
855
 3380                        		lda	[pbrp],y	; typical value: $3F
856
 3381                        		cmp	hidsec		; must match
857
 3382                        		bne	?10
858
 3383                        		iny
859
 3384                        		iny
860
 3385                        		lda	[pbrp],y
861
 3386                        		cmp	hidsec+2
862
 3387                        		bne	?10
863
 3388                        		cmp	#0
864
 3389                        		bne	?10		; must be 0
865
 3390                        		ldy	#$0E		; pointer to reserved sector's
866
 3391                        		lda	[pbrp],y	; typical value: 1 (no mandatory)
867
 3392                        		sta	rsvsec
868
 3393                        		ldy	#$11		; pointer to root dir entry #
869
  Tue Jul 17 11:00:20 2018                                                                                               Page   15
870
 
871
 
872
 
873
 
874
 3394                        		lda	[pbrp],y
875
 3395                        		beq	?10		; fat32?
876
 3396                        		cmp	#$0200		; typical value: not mandatory...
877
 3397                        		bne	?10		; ...but this will be
878
 3398                        		sta	rootent
879
 3399                        		lsr	a		; divide by 16...
880
 3400                        		lsr	a
881
 3401                        		lsr	a
882
 3402                        		lsr	a		;...to get root dir size in sec's
883
 3403                        		sta	rootsiz
884
 3404                        		ldy	#$13		; pointer to tot. sec16
885
 3405                        		lda	[pbrp],y
886
 3406                        		beq	?06		; invalid: is valid field tot. sec32
887
 3407                        		cmp	totsec
888
 3408                        		bne	?10		; error
889
 3409                        		lda	totsec+2	; must be 0
890
 3410                        		bne	?10		; errore
891
 3411                        		beq	?08		; ok
892
 3412                        	?06:	ldy	#$20		; pointer to tot. sec32
893
 3413                        		lda	[pbrp],y
894
 3414                        		cmp	totsec
895
 3415                        		bne	?10		; error
896
 3416                        		iny
897
 3417                        		iny
898
 3418                        		lda	[pbrp],y
899
 3419                        		cmp	totsec+2
900
 3420                        		bne	?10		; error
901
 3421                        	?08:	ldy	#$16		; pointer to fat size (FAT16)
902
 3422                        		lda	[pbrp],y
903
 3423                        		sta	fatsiz
904
 3424                        		beq	?10		; hmmm... is fat32... not good
905
 3425                        		cmp	#257		; fat16 table size limited to 256 sec. max
906
 3426                        		bra	?12
907
 3427                        	?10:	sec
908
 3428                        	?12:	CPU08
909
 3429                        		bcs	?18		; error
910
 3430                        		ldy	#$15		; pointer to media byte
911
 3431                        		lda	[pbrp],y	; must be $F8
912
 3432                        		cmp	#$F8
913
 3433                        		bne	?16
914
 3434                        		ldy	#$10		; pointer to count of fat table's
915
 3435                        		lda	[pbrp],y
916
 3436                        		cmp	#2		; must be 2
917
 3437                        		bne	?16
918
 3438                        		ldy	#$0D		; pointer to sector(s) per cluster
919
 3439                        		lda	[pbrp],y
920
 3440                        		ldx	#CLSCNT-1
921
 3441                        	?14:	cmp	>CLSSIZE,x
922
 3442                        		beq	?20
923
 3443                        		dex
924
 3444                        		bpl	?14
925
 3445                        	?16:	sec
926
 3446                        	?18:	rts
927
 3447                        	?20:	sta	clssiz
928
 3448                        		dec	a
929
 3449                        		sta	clsmod
930
 3450                        		lda	>CLSSHIFT,x
931
  Tue Jul 17 11:00:20 2018                                                                                               Page   16
932
 
933
 
934
 
935
 
936
 3451                        		sta	clsshf
937
 3452                        		clc
938
 3453                        		rts
939
 3454
940
 3455                        	@
941
 3456
942
 3457
943
 3458                        	;---------------------------------------------------------------------------
944
 3459                        	; tables
945
 3460                        	;---------------------------------------------------------------------------
946
 3461
947
 3462                        	; address of pbr buffer of fixed disk's
948
 3463  F902F3                	PBRBUFL:
949
 3464                        		;.DB	<_pbr0, <_pbr1, <_pbr2, <_pbr3
950
 3465  F902F3                	PBRBUFH:
951
 3466  F902F3  8C 8E 90 92   		.DB	>_pbr0, >_pbr1, >_pbr2, >_pbr3
952
 3467  F902F7
953
 3468                        	; sector's per cluster table
954
 3469  F902F7                	CLSSIZE:
955
 3470  F902F7  01 02 04 08 10 		.DB	$01, $02, $04, $08, $10, $20, $40
956
               20 40
957
 3471
958
 3472          000007        	CLSCNT	.EQU	$-CLSSIZE
959
 3473
960
 3474                        	; sector's per cluster shift table
961
 3475  F902FE                	CLSSHIFT:
962
 3476  F902FE  00 01 02 03 04 		.DB	$00, $01, $02, $03, $04, $05, $06
963
               05 06
964
 
965
 
966
             Lines Assembled : 3455                  Errors : 0
967
 
968
 
969