A2osX/SYS/KERNEL.S.DRV.txt
2018-08-25 13:23:59 +02:00

587 lines
11 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.

NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
*--------------------------------------
* DRV.DiskII
* X = IOCTL
* Y,A = PTR to S.IOCTL
*--------------------------------------
DRV.DiskII cld
cpx #IOCTL.FORMAT
bcs .9
>STYA pIOCTL
jmp (.1,x)
.1 .DA DRV.DiskII.STATUS
.DA DRV.BLK READ
.DA DRV.BLK WRITE
.9 jmp A2osX.BadCall
*--------------------------------------
DRV.DiskII.STATUS
>LDYAI DRV.DiskII.DIB
jmp DRV.STATUS.YA
*--------------------------------------
DRV.DiskII.DIB .DA #S.DIB.S.BLOCK+S.DIB.S.WRITE+S.DIB.S.READ
.DA 280
.DA #0
>PSTR "Disk II 5.25"
.BS 4
.DA #S.DIB.T.DISKII
.DA #0
.DA K.VER
*--------------------------------------
* DRV.RamDrive
* X = IOCTL
* Y,A = PTR to S.IOCTL
*--------------------------------------
DRV.RamDrive cld
cpx #IOCTL.CONTROL
bcs .9
>STYA pIOCTL
jmp (.1,x)
.1 .DA DRV.RamDrive.STATUS
.DA DRV.BLK READ
.DA DRV.BLK WRITE
.DA DRV.BLK FORMAT
.9 jmp A2osX.BadCall
*--------------------------------------
DRV.RamDrive.STATUS
jsr DRV.Blk
bcs .9
stx DRV.RamDrive.DIB+S.DIB.SIZE
sty DRV.RamDrive.DIB+S.DIB.SIZE+1
>LDYAI DRV.RamDrive.DIB
jmp DRV.STATUS.YA
.9 rts
*--------------------------------------
DRV.RamDrive.DIB
.DA #S.DIB.S.BLOCK+S.DIB.S.WRITE+S.DIB.S.READ
.BS 3
>PSTR "ProDOS /RAM Disk"
.DA #S.DIB.T.RAM
.DA #0
.DA K.VER
*--------------------------------------
* DRV.BlkDevice
* X = IOCTL
* Y,A = PTR to S.IOCTL
*--------------------------------------
DRV.BlkDevice cld
cpx #IOCTL.CONTROL
bcs .9
>STYA pIOCTL
jmp (.1,x)
.1 .DA DRV.BlkDevice.STATUS
.DA DRV.BLK READ
.DA DRV.BLK WRITE
.DA DRV.BLK FORMAT
.9 jmp A2osX.BadCall
*--------------------------------------
DRV.BlkDevice.STATUS
jsr DRV.Blk
bcs .9
stx DRV.BlkDevice.DIB+S.DIB.SIZE
sty DRV.BlkDevice.DIB+S.DIB.SIZE+1
>LDYAI DRV.BlkDevice.DIB
jmp DRV.STATUS.YA
.9 rts
*--------------------------------------
DRV.BlkDevice.DIB
.DA #S.DIB.S.BLOCK+S.DIB.S.WRITE+S.DIB.S.READ
.BS 3
>PSTR "ProDOS Block Dev"
.DA #S.DIB.T.PRODOS
.DA #0
.DA K.VER
*--------------------------------------
* IOCTL to BLK protocol converter
* in : pIOCTL (AUX)
*--------------------------------------
DRV.BLK txa
lsr
sta DRV.BLK.PARAMS CMD
ldy #S.FD.DEV.DEVID Drive 1, or 2
lda (pFD),y
dec O or 1
lsr in Carry
php
ldy #S.FD.DEV.BUSID
lda (pFD),y
asl
asl
asl
asl
asl
plp
ror DSSS0000
sta DRV.BLK.PARAMS+1 UNITNUM
ldx #3
ldy #S.IOCTL.BUFPTR+3
.1 lda (pIOCTL),y BUF,BLKNUM
sta DRV.BLK.PARAMS+2,x
dey
dex
bpl .1
ldy #S.FD.DEV.BUSPTR
lda (pFD),y
sta .3+1
iny
lda (pFD),y
sta .3+2
jsr GO.ProDOS
ldx #5
.2 lda DRV.BLK.PARAMS,x
sta $42,x
dex
bpl .2
.3 jsr $ffff SELF MODIFIED
jsr GO.A2osX
rts
DRV.BLK.PARAMS .BS 6
*--------------------------------------
* Smartport Driver
*--------------------------------------
DRV.SmartPort cld
>STYA DRV.SmartPort.Go.IOCTL
txa
lsr
sta DRV.SmartPort.Go.Cmd
tax
lda DRV.SmartPort.Cnt,x
sta DRV.SmartPort.Go.Cmd
ldy #S.FD.DEV.BUSPTR
lda (pFD),y
sta .8+1
iny
lda (pFD),y
sta .8+2
.8 jsr $ffff
DRV.SmartPort.Go.Cmd
.BS 1
DRV.SmartPort.Go.IOCTL
.BS 2
rts
DRV.SmartPort.Cnt
.HS 03030301030101010404
*--------------------------------------
* NULL DEVICE
* - OPEN,WRITE,CLOSE always succeed.
* - READ returns EOF.
*--------------------------------------
DRV.NULL cld
>STYA pIOCTL
jmp (.1,x)
*--------------------------------------
.1 .DA DRV.NULL.STATUS
.DA A2osX.BADCALL READBLOCK
.DA A2osX.BADCALL WRITEBLOCK
.DA A2osX.BADCALL FORMAT
.DA A2osX.BADCALL CONTROL
.DA A2osX.BADCALL INIT
.DA DRV.NULL.OPEN
.DA DRV.NULL.CLOSE
.DA DRV.NULL.READ
.DA DRV.NULL.WRITE
.DA A2osX.BADCALL IRQ
*--------------------------------------
DRV.NULL.STATUS >LDYAI DRV.NULL.DIB
jmp DRV.STATUS.YA
DRV.NULL.READ ldx #C.EOF
jmp DRV.READ.X
DRV.NULL.OPEN
DRV.NULL.WRITE
DRV.NULL.CLOSE clc
rts
*--------------------------------------
DRV.NULL.DIB .DA #S.DIB.S.WRITE+S.DIB.S.READ+S.DIB.S.OPENED
.DA #0,#0,#0
>PSTR "NULL DEVICE"
.BS 5
.DA #S.DIB.T.CHAR
.DA #0
.DA K.VER
*--------------------------------------
* SYS DEVICE
*--------------------------------------
DRV.SYS cld
>STYA pIOCTL
jmp (.1,x)
.1 .DA DRV.SYS.STATUS
.DA A2osX.BADCALL READBLOCK
.DA A2osX.BADCALL WRITEBLOCK
.DA A2osX.BADCALL FORMAT
.DA DRV.SYS.Control
.DA A2osX.BADCALL INIT
.DA DRV.SYS.OPEN
.DA DRV.SYS.CLOSE
.DA DRV.SYS.Read
.DA DRV.SYS.Write
.DA A2osX.BADCALL IRQ
*--------------------------------------
DRV.SYS.STATUS >LDYAI DRV.SYS.DIB
jmp DRV.STATUS.YA
*--------------------------------------
DRV.SYS.Open lda #DEVID.SYS
sta A2osX.SCRNDEVS+1
jsr DRV.SYS.FF
*--------------------------------------
DRV.SYS.Control sta SETTEXT
sta SETALTCHAR
sta SET80DISP
sta CLR80STORE
sta SETPAGE2
lda #2
sta A2osX.ASCREEN
DRV.SYS.CLOSE
clc
rts
*--------------------------------------
DRV.SYS.Read lda A2osX.ASCREEN
cmp #2 is SYS active?
bne .9
lda OPENAPPLE
bmi .9 Open apple key, not for us...
lda KBD
bpl .9
sta KBDSTROBE
and #$7F
tax
jmp DRV.READ.X
.9 lda #0 Error = no event
sec
rts
*--------------------------------------
DRV.SYS.WRITE ldy #S.IOCTL.BUFPTR
lda (pIOCTL),y
sta ZPDRV+4
iny
lda (pIOCTL),y
sta ZPDRV+5
ldy #S.IOCTL.BYTECNT
lda (pIOCTL),y
eor #$ff
tax
iny
lda (pIOCTL),y
eor #$ff
tay
.2 inx
bne .3
iny
bne .3
clc
rts
.3 lda (ZPDRV+4)
inc ZPDRV+4
bne .4
inc ZPDRV+5
.4 jsr DRV.SYS.COUT
.5 bra .2
*--------------------------------------
DRV.SYS.COUT phx
phy
cmp #' '
bcs .1
jsr DRV.SYS.CTRL
bra .8
.1 ora #$80
ldy DRV.SYS.CH
ldx DRV.SYS.CV
jsr DRV.SYS.SetCharAtYX
jsr DRV.SYS.FS
.8 ply
plx
clc
rts
*--------------------------------------
DRV.SYS.CTRL ldx #DRV.SYS.CTRLCNT-1
.1 cmp DRV.SYS.CTRLS,x
beq .2
dex
bpl .1
clc
rts
.2 txa
asl
tax
jmp (.3,x)
.3 .DA DRV.SYS.ENQ 5
.DA DRV.SYS.BS 8
.DA DRV.SYS.LF 10
.DA DRV.SYS.FF 12
.DA DRV.SYS.CR 13
.DA DRV.SYS.FS 21
.DA DRV.SYS.ESC 27
*--------------------------------------
DRV.SYS.ENQ clc
rts
*--------------------------------------
DRV.SYS.BS ldx DRV.SYS.CH
beq .1
dec DRV.SYS.CH
bra .3
.1 ldy DRV.SYS.CV
cpy #1
bne .2
clc
rts
.2 lda #79
sta DRV.SYS.CH
dec DRV.SYS.CV
.3 clc
rts
*--------------------------------------
DRV.SYS.LF ldx DRV.SYS.CV
cpx #23
beq DRV.SYS.Scroll
inc DRV.SYS.CV
rts
*--------------------------------------
DRV.SYS.FF ldx #23
.1 jsr DRV.SYS.ClrLineAtX
dex
bne .1
stz DRV.SYS.CH
lda #1
sta DRV.SYS.CV
rts
*--------------------------------------
DRV.SYS.CR jsr DRV.SYS.ClrEOL
stz DRV.SYS.CH
rts
*--------------------------------------
DRV.SYS.FS lda DRV.SYS.CH
cmp #79
bne .1
stz DRV.SYS.CH
bra DRV.SYS.LF
.1 inc DRV.SYS.CH
rts
*--------------------------------------
DRV.SYS.ESC
clc
rts
*--------------------------------------
DRV.SYS.ClrEOL ldx DRV.SYS.CV
lda #$A0
ldy DRV.SYS.CH
.1 cpy #79
beq .2
jsr DRV.SYS.SetCharAtYX
iny
bne .1
.2 rts
*--------------------------------------
DRV.SYS.ScrollAux
sta SETREADAUX
.1 lda (ZPDRV+2),y
sta (ZPDRV),y
dey
bpl .1
sta CLRREADAUX
rts
*--------------------------------------
DRV.SYS.Scroll ldx #DRV.SYS.Scroll-DRV.SYS.ScrollAux-1
.1 lda DRV.SYS.ScrollAux,x
sta $102,x
dex
bpl .1
ldx #1
.2 jsr DRV.SYS.SetBaseX
inx
lda DRV.SYS.BASEL,x
sta ZPDRV+2
lda DRV.SYS.BASEH,x
sta ZPDRV+3
ldy #39
sta SETWRITEAUX
jsr $102
sta CLRWRITEAUX
ldy #39
.3 lda (ZPDRV+2),y
sta (ZPDRV),y
dey
bpl .3
cpx #23
bne .2 Fall in ClrLineAtX for last line
*--------------------------------------
DRV.SYS.ClrLineAtX
jsr DRV.SYS.SetBaseX
lda #$A0
ldy #39
.1 sta SETWRITEAUX
sta (ZPDRV),y
sta CLRWRITEAUX
sta (ZPDRV),y
dey
bpl .1
rts
*--------------------------------------
DRV.SYS.SetCharAtYX
cmp #$40
bcc .1
cmp #$5F
bcs .1
and #$3F
.1 phy
pha
jsr DRV.SYS.SetBaseX
tya
lsr
tay
pla
bcs .2
sta SETWRITEAUX
sta (ZPDRV),y
sta CLRWRITEAUX
ply
rts
.2 sta (ZPDRV),y
ply
rts
*--------------------------------------
DRV.SYS.SetBaseX
lda DRV.SYS.BASEL,x
sta ZPDRV
lda DRV.SYS.BASEH,x
sta ZPDRV+1
rts
*--------------------------------------
DRV.SYS.DIB .DA #S.DIB.S.WRITE+S.DIB.S.READ+S.DIB.S.OPENED
.DA #0,#0,#0
>PSTR "A2osX SYS Screen"
.DA #S.DIB.T.CHAR
.DA #0
.DA K.VER
*--------------------------------------
DRV.SYS.CH .BS 1
DRV.SYS.CV .BS 1
*--------------------------------------
DRV.SYS.BASEL .HS 00.80.00.80.00.80.00.80.28.A8.28.A8.28.A8.28.A8.50.D0.50.D0.50.D0.50.D0
DRV.SYS.BASEH .HS 08.08.09.09.0A.0A.0B.0B.08.08.09.09.0A.0A.0B.0B.08.08.09.09.0A.0A.0B.0B
DRV.SYS.CTRLCNT .EQ 7
DRV.SYS.CTRLS .HS 05080A0C0D151B
*--------------------------------------
DRV.STATUS.YA >STYA .2+1
ldy #S.IOCTL.STATCODE
lda (pIOCTL),y
beq .1
cmp #S.IOCTL.STATCODE.GETDIB
bne .9
ldx #S.DIB-1
.HS 2C bit abs
.1 ldx #3
ldy #S.IOCTL.BUFPTR
lda (pIOCTL),y
sta .3+1
iny
lda (pIOCTL),y
sta .3+2
.2 lda $ffff,x SELF MODIFIED
.3 sta $ffff,x SELF MODIFIED
dex
bpl .2
clc
rts
.9 lda #MLI.E.BADCTL
sec
rts
*--------------------------------------
DRV.READ.X ldy #S.IOCTL.BYTECNT
lda #1
sta (pIOCTL),y
iny
dec
sta (pIOCTL),y
ldy #S.IOCTL.BUFPTR
lda (pIOCTL),y
sta .1+1
iny
lda (pIOCTL),y
sta .1+2
.1 stx $ffff SELF MODIFIED
clc
rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.DRV
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM