A2osX/DRV/DHGR.DRV.S.txt

650 lines
12 KiB
Plaintext
Raw Normal View History

2015-03-14 21:48:35 +00:00
PR#3
PREFIX /A2OSX.BUILD
LOMEM $A00
2015-03-14 21:48:35 +00:00
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BUILD/DRV/DHGR.DRV
2015-03-14 21:48:35 +00:00
*--------------------------------------
.INB /A2OSX.BUILD/INC/MACROS.I
.INB /A2OSX.BUILD/INC/A2OSX.I
.INB /A2OSX.BUILD/INC/PRODOS.I
.INB /A2OSX.BUILD/INC/IO.I
.INB /A2OSX.BUILD/INC/LIBGFX.I
2015-03-14 21:48:35 +00:00
*--------------------------------------
ZPBase .EQ ZPDRV
2016-07-22 14:11:13 +00:00
ZPShiftLo .EQ ZPDRV+2
ZPShiftHi .EQ ZPDRV+4
ZPCtrlBlk .EQ ZPDRV+8 limited to 8 bytes for now...have to modify kernel
2015-03-14 21:48:35 +00:00
*--------------------------------------
2015-06-03 18:30:57 +00:00
* File Header (16 Bytes)
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.START cld
2015-06-03 18:30:57 +00:00
jmp Dev.Detect cld,jmp abs=DRV
.DA #$61 6502,Level 1 (65c02)
.DA #1 DRV Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length
.DA DEV.HEADER-CS.START Device Header Offset
.DA DRV.CS.START-CS.START Driver Code Offset
.DA DRV.CS.END-DRV.CS.START Drv Code Length
*--------------------------------------
* Relocation Table
*--------------------------------------
L.MSG.DETECT .DA MSG.DETECT
.DA 0 End Of Reloc Table
*--------------------------------------
Dev.Detect >LDYA L.MSG.DETECT
>SYSCALL CPrintFYA
2015-06-03 18:30:57 +00:00
2016-06-21 15:29:27 +00:00
ldx #0
.1 txa
stz Shift0.hi,x
asl
rol Shift0.hi,x
lsr
sta Shift0.lo,x
inx
2016-06-22 15:29:43 +00:00
bpl .1
2016-06-21 15:29:27 +00:00
2016-06-22 15:29:43 +00:00
ldx #0
2016-06-21 15:29:27 +00:00
.2 lda Shift0.hi,x
sta Shift1.hi,x
lda Shift0.lo,x
asl
asl
rol Shift1.hi,x
lsr
sta Shift1.lo,x
inx
2016-06-22 15:29:43 +00:00
bpl .2
2016-06-21 15:29:27 +00:00
2016-06-22 15:29:43 +00:00
ldx #0
2016-06-21 15:29:27 +00:00
.3 lda Shift1.hi,x
sta Shift2.hi,x
lda Shift1.lo,x
asl
asl
rol Shift2.hi,x
lsr
sta Shift2.lo,x
inx
2016-06-22 15:29:43 +00:00
bpl .3
2016-06-21 15:29:27 +00:00
2016-06-22 15:29:43 +00:00
ldx #0
2016-06-21 15:29:27 +00:00
.4 lda Shift2.hi,x
sta Shift3.hi,x
lda Shift2.lo,x
asl
asl
rol Shift3.hi,x
lsr
sta Shift3.lo,x
inx
2016-06-22 15:29:43 +00:00
bpl .4
2016-06-21 15:29:27 +00:00
2016-06-22 15:29:43 +00:00
ldx #0
2016-06-21 15:29:27 +00:00
.5 lda Shift3.hi,x
sta Shift4.hi,x
lda Shift3.lo,x
asl
asl
rol Shift4.hi,x
lsr
sta Shift4.lo,x
inx
2016-06-22 15:29:43 +00:00
bpl .5
2016-06-21 15:29:27 +00:00
2016-06-22 15:29:43 +00:00
ldx #0
2016-06-21 15:29:27 +00:00
.6 lda Shift4.hi,x
sta Shift5.hi,x
lda Shift4.lo,x
asl
asl
rol Shift5.hi,x
lsr
sta Shift5.lo,x
inx
2016-06-22 15:29:43 +00:00
bpl .6
2016-06-21 15:29:27 +00:00
2016-06-22 15:29:43 +00:00
ldx #0
2016-06-21 15:29:27 +00:00
.7 lda Shift5.hi,x
sta Shift6.hi,x
lda Shift5.lo,x
asl
asl
rol Shift6.hi,x
lsr
sta Shift6.lo,x
inx
2016-06-22 15:29:43 +00:00
bpl .7
2016-06-21 15:29:27 +00:00
2015-06-03 18:30:57 +00:00
clc
rts
CS.END
MSG.DETECT >CSTR "\nApple IIe/IIc DHGR Driver.\n"
2015-06-03 18:30:57 +00:00
*--------------------------------------
* Device Header (16 Bytes)
*--------------------------------------
DEV.HEADER .DA DRV.CS.START
.DA #0
>PSTR "GFX" NAME
2015-06-03 18:30:57 +00:00
.HS 00 NAME must Be 5 bytes long
*--------------------------------------
* Driver Code
*--------------------------------------
DRV.CS.START cld
jmp (.1,x)
.1 .DA STATUS
.DA BADCALL
.DA BADCALL
.DA BADCALL
.DA BADCALL
.DA BADCALL
.DA OPEN
2015-03-14 21:48:35 +00:00
.DA CLOSE
.DA BADCALL
.DA BADCALL
2015-03-14 21:48:35 +00:00
.DA SETPIXEL
.DA GETPIXEL
.DA HLINE
.DA VLINE
.DA BITBLT
2015-06-03 18:30:57 +00:00
.DA FILLREC
2016-06-15 15:58:45 +00:00
.DA SETCURPOS
.DA SETCUR
.DA HIDECUR
.DA SHOWCUR
L.DEVSTAT .DA DEVSTAT
L.DIV7.0 .DA DIV7.0
L.MOD7.0 .DA MOD7.0
L.Shift0.Lo .DA Shift0.lo
L.Shift0.Hi .DA Shift0.hi
2015-03-14 21:48:35 +00:00
.DA 0 end or relocation
*--------------------------------------
BADCALL lda #MLI.ERR.BADCALL
sec
rts
*--------------------------------------
STATUS >LDYA L.DEVSTAT
clc
rts
*--------------------------------------
OPEN sta A2osX.SCRNDEVS+2 DEV.ID in A
2016-10-07 20:48:49 +00:00
lda L.DIV7.0+1
sta DIV7.hi
2016-06-22 21:12:09 +00:00
inc
sta DIV7.hi+1
2016-06-22 21:12:09 +00:00
inc
sta DIV7.hi+2
2016-07-22 14:11:13 +00:00
ldy #0
ldx #0
.1 lda L.MOD7.0,y
sta MOD7.lo,x
iny
lda L.MOD7.0,y
sta MOD7.hi,x
iny
inx
cpx #3
bne .1
ldx #7
lda L.Shift0.Lo+1
.10 sta Shiftlo.hi,x
inc
dex
bne .10
ldx #7
lda L.Shift0.hi+1
.11 sta Shifthi.hi,x
inc
dex
bne .11
.8 clc
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
CONTROL sta CLRTEXT
2016-06-07 06:10:18 +00:00
sta CLRMIXED
sta SETHIRES
sta CLR80STORE
sta CLRPAGE2
sta SETIOUDIS
sta SETDHIRES
* sta CLR80DISP
* sta SETDHIRES
* sta CLRDHIRES
* sta SET80DISP
* sta SETDHIRES
* sta CLRDHIRES
* sta SETDHIRES
lda #3
sta A2osX.ASCREEN
2016-06-07 06:10:18 +00:00
clc
rts
*--------------------------------------
CLOSE clc
rts
*--------------------------------------
2015-03-14 21:48:35 +00:00
* SETPIXEL
2016-07-22 14:11:13 +00:00
* In : YA = Ptr to CtrlBlk :
* 0 : X
* 2 : Y
* 4 : Mode
* 00000000=xor
* 00000001=b/w (1 bit/pixel)
* 00000100=16 colors (4 bits/pixel)
* 00001000=256 colors (8 bits/pixel)
* 5 : Color
*--------------------------------------
SETPIXEL >STYA ZPBase
ldy #5
.1 lda (ZPBase),y
sta ZPCtrlBlk,y
dey
bpl .1
2015-06-03 18:30:57 +00:00
2016-07-22 14:11:13 +00:00
sta SET80STORE
lda ZPCtrlBlk+4
bit #%00000100
bne .7
*-----B&W -----------------------------
2016-07-22 14:11:13 +00:00
ldx ZPCtrlBlk+1 X.HI
2016-06-22 15:29:43 +00:00
lda DIV7.hi,x
sta .2+2
2016-07-22 14:11:13 +00:00
lda MOD7.lo,x
sta .4+1
lda MOD7.hi,x
sta .4+2
ldx ZPCtrlBlk X.LO
.2 lda DIV7.0,x A=Col*2+AuxBit
2015-03-14 21:48:35 +00:00
eor #1 toggle last bit : 0=Aux, 1=Main
2016-07-22 14:11:13 +00:00
lsr .3+1 reset CLRPAGE2 address
lsr CS=Aux
rol .3+1 if CS, -> SETPAGE2
.3 sta CLRPAGE2
adc BASEL,y setup line Base Ptr (A=Col)
sta ZPBase
2016-07-22 14:11:13 +00:00
lda BASEH,y
sta ZPBase+1
2016-06-22 15:29:43 +00:00
2016-07-22 14:11:13 +00:00
.4 ldy MOD7.0,x x = X.LO
dec ZPCtrlBlk+4 get mode
bne .5
lda (ZPBase) Mode=0, XOR
eor Mono.Masks,y y = mod 7
sta (ZPBase)
sta CLR80STORE
rts
2015-06-03 18:30:57 +00:00
2016-07-22 14:11:13 +00:00
.5 lda (ZPBase)
ldx ZPCtrlBlk+5 mode=1, get color
bne .6
2016-06-22 21:12:09 +00:00
2016-07-22 14:11:13 +00:00
and Mono.NMasks,y includes And $7F for mono
sta (ZPBase)
sta CLR80STORE
2015-03-14 21:48:35 +00:00
rts
2016-06-22 21:12:09 +00:00
.6 and #$7F switch back this byte to mono
2016-07-22 14:11:13 +00:00
ora Mono.Masks,y
sta (ZPBase)
sta CLR80STORE
2015-03-14 21:48:35 +00:00
rts
*-----16 Colors -----------------------
2016-07-22 14:11:13 +00:00
.7 lda ZPCtrlBlk X.LO
lsr ZPCtrlBlk+1 divide by 4
2015-06-03 18:30:57 +00:00
ror
2016-07-22 14:11:13 +00:00
lsr ZPCtrlBlk+1
2015-06-03 18:30:57 +00:00
ror
tay Y=CX/4 (range 0->139)
lda DIV7.0,y A=CX/4/7 (range 0->19)
asl times 2 (range 0->38)
2016-07-22 14:11:13 +00:00
ldx ZPCtrlBlk+2
adc BASEL,x setup line Base Ptr (cc by asl)
sta ZPBase ZPBase now point to first of...
2015-06-03 18:30:57 +00:00
lda BASEH,x
sta ZPBase+1 ...the 4 columns
2015-06-03 18:30:57 +00:00
lda MOD7.0,y get MOD
asl times 4 to compute index in MASK tables
2015-06-03 18:30:57 +00:00
asl
2015-03-14 21:48:35 +00:00
tax set in X for Masks,NMasks
2016-07-22 14:11:13 +00:00
lda ZPCtrlBlk+5 get COLOR
2015-06-03 18:30:57 +00:00
asl times 4 to compute index in PIXELS table
2015-03-14 21:48:35 +00:00
asl
tay
lda Color.Masks,x bits in 1st byte to light?
2016-07-22 14:11:13 +00:00
beq .10
2015-03-23 17:09:21 +00:00
and Color.Pixels,y apply color
sta GBYTE
2015-03-14 21:48:35 +00:00
sta SETPAGE2
lda (ZPBase)
2015-03-14 21:48:35 +00:00
and Color.NMasks,x reset existing pixel,
2015-03-23 17:09:21 +00:00
ora GBYTE
sta (ZPBase)
2015-03-14 21:48:35 +00:00
2016-07-22 14:11:13 +00:00
.10 inx
2015-03-14 21:48:35 +00:00
iny
lda Color.Masks,x
2016-07-22 14:11:13 +00:00
beq .11
2015-03-23 17:09:21 +00:00
and Color.Pixels,y apply color
sta GBYTE
2015-03-14 21:48:35 +00:00
sta CLRPAGE2
lda (ZPBase)
2015-03-14 21:48:35 +00:00
and Color.NMasks,x reset existing pixel,
2015-03-23 17:09:21 +00:00
ora GBYTE
sta (ZPBase)
2015-03-14 21:48:35 +00:00
2016-07-22 14:11:13 +00:00
.11 inc ZPBase
2015-03-14 21:48:35 +00:00
inx
iny
lda Color.Masks,x
2016-07-22 14:11:13 +00:00
beq .12
2015-03-23 17:09:21 +00:00
and Color.Pixels,y apply color
sta GBYTE
2015-03-14 21:48:35 +00:00
sta SETPAGE2
lda (ZPBase)
2015-03-14 21:48:35 +00:00
and Color.NMasks,x reset existing pixel,
2015-03-23 17:09:21 +00:00
ora GBYTE
sta (ZPBase)
2015-03-14 21:48:35 +00:00
2016-07-22 14:11:13 +00:00
.12 inx
2015-03-14 21:48:35 +00:00
iny
lda Color.Masks,x
2016-07-22 14:11:13 +00:00
beq .13
2015-03-23 17:09:21 +00:00
and Color.Pixels,y apply color
sta GBYTE
2015-03-14 21:48:35 +00:00
sta CLRPAGE2
lda (ZPBase)
2015-03-14 21:48:35 +00:00
and Color.NMasks,x reset existing pixel,
2015-03-23 17:09:21 +00:00
ora GBYTE
sta (ZPBase)
2015-03-23 17:09:21 +00:00
2016-07-22 14:11:13 +00:00
.13 sta CLR80STORE
rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
GETPIXEL rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
HLINE rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
VLINE rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
FILLREC rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
2016-06-15 06:21:42 +00:00
* BitBlt
2016-07-22 14:11:13 +00:00
* In : YA = Ptr to CtrlBlk :
2016-06-15 06:21:42 +00:00
* 0 : Operation
2016-06-15 15:58:45 +00:00
* %00000001 : Save
* %00000010 : Replace
* %00000100 : AND with Src BitMask
* %00001000 : ORA with Src BitMap
* %00010000 : XOR
* 2 : SavePTR
* 4 : SrcAX
* 6 : SrcAY
* 8 : SrcBX
* 10 : SrcBY
* 12 : DestX
* 14 : DestY
* 16 : BM Struct
2015-03-14 21:48:35 +00:00
*--------------------------------------
2016-07-22 14:11:13 +00:00
BITBLT >STYA ZPCtrlBlk
lda (ZPCtrlBlk)
2016-06-15 15:58:45 +00:00
clc
rts
2016-06-21 15:29:27 +00:00
*--------------------------------------
* Y,A = pPoint
*--------------------------------------
SETCURPOS >STYA ZPBase
2016-06-15 15:58:45 +00:00
ldy #3
.1 lda (ZPBase),y
sta CUR.X,y
dey
bpl .1
bit CUR.State
bpl .2
jsr HIDECUR.I
jsr SHOWCUR.I
.2 clc
rts
*--------------------------------------
2016-06-21 15:29:27 +00:00
* Y,A = pCur
*--------------------------------------
2016-06-15 15:58:45 +00:00
SETCUR >STYA ZPBase
ldy #S.CUR-1
.1 lda (ZPBase),y
sta CUR.Buf,y
2016-06-15 15:58:45 +00:00
dey
bpl .1
bit CUR.State
bpl .2
jsr HIDECUR.I
jsr SHOWCUR.I
.2 clc
rts
*--------------------------------------
SHOWCUR bit CUR.State
bpl SHOWCUR.I
clc
rts
SHOWCUR.I sta SET80STORE
ldx CUR.X+1
lda DIV7.hi,x
sta .71+2
lda MOD7.hi,x
sta .72+2
2016-06-15 15:58:45 +00:00
ldx CUR.X
2016-06-15 15:58:45 +00:00
.71 lda DIV7.0,x
lsr
sta SB.StartCol
lda #0
sbc #0
sta SB.StartPage
.72 ldy MOD7.0,x
lda Shiftlo.Hi,y
sta ZPShiftLo+1
lda ShiftHi.Hi,y
sta ZPShiftHi+1
lda L.Shift0.Lo
sta ZPShiftLo
lda L.Shift0.hi
sta ZPShifthi
lda CUR.Y
sta CY
ldx #0 index to CUR data/mask
.1 ldy CY
lda BaseL,y
clc
adc SB.StartCol
sta ZPBase
lda BaseH,y
sta ZPBase+1
lda SB.StartPage
sta SB.Page
lda SB.Page
tay
eor #1
sta SB.Page
sta CLRPAGE2,y
lda (ZPBase)
ldy CUR.Buf+S.CUR.MASK,x
and (ZPShiftLo),y
ldy CUR.Buf+S.CUR.DATA,x
ora (ZPShiftLo),y
sta (ZPBase)
lda SB.Page
tay
eor #1
sta SB.Page
sta CLRPAGE2,y
beq .3
inc ZPBase
.3 lda (ZPBase)
ldy CUR.Buf+S.CUR.MASK,x
and (ZPShiftHi),y
ldy CUR.Buf+S.CUR.DATA,x
ora (ZPShiftHi),y
inx
ldy CUR.Buf+S.CUR.MASK,x
and (ZPShiftLo),y
ldy CUR.Buf+S.CUR.DATA,x
ora (ZPShiftLo),y
sta (ZPBase)
lda SB.Page
tay
eor #1
sta SB.Page
sta CLRPAGE2,y
beq .4
inc ZPBase
.4 lda (ZPBase)
ldy CUR.Buf+S.CUR.MASK,x
and (ZPShiftHi),y
ldy CUR.Buf+S.CUR.DATA,x
ora (ZPShiftHi),y
sta (ZPBase)
2016-06-15 15:58:45 +00:00
inx
cpx #32
bne .1
sta CLR80STORE
2016-06-15 15:58:45 +00:00
sec
ror CUR.State
SHOWCUR.RTS clc
2016-06-15 15:58:45 +00:00
rts
*--------------------------------------
HIDECUR bit CUR.State
bpl HIDECUR.RTS
2016-06-15 15:58:45 +00:00
HIDECUR.I
clc
ror CUR.State
HIDECUR.RTS clc
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
2015-06-03 18:30:57 +00:00
DRV.CS.END
*--------------------------------------
Shift0.lo .BS 128
Shift0.hi .BS 128
Shift1.lo .BS 128
Shift1.hi .BS 128
Shift2.lo .BS 128
Shift2.hi .BS 128
Shift3.lo .BS 128
Shift3.hi .BS 128
Shift4.lo .BS 128
Shift4.hi .BS 128
Shift5.lo .BS 128
Shift5.hi .BS 128
2016-06-22 15:29:43 +00:00
Shift6.lo .BS 128
Shift6.hi .BS 128
*--------------------------------------
.INB DRV/DHGR.DRV.T
*--------------------------------------
DIV7.hi .BS 3
2016-07-22 14:11:13 +00:00
MOD7.lo .BS 3
MOD7.hi .BS 3
Shiftlo.hi .BS 7
Shifthi.hi .BS 7
2015-03-14 21:48:35 +00:00
*--------------------------------------
CX .BS 2
CY .BS 1
COL .BS 1
2015-03-23 17:09:21 +00:00
GBYTE .BS 1
2015-03-14 21:48:35 +00:00
*--------------------------------------
2016-06-15 15:58:45 +00:00
CUR.State .BS 1
CUR.X .BS 2
CUR.Xdiv7 .BS 1
CUR.Xmod7 .BS 1
2016-06-15 15:58:45 +00:00
CUR.Y .BS 2
CUR.Buf .BS S.CUR
2016-06-15 15:58:45 +00:00
CUR.SaveCol .BS 1
CUR.SaveColCnt .BS 1
CUR.SaveRow .BS 1
CUR.SaveRowCnt .BS 1
CUR.SaveBuf .BS 3*16 MAX 3 bytes*16 rows
SB.StartPage .BS 1
SB.Page .BS 1
SB.StartCol .BS 1
SB.Col .BS 1
2016-06-15 15:58:45 +00:00
*--------------------------------------
DEVSTAT .DA #0
.DA #0,#0,#0 size
>PSTR "Apple II Mouse"
.BS 2
.DA #0
.DA #0
.DA $0900
*--------------------------------------
DEVSTAT.MODES .DA #%10000011 XOR,16 & B/W
DEVSTAT.W .DA 560 X.SIZE
DEVSTAT.H .DA 192 Y.SIZE
2016-06-21 15:29:27 +00:00
.LIST ON
2016-06-22 21:12:09 +00:00
*--------------------------------------
2016-06-21 15:29:27 +00:00
DRV.SIZE .EQ *-DRV.CS.START
2016-06-22 21:12:09 +00:00
*--------------------------------------
2016-06-21 15:29:27 +00:00
.LIST OFF
2015-03-14 21:48:35 +00:00
MAN
SAVE DRV/DHGR.DRV.S
ASM