mirror of
https://github.com/A2osX/A2osX.git
synced 2024-08-14 13:29:02 +00:00
743 lines
14 KiB
Plaintext
743 lines
14 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
LOMEM $A00
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BUILD/DRV/DHGR.DRV
|
||
*--------------------------------------
|
||
.INB /A2OSX.BUILD/INC/MACROS.I
|
||
.INB /A2OSX.BUILD/INC/A2OSX.I
|
||
.INB /A2OSX.BUILD/INC/MLI.ERR.I
|
||
.INB /A2OSX.BUILD/INC/IO.I
|
||
.INB /A2OSX.BUILD/INC/LIBGFX.I
|
||
*--------------------------------------
|
||
ZPBase .EQ ZPDRV
|
||
ZPShiftLo .EQ ZPDRV+2
|
||
ZPShiftHi .EQ ZPDRV+4
|
||
ZPCount .EQ ZPDRV+6
|
||
*--------------------------------------
|
||
* File Header (16 Bytes)
|
||
*--------------------------------------
|
||
CS.START cld
|
||
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
|
||
|
||
ldx #0
|
||
.1 txa
|
||
stz Shift0.hi,x
|
||
asl
|
||
rol Shift0.hi,x
|
||
lsr
|
||
sta Shift0.lo,x
|
||
inx
|
||
bpl .1
|
||
|
||
ldx #0
|
||
.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
|
||
bpl .2
|
||
|
||
ldx #0
|
||
.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
|
||
bpl .3
|
||
|
||
ldx #0
|
||
.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
|
||
bpl .4
|
||
|
||
ldx #0
|
||
.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
|
||
bpl .5
|
||
|
||
ldx #0
|
||
.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
|
||
bpl .6
|
||
|
||
ldx #0
|
||
.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
|
||
bpl .7
|
||
|
||
clc
|
||
rts
|
||
CS.END
|
||
MSG.DETECT >CSTR "Apple IIe/IIc DHGR Driver.\r\n"
|
||
*--------------------------------------
|
||
* Device Header (16 Bytes)
|
||
*--------------------------------------
|
||
DEV.HEADER cld
|
||
jmp (DRV.CS.START,x)
|
||
.DA #0
|
||
.BS 6
|
||
DEV.HEADER.NAME >PSTR "GFX"
|
||
.BS 1
|
||
*--------------------------------------
|
||
* Driver Code
|
||
*--------------------------------------
|
||
DRV.CS.START .DA STATUS
|
||
.DA BADCALL
|
||
.DA BADCALL
|
||
.DA BADCALL
|
||
.DA CONTROL
|
||
.DA BADCALL
|
||
.DA OPEN
|
||
.DA CLOSE
|
||
.DA BADCALL
|
||
.DA BADCALL
|
||
.DA BADCALL
|
||
*--------------------------------------
|
||
.DA SETPIXEL
|
||
.DA GETPIXEL
|
||
.DA HLINE
|
||
.DA VLINE
|
||
.DA FILLRECT
|
||
.DA BITBLT
|
||
*--------------------------------------
|
||
L.STAT .DA STAT
|
||
L.DIV7.0 .DA DIV7.0
|
||
.DA DIV7.256
|
||
.DA DIV7.512
|
||
L.MOD7.0 .DA MOD7.0
|
||
.DA MOD7.256
|
||
.DA MOD7.512
|
||
L.Shift0.Lo .DA Shift0.lo
|
||
L.Shift0.Hi .DA Shift0.hi
|
||
.DA 0 end or relocation
|
||
*--------------------------------------
|
||
BADCALL lda #MLI.ERR.BADCALL
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
STATUS >LDYA L.STAT
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
OPEN sta A2osX.SCRNDEVS+2 DEV.ID in A
|
||
|
||
ldy #0
|
||
ldx #0
|
||
|
||
.1 lda L.DIV7.0,y
|
||
sta DIV7.lo,x
|
||
lda L.MOD7.0,y
|
||
sta MOD7.lo,x
|
||
|
||
iny
|
||
|
||
lda L.DIV7.0,y
|
||
sta DIV7.hi,x
|
||
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
|
||
rts
|
||
*--------------------------------------
|
||
CONTROL sta CLRTEXT
|
||
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
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CLOSE clc
|
||
rts
|
||
*--------------------------------------
|
||
* SETPIXEL
|
||
* In : YA = Ptr to CtrlBlk :
|
||
* 1 : OP (XOR only)
|
||
* 2 : Mode
|
||
* 3 : Color
|
||
* 4 : SrcX1
|
||
* 6 : SrcY1
|
||
*--------------------------------------
|
||
SETPIXEL >STYA ZPBase
|
||
ldy #S.CB.Y1 Skip S.CB.Y1+1.....always 0
|
||
.1 lda (ZPBase),y
|
||
sta CB.Cache,y
|
||
dey
|
||
bpl .1
|
||
|
||
sta SET80STORE
|
||
|
||
lda CB.Cache+S.CB.MODE
|
||
bit #S.CB.MODE.C16
|
||
bne SETPIXEL.C16
|
||
|
||
SETPIXEL.MONO ldx CB.Cache+S.CB.X1+1 Get X Hi byte....
|
||
|
||
lda DIV7.lo,x
|
||
sta .1+1
|
||
lda DIV7.hi,x
|
||
sta .1+2
|
||
|
||
lda MOD7.lo,x
|
||
sta .2+1
|
||
lda MOD7.hi,x
|
||
sta .2+2
|
||
|
||
lda DIV7.BASE,x
|
||
ldx CB.Cache+S.CB.X1
|
||
|
||
clc
|
||
.1 adc $ffff,x DIV7 : x = X.LO, a = X DIV 7
|
||
|
||
pha save X DIV 7
|
||
lsr
|
||
ldy CB.Cache+S.CB.Y1
|
||
clc
|
||
adc BASEL,y setup line Base Ptr (A=Col)
|
||
sta ZPBase
|
||
lda BASEH,y
|
||
sta ZPBase+1
|
||
ply
|
||
lda COL.BANK,y
|
||
tay
|
||
sta $c000,y
|
||
|
||
.2 ldy $ffff,x MOD7 : x = X.LO, y = X MOD 7
|
||
|
||
lda CB.Cache+S.CB.OP
|
||
beq .5
|
||
|
||
lda (ZPBase) XOR
|
||
eor Mono.Masks,y y = mod 7
|
||
sta (ZPBase)
|
||
|
||
sta CLR80STORE
|
||
rts
|
||
|
||
.5 lda (ZPBase)
|
||
ldx CB.Cache+S.CB.COLOR get color
|
||
bne .6
|
||
|
||
and Mono.NMasks,y includes And $7F for mono
|
||
sta (ZPBase)
|
||
sta CLR80STORE
|
||
rts
|
||
|
||
.6 and #$7F switch back this byte to mono
|
||
ora Mono.Masks,y
|
||
sta (ZPBase)
|
||
sta CLR80STORE
|
||
rts
|
||
|
||
SETPIXEL.C16 lda CB.Cache+S.CB.X1
|
||
lsr CB.Cache+S.CB.X1+1 divide by 4
|
||
ror
|
||
lsr CB.Cache+S.CB.X1+1
|
||
ror
|
||
tay Y=X/4 (range 0->139)
|
||
lda DIV7.0,y A=X/4/7 (range 0->19)
|
||
|
||
asl times 2 (range 0->38)
|
||
|
||
ldx CB.Cache+S.CB.Y1
|
||
adc BASEL,x setup line Base Ptr (cc by asl)
|
||
sta ZPBase ZPBase now point to first of...
|
||
lda BASEH,x
|
||
sta ZPBase+1 ...the 4 columns
|
||
|
||
lda MOD7.0,y get MOD
|
||
|
||
asl times 4 to compute index in MASK tables
|
||
asl
|
||
tax set in X for Masks,NMasks
|
||
|
||
lda CB.Cache+S.CB.COLOR
|
||
|
||
asl times 4 to compute index in PIXELS table
|
||
asl
|
||
tay
|
||
|
||
lda Color.Masks,x bits in 1st byte to light?
|
||
beq .10
|
||
and Color.Pixels,y apply color
|
||
sta GBYTE
|
||
|
||
sta SETPAGE2
|
||
|
||
lda (ZPBase)
|
||
and Color.NMasks,x reset existing pixel,
|
||
ora GBYTE
|
||
sta (ZPBase)
|
||
|
||
.10 inx
|
||
iny
|
||
|
||
lda Color.Masks,x
|
||
beq .11
|
||
and Color.Pixels,y apply color
|
||
sta GBYTE
|
||
|
||
sta CLRPAGE2
|
||
|
||
lda (ZPBase)
|
||
and Color.NMasks,x reset existing pixel,
|
||
ora GBYTE
|
||
sta (ZPBase)
|
||
|
||
.11 inc ZPBase
|
||
inx
|
||
iny
|
||
|
||
lda Color.Masks,x
|
||
beq .12
|
||
and Color.Pixels,y apply color
|
||
sta GBYTE
|
||
|
||
sta SETPAGE2
|
||
|
||
lda (ZPBase)
|
||
and Color.NMasks,x reset existing pixel,
|
||
ora GBYTE
|
||
sta (ZPBase)
|
||
|
||
.12 inx
|
||
iny
|
||
|
||
lda Color.Masks,x
|
||
beq .13
|
||
and Color.Pixels,y apply color
|
||
sta GBYTE
|
||
|
||
sta CLRPAGE2
|
||
|
||
lda (ZPBase)
|
||
and Color.NMasks,x reset existing pixel,
|
||
ora GBYTE
|
||
sta (ZPBase)
|
||
|
||
.13 sta CLR80STORE
|
||
rts
|
||
*--------------------------------------
|
||
* GETPIXEL
|
||
*--------------------------------------
|
||
GETPIXEL rts
|
||
*--------------------------------------
|
||
* HLINE X1,X2 at Y1
|
||
*--------------------------------------
|
||
HLINE >STYA ZPBase
|
||
ldy #S.CB.X2+1
|
||
|
||
.1 lda (ZPBase),y
|
||
sta CB.Cache,y
|
||
dey
|
||
bpl .1
|
||
|
||
HLINE.I lda CB.Cache+S.CB.MODE
|
||
bit #S.CB.MODE.C16
|
||
bne HLINE.C16
|
||
|
||
HLINE.MONO lda CB.Cache+S.CB.X2 Count=X2-X1
|
||
sec
|
||
sbc CB.Cache+S.CB.X1
|
||
eor #$ff
|
||
sta ZPCount
|
||
lda CB.Cache+S.CB.X2+1
|
||
sbc CB.Cache+S.CB.X1+1
|
||
eor #$ff
|
||
sta ZPCount+1
|
||
|
||
ldx CB.Cache+S.CB.X1+1 Get X Hi byte....
|
||
|
||
lda DIV7.lo,x
|
||
sta .1+1
|
||
lda DIV7.hi,x
|
||
sta .1+2
|
||
|
||
lda MOD7.lo,x
|
||
sta .2+1
|
||
lda MOD7.hi,x
|
||
sta .2+2
|
||
|
||
lda DIV7.BASE,x
|
||
ldx CB.Cache+S.CB.X1
|
||
|
||
clc
|
||
.1 adc $ffff,x DIV7 : x = X.LO, a = X DIV 7
|
||
|
||
pha save X DIV 7
|
||
lsr
|
||
ldy CB.Cache+S.CB.Y1
|
||
clc
|
||
adc BASEL,y setup line Base Ptr (A=Col)
|
||
sta ZPBase
|
||
lda BASEH,y
|
||
sta ZPBase+1
|
||
ply
|
||
lda COL.BANK,y
|
||
tay
|
||
sta $c000,y
|
||
|
||
.2 ldy $ffff,x MOD7 : x = X.LO, y = X MOD 7
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
HLINE.C16
|
||
rts
|
||
*--------------------------------------
|
||
* VLINE Y1,Y2 at X1
|
||
*--------------------------------------
|
||
VLINE >STYA ZPBase
|
||
ldy #S.CB.Y2
|
||
|
||
.1 lda (ZPBase),y
|
||
sta CB.Cache,y
|
||
dey
|
||
bpl .1
|
||
|
||
sta SET80STORE
|
||
|
||
VLINE.MONO ldx CB.Cache+S.CB.X1+1 Get X Hi byte....
|
||
|
||
lda DIV7.lo,x
|
||
sta .1+1
|
||
lda DIV7.hi,x
|
||
sta .1+2
|
||
|
||
lda MOD7.lo,x
|
||
sta .2+1
|
||
lda MOD7.hi,x
|
||
sta .2+2
|
||
|
||
lda DIV7.BASE,x
|
||
ldx CB.Cache+S.CB.X1
|
||
|
||
clc
|
||
|
||
.1 adc $ffff,x DIV7 : x = X.LO, a = X DIV 7
|
||
sta XDIV7 save X DIV 7
|
||
|
||
.2 lda $ffff,x MOD7 : x = X.LO, y = X MOD 7
|
||
sta XMOD7
|
||
|
||
lda CB.Cache+S.CB.OP
|
||
beq .4
|
||
|
||
ldx CB.Cache+S.CB.Y1
|
||
|
||
.3 lda XDIV7
|
||
tay
|
||
lsr
|
||
clc
|
||
adc BASEL,x
|
||
sta ZPBase
|
||
lda BASEH,x
|
||
sta ZPBase+1
|
||
|
||
ldx COL.BANK,y
|
||
sta $C000,x
|
||
|
||
ldy XMOD7
|
||
lda (ZPBase) XOR
|
||
eor Mono.Masks,y y = mod 7
|
||
sta (ZPBase)
|
||
|
||
bra .6
|
||
|
||
.4 lda (ZPBase)
|
||
ldx CB.Cache+S.CB.COLOR get color
|
||
bne .5
|
||
|
||
and Mono.NMasks,y includes And $7F for mono
|
||
sta (ZPBase)
|
||
bra .6
|
||
|
||
.5 and #$7F switch back this byte to mono
|
||
ora Mono.Masks,y
|
||
sta (ZPBase)
|
||
|
||
.6 inc CB.Cache+S.CB.Y1
|
||
ldx CB.Cache+S.CB.Y1
|
||
cpx CB.Cache+S.CB.Y2
|
||
bne .3
|
||
|
||
sta CLR80STORE
|
||
rts
|
||
|
||
VLINE.C16 lda CB.Cache+S.CB.X1
|
||
lsr CB.Cache+S.CB.X1+1 divide by 4
|
||
ror
|
||
lsr CB.Cache+S.CB.X1+1
|
||
ror
|
||
tay Y=X/4 (range 0->139)
|
||
lda DIV7.0,y A=X/4/7 (range 0->19)
|
||
|
||
asl times 2 (range 0->38)
|
||
|
||
ldx CB.Cache+S.CB.Y1
|
||
adc BASEL,x setup line Base Ptr (cc by asl)
|
||
sta ZPBase ZPBase now point to first of...
|
||
lda BASEH,x
|
||
sta ZPBase+1 ...the 4 columns
|
||
|
||
lda MOD7.0,y get MOD
|
||
|
||
asl times 4 to compute index in MASK tables
|
||
asl
|
||
tax set in X for Masks,NMasks
|
||
|
||
lda CB.Cache+S.CB.COLOR
|
||
|
||
asl times 4 to compute index in PIXELS table
|
||
asl
|
||
tay
|
||
|
||
lda Color.Masks,x bits in 1st byte to light?
|
||
beq .10
|
||
and Color.Pixels,y apply color
|
||
sta GBYTE
|
||
|
||
sta SETPAGE2
|
||
|
||
lda (ZPBase)
|
||
and Color.NMasks,x reset existing pixel,
|
||
ora GBYTE
|
||
sta (ZPBase)
|
||
|
||
.10 inx
|
||
iny
|
||
|
||
lda Color.Masks,x
|
||
beq .11
|
||
and Color.Pixels,y apply color
|
||
sta GBYTE
|
||
|
||
sta CLRPAGE2
|
||
|
||
lda (ZPBase)
|
||
and Color.NMasks,x reset existing pixel,
|
||
ora GBYTE
|
||
sta (ZPBase)
|
||
|
||
.11 inc ZPBase
|
||
inx
|
||
iny
|
||
|
||
lda Color.Masks,x
|
||
beq .12
|
||
and Color.Pixels,y apply color
|
||
sta GBYTE
|
||
|
||
sta SETPAGE2
|
||
|
||
lda (ZPBase)
|
||
and Color.NMasks,x reset existing pixel,
|
||
ora GBYTE
|
||
sta (ZPBase)
|
||
|
||
.12 inx
|
||
iny
|
||
|
||
lda Color.Masks,x
|
||
beq .13
|
||
and Color.Pixels,y apply color
|
||
sta GBYTE
|
||
|
||
sta CLRPAGE2
|
||
|
||
lda (ZPBase)
|
||
and Color.NMasks,x reset existing pixel,
|
||
ora GBYTE
|
||
sta (ZPBase)
|
||
|
||
.13 sta CLR80STORE
|
||
rts
|
||
*--------------------------------------
|
||
* FILLRECT
|
||
* 2 : Mode
|
||
* 3 : Color
|
||
* 4 : SrcX1
|
||
* 6 : SrcY1
|
||
* 8 : SrcX2
|
||
* 10 : SrcY2
|
||
*--------------------------------------
|
||
FILLRECT >STYA ZPBase
|
||
ldy #S.CB.Y2
|
||
|
||
.1 lda (ZPBase),y
|
||
sta CB.Cache,y
|
||
dey
|
||
bpl .1
|
||
|
||
|
||
.2 jsr HLINE.I
|
||
|
||
lda CB.Cache+S.CB.Y1
|
||
cmp CB.Cache+S.CB.Y2
|
||
beq .8
|
||
|
||
inc CB.Cache+S.CB.Y1
|
||
bra .2
|
||
.8 rts
|
||
*--------------------------------------
|
||
* BitBlt
|
||
* In : YA = Ptr to CtrlBlk :
|
||
* 1 : OP
|
||
* 4 : SrcX1
|
||
* 6 : SrcY1
|
||
* 8 : SrcX2
|
||
* 10 : SrcY2
|
||
* 12 : DestX
|
||
* 14 : DestY
|
||
* 16 : BM Struct Ptr
|
||
* 18 : Save Ptr
|
||
*--------------------------------------
|
||
BITBLT >STYA ZPBase
|
||
lda (ZPBase)
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
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
|
||
Shift6.lo .BS 128
|
||
Shift6.hi .BS 128
|
||
*--------------------------------------
|
||
.INB /A2OSX.SRC/DRV/DHGR.DRV.T
|
||
*--------------------------------------
|
||
DIV7.lo .BS 3
|
||
DIV7.hi .BS 3
|
||
MOD7.lo .BS 3
|
||
MOD7.hi .BS 3
|
||
Shiftlo.hi .BS 7
|
||
Shifthi.hi .BS 7
|
||
*--------------------------------------
|
||
CB.Cache .BS S.CB
|
||
*--------------------------------------
|
||
XDIV7 .BS 1
|
||
XMOD7 .BS 1
|
||
GBYTE .BS 1
|
||
*--------------------------------------
|
||
STAT .DA #0
|
||
.DA #0,#0,#0
|
||
>PSTR "Apple II DHGR"
|
||
.BS 3
|
||
.DA #S.DEVSTAT.T.GFX
|
||
.DA #0
|
||
.DA $0900
|
||
*--------------------------------------
|
||
DEVSTAT.MODES .DA #S.CB.MODE.MONO+S.CB.MODE.C16
|
||
DEVSTAT.W .DA 560 X.SIZE
|
||
DEVSTAT.H .DA 192 Y.SIZE
|
||
*--------------------------------------
|
||
DRV.SIZE .EQ *-DRV.CS.START
|
||
*--------------------------------------
|
||
.LIST OFF
|
||
MAN
|
||
SAVE /A2OSX.SRC/DRV/DHGR.DRV.S
|
||
ASM
|