PR#3 PREFIX /A2OSX.SRC NEW INC 1 AUTO 6 .LIST OFF *-------------------------------------- * For All SYS.xxxx calls, X = #SYSCall * Must be kept in X before calling * K.PFTCheck* *-------------------------------------- * K.FOPEN * In : * PULLW = PATH (PSTR) * PULLB = MODE * SYS.FOPEN.R .EQ $01 if R and !exists -> ERROR * SYS.FOPEN.W .EQ $02 if W and !exists -> CREATE * SYS.FOPEN.A .EQ $04 Append * SYS.FOPEN.T .EQ $08 Open/Append in Text mode * SYS.FOPEN.X .EQ $80 Create if not exists * PULLB = TYPE * PULLW = AUXTYPE * Out : * CC : A = hFILE * CS : A = EC *-------------------------------------- K.FOPEN jsr K.PFTCheckPathSTK >PULLW MLICALL.PARAMS+1 >PULLB K.FOPEN.MODE >PULLB K.FOPEN.TYPE >PULLW K.FOPEN.AUXTYPE >MLICALL MLIGETFILEINFO bcc .10 Already Exists bit K.FOPEN.MODE Create if not exists ? bpl .9 No, return MLI error lda #S.FILEINFO.ACCESS.FULL Yes, Create... sta MLICALL.PARAMS+3 Access lda K.FOPEN.TYPE sta MLICALL.PARAMS+4 File type >LDYA K.FOPEN.AUXTYPE >STYA MLICALL.PARAMS+5 Aux type lda #S.FILEINFO.STORETYPE.STD sta MLICALL.PARAMS+7 >MLICALL MLICREATE bcc .10 .9 rts .10 >PUSHWI S.FILE.PRODOS >PUSHBI S.MEM.F.INIT0 jsr K.GetMem bcs .99 >STYA ZPQuickPtr1 stx hFILE >PUSHWI 1024 get a ProDOS IOBUF >PUSHBI S.MEM.F.ALIGN+S.MEM.F.NOMOVE jsr K.GetMem bcs .98 >STYA MLICALL.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call txa ldy #S.FILE.PRODOS.IOBUF sta (ZPQuickPtr1),y >MLICALL MLIOPEN bcs .98 lda MLICALL.PARAMS+5 get ref_num ldy #S.FILE.PRODOS.REF sta (ZPQuickPtr1),y sta MLICALL.PARAMS+1 Next MLI Calls are REF_NUM based lda K.FOPEN.MODE and #SYS.FOPEN.A Append ? beq .20 >MLICALL MLIGETEOF bcs .98 >MLICALL MLISETMARK bcs .98 .20 lda K.FOPEN.MODE and #SYS.FOPEN.T Text Mode ? beq .30 lda #$FF sta MLICALL.PARAMS+2 lda #$0D sta MLICALL.PARAMS+3 >MLICALL MLINEWLINE .30 lda hFILE clc rts CC .98 pha save MLI error jsr K.FCLOSEA.1 pla get back MLI error sec .99 rts *-------------------------------------- K.FOPEN.MODE .BS 1 K.FOPEN.TYPE .BS 1 K.FOPEN.AUXTYPE .BS 2 hFILE .BS 1 *-------------------------------------- * K.FCLOSEA * In : * A = hFILE *-------------------------------------- K.FCLOSEA jsr K.PFTCheckFileA sta hFILE jsr K.GetMemPtrA >STYA ZPQuickPtr1 K.FCLOSEA.1 ldy #S.FILE.PRODOS.REF lda (ZPQuickPtr1),y beq .1 sta MLICALL.PARAMS+1 >MLICALL MLICLOSE .1 ldy #S.FILE.PRODOS.IOBUF lda (ZPQuickPtr1),y beq .2 jsr K.FreeMemA .2 lda hFILE jsr K.FreeMemA rts *-------------------------------------- * K.FREAD * In : * PULLB = hFILE * PULLW = Bytes To Read * PULLW = Dest Ptr * Out : * Y,A = Bytes Read *-------------------------------------- K.FREAD jsr K.PFTCheckFileSTK >PULLA jsr FIL.SetupPrt1A >PULLW MLICALL.PARAMS+4 >PULLW MLICALL.PARAMS+2 >MLICALL MLIREAD bcs .9 >LDYA MLICALL.PARAMS+6 .9 rts *-------------------------------------- * K.FWRITE * In : * PULLB = hFILE * PULLW = Bytes To Write * PULLW = Src Ptr * Out : * Y,A = Bytes Written *-------------------------------------- K.FWRITE jsr K.PFTCheckFileSTK >PULLA jsr FIL.SetupPrt1A >PULLW MLICALL.PARAMS+4 >PULLW MLICALL.PARAMS+2 >MLICALL MLIWRITE bcs .9 >LDYA MLICALL.PARAMS+6 .9 rts *-------------------------------------- * K.FFLUSHA * In : * A = hFILE *-------------------------------------- K.FFLUSHA jsr K.PFTCheckFileA jsr FIL.SetupPrt1A >MLICALL MLIFLUSH rts *-------------------------------------- * K.FSEEK * In : * PULLB = hFILE * PULLB = From * PULLW = OffsetLo * PULLW = OffsetHi *-------------------------------------- K.FSEEK jsr K.PFTCheckFileSTK >PULLA jsr FIL.SetupPrt1A >PULLB K.FSEEK.FROM >PULLW K.FSEEK.OFFSET >PULLW K.FSEEK.OFFSET+2 lda K.FSEEK.FROM * cmp #SYS.FSEEK.SET =0 bne .1 stz MLICALL.PARAMS+2 stz MLICALL.PARAMS+3 stz MLICALL.PARAMS+4 bra .8 .1 cmp #SYS.FSEEK.CUR bne .2 >MLICALL MLIGETMARK bcc .8 rts .2 cmp #SYS.FSEEK.END bne .98 >MLICALL MLIGETEOF bcs .9 .8 lda MLICALL.PARAMS+2 adc K.FSEEK.OFFSET sta MLICALL.PARAMS+2 lda MLICALL.PARAMS+3 adc K.FSEEK.OFFSET+1 sta MLICALL.PARAMS+3 lda MLICALL.PARAMS+4 adc K.FSEEK.OFFSET+2 sta MLICALL.PARAMS+4 bcs .99 Offset out of range! >MLICALL MLISETMARK .9 rts .98 lda #SYSMGR.ERRSYN .HS 2C bit abs .99 lda #SYSMGR.ERRFTB sec rts *-------------------------------------- K.FSEEK.FROM .BS 1 K.FSEEK.OFFSET .BS 4 *-------------------------------------- * K.FTELLA * In : * A = hFILE * Out : * Y,A,X = Offset *-------------------------------------- K.FTELLA jsr K.PFTCheckFileA K.FTELLA.1 jsr FIL.SetupPrt1A >MLICALL MLIGETMARK bcs .9 >LDYA MLICALL.PARAMS+2 ldx MLICALL.PARAMS+4 .9 rts *-------------------------------------- * K.FEOFA * In : * A = hFILE * Out : * CC : * A=0 EOF * A !=0 NOT EOF * CS : *-------------------------------------- K.FEOFA jsr K.PFTCheckFileA jsr FIL.SetupPrt1A jsr K.FTELLA.1 bcs .9 >STYA K.FEOFA.MARK stx K.FEOFA.MARK+2 >MLICALL MLIGETEOF bcs .9 sec lda MLICALL.PARAMS+2 sbc K.FEOFA.MARK bne .8 lda MLICALL.PARAMS+3 sbc K.FEOFA.MARK+1 bne .8 lda MLICALL.PARAMS+4 sbc K.FEOFA.MARK+2 .8 clc .9 rts K.FEOFA.MARK .BS 3 *-------------------------------------- * K.REMOVEYA *-------------------------------------- K.REMOVEYA jsr K.PFTCheckPathYA >STYA MLICALL.PARAMS+1 >MLICALL MLIDESTROY rts *-------------------------------------- * K.RENAME * In : * PULLW = Old Name * PULLW = New Name *-------------------------------------- K.RENAME jsr K.PFTCheckPathSTK >PULLW MLICALL.PARAMS+1 >PULLW MLICALL.PARAMS+3 >MLICALL MLIRENAME rts *-------------------------------------- * K.STAT * In : * PULLB = hFILE * PULLW = PTR to S.STAT buffer *-------------------------------------- K.STAT jsr K.PFTCheckFileA >PULLA jsr FIL.SetupPrt1A >PULLW ZPQuickPtr2 >MLICALL MLIGETFILEINFO bcs .9 >LDYAI MLICALL.PARAMS+3 .9 rts *-------------------------------------- * K.FSTAT * In : * PULLW = PTR to Filename * PULLW = PTR to S.STAT buffer *-------------------------------------- K.FSTAT jsr K.PFTCheckPathSTK >PULLW MLICALL.PARAMS+1 >PULLW ZPQuickPtr2 >MLICALL MLIGETFILEINFO bcs .9 >LDYAI MLICALL.PARAMS+3 .9 rts *-------------------------------------- FIL.SetupPrt1A jsr K.GetMemPtrA >STYA ZPQuickPtr1 ldy #S.FILE.PRODOS.REF lda (ZPQuickPtr1),y sta MLICALL.PARAMS+1 rts *-------------------------------------- MAN SAVE SYS/KERNEL.S.FILE LOAD SYS/KERNEL.S ASM