1000 REM "osfile" 1010[OPT Pass 1020.OsArgs \ Return file system no. 1030 Cpy #0 1040 Bne args2 1050 Cmp #0 1060 Bne next_args 1070 Lda #our_fs_no 1080 Rts 1090.next_args 1100 Cmp #1 1110 Bne args2 1120 Lda cline 1130 Sta &0,X 1140 Lda cline+1 1150 Sta &1,X 1160 Lda #0 1170 Sta &2,X 1180 Sta &3,X 1190 Lda #1 1200 Rts 1210.args2 1220 Cpy #2 1230 Bne args3 1240 Pha 1250 Lda #05 \ **************** File length !!!!!!!!!!!! 1260 Sta &0,X 1270 Lda #0 1280 Sta &1,X 1290 Sta &2,X 1300 Sta &2,X 1310 Pla 1320.args3 1330 Rts 1340 1350.attributes 1360 Lda zp0: Pha: Lda zp1: Pha 1370 Ldy #0: Lda (zp0),Y: Tax 1380 Iny: Lda (zp0),Y: Sta zp1 1390 Stx zp0 1400 \ zp0,1 now points to file name string 1410 Ldy #ASC("F") 1420 Jsr transact \ zp0,1 should point to string !!!!!!!!! 1430 Pla: Sta zp1 1440 Pla: Sta zp0 1450 Jsr verify 1460 Jsr GetLoadAddr \ reads 16 bytes, reads esc 1470.sneaky_fixup 1480 Ldy #2 1490.attr1 1500 Lda info_block-2+4,Y \ load, exec 1510 Sta (zp0),Y 1520 Iny 1530 Cpy #8+2 1540 Bne attr1 1550.attr2 1560 lda info_block-2-8,Y \ len 1570 Sta (zp0),Y 1580 Iny 1590 Cpy #12+2 1600 Bne attr2 1610.attr3 1620 Lda info_block-2,Y \ attr 1630 Sta (zp0),Y 1640 Iny 1650 Cpy #16+2 1660 Bne attr3 1670 Ldx zp0 1680 Ldy zp1 1690 Lda #1 1700 Rts 1710 1720.GetLoadAddr 1730 \ Expect 16 bytes in hex 1740 \ Store in private workspace (info_block) 1750 Lda #0 1760 Sta work1 1770.next_info 1780 Jsr GetHex 1790 Ldy work1 1800 Sta info_block,Y 1810 Inc work1 1820 Cpy #15 1830 Bne next_info 1840 Jsr verify 1850 Rts 1860 1870.starload 1880 \ zp 0,1 point to control block for OSFILE 1890 Ldy #6 1900 Lda (zp0),Y 1910 Beq use_CB 1920 Jsr dobrk 1930 EQUB &FF: EQUS "No load address": EQUB 0 1940.use_CB 1950 Lda zp0: Pha: Lda zp1: Pha 1960 Ldy #0: Lda (zp0),Y: Tax 1970 Iny: Lda (zp0),Y: Sta zp1 1980 Stx zp0 1990 \ zp0,1 now points to file name string 2000 Ldy #ASC("L") 2010 Jsr transact 2020 Jsr verify 2030 Jsr GetLoadAddr 2040 Lda #27 2050 Jsr SendCom 2060 Pla: Sta zp1 2070 Pla: Sta zp0 2080 \ zp 0,1 now ppoint at CB again 2090 Lda #2 2100 Clc 2110 Adc zp0 \ Load address block 2120 Sta scratch0 2130 Lda zp1 2140 Adc #0 2150 Sta scratch1 2160 Jsr initload 2170 Ldy #0 2180 Lda (scratch0),Y 2190 Pha 2200 Iny 2210 Lda (scratch0),Y 2220 Sta scratch1 2230 Pla 2240 Sta scratch0 2250\ Lda scratch1:\ Pha 2260\ Lda scratch0:\ Pha \ Save start addr for working out length 2270.load_loop 2280 Jsr GetHex 2290 Bcs load_done 2300 Jsr putbyte 2310 Inc scratch0 2320 BNE ncy2 2330 Inc scratch1 2340.ncy2 2350 Jmp load_loop 2360.load_done 2370 Jsr reltub 2380 Jsr sneaky_fixup 2390\ Ldy #&0A 2400\ Pla:\ Sta work1 2410\ Lda scratch0:\ Sec:\ Sbc work1 \ Might be a byte too long 2420\ Sta (zp0),Y \ Y<-&A 2430\ Pla:\ Sta work1 2440\ Lda scratch1:\ Sbc work1 2450\ Iny 2460\ Sta (zp0),Y \ Y<-&B 2470\ Iny 2480\ Lda #0 2490\ Sta (zp0),Y 2500\ Iny 2510\ Sta (zp0),Y 2520 Lda #1 \ type code for file. 2530 Ldx zp0 2540 Ldy zp1 2550 Rts 2560.starsave 2570 \ zp 0,1 point to control block for OSFILE 2580 Lda zp0: Pha: Lda zp1: Pha 2590 Ldy #0: Lda (zp0),Y: Tax 2600 Iny: Lda (zp0),Y: Sta zp1 2610 Stx zp0 2620 \ zp0,1 now points to file name string 2630 Ldy #ASC("S") 2640 Jsr transact 2650 Jsr verify 2660 Pla: Sta zp1 2670 Pla: Sta zp0 \zp 0,1 now point to CB again 2680 Lda #&0A 2690 Clc 2700 Adc zp0 2710 Sta scratch0 2720 Lda zp1 2730 Adc #0 2740 Sta scratch1 2750 Jsr initsave 2760 Ldy #0 2770 Lda (scratch0),Y 2780 Pha 2790 Iny 2800 Lda (scratch0),Y 2810 Sta scratch1 2820 Pla 2830 Sta scratch0 2840 Lda #0 2850 Sta work3 2860.next_save 2870 Ldy #&0E: Lda (zp0),Y 2880 Cmp scratch0 2890 bne notend 2900 Iny: Lda (zp0),Y 2910 Cmp scratch1 2920 bne notend 2930 Jmp save_done 2940.notend 2950 Jsr getbyte 2960 Pha 2970 Lsr A:Lsr A:Lsr A:Lsr A 2980 CLC: ADC #ASC("0") 2990 Jsr SendCom 3000 Pla 3010 And #&0F 3020 CLC: ADC #ASC("0") 3030 Jsr SendCom 3040 Inc scratch0 3050 BNE ncy3 3060 inc scratch1 3070.ncy3 3080 Inc work3 3090 Lda work3:And #15:Tay 3091 Bne next_save 3100 Jsr verify 3110 Jmp next_save 3120.save_done 3130 Jsr reltub 3140 Lda #27: jsr SendCom 3150 jsr verify 3160 Ldx zp0 3170 ldy zp1 3180 Lda #0 3190 rts 3200] 3210RETURN