Subversion Repositories MB01 Project

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 - 1
  Tue Jul 17 11:00:21 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\toscmd.asm
13
                       Output Filename : obj\F9\toscmd.obj
14
                       Listing Has Been Relocated
15
 
16
 
17
 2603                        	.LIST		on
18
 2604
19
 2605  F8FFB1                		.INCLUDE inc\dirp00.inc
20
 2606                        	;----------------------------------------------------------
21
 2607                        	; DIRP00.ASM
22
 2608                        	; PROGETTO: B1601
23
 2609                        	;
24
 2610                        	; Variabili in Direct Page $00
25
 2611                        	;----------------------------------------------------------
26
 2612
27
 2613                        	; sezione COMMON -- questo permette di includere il file in piu' file
28
 2614
29
 2615                        	.LIST on
30
 2616
31
 2617                        	DIRP00:	.SECTION page0, ref_only, common	;Direct-Page 00
32
 2618
33
 2619  000000                		.ABSOLUTE		;; inizia sempre da $00
34
 2620  000000                		.ORG		0x00
35
 2621  000000
36
 2622  000000  0000          	JiffyClk	.DW			; contatore 10ms 32 bit
37
 2623  000002  0000          			.DW
38
 2624  000004                	SysTmr		.DS	SYSTMRCNT	; system timer 0 (10ms)
39
 2625  000008                	SysTMF		.DS	SYSTMRCNT	; flag timer (80 -> start)
40
 2626  00000C  00            	Bnk0Flag	.DB			; <7>: flag test RAM banco 0 ok
41
 2627                        						; <6>: flag warm reset
42
 2628  00000D  00            	RTCFlag		.DB
43
 2629
44
 2630  00000E                	diskstat	.DS	2	; flag device on ata bus #0 & #1
45
 2631                        					; <7>: device ready
46
 2632                        					; <6>: compact flash device (C.F.)
47
 2633                        					; <5>: device identification ok
48
 2634                        					; <4>: MBR loaded
49
 2635                        					; <3>: valid signature in MBR
50
 2636                        					; <2>: first partition found&active
51
 2637                        					; <1>:
52
 2638                        					; <0>: valid partition flag
53
 2639
54
 2640                        					; <7>: device ready
55
 2641                        					; <6>: USB device
56
 2642                        					; <5>: compact flash device (C.F.)
57
 2643                        					; <4>: device identification ok
58
 2644                        					; <3>: MBR loaded
59
 2645                        					; <2>: first partition found&active
60
 2646                        					; <1>: always 1
61
 2647                        					; <0>: valid partition flag
62
 2648  000010
63
  Tue Jul 17 11:00:21 2018                                                                                               Page    2
64
 
65
 
66
 
67
 
68
 2649
69
 2650          00000E        	atadev		.EQU	diskstat
70
 2651
71
 2652  000010                	usbdev		.DS	2	; flag flash disk on usb bus #0
72
 2653                        					; <7>: device plugged and ready
73
 2654                        					; <6>: always 1
74
 2655                        					; <5>: device identification ok
75
 2656                        					; <4>: MBR loaded
76
 2657                        					; <3>: valid signature in MBR
77
 2658                        					; <2>: first partition found&active
78
 2659                        					; <1>:
79
 2660                        					; <0>: valid partition flag
80
 2661
81
 2662  000012                	diskmax		.DS	16	; disk max. sector's
82
 2663          000012        	atasec		.EQU	diskmax
83
 2664          00001A        	usbsec		.EQU	diskmax+8
84
 2665
85
 2666
86
 2667  000022                	atambr		.DS	8	; data for first partition found in mbr
87
 2668                        					; first 3 bytes for start sector of partition
88
 2669                        					; last byte for partition type
89
 2670  00002A                	usbmbr		.DS	8
90
 2671
91
 2672  000032                	ataprt		.DS	8	; total sec's of first partition
92
 2673  00003A                	usbprt		.DS	8	; total sec's of first partition
93
 2674
94
 2675
95
 2676  000042  00            	usb0ch		.DB	; usb0 (ch375/ch376) flag
96
 2677                        				; <7>: module on
97
 2678                        				; <6>: ch376 flag
98
 2679                        				; <5:0>: chip version
99
 2680
100
 2681  000043  00            	usb0st		.DB	; usb0 status
101
 2682                        				; <7>: usb0 host mode ok
102
 2683                        				; <6>: flash disk attached flag
103
 2684                        				; <5>: usb device attached
104
 2685
105
 2686  000044  00            	fdcdrv		.DB		; phisycal drive status (drive #0)
106
 2687                        					; <7>: disk format established in bit 0&1
107
 2688                        					; <6>: double step seek done
108
 2689                        					; <5>: trust format bit's (set after ok r/w)
109
 2690                        					; <4>: write protect bit (if disk in drive)
110
 2691                        					; <3>: don't care
111
 2692                        					; <2>: don't care
112
 2693                        					; <1>: HD disk if set else DD disk
113
 2694                        					; <0>: CBM format if set else IBM format
114
 2695
115
 2696  000045  00            	vdrive		.DB		; virtual drive status (ram disk, drive #1)
116
 2697                        					; <7>: disk format established in bit 0&1
117
 2698                        					; <6>: change disk simulation (after format)
118
 2699                        					; <5>: don't care
119
 2700                        					; <4>: write protect bit (under sw control)
120
 2701                        					; <3>: don't care
121
 2702                        					; <2>: don't care
122
 2703                        					; <1>: HD disk if set else DD disk
123
 2704                        					; <0>: CBM format if set else IBM format
124
 2705
125
  Tue Jul 17 11:00:21 2018                                                                                               Page    3
126
 
127
 
128
 
129
 
130
 2706  000046  00            	fdcctl		.DB		; fdc controller status
131
 2707                        					; <7>: drive is attached
132
 2708                        					; <6>: drive need recalibration (restore)
133
 2709                        					; <5>: FDC controller ok
134
 2710                        					; <4>: motor on
135
 2711                        					; <3>: dma is active
136
 2712                        					; <2>: dma chip ok (post routine)
137
 2713                        					; <1>: clock rate (1=HD,0=DD)
138
 2714                        					; <0>: disk ready
139
 2715
140
 2716  000047  00            	fdctrk		.DB		; fd: current seek track
141
 2717  000048  00            	fdcerr		.DB		; fd: last error code
142
 2718  000049  00            	ataerr		.DB		; ata: last error code
143
 2719  00004A  00            	ataxer		.DB		; ata: last extended error code
144
 2720
145
 2721  00004B  00            	CtrlBrk		.DB		; flag CTRL+BREAK (NMI)
146
 2722
147
 2723  00004C  0000          	MemTop		.DW		; top memoria RAM
148
 2724  00004E  00            			.DB		; banco top mem
149
 2725
150
 2726  00004F  00            	DflTxtIn	.DB		; device di default text input
151
 2727  000050  00            	DflTxtOut	.DB		; device di default text output
152
 2728
153
 2729  000051                	COPPtr		LP		; long pointer for COP decoding
154
 2730  000054  00            	COPIdx		.DB		; COP signature/index
155
 2731
156
 2732  000055  00            	BiosEnt		.DB		; flag accesso a bios setup
157
 2733
158
 2734                        	; variabili utilizzate da ACIA
159
 2735  000056                	spwrk		.DS	$30
160
 2736
161
 2737                        	; bios mem
162
 2738  000086  0000          	nsize		.DW	; dimensione blocco da allocare
163
 2739                        	;bsize		.DW	; dimensione vera blocco free
164
 2740  000088  0000          	splitsz		.DW	; dimensione blocco splittato
165
 2741  00008A  0000          	bfree		.DW	; puntatore blocco free
166
 2742  00008C  0000          	hdrptr		.DW	; puntatore header heap
167
 2743
168
 2744  00008E  0000          	pbrklv		.DW	; current break level of current process
169
 2745  000090  0000          	pbrkmin		.DW	; minimum breal level of current process
170
 2746  000092  0000          	pbrkmax		.DW	; maximum breal level of current process
171
 2747  000094
172
 2748                        	; bios temp. work area
173
 2749  000094                	bwrktmp		.DS	$28
174
 2750
175
 2751  0000BC  00            	coptmp		.DB	; temp. used while cop
176
 2752
177
 2753  0000BD  00            	tstser		.DB	; check ser/usb test board post
178
 2754                        				; <7>: VIA2 ok
179
 2755                        				; <6>: PICRAM ok
180
 2756                        				; <1>: UART 16C550 ok
181
 2757                        				; <0>: R65C51 ok
182
 2758
183
 2759
184
 2760                        	;crc16		.DW
185
 2761
186
 2762  0000BD                		.RELATIVE
187
  Tue Jul 17 11:00:21 2018                                                                                               Page    4
188
 
189
 
190
 
191
 
192
 2763
193
 2764                        		.ENDS
194
 2765
195
 2766          [01]          	.IFDEF		_ACIA_INC_
196
 2767                        		.INCLUDE INC\SP.INC
197
 2768          [00]          	.ENDIF
198
 2769
199
 2793                        	.LIST on
200
 2794
201
 2795                        	;---------------------------------------------------------------------------
202
 2796
203
 2797          000020        	HPLMAX		.EQU	32		; Max. subdirectory level
204
 2798
205
 2799          000200        	BCBCNT		.EQU	$200		; BCB's struct's count #
206
 2800          000C00        	BCBXBNK		.EQU	$0C00		; starting BCB x-mem buffer #
207
 2801          000040        	DMACNT		.EQU	64
208
 2802
209
 2803          0000E0        	FAT0X		.EQU	$E0		; x-mem bank for fat table of ata #0
210
 2804          0000F0        	FAT1X		.EQU	$F0		; x-mem bank for fat table of ata #1
211
 2805
212
 2806  F8FFB1                		.INCLUDE INC\LDT.INC
213
 2807                        	; LDT.INC
214
 2808
215
 2809          [01]          	.IFNDEF		__LDT_INC__
216
 2810          000001        	__LDT_INC__	.SET	1
217
 2811
218
 2812                        	.LIST on
219
 2813                        	;---------------------------------------------------------------------------
220
 2814                        	; Logical Drive Table (LDT) -- page 0 offset's
221
 2815                        	;---------------------------------------------------------------------------
222
 2816
223
 2817  F8FFB1                	 STRUCT		LDT
224
 2818                        	_LDT	.SECTION page0,common,ref_only,offset 0	;LDT Struct
225
 2819                        			;.ABSOLUTE
226
 2820                        			;.ORG	0
227
 2821                        		.MNLIST
228
 2822  000000  00            	ldt_fg1		.DB		; logical volume flag's
229
 2823                        					; <7>: device ready (fdc drive or ata device)
230
 2824                        					; <6>: if=1->HD/CF else->FD
231
 2825                        					; <1:0>: phisycal device number
232
 2826
233
 2827  000001  00            	ldt_fg2		.DB		; <7>: valid volume (fat volume or cbm disk)
234
 2828                        					; <6>: if=1->FAT else->CBM (FD only)
235
 2829                        					; <5>: disk format checked
236
 2830                        					; <1:0>: disk format (fdc only)
237
 2831
238
 2832  000002  0000          	ldt_root	.DW		; lba of root dir
239
 2833  000004  0000          	ldt_fat1	.DW		; lba of fat1 table
240
 2834  000006  0000          	ldt_fat2	.DW		; lba of fat2 table
241
 2835  000008  0000          	ldt_cls		.DW		; lba of first data cluster
242
 2836  00000A  0000          	ldt_max		.DW		; max usable cluster + 1
243
 2837  00000C  0000          	ldt_rent	.DW		; root dir. max. entries
244
 2838  00000E  0000          	ldt_cent	.DW		; max. entries in dir. cluster
245
 2839  000010  0000          	ldt_eoc		.DW		; end of cluster chain marker
246
 2840  000012  0000          	ldt_free	.DW		; count of free cluster's
247
 2841  000014  0000          	ldt_nxt		.DW		; next free cluster
248
 2842  000016  0000          	ldt_fsiz	.DW		; fat table size
249
  Tue Jul 17 11:00:21 2018                                                                                               Page    5
250
 
251
 
252
 
253
 
254
 2843
255
 2844  000018  00            	ldt_csiz	.DB		; cluster size (1,2,4,8,16,32,64)
256
 2845  000019  00            	ldt_cshf	.DB		; cluster shift (0,1,2,3,4,5,6)
257
 2846  00001A  00            	ldt_rsiz	.DB		; root dir. size (sector's)
258
 2847  00001B  00            	ldt_mcls	.DB		; mask for clust. module: 00,01,03,07,0F,1F,3F
259
 2848  00001C  0000          	ldt_cdlp	.DW		; current working dir list pointer
260
 2849  00001E  0000          	ldt_cdcls	.DW		; current working dir start cluster
261
 2850  000020  00            	ldt_cdlvl	.DB		; current working dir level count
262
 2851
263
 2852  000021  00            	ldt_ptype	.DB
264
 2853  000022  0000 0000     	ldt_pstart	.LWORD
265
 2854  000026  0000 0000     	ldt_psize	.LWORD
266
 2855
267
 2856          000022        	ldt_fp		.EQU	ldt_pstart	; fat table buffer long pointer
268
 2857          000025        	ldt_fbuf	.EQU	ldt_pstart+3		; fat table: x-mem base bank/dma buffer
269
 2858
270
 2859          000026        	ldt_pbr		.EQU	ldt_psize		; long pointer to PBR cache buffer
271
 2860          000029        	ldt_fmt		.EQU	ldt_psize+3
272
 2861
273
 2862  00002A                	 ESTRUCT	LDT
274
 2863  00002A                	LDTSIZE	.DS	0
275
 2864                        			;.RELATIVE
276
 2865                        			.ENDS
277
 2866                        		.MNLIST
278
 2867
279
 2868          [00]          	.ENDIF
280
 2869
281
 2870  F8FFB1
282
 2871                        	;---------------------------------------------------------------------------
283
 2872                        	; Hierarchical Path List (HPL) -- 16 bit offset's
284
 2873                        	;---------------------------------------------------------------------------
285
 2874
286
 2875  F8FFB1                	 LSTRUCT	HPL
287
 2876                        	_HPL	.SECTION common,ref_only,offset 0	;HPL Struct
288
 2877                        		.MNLIST
289
 2878  000000  0000          	hpl_cls		.DW		; parent cluster
290
 2879  000002  0000          	hpl_ix		.DW		; entry index in parent cluster
291
 2880  000004                	hpl_fcb		.DS	11	; fcb name
292
 2881  00000F  00            	hpl_lst		.DB		; unused
293
 2882  000010                	 ESTRUCT	HPL
294
 2883  000010                	HPLSIZE	.DS	0
295
 2884                        			;.RELATIVE
296
 2885                        			.ENDS
297
 2886                        		.MNLIST
298
 2887
299
 2888                        	;---------------------------------------------------------------------------
300
 2889                        	; Buffer Control Block (BCB) -- 16 bit offset's
301
 2890                        	;---------------------------------------------------------------------------
302
 2891
303
 2892  F8FFB1                	 LSTRUCT	BCB
304
 2893                        	_BCB	.SECTION common,ref_only,offset 0	;BCB Struct
305
 2894                        		.MNLIST
306
 2895  000000  0000          	bcb_next	.DW			; next logical linked BCB
307
 2896  000002  00            	bcb_drv		.DB			; logical drive
308
 2897  000003  00            	bcb_sec		.DB			; sector offset
309
 2898  000004  0000          	bcb_cls		.DW			; cluster
310
 2899  000006  0000          	bcb_lba		.DW			; sector lba address
311
  Tue Jul 17 11:00:21 2018                                                                                               Page    6
312
 
313
 
314
 
315
 
316
 2900  000008  0000          	bcb_lbah	.DW			; lba high
317
 2901          000008        	bcb_head	.EQU	bcb_lbah	; floppy head
318
 2902  00000A  0000          	bcb_buf		.DW			; x-mem buffer number
319
 2903          00000A        	bcb_trk		.EQU	bcb_buf		; floppy track(low) & sector(hi)
320
 2904  00000C  0000          	bcb_ptr		.DW			; buffer pointer
321
 2905  00000E  0000          	bcb_xbnk	.DW			; buffer pointer hi & x-mem bank
322
 2906          00000E        	bcb_dma		.EQU	bcb_xbnk	; buffer pointer hi & dma buffer
323
 2907  000010                	 ESTRUCT	BCB
324
 2908  000010                	BCBSIZE	.DS	0
325
 2909                        			;.RELATIVE
326
 2910                        			.ENDS
327
 2911                        		.MNLIST
328
 2912
329
 2913                        	;---------------------------------------------------------------------------
330
 2914                        	; hash Control Block (BCB) -- 16 bit offset's
331
 2915                        	;---------------------------------------------------------------------------
332
 2916
333
 2917  F8FFB1                	 LSTRUCT	HCB
334
 2918                        	_HCB	.SECTION common,ref_only,offset 0	;HCB Struct
335
 2919                        		.MNLIST
336
 2920  000000  0000          	hcb_next	.DW		; pointer to next HCB
337
 2921  000002  0000          	hcb_cls		.DW		; cluster number
338
 2922  000004  0000          	hcb_seq		.DW		; sequence number + logical drive number
339
 2923  000006  0000          	hcb_cnt		.DW		; number of hashed entries
340
 2924  000008                	hcb_data	.DS	0	; hash buffer data
341
 2925  000008                	 ESTRUCT	HCB
342
 2926  000008                	HCBSIZE	.DS	0
343
 2927                        			;.RELATIVE
344
 2928                        			.ENDS
345
 2929                        		.MNLIST
346
 2930
347
 2931                        	;---------------------------------------------------------------------------
348
 2932                        	; TOS Working Segment
349
 2933                        	;---------------------------------------------------------------------------
350
 2934
351
 2935          000001        	WKB		.EQU	.SEG.TOSSEG	; TOS working bank
352
 2936
353
 2937          010000        	TS		.SET	TOSSEG
354
 2938          01FFFF        	TE		.SET	TOSSEG + $FFFF
355
 2939          018C00        	TO0		.SET	$018C00
356
 2940          019E00        	TO1		.SET	TOSWKM
357
 2941
358
 2942                        	.comment @
359
 2943                        	_TOS0:	.SECTION ref_only, common, offset TO0, range TS TE ;FAT Struct's
360
 2944                        	_TOS0_START	.DS	0
361
 2945
362
 2946                        	_pbr0		.DS	512
363
 2947                        	_pbr1		.DS	512
364
 2948                        	_pbr2		.DS	512
365
 2949                        	_pbr3		.DS	512
366
 2950
367
 2951                        	_TOS0_END	.DS	0
368
 2952                        	TOS0SIZ		.EQU	(_TOS0_END - _TOS0_START)
369
 2953                        	.ENDS
370
 2954                        	@
371
 2955
372
 2956                        	_TOS1:	.SECTION ref_only, common, offset TO1, range TS TE ;FAT Struct's
373
  Tue Jul 17 11:00:21 2018                                                                                               Page    7
374
 
375
 
376
 
377
 
378
 2957  019E00                	_TOS1_START	.DS	0
379
 2958
380
 2959                        	; current working directory HPL
381
 2960  019E00                	cwdl0		.DS	(HPLSIZE*HPLMAX)
382
 2961  01A000                	cwdl1		.DS	(HPLSIZE*HPLMAX)
383
 2962  01A200                	cwdl2		.DS	(HPLSIZE*HPLMAX)
384
 2963  01A400                	cwdl3		.DS	(HPLSIZE*HPLMAX)
385
 2964
386
 2965                        	; current building path HPL
387
 2966  01A600                	cbpl		.DS	(HPLSIZE*HPLMAX)
388
 2967          01A600        	HPL_CLS		.EQU	hpl_cls+cbpl
389
 2968          01A602        	HPL_IX		.EQU	hpl_ix+cbpl
390
 2969          01A604        	HPL_FCB		.EQU	hpl_fcb+cbpl
391
 2970
392
 2971                        	; BCB list's
393
 2972  01A800                	bcbstart	.DS	(BCBCNT*BCBSIZE)
394
 2973  01C800                	bcbend		.DS	0
395
 2974  01C800                	dmastart	.DS	(DMACNT*BCBSIZE)
396
 2975  01CC00                	dmaend		.DS	0
397
 2976  01CC00                	dma0s		.DS	(17*BCBSIZE)
398
 2977  01CD10                	dma1s		.DS	(17*BCBSIZE)
399
 2978
400
 2979  01CE20                	_TOS1_END	.DS	0
401
 2980          003020        	TOS1SIZ		.EQU	(_TOS1_END - _TOS1_START)
402
 2981                        	.ENDS
403
 2982
404
 2983                        	;---------------------------------------------------------------------------
405
 2984                        	; HCB Segment
406
 2985                        	;---------------------------------------------------------------------------
407
 2986
408
 2987          000004        	HCBBNK		.EQU	.SEG.HCBSEG
409
 2988          040000        	HS		.SET	HCBSEG
410
 2989          04FFFF        	HE		.SET	HCBSEG + $FFFF
411
 2990          040000        	HO		.SET	HCBSEG
412
 2991
413
 2992                        	_HCBS:	.SECTION ref_only, common, offset HO, range HS HE	;HCB's List
414
 2993  040000                	hcb_bnk		.DS	8
415
 2994  040008                	hcbstart	.DS	0
416
 2995                        	.ENDS
417
 2996
418
 2997                        	;.comment @
419
 2998                        	;---------------------------------------------------------------------------
420
 2999                        	; direct page for LDT var's
421
 3000                        	;---------------------------------------------------------------------------
422
 3001
423
 3002                        	; P0OS
424
 3003                        	DPOS:	.SECTION page0, common, ref_only, offset 0	;OS Main D.P.
425
 3004
426
 3005                        	;sysbuf		.DS	2	; floppy track 0 cache buffer
427
 3006  000000  00            	defhsec		.DB		; default hidden sector's in fdisk
428
 3007  000001  00            			.DB
429
 3008  000002  0000          	cmdstk		.DW		; saved stack on TOS command's
430
 3009  000004                	bpath		.DS	80
431
 3010
432
 3011  000054                	bpath1		.DS	0
433
 3012                        	.ENDS
434
 3013                        	;@
435
  Tue Jul 17 11:00:21 2018                                                                                               Page    8
436
 
437
 
438
 
439
 
440
 3014
441
 3015                        	; P0LDT
442
 3016                        	DPLDT:	.SECTION page0, common, ref_only, offset 0	;LDT D.P.
443
 3017
444
 3018  000000                	ldt0		.DS	LDTSIZE
445
 3019  00002A                	ldt1		.DS	LDTSIZE
446
 3020  000054                	ldt2		.DS	LDTSIZE
447
 3021  00007E                	ldt3		.DS	LDTSIZE
448
 3022  0000A8                	ldt4		.DS	LDTSIZE
449
 3023
450
 3024  0000D2                	ldtp		.DS	6	; pointer to LDT's in DPLDT page
451
 3025
452
 3026  0000D8                	sysbuf		.DS	4	; floppy track 0 cache buffer
453
 3027
454
 3028                        	.ENDS
455
 3029
456
 3030                        	;---------------------------------------------------------------------------
457
 3031                        	; direct page for FAT var's
458
 3032                        	;---------------------------------------------------------------------------
459
 3033
460
 3034                        	; P0FAT
461
 3035                        	DPFAT:	.SECTION page0, common, ref_only, offset 0	;FAT D.P.
462
 3036
463
 3037  000000  0000          	ostos		.DW		; saved top of stack
464
 3038  000002  00            	ioerr		.DB		; i/o error
465
 3039  000003  00            	ioerr2		.DB		; extended i/o error
466
 3040  000004  0000          	hcbroot		.DW		; HCB struct's list
467
 3041  000006  0000          	hcblst		.DW		; the last one HCB
468
 3042  000008  00            	hsiz		.DB		; how many sector's an HCB can hold
469
 3043  000009  00            	hlog2		.DB		; shift count related to hsiz
470
 3044  00000A  0000          	bcbroot		.DW		; BCB buffer's list
471
 3045  00000C  0000          	bcblst		.DW		; the last one BCB
472
 3046  00000E  0000          	dmaroot		.DW		; dma BCB buffer's list
473
 3047  000010  0000          	dmalst		.DW		; the last one dma BCB
474
 3048  000012  0000          	dmabcb		.DW		; BCB list for floppy root, cluster#2,#3&#4
475
 3049  000014  00            	fspt		.DB		; sector per track (floppy)
476
 3050  000015  00            	pdrive		.DB		; phisycal drive number
477
 3051  000016  00            	bplvl		.DB		; subdir level while build path
478
 3052  000017  00            	defdrv		.DB		; default drive
479
 3053
480
 3054                        	; the first block of ldt_ var's is copied from the LDT struct
481
 3055  000018  00            	ldtfg1		.DB		; logical volume flag's
482
 3056                        					; <7>: device ready (fdc drive or ata device)
483
 3057                        					; <6>: if=1->HD/CF else->FD
484
 3058                        					; <0>: phisycal device number
485
 3059
486
 3060  000019  00            	ldtfg2		.DB		; <7>: valid volume (fat volume or cbm disk)
487
 3061                        					; <6>: if=1->FAT else->CBM (FD only)
488
 3062                        					; <5>: disk format checked
489
 3063                        					; <1:0>: disk format (fdc only)
490
 3064
491
 3065  00001A                	ldtfp		LP		; fat table buffer long pointer
492
 3066  00001D  00            	ldtfbuf		.DB		; fat table: x-mem base bank/dma buffer
493
 3067
494
 3068  00001E  0000          	ldtroot		.DW		; lba of root dir
495
 3069  000020  0000          	ldtfat1		.DW		; lba of fat1 table
496
 3070  000022  0000          	ldtfat2		.DW		; lba of fat2 table
497
  Tue Jul 17 11:00:21 2018                                                                                               Page    9
498
 
499
 
500
 
501
 
502
 3071  000024  0000          	ldtcls		.DW		; lba of first data cluster
503
 3072  000026  0000          	ldtmax		.DW		; max usable cluster + 1
504
 3073  000028  00            	ldtcsiz		.DB		; cluster size (1,2,4,8,16,32,64)
505
 3074  000029  00            	ldtcshf		.DB		; cluster shift (0,1,2,3,4,5,6)
506
 3075  00002A  00            	ldtfsiz		.DB		; fat table size (if 0 -> 256)
507
 3076  00002B  00            	ldtrsiz		.DB		; root dir. size (sector's)
508
 3077  00002C  0000          	ldtrent		.DW		; root dir. max. entries
509
 3078  00002E  0000          	ldtcent		.DW		; max. entries in dir. cluster
510
 3079  000030  0000          	ldteoc		.DW		; end of cluster chain marker
511
 3080  000032  00            	ldtmcls		.DB		; mask for clust. module: 00,01,03,07,0F,1F,3F
512
 3081  000033  00            	ldtfmt		.DB		; floppy disk format (0,1,2, FF if ata device)
513
 3082  000034  0000          	ldtcdlp		.DW		; current working dir list pointer
514
 3083  000036  0000          	ldtcdcls	.DW		; current working dir start cluster
515
 3084  000038  0000          	ldtfree		.DW		; count of free cluster's
516
 3085  00003A  0000          	ldtnxt		.DW		; next free cluster
517
 3086  00003C  00            	ldtcdlvl	.DB		; current working dir level count
518
 3087  00003D                	ldtpbr		LP		; long pointer to PBR cache buffer
519
 3088
520
 3089  000040  0000          	chdcls		.DW		; last accessed chained dir. cluster
521
 3090  000042  0000          	clsofs		.DW		; cluster's offset from start of chain
522
 3091
523
 3092                        	; not change order of the 2 following var's: will be accessed as 16 bit var
524
 3093  000044  00            	entofs		.DB		; entry offset from start of sector
525
 3094  000045  00            	secofs		.DB		; sector's offset from start of cluster
526
 3095
527
 3096  000046  0000          	dircls		.DW		; directory cluster
528
 3097  000048  0000          	dcnt		.DW		; directory entry counter
529
 3098  00004A  0000          	lba		.DW		; lba sector address
530
 3099  00004C  0000          	lbah		.DW		; lba is 24 bit's only
531
 3100  00004E  0000          	xbuf		.DW		; x-mem buffer transfer number
532
 3101
533
 3102          00004C        	fhead		.EQU	lbah	; fd head
534
 3103          00004E        	ftrack		.EQU	xbuf	; fd track
535
 3104          00004F        	fsec		.EQU	xbuf+1	; fd sector
536
 3105
537
 3106  000050  00            	dfcbtyp		.DB		; FCB type to search
538
 3107  000051  00            	dfcbatt		.DB		; attribute of found FCB
539
 3108
540
 3109  000052  00            	curdrv		.DB		; current logical drive
541
 3110  000053                	fcbs		.DS	11	; file control block name
542
 3111
543
 3112                        	;dcmask		.DW		; mask to start of cluster
544
 3113                        					; FFF0, FFE0, FFC0, FF80, FF00, FE00
545
 3114
546
 3115  00005E  0000          	fcbp		.DW		; FCB buffer long pointer
547
 3116  000060  0000          			.DW		; low=fcbp+2, high=x-mem bank or dma buffer
548
 3117          000061        	dmabuf		.EQU	fcbp+3	; dma buffer #
549
 3118          000061        	xmbank		.EQU	fcbp+3	; x-mem bank #
550
 3119
551
 3120                        	; temp area
552
 3121  000062  00            	hcbseq		.DB
553
 3122  000063  00            	hcbdrv		.DB
554
 3123  000064  0000          	bcbcls		.DW
555
 3124  000066  00            	bcbdrv		.DB
556
 3125  000067  00            	bcbsec		.DB
557
 3126
558
 3127  000068  0000          	thash		.DW
559
  Tue Jul 17 11:00:21 2018                                                                                               Page   10
560
 
561
 
562
 
563
 
564
 3128          000068        	hcbrec	.EQU	thash
565
 3129          000068        	wtmp	.EQU	thash
566
 3130
567
 3131  00006A  0000          	hlast		.DW
568
 3132  00006C  0000          	hcbcls		.DW
569
 3133  00006E  0000          	hcbx		.DW
570
 3134  000070  0000          	hcby		.DW
571
 3135          00006A        	tmpp	.EQU	hlast	; temp. long pointer
572
 3136          00006E        	tmpx	.EQU	hcbx
573
 3137          00006F        	wild	.EQU	hcbx+1
574
 3138          000070        	fsiz	.EQU	hcby
575
 3139          000071        	fptr	.EQU	hcby+1
576
 3140          00006E        	ldrv	.EQU	hcbx
577
 3141          00006F        	tmpldt	.EQU	hcbx+1
578
 3142
579
 3143  000072  0000          	fhash		.DW
580
 3144  000074  0000          	fcbofs		.DW
581
 3145  000076  00            	bcbload		.DB
582
 3146  000077  00            	xstart		.DB
583
 3147  000078  00            	xend		.DB
584
 3148  000079  00            	seccnt		.DB
585
 3149  00007A  00            	maxseq		.DB
586
 3150  00007B  00            	dsiz		.DB
587
 3151
588
 3152  00007C  00            	haswld		.DB
589
 3153  00007D  00            	strix		.DB
590
 3154  00007E                	pathp		LP		; long pointer to path string
591
 3155
592
 3156                        	; TEMP
593
 3157  000081  0000          	quot		.DW
594
 3158  000083  0000          	dvsor		.DW
595
 3159  000085  0000          	troot		.DW
596
 3160  000087  0000          	tlst		.DW
597
 3161  000089  0000          	bdmask		.DW
598
 3162  00008B  0000          	bcmask		.DW
599
 3163
600
 3164  00008D  00            	hcbuse		.DB
601
 3165
602
 3166                        	.ENDS
603
 3167
604
 3172                        	.LIST on
605
 3173
606
 3174                        	; P0OS
607
 3175                        	; page 0 (LDT var's) local var's
608
 3176                        	_FSTMP:	.SECTION page0, ref_only, offset bpath
609
 3177          000004        	FSTMP_START	.EQU	$
610
 3178
611
 3179  000004  0000 0000     	maxsec		.LWORD		; ata device max sector's
612
 3180  000008  0000 0000     	hidsec		.LWORD		; hidden sectors
613
 3181  00000C  0000 0000     	totsec		.LWORD		; partition size in sector's
614
 3182  000010  0000          	maxcnt		.DW		; max. cluster's count
615
 3183  000012  0000          	first		.DW		; relative first data sector
616
 3184
617
 3185          000012        	totrsv		.EQU	first
618
 3186          000004        	bcbbnk		.EQU	maxsec
619
 3187          000006        	hcbsiz		.EQU	maxsec+2
620
 3188          000010        	hcbrem		.EQU	maxcnt
621
  Tue Jul 17 11:00:21 2018                                                                                               Page   11
622
 
623
 
624
 
625
 
626
 3189          000004        	tbdrv		.EQU	maxsec
627
 3190          000006        	tbcls		.EQU	maxsec+2
628
 3191          000008        	tblba		.EQU	hidsec
629
 3192          00000A        	tbhead		.EQU	hidsec+2
630
 3193          00000C        	tbtrk		.EQU	totsec
631
 3194          00000E        	tbptr		.EQU	totsec+2
632
 3195          000010        	tbdma		.EQU	maxcnt
633
 3196          000004        	fdopt		.EQU	maxsec
634
 3197          000005        	fdarg		.EQU	maxsec+1
635
 3198          000006        	fdlbl		.EQU	maxsec+2
636
 3199
637
 3200  000014  0000          	clscnt		.DW		; cluster's count #
638
 3201  000016  0000          	rsvsec		.DW		; reserved sector's
639
 3202  000018  0000          	fatsiz		.DW		; FAT16 fat table size
640
 3203  00001A  0000          	rootsiz		.DW		; root directory size
641
 3204  00001C  0000          	rootent		.DW		; root dir. max. entries
642
 3205  00001E  0000          	clsent		.DW		; sub-diectory max. entries
643
 3206  000020  0000          	root		.DW		; root dir start
644
 3207  000022  0000          	fat1		.DW		; fat1 table start
645
 3208  000024  0000          	fat2		.DW		; fat 2 table start
646
 3209  000026  0000          	start		.DW		; first data sector
647
 3210  000028  0000          	maxcls		.DW		; last usable cluster+1
648
 3211  00002A  0000          	xfatb		.DW		; x-mem fat table buffer
649
 3212
650
 3213          00002A        	fdix		.EQU	xfatb	; floppy disk index DD/HD
651
 3214          00002B        	media		.EQU	xfatb+1	; floppy disk media field
652
 3215
653
 3216  00002C  0000          	flba		.DW		; low 16 bit lba
654
 3217  00002E  0000          	freecnt		.DW		; free cluster's count
655
 3218  000030  0000          	freecls		.DW		; first free cluster
656
 3219
657
 3220          00002E        	remsec		.EQU	freecnt
658
 3221
659
 3222  000032                	pbrp		LP		; PBR pointer
660
 3223  000035  00            	clssiz		.DB		; cluster size
661
 3224  000036  00            	clsshf		.DB		; cluster shift
662
 3225  000037  00            	clsmod		.DB
663
 3226  000038  00            	xbnk		.DB		; x-mem bank
664
 3227  000039  00            	lunit		.DB		; unity letter
665
 3228  00003A                	tp		LP		; fat cache pointer
666
 3229  00003D  00            	fdfmt		.DB		; floppy format
667
 3230  00003E  00            	pdev		.DB		; phisycal device
668
 3231  00003F  00            	ldev		.DB		; logical device
669
 3232  000040  00            	ldtcur		.DB		; current LDT ptr
670
 3233  000041  00            	lflag		.DB		; flag load fat table
671
 3234  000042  00            	rtcsec		.DB		; seconds
672
 3235  000043  00            	rtcmin		.DB		; minutes
673
 3236
674
 3237          000042        	badcls		.EQU	rtcsec
675
 3238
676
 3239  000044  00            	rtchour		.DB		; hours
677
 3240  000045  00            	rtcday		.DB		; day of month
678
 3241  000046  00            	rtcmonth	.DB		; month
679
 3242  000047  00            	rtcyear		.DB		; year
680
 3243  000048  0000          	ctime		.DW		; compact time
681
 3244  00004A  0000          	cdate		.DW
682
 3245  00004C                	tlp		LP
683
  Tue Jul 17 11:00:21 2018                                                                                               Page   12
684
 
685
 
686
 
687
 
688
 3246  00004F  00            	fd2ix		.DB
689
 3247
690
 3248          00004F        	nulptr		.EQU	fd2ix	; flag null ptr
691
 3249
692
 3250  000050  00            	rootbnk		.DB
693
 3251
694
 3252          000050        	getfmt		.EQU	rootbnk	; get format from floppy disk
695
 3253
696
 3254  000051  00            	fatbnk		.DB
697
 3255  000052  00            	clsbnk		.DB
698
 3256  000053  00            	sec100		.DB		; tenths of seconds for ctime (ms stamp)
699
 3257
700
 3258          000050        	FSTMP_SIZ	.EQU	($-FSTMP_START)
701
 3259                        		.ENDS
702
 3263                        	.LIST on
703
 3264
704
 3265                        	;---------------------------------------------------------------------------
705
 3266                        	; code segment -- bank $F9
706
 3267                        	;---------------------------------------------------------------------------
707
 3268
708
 3269                        		.CODEF9
709
 3270                        		.EXTERN cbmfs_cmd, cbmfs_err	; fscbm.asm
710
 3271                        		.EXTERN lhdfmt, shpart, lfdisk	; fsint.asm
711
 3272                        		.EXTERN	prslbl			; fatdir.asm
712
 3273                        		.EXTERN _getopt			; FA/getopt.asm
713
 3274
714
 3275                        		.LONGA	off
715
 3276                        		.LONGI	off
716
 3277
717
 3278                        	;---------------------------------------------------------------------------
718
 3279                        	; System interface -- built in command's
719
 3280                        	;---------------------------------------------------------------------------
720
 3281
721
 3282          000013        	lpCmd	.SET	STKPRMS
722
 3283
723
 3284  F9001D                	tos_cmd:
724
 3285                        		.GLOBAL	tos_cmd
725
 3286
726
 3287  F9001D  A3 12         		lda	STKPBR,s	; bank where was executed cop instruction
727
 3288  F9001F  85 53         		sta	COPPtr+2
728
 3289  F90021                		ACC16			; retrieve function number
729
 3290  F90021  C2 20         		rep	#PMFLAG
730
 3291                        		.LONGA	on
731
 3292                        		.MNLIST
732
 3293  F90023  A3 10         		lda	STKPCL,s	; pointer to byte after signature
733
 3294  F90025  85 51         		sta	COPPtr
734
 3295  F90027  1A            		inc	a		; update return address
735
 3296  F90028  83 10         		sta	STKPCL,s
736
 3297  F9002A  A7 51         		lda	[COPPtr]	; byte after signature: function number #
737
 3298  F9002C  AA            		tax			; X=function number
738
 3299  F9002D  A9 00 42      		lda	#P0OS		; set dpr
739
 3300  F90030  5B            		tcd
740
 3301  F90031  3B            		tsc			; save stack pointer
741
 3302  F90032  85 02         		sta	cmdstk
742
 3303  F90034  A3 13         		lda	lpCmd,s
743
 3304  F90036  85 4C         		sta	tlp
744
 3305  F90038                		ACC08
745
  Tue Jul 17 11:00:21 2018                                                                                               Page   13
746
 
747
 
748
 
749
 
750
 3306  F90038  E2 20         		sep	#PMFLAG
751
 3307                        		.LONGA	off
752
 3308                        		.MNLIST
753
 3309  F9003A  A3 15         		lda	lpCmd+2,s
754
 3310  F9003C  85 4E         		sta	tlp+2
755
 3311  F9003E  E0 02         		cpx	#MAXCMDS
756
 3312  F90040  B0 08         		bcs	?10		; invalid function
757
 3313  F90042  8A            		txa
758
 3314  F90043  0A            		asl	a
759
 3315  F90044  AA            		tax			; function index
760
 3316  F90045  FC EF 02      		jsr	(CMDJMP,x)
761
 3317  F90048  80 0B         		bra	?15
762
 3318  F9004A  DA            	?10:	phx
763
 3319  F9004B  4B            		phk
764
 3320  F9004C  F4 58 00      		pea	#!?20
765
 3321  F9004F  A9 05         		lda	#5
766
 3322  F90051  48            		pha
767
 3323  F90052                		BPRINTF
768
 3324  F90052  02 11         		cop	$11
769
 3325                        		.MNLIST
770
 3326  F90054  38            		sec
771
 3327  F90055  A9 01         	?15:	lda	#1		; return always 1 if error
772
 3328  F90057  6B            		rtl
773
 3329
774
 3330  F90058  69 6E 76 61 6C 	?20:	.DB	'invalid shell function number (%bu).', 13, 0
775
               69 64 20 73 68
776
               65 6C 6C 20 66
777
               75 6E 63 74 69
778
               6F 6E 20 6E 75
779
               6D 62 65 72 20
780
               28 25 62 75 29
781
               2E 0D 00
782
 3331
783
 3332                        	; fdisk command
784
 3333                        	;
785
 3334                        	;	fdisk [-s] X:		; show partition on drive X
786
 3335                        	;	fdisk -d X:		; delete partition on drive X
787
 3336                        	;	fdisk -c [-llabel] X:	; create partition on drive X and format it
788
 3337                        	;
789
 3338  F9007E                	fdisk:
790
 3339  F9007E  20 EF 01      		jsr	fdskopt		; get option (A=drive)
791
 3340  F90081  B0 10         		bcs	?10
792
 3341  F90083  A4 04         		ldy	fdopt
793
 3342  F90085  D0 03         		bne	?02
794
 3343  F90087  4C C1 16      		jmp	shpart		; show partition
795
 3344  F9008A  88            	?02:	dey
796
 3345  F9008B  F0 06         		beq	?04		; delete partition
797
 3346  F9008D  A4 06         		ldy	fdlbl		; flag label
798
 3347  F9008F  AA            		tax			; drive
799
 3348  F90090  4C EB 0E      		jmp	lfdisk		; create & format
800
 3349  F90093                	?04:
801
 3350  F90093  60            	?10:	rts
802
 3351
803
 3352                        	; format logical drive
804
 3353                        	;
805
 3354                        	;	param's (5 bytes)
806
 3355                        	;
807
  Tue Jul 17 11:00:21 2018                                                                                               Page   14
808
 
809
 
810
 
811
 
812
 3356                        	;		bDrive		logical drive number
813
 3357                        	;		bFmt		format (0,1 or 2) + quick flag (bit 7)
814
 3358                        	;		lpLabel		long ptr to label string (volume name)
815
 3359                        	;
816
 3360                        	; param's offset
817
 3361          000015        	lpLabel	.SET	STKPRMS + 2
818
 3362          000018        	bFmt	.SET	STKPRMS + 5
819
 3363          000019        	bDrive	.SET	STKPRMS + 6
820
 3364
821
 3365  F90094                	format:
822
 3366  F90094  A3 19         		lda	bDrive,s
823
 3367  F90096  20 9A 01      		jsr	chkdrv		; valid drive number?
824
 3368  F90099  85 3F         		sta	ldev		; logical drive
825
 3369  F9009B  A8            		tay
826
 3370  F9009C  A3 18         		lda	bFmt,s
827
 3371  F9009E  85 41         		sta	lflag		; quick format flag
828
 3372  F900A0  29 03         		and	#3
829
 3373  F900A2  C9 03         		cmp	#3
830
 3374  F900A4  D0 02         		bne	?04
831
 3375  F900A6  A9 02         		lda	#2		; force dos HD format
832
 3376  F900A8  85 3D         	?04:	sta	fdfmt
833
 3377  F900AA  B6 D2         		ldx	ldtp,y
834
 3378  F900AC  86 40         		stx	ldtcur		; LDT ptr
835
 3379  F900AE  20 81 01      		jsr	chkrdy		; drive is ready?
836
 3380  F900B1                		ACC16
837
 3381  F900B1  C2 20         		rep	#PMFLAG
838
 3382                        		.LONGA	on
839
 3383                        		.MNLIST
840
 3384  F900B3  A3 15         		lda	lpLabel,s	; get label string pointer
841
 3385  F900B5  8D 7E 41      		sta	!P0FAT+pathp
842
 3386  F900B8  85 4C         		sta	tlp
843
 3387  F900BA                		ACC08
844
 3388  F900BA  E2 20         		sep	#PMFLAG
845
 3389                        		.LONGA	off
846
 3390                        		.MNLIST
847
 3391  F900BC  A0 00         		ldy	#0
848
 3392  F900BE  A3 17         		lda	lpLabel+2,s
849
 3393  F900C0  85 4E         		sta	tlp+2		; test null ptr
850
 3394  F900C2  8D 80 41      		sta	!P0FAT+pathp+2
851
 3395  F900C5  05 4D         		ora	tlp+1
852
 3396  F900C7  05 4C         		ora	tlp
853
 3397  F900C9  F0 01         		beq	?06		; no label
854
 3398  F900CB  88            		dey			; Y=$FF
855
 3399  F900CC  84 4F         	?06:	sty	nulptr		; flag null ptr
856
 3400  F900CE  34 00         		bit	ldt_fg1,x	; test fixed disk/floppy disk
857
 3401  F900D0  70 13         		bvs	?12		; fixed disk
858
 3402  F900D2  20 67 01      		jsr	tstfd		; test floppy disk format
859
 3403  F900D5  A5 50         		lda	getfmt		; here X=phisycal drive
860
 3404  F900D7  30 04         		bmi	?08		; can't use quick format
861
 3405  F900D9  C5 3D         		cmp	fdfmt		; compare with requested format
862
 3406  F900DB  F0 02         		beq	?10		; we can use quick format
863
 3407  F900DD  64 41         	?08:	stz	lflag		; standard full fd format
864
 3408  F900DF  A5 3D         	?10:	lda	fdfmt
865
 3409  F900E1  C9 01         		cmp	#1
866
 3410                        		;bne	?12		; ibm-dos format
867
 3411  F900E3  F0 23         		beq	cbmfmt		; cbm format
868
 3412  F900E5  98            	?12:	tya
869
  Tue Jul 17 11:00:21 2018                                                                                               Page   15
870
 
871
 
872
 
873
 
874
 3413  F900E6  F0 12         		beq	?16		; no volume name specified
875
 3414  F900E8  0B            		phd
876
 3415  F900E9  F4 00 41      		pea	#P0FAT
877
 3416  F900EC  2B            		pld
878
 3417  F900ED  20 96 1E      		jsr	prslbl		; parse label string
879
 3418  F900F0  2B            		pld
880
 3419  F900F1  90 07         		bcc	?16
881
 3420  F900F3  F0 03         		beq	?14		; empty string
882
 3421  F900F5  4C CB 01      		jmp	invlbl		; invalid label
883
 3422  F900F8  64 4F         	?14:	stz	nulptr		; like if not string given
884
 3423  F900FA  A6 40         	?16:	ldx	ldtcur
885
 3424  F900FC  34 00         		bit	ldt_fg1,x	; test fixed disk/floppy disk
886
 3425  F900FE  50 07         		bvc	?18		; floppy disk
887
 3426  F90100  A6 3E         		ldx	pdev
888
 3427  F90102  A4 4F         		ldy	nulptr
889
 3428  F90104  4C 56 0F      		jmp	lhdfmt
890
 3429  F90107  60            	?18:	rts
891
 3430
892
 3431                        	; format cbm diskette (X=phisycal drive)
893
 3432  F90108                	cbmfmt:
894
 3433  F90108  A5 4F         		lda	nulptr
895
 3434  F9010A  F0 32         		beq	nolbl		; cbm format need a volume name
896
 3435  F9010C  A9 51         		lda	#'Q'		; send command "Qx:...." (quick format)
897
 3436  F9010E  85 04         		sta	bpath
898
 3437  F90110  8A            		txa
899
 3438  F90111  09 30         		ora	#'0'
900
 3439  F90113  85 05         		sta	bpath+1
901
 3440  F90115  A9 3A         		lda	#':'
902
 3441  F90117  85 06         		sta	bpath+2
903
 3442  F90119  A0 00         		ldy	#0
904
 3443  F9011B  A2 03         		ldx	#3
905
 3444  F9011D  B7 4C         	?02:	lda	[tlp],y
906
 3445  F9011F  95 04         		sta	bpath,x
907
 3446  F90121  F0 08         		beq	?04
908
 3447  F90123  C8            		iny
909
 3448  F90124  E8            		inx
910
 3449  F90125  E0 20         		cpx	#32		; max. 32 char's
911
 3450  F90127  90 F4         		bcc	?02
912
 3451  F90129  74 04         		stz	bpath,x		; trunc
913
 3452  F9012B  A9 04         	?04:	lda	#bpath		; address of command string
914
 3453  F9012D  A2 42         		ldx	#>P0OS
915
 3454  F9012F  A0 00         		ldy	#0
916
 3455  F90131  20 F6 2E      		jsr	cbmfs_cmd	; cbm quick format
917
 3456  F90134  B0 01         		bcs	cbmerr
918
 3457  F90136  60            		rts
919
 3458  F90137
920
 3459                        	;---------------------------------------------------------------------------
921
 3460                        	; check routines & error handling
922
 3461                        	;---------------------------------------------------------------------------
923
 3462
924
 3463                        	; report cbm emulator error
925
 3464  F90137                	cbmerr:
926
 3465  F90137  20 12 2F      		jsr	cbmfs_err	; return error string pointer (C,X)
927
 3466  F9013A                		SCNSTROUT		; print error string
928
 3467  F9013A  02 03         		cop	$03
929
 3468                        		.MNLIST
930
 3469  F9013C  80 7D         		bra	cmderr
931
  Tue Jul 17 11:00:21 2018                                                                                               Page   16
932
 
933
 
934
 
935
 
936
 3470
937
 3471                        	; no label/disk name specified error
938
 3472  F9013E                	nolbl:
939
 3473  F9013E                		SCNPRINT
940
 3474  F9013E  02 01         		cop	$01
941
 3475                        		.MNLIST
942
 3476  F90140  6E 6F 20 6C 61 		.DB	'no label nor cbm disk name specified', 0
943
               62 65 6C 20 6E
944
               6F 72 20 63 62
945
               6D 20 64 69 73
946
               6B 20 6E 61 6D
947
               65 20 73 70 65
948
               63 69 66 69 65
949
               64 00
950
 3477  F90165  80 54         		bra	cmderr
951
 3478
952
 3479                        	; test floppy disk and get format (X=LDT pointer)
953
 3480                        	; return X=phisycal drive
954
 3481  F90167                	tstfd:
955
 3482  F90167  B5 00         		lda	ldt_fg1,x
956
 3483  F90169  29 01         		and	#1
957
 3484  F9016B  AA            		tax			; phisycal drive
958
 3485  F9016C                		FDCTST			; check media inside drive
959
 3486  F9016C  02 30         		cop	$30
960
 3487  F9016E  03            		.DB	$03
961
 3488                        		.MNLIST
962
 3489  F9016F  90 04         		bcc	?02		; media ready
963
 3490  F90171  C0 11         		cpy	#FDC_CHANGE	; check error code
964
 3491  F90173  D0 10         		bne	notrdy		; disk not ready
965
 3492  F90175  A0 FF         	?02:	ldy	#$FF
966
 3493  F90177  84 50         		sty	getfmt		; invalid disk format
967
 3494  F90179                		FDCGETFMT		; try to get media format
968
 3495  F90179  02 30         		cop	$30
969
 3496  F9017B  04            		.DB	$04
970
 3497                        		.MNLIST
971
 3498  F9017C  B0 02         		bcs	?04		; unformatted disk or unknow disk format
972
 3499  F9017E  84 50         		sty	getfmt		; current disk format
973
 3500  F90180  60            	?04:	rts
974
 3501
975
 3502                        	; check drive ready (X=LDT pinter)
976
 3503  F90181                	chkrdy:
977
 3504  F90181  34 00         		bit	ldt_fg1,x
978
 3505  F90183  30 14         		bmi	noer
979
 3506  F90185                	notrdy:	SCNPRINT
980
 3507  F90185  02 01         		cop	$01
981
 3508                        		.MNLIST
982
 3509  F90187  64 72 69 76 65 		.DB	'drive not ready', 0
983
               20 6E 6F 74 20
984
               72 65 61 64 79
985
               00
986
 3510  F90197  80 22         		bra	cmderr
987
 3511
988
 3512  F90199  60            	noer:	rts
989
 3513  F9019A
990
 3514                        	; check drive number (A=drive #)
991
 3515  F9019A                	chkdrv:
992
 3516  F9019A  C9 04         		cmp	#MAXDRV
993
  Tue Jul 17 11:00:21 2018                                                                                               Page   17
994
 
995
 
996
 
997
 
998
 3517  F9019C  90 FB         		bcc	noer
999
 3518  F9019E  18            		clc
1000
 3519  F9019F  F0 F8         		beq	noer		; usb #0 device
1001
 3520  F901A1                	invdrv:	SCNPRINT
1002
 3521  F901A1  02 01         		cop	$01
1003
 3522                        		.MNLIST
1004
 3523  F901A3  69 6E 76 61 6C 		.DB	'invalid drive specified', 0
1005
               69 64 20 64 72
1006
               69 76 65 20 73
1007
               70 65 63 69 66
1008
               69 65 64 00
1009
 3524  F901BB                	cmderr:
1010
 3525  F901BB                		SCNPRINT
1011
 3526  F901BB  02 01         		cop	$01
1012
 3527                        		.MNLIST
1013
 3528  F901BD  2E 0D 00      		.DB	'.', 13, 0
1014
 3529  F901C0                		ACC16CLC
1015
 3530  F901C0  C2 21         		rep	#(PMFLAG.OR.PCFLAG)
1016
 3531                        		.LONGA	on
1017
 3532                        		.MNLIST
1018
 3533  F901C2  A5 02         		lda	cmdstk		; recover stack
1019
 3534  F901C4  1B            		tcs
1020
 3535  F901C5                		ACC08
1021
 3536  F901C5  E2 20         		sep	#PMFLAG
1022
 3537                        		.LONGA	off
1023
 3538                        		.MNLIST
1024
 3539  F901C7  A9 01         		lda	#1
1025
 3540  F901C9  38            		sec
1026
 3541  F901CA  6B            		rtl			; return to caller
1027
 3542
1028
 3543                        	; invalid label
1029
 3544  F901CB                	invlbl:
1030
 3545  F901CB                		SCNPRINT
1031
 3546  F901CB  02 01         		cop	$01
1032
 3547                        		.MNLIST
1033
 3548  F901CD  69 6E 76 61 6C 		.DB	'invalid label', 0
1034
               69 64 20 6C 61
1035
               62 65 6C 00
1036
 3549  F901DB  80 DE         		bra	cmderr
1037
 3550
1038
 3551                        	; missing drive
1039
 3552  F901DD                	nodrv:
1040
 3553  F901DD                		SCNPRINT
1041
 3554  F901DD  02 01         		cop	$01
1042
 3555                        		.MNLIST
1043
 3556  F901DF  6D 69 73 73 69 		.DB	'missing drive', 0
1044
               6E 67 20 64 72
1045
               69 76 65 00
1046
 3557  F901ED  80 CC         		bra	cmderr
1047
 3558
1048
 3559                        	; parse command line for 'fdisk' command
1049
 3560  F901EF                	fdskopt:
1050
 3561  F901EF  64 04         		stz	fdopt
1051
 3562  F901F1  64 05         		stz	fdarg
1052
 3563  F901F3  64 06         		stz	fdlbl
1053
 3564  F901F5  A2 80         		ldx	#$80
1054
 3565  F901F7  DA            		phx			; flag
1055
  Tue Jul 17 11:00:21 2018                                                                                               Page   18
1056
 
1057
 
1058
 
1059
 
1060
 3566  F901F8  A6 4E         		ldx	tlp+2		; command line
1061
 3567  F901FA  DA            		phx
1062
 3568  F901FB  D4 4C         		pei	(tlp)
1063
 3569  F901FD  4B            		phk			; option string
1064
 3570  F901FE  F4 A3 02      		pea	#!?100
1065
 3571  F90201  F4 00 00      		pea	#0		; result
1066
 3572  F90204  F4 00 00      		pea	#0
1067
 3573  F90207  22 09 00 FA   	?10:	jsl	_getopt		; get opttion's loop
1068
 3574  F9020B  B0 48         		bcs	?20		; error
1069
 3575  F9020D  AA            		tax			; option char
1070
 3576  F9020E  F0 45         		beq	?20		; end of command line
1071
 3577  F90210  30 31         		bmi	?18		; no option argument
1072
 3578  F90212  C9 73         		cmp	#'s'
1073
 3579  F90214  D0 04         		bne	?12
1074
 3580  F90216  64 04         		stz	fdopt		; show
1075
 3581  F90218  80 ED         		bra	?10
1076
 3582  F9021A  C9 64         	?12:	cmp	#'d'
1077
 3583  F9021C  D0 06         		bne	?14
1078
 3584  F9021E  A9 01         		lda	#1
1079
 3585  F90220  85 04         		sta	fdopt		; delete
1080
 3586  F90222  80 E3         		bra	?10
1081
 3587  F90224  C9 63         	?14:	cmp	#'c'
1082
 3588  F90226  D0 06         		bne	?16
1083
 3589  F90228  A9 02         		lda	#2
1084
 3590  F9022A  85 04         		sta	fdopt		; create
1085
 3591  F9022C  80 D9         		bra	?10
1086
 3592  F9022E  A3 01         	?16:	lda	$01,s		; argument for 'l' option
1087
 3593  F90230  8D 7E 41      		sta	!P0FAT+pathp
1088
 3594  F90233  A3 02         		lda	$02,s		; store argument pointer
1089
 3595  F90235  8D 7F 41      		sta	!P0FAT+pathp+1
1090
 3596  F90238  A3 03         		lda	$03,s
1091
 3597  F9023A  8D 80 41      		sta	!P0FAT+pathp+2
1092
 3598  F9023D  A9 FF         		lda	#$FF
1093
 3599  F9023F  85 06         		sta	fdlbl
1094
 3600  F90241  80 C4         		bra	?10
1095
 3601  F90243  A3 01         	?18:	lda	$01,s		; argument without option
1096
 3602  F90245  85 4C         		sta	tlp
1097
 3603  F90247  A3 02         		lda	$02,s		; store argument pointer
1098
 3604  F90249  85 4D         		sta	tlp+1
1099
 3605  F9024B  A3 03         		lda	$03,s
1100
 3606  F9024D  85 4E         		sta	tlp+2
1101
 3607  F9024F  A9 80         		lda	#$80
1102
 3608  F90251  85 05         		sta	fdarg
1103
 3609  F90253  80 B2         		bra	?10
1104
 3610  F90255  08            	?20:	php			; clean stack
1105
 3611  F90256  FA            		plx			; save carry
1106
 3612  F90257                		ACC16CLC
1107
 3613  F90257  C2 21         		rep	#(PMFLAG.OR.PCFLAG)
1108
 3614                        		.LONGA	on
1109
 3615                        		.MNLIST
1110
 3616  F90259  3B            		tsc
1111
 3617  F9025A  69 0B 00      		adc	#11
1112
 3618  F9025D  1B            		tcs
1113
 3619  F9025E                		ACC08
1114
 3620  F9025E  E2 20         		sep	#PMFLAG
1115
 3621                        		.LONGA	off
1116
 3622                        		.MNLIST
1117
  Tue Jul 17 11:00:21 2018                                                                                               Page   19
1118
 
1119
 
1120
 
1121
 
1122
 3623  F90260  8A            		txa
1123
 3624  F90261  4A            		lsr	a		; test carry
1124
 3625  F90262  B0 2F         		bcs	?30		; exit
1125
 3626  F90264  24 05         		bit	fdarg
1126
 3627  F90266  30 03         		bmi	?21
1127
 3628  F90268  4C DD 01      		jmp	nodrv
1128
 3629  F9026B  20 CB 02      	?21:	jsr	drvarg
1129
 3630  F9026E  C9 02         		cmp	#ATADRV
1130
 3631  F90270  90 22         		bcc	?40
1131
 3632  F90272  A4 04         		ldy	fdopt
1132
 3633  F90274  C0 02         		cpy	#2
1133
 3634  F90276  D0 1A         		bne	?26
1134
 3635  F90278  24 06         		bit	fdlbl
1135
 3636  F9027A  10 16         		bpl	?26
1136
 3637  F9027C  85 3F         		sta	ldev
1137
 3638  F9027E  0B            		phd
1138
 3639  F9027F  F4 00 41      		pea	#P0FAT
1139
 3640  F90282  2B            		pld
1140
 3641  F90283  20 96 1E      		jsr	prslbl		; parse label string
1141
 3642  F90286  2B            		pld
1142
 3643  F90287  90 07         		bcc	?24
1143
 3644  F90289  F0 03         		beq	?22		; empty string
1144
 3645  F9028B  4C CB 01      		jmp	invlbl		; invalid label
1145
 3646  F9028E  64 06         	?22:	stz	fdlbl		; like if not string given
1146
 3647  F90290  A5 3F         	?24:	lda	ldev
1147
 3648  F90292  18            	?26:	clc
1148
 3649  F90293  60            	?30:	rts
1149
 3650  F90294  69 41         	?40:	adc	#'A'
1150
 3651  F90296  48            		pha
1151
 3652  F90297  4B            		phk
1152
 3653  F90298  F4 AC 02      		pea	#!?110
1153
 3654  F9029B  A9 05         		lda	#5
1154
 3655  F9029D  48            		pha
1155
 3656  F9029E                		BPRINTF
1156
 3657  F9029E  02 11         		cop	$11
1157
 3658                        		.MNLIST
1158
 3659  F902A0  4C BB 01      		jmp	cmderr
1159
 3660
1160
 3661  F902A3  73 20 63 20 64 	?100:	.DB	's c d l:', 0
1161
               20 6C 3A 00
1162
 3662  F902AC  64 72 69 76 65 	?110:	.DB	'drive <%c> is not a fixed disk', 0
1163
               20 3C 25 63 3E
1164
               20 69 73 20 6E
1165
               6F 74 20 61 20
1166
               66 69 78 65 64
1167
               20 64 69 73 6B
1168
               00
1169
 3663
1170
 3664                        	; check if drive argument is valid
1171
 3665  F902CB                	drvarg:
1172
 3666  F902CB  A0 01         		ldy	#1
1173
 3667  F902CD  B7 4C         		lda	[tlp],y
1174
 3668  F902CF  C9 3A         		cmp	#':'
1175
 3669  F902D1  D0 19         		bne	?20
1176
 3670  F902D3  C8            		iny
1177
 3671  F902D4  B7 4C         		lda	[tlp],y
1178
 3672  F902D6  D0 14         		bne	?20
1179
  Tue Jul 17 11:00:21 2018                                                                                               Page   20
1180
 
1181
 
1182
 
1183
 
1184
 3673  F902D8  A7 4C         		lda	[tlp]
1185
 3674  F902DA  C9 61         		cmp	#'a'
1186
 3675  F902DC  90 06         		bcc	?08
1187
 3676  F902DE  C9 7B         		cmp	#'z'+1
1188
 3677  F902E0  B0 03         		bcs	?10
1189
 3678  F902E2  29 DF         		and	#$DF
1190
 3679  F902E4  38            	?08:	sec
1191
 3680  F902E5  E9 41         	?10:	sbc	#'A'
1192
 3681  F902E7  90 03         		bcc	?20
1193
 3682  F902E9  4C 9A 01      		jmp	chkdrv
1194
 3683  F902EC  4C A1 01      	?20:	jmp	invdrv
1195
 3684
1196
 3685                        	;---------------------------------------------------------------------------
1197
 3686                        	; Tables
1198
 3687                        	;---------------------------------------------------------------------------
1199
 3688
1200
 3689                        	; command's jump table
1201
 3690  F902EF                	CMDJMP:
1202
 3691  F902EF  7E00 9400     		.DW	fdisk, format
1203
 3692
1204
 3693          000002        	MAXCMDS		.EQU	($ - CMDJMP)/2
1205
 
1206
 
1207
             Lines Assembled : 3606                  Errors : 0
1208
 
1209
 
1210