mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-04 03:05:43 +00:00
313 lines
5.3 KiB
Plaintext
313 lines
5.3 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*---------------------------------------
|
||
FIO.Init ldy #S.PS.hCMD
|
||
lda (pPS),y
|
||
>SYSCALL SYS.GetMemPtrA
|
||
bcs .99
|
||
>STYA ZPPtr1
|
||
lda (ZPPtr1)
|
||
tay
|
||
adc #3 len of ".T."
|
||
sta ASM.T.FILENAMELEN
|
||
adc #4 len of "6502"
|
||
sta ASM.T.FILENAME
|
||
tax
|
||
|
||
.2 lda (ZPPtr1),y
|
||
sta ASM.T.FILENAME,y
|
||
dey
|
||
bne .2
|
||
|
||
ldy #6
|
||
|
||
.3 lda ASM.T.DEFAULT,y
|
||
sta ASM.T.FILENAME,x
|
||
dex
|
||
dey
|
||
bpl .3
|
||
|
||
jmp FIO.LOAD.ASM.T
|
||
.99 rts
|
||
*---------------------------------------
|
||
FIO.OpenFileA sta FIO.hFileName
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>STYA ZPPtr1
|
||
|
||
stz FIO.hFullPath
|
||
|
||
ldy #1
|
||
lda (ZPPtr1),y
|
||
cmp #'/'
|
||
beq .1
|
||
|
||
>PUSHB FIO.hFileName
|
||
ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
>PUSHA
|
||
>SYSCALL SYS.PStrCat
|
||
sta FIO.hFullPath
|
||
sta FIO.hFileName
|
||
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>STYA ZPPtr1
|
||
|
||
.1 >PUSHW ZPPtr1
|
||
>PUSHW L.MSG.SRC.FILE
|
||
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
||
|
||
ldy #SRC.COUNT
|
||
lda (pData),y
|
||
cmp #SRC.IN.MAXDEPTH
|
||
bne .10
|
||
|
||
lda #ERR.SRC.TOO.MANY.IN
|
||
sec
|
||
bra FIO.OpenFileA.Exit
|
||
|
||
.10 lda FIO.hFileName
|
||
>SYSCALL SYS.MLIOpenA
|
||
bcs .99
|
||
|
||
pha
|
||
ldy #SRC.COUNT
|
||
lda (pData),y
|
||
clc
|
||
adc #SRC.hREFNUMS
|
||
tay
|
||
pla
|
||
sta (pData),y
|
||
|
||
ldy #SRC.COUNT
|
||
lda (pData),y
|
||
clc
|
||
adc #SRC.hBUFFERS
|
||
tay
|
||
txa
|
||
sta (pData),y
|
||
|
||
lda FIO.hFileName
|
||
>SYSCALL SYS.MLIGetFileInfoA
|
||
bcs .99
|
||
|
||
>STYA ZPPtr1
|
||
ldy #1
|
||
lda (ZPPtr1),y
|
||
tax
|
||
|
||
ldy #SRC.COUNT
|
||
lda (pData),y
|
||
clc
|
||
adc #SRC.hFILETYPES
|
||
tay
|
||
|
||
txa
|
||
sta (pData),y
|
||
|
||
cmp #$FA S-C/BAS?
|
||
beq .8
|
||
|
||
cmp #$04 TXT ?
|
||
|
||
bne .98
|
||
|
||
>PUSHBI $0D Line separator for TXT file
|
||
>PUSHBI $FF
|
||
|
||
ldy #SRC.COUNT
|
||
lda (pData),y
|
||
clc
|
||
adc #SRC.hREFNUMS
|
||
tay
|
||
lda (pData),y
|
||
>PUSHA
|
||
>SYSCALL SYS.MLINewLine
|
||
bcs .99
|
||
|
||
.8 ldy #SRC.COUNT
|
||
lda (pData),y
|
||
inc
|
||
sta (pData),y
|
||
clc
|
||
bra FIO.OpenFileA.Exit
|
||
|
||
.98 lda #ERR.SRC.INV.TYPE
|
||
|
||
.99 sec
|
||
FIO.OpenFileA.Exit php
|
||
pha
|
||
lda FIO.hFullPath
|
||
beq .1
|
||
>SYSCALL SYS.FreeMemA
|
||
.1 pla
|
||
plp
|
||
rts
|
||
*---------------------------------------
|
||
FIO.ReadLine stz SRC.BufPtr
|
||
|
||
ldy #SRC.COUNT
|
||
lda (pData),y
|
||
clc
|
||
adc #SRC.hFILETYPES-1
|
||
tay
|
||
lda (pData),y
|
||
bmi .10
|
||
|
||
>PUSHWI 256
|
||
>PUSHWI TmpBuffer256
|
||
jsr FIO.ReadFromFile
|
||
bcs .19
|
||
|
||
lda #0 replace ending $0D with $00
|
||
sta TmpBuffer256,y
|
||
.19 rts
|
||
|
||
.10 >PUSHWI 3
|
||
>PUSHW L.SRC.Buffer
|
||
jsr FIO.ReadFromFile
|
||
bcs .9
|
||
|
||
lda SRC.Buffer+1
|
||
sta SRC.LINENUM
|
||
lda SRC.Buffer+2
|
||
sta SRC.LINENUM+1
|
||
|
||
lda SRC.Buffer LEN
|
||
sec
|
||
sbc #3
|
||
bcc .9 LEN should be at least 3
|
||
|
||
tay
|
||
lda #0
|
||
>PUSHYA
|
||
>PUSHW L.SRC.BUFFER
|
||
jsr FIO.ReadFromFile
|
||
|
||
ldy #0
|
||
ldx #0
|
||
|
||
.1 lda SRC.Buffer,y
|
||
bmi .2
|
||
|
||
sta TmpBuffer256,x
|
||
beq .8 Ending 00
|
||
inx
|
||
beq .99
|
||
iny
|
||
bne .1
|
||
bra .99
|
||
|
||
.2 cmp #$C0 REPEAT char?
|
||
bne .5
|
||
iny
|
||
beq .99
|
||
lda SRC.Buffer,y
|
||
iny
|
||
beq .99
|
||
.3 pha
|
||
lda SRC.Buffer,y
|
||
sta TmpBuffer256,x
|
||
pla
|
||
inx
|
||
beq .99
|
||
dec
|
||
bne .3
|
||
iny
|
||
bne .1
|
||
bra .99
|
||
|
||
.5 and #$3F Compute blank count
|
||
.6 pha
|
||
lda #$20
|
||
sta TmpBuffer256,x
|
||
pla
|
||
inx
|
||
beq .99
|
||
dec
|
||
bne .6
|
||
iny
|
||
bne .1
|
||
bra .99
|
||
|
||
.8 clc
|
||
.9 rts
|
||
|
||
.99 lda #ERR.LINE.TOO.LONG
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
FIO.ReadFromFile ldy #SRC.COUNT
|
||
lda (pData),y
|
||
clc
|
||
adc #SRC.hREFNUMS-1
|
||
tay
|
||
lda (pData),y
|
||
>PUSHA
|
||
>SYSCALL SYS.MLIRead
|
||
bcs .9
|
||
tax $100 byte transfered ?
|
||
beq .9
|
||
lda #ERR.LINE.TOO.LONG
|
||
sec
|
||
.9 rts
|
||
*---------------------------------------
|
||
FIO.FileClose ldy #SRC.COUNT
|
||
lda (pData),y
|
||
beq .8
|
||
|
||
clc
|
||
adc #SRC.hREFNUMS-1
|
||
tay
|
||
lda (pData),y
|
||
>SYSCALL SYS.MLICloseA
|
||
|
||
ldy #SRC.COUNT
|
||
lda (pData),y
|
||
clc
|
||
adc #SRC.hBUFFERS-1
|
||
tay
|
||
lda (pData),y
|
||
>SYSCALL SYS.FreeMemA
|
||
|
||
ldy #SRC.COUNT
|
||
lda (pData),y
|
||
dec
|
||
sta (pData),y
|
||
|
||
.8 clc
|
||
rts
|
||
*---------------------------------------
|
||
FIO.LOAD.ASM.T ldy #ASM.T.hMem
|
||
lda (pData),y
|
||
beq .1
|
||
>SYSCALL SYS.FreeMemA
|
||
ldy #ASM.T.hMem
|
||
lda #0
|
||
sta (pData),y
|
||
|
||
.1 >PUSHW L.ASM.T.FILENAME
|
||
>PUSHW L.MSG.T.FILE
|
||
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
||
|
||
>LDYA L.ASM.T.FILENAME
|
||
>SYSCALL SYS.LoadFileYA
|
||
bcs .9
|
||
|
||
txa
|
||
ldy #ASM.T.hMem
|
||
sta (pData),y
|
||
|
||
.9 rts
|
||
*---------------------------------------
|
||
FIO.EmitByte clc
|
||
rts
|
||
*---------------------------------------
|
||
MAN
|
||
SAVE BIN/ASM.S.FIO
|
||
LOAD BIN/ASM.S
|
||
ASM
|