A2osX/BIN/LSDEV.S.txt
2016-12-13 17:32:37 +01:00

286 lines
5.8 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/BIN/LSDEV
*--------------------------------------
.INB /A2OSX.DEV/INC/MACROS.I
.INB /A2OSX.DEV/INC/PRODOS.I
.INB /A2OSX.DEV/INC/A2OSX.I
*--------------------------------------
ZPPTR1 .EQ ZPBIN
ZPPTR2 .EQ ZPBIN+2
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length To Relocate
.DA 0 Data Segment to Allocate
.DA 0
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.EVENT
.DA CS.QUIT
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.MSG2 .DA MSG2
L.MSG3 .DA MSG3
L.RAM .DA RAM
L.DISK2 .DA DISK2
L.GENERIC .DA GENERIC
.DA 0
*--------------------------------------
CS.INIT jsr DumpA2osXDev
bcs .9
jsr DumpProDOSDev
bcs .9
lda #0 tell TSKMGR that all done ok, but
.9 sec we do not want to stay in memory
rts
*--------------------------------------
DumpA2osXDev >LDYA L.MSG0
>SYSCALL CPrintFYA
>LDYAI DevMgr.Table
>STYA ZPPTR1
stz DEV.ID
.2 lda (ZPPTR1)
cmp #$D8
bne .8
ldy #S.DEV.JMP+1
>PUSHB (ZPPTR1),y
dey
>PUSHB (ZPPTR1),y
lda ZPPTR1
clc
adc #S.DEV.NAME
tay
lda ZPPTR1+1
adc #0
>PUSHYA
ldy #S.DEV.F
>PUSHB (ZPPTR1),y
ldy #S.DEV.ID
>PUSHB (ZPPTR1),y
>LDYA L.MSG1
>SYSCALL CPrintFYA
lda ZPPTR1
clc
adc #S.DEV
sta ZPPTR1
bcc .3
inc ZPPTR1+1
.3 inc DEV.ID
lda DEV.ID
cmp #K.DEV.MAX
bne .2
.8 clc
rts
*--------------------------------------
DumpProDOSDev >LDYA L.MSG2
>SYSCALL CPrintFYA
stz BLKCALL.PARAMS CmdNum = 0, STATUS Call
stz BLKCALL.PARAMS+4 ask for Block 0
stz BLKCALL.PARAMS+5 (in case driver check block validity before checking CmdNum)
ldx DEVCNT
stx DEV.ID
.1 ldx DEV.ID
ldy #1
lda DEVLST,x
bpl .2
iny
.2 sty Drive
and #$F0
sta BLKCALL.PARAMS+1 UnitNum for BLKCALL, if needed
lsr
lsr
lsr
tay Y = DSSS*2
lsr
and #$7
sta Slot
stz ZPPTR1 make Ptr1 = Cn00
lda DEVPTRS,y
sta ZPPTR2 make Ptr2 = Cnxx (prodos BLK entry point)
lda DEVPTRS+1,y
sta ZPPTR1+1
sta ZPPTR2+1
cmp #$C1
bcc .6 3rd Party Driver loaded in RAM...
cmp #$C8
bcs .4 In ProDOS Space.../RAM or DisK II
ldx #SmartPort.SIG-SmartPort.OFS
.3 ldy SmartPort.OFS-1,x Check if there is a smartport firmware
lda (ZPPTR1),y
cmp SmartPort.SIG-1,x
bne .6 not a smartport...go check $CnFE
dex
bne .3
jsr GO.SmartPort Perform a Smartpot STATUS call
bcs .8
jsr PrintDevStatus
bra .8
.4 cmp #$ff RAM ?
bne .5
>LDYA L.RAM
bra .7
.5 >LDYA L.DISK2
bra .7
.6 >LDYA L.GENERIC
.7 >STYA .71+1
ldy #16
.71 lda $ffff,y
sta UsrBuf256+S.SPSTAT.NAME,y
dey
bpl .71
>LDYA ZPPTR2 Get Block device PTR
jsr A2osX.BLKCALL
bcs .8
stx UsrBuf256+S.SPSTAT.BLKNUM
sty UsrBuf256+S.SPSTAT.BLKNUM+1
stz UsrBuf256+S.SPSTAT.BLKNUM+2
jsr PrintDevStatus
.8 dec DEV.ID
bmi .9
jmp .1
.9 clc
rts
*--------------------------------------
S.SPSTAT.STATUS .EQ 0
S.SPSTAT.STATUS.BLK .EQ %10000000
S.SPSTAT.STATUS.WRT .EQ %01000000
S.SPSTAT.STATUS.RD .EQ %00100000
S.SPSTAT.STATUS.ONL .EQ %00010000
S.SPSTAT.STATUS.FMT .EQ %00001000
S.SPSTAT.STATUS.WRP .EQ %00000100
S.SPSTAT.STATUS.IRQ .EQ %00000010
S.SPSTAT.STATUS.OPN .EQ %00000001
S.SPSTAT.BLKNUM .EQ 1
S.SPSTAT.NAME .EQ 4
S.SPSTAT.TYPE .EQ 21
S.SPSTAT.SUBTYP .EQ 22
S.SPSTAT.VER .EQ 23
S.SPSTAT .EQ 25
*--------------------------------------
GO.SmartPort ldy #$ff
lda (ZPPTR1),y
inc
inc
inc
sta .2+1 Entrypoint Offset=+3
lda ZPPTR1+1 Get $Cn
sta .2+2
and #$0f
cmp Slot Driver Slot match Dev Slot ?
beq .1 yes...
inc Slot
inc Slot
inc Slot
inc Drive no...
inc Drive Must have been remapped by ProDOS
.1 stz .3 CMD=Status
lda Drive
sta SMP.Params+1 UnitNum
.2 jsr $ffff
.3 lda SMP.Params will be relocated
rts
*--------------------------------------
PrintDevStatus >PUSHW UsrBuf256+S.SPSTAT.BLKNUM
ldy #S.SPSTAT.NAME
lda /UsrBuf256
>PUSHYA
>PUSHB Drive
>PUSHB Slot
>PUSHB UsrBuf256 STATUS
>PUSHB Dev.ID
>LDYA L.MSG3
>SYSCALL CPrintFYA
rts
*--------------------------------------
CS.RUN
CS.EVENT
CS.QUIT clc
rts
*--------------------------------------
CS.END
SmartPort.OFS .HS 01030507
SmartPort.SIG .HS 20000300
DiskII.OFS .HS 010305FF
DiskII.SIG .HS 20000300
MSG0 >CSTR "ID Flags Name Address\n"
MSG1 >CSTR "%03d %b %4S $%H\n"
MSG2 >CSTR "ID Flags Name Description Size\n"
MSG3 >CSTR "%03d %b S%dD%d %S %05D\n"
RAM >PSTR "ProDOS Ram Disk "
DISK2 >PSTR "Apple Disk ][ "
GENERIC >PSTR "Generic Blk Dev "
*--------------------------------------
SMP.Params .DA #3 Param Count
.BS 1 unitNumber
.DA UsrBuf256
.DA #3 Return DIB
*--------------------------------------
DEV.ID .BS 1
Slot .BS 1
Drive .BS 1
MAN
SAVE BIN/LSDEV.S
ASM