A2osX/DRV/DHGR.DRV.S.txt
2016-06-23 17:56:13 +02:00

678 lines
12 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/DRV/DHGR.DRV
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/IO.I
.INB INC/LIBGFX.I
*--------------------------------------
ZPBase .EQ ZPDRV
ZPBitBlt .EQ ZPDRV+2
ZPShiftLo .EQ ZPDRV+4
ZPShiftHi .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 SYS.PSTROutYA
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 >PSTRING "\nApple IIe/IIc DHGR Driver.\n"
*--------------------------------------
* Device Header (16 Bytes)
*--------------------------------------
DEV.HEADER cld
jmp (DRV.CS.START,x)
.HS 00 DevID
.DA #S.DEV.F.EVENT
>PSTRING "GFX" NAME
.HS 00 NAME must Be 5 bytes long
.HS 00
.HS 00.00.00.00
*--------------------------------------
* Driver Code
*--------------------------------------
DRV.CS.START .DA OPEN
.DA GETEVENT
.DA COUT
.DA CLOSE
.DA GETINFO
.DA IRQ
.DA SELECT
.DA SETPIXEL
.DA GETPIXEL
.DA HLINE
.DA VLINE
.DA BITBLT
.DA FILLREC
.DA SETCURPOS
.DA SETCUR
.DA HIDECUR
.DA SHOWCUR
L.DEVINFO .DA DEVINFO
L.DIV7.0 .DA DIV7.0
L.MOD7.0 .DA MOD7.0
L.Shift0.Lo .DA Shift0.lo
L.Shift0.Hi .DA Shift0.hi
.DA 0 end or relocation
*--------------------------------------
OPEN ldy #S.DEV.ID
lda (pDev),y
sta A2osX.SCRNDEVS+2
jsr SELECT
lda #3
sta A2osX.ASCREEN
lda L.DIV7.0+1
sta DIV7.hi
inc
sta DIV7.hi+1
inc
sta DIV7.hi+2
lda L.MOD7.0+1
sta MOD7.hi
inc
sta MOD7.hi+1
inc
sta MOD7.hi+2
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
*--------------------------------------
GETEVENT lda A2osX.ASCREEN
cmp #3
bne .9
>SYSCALL SYS.GetKeyboardEvent
bcs .9
rts
.9 lda #0 Error = no event
sec
rts
*--------------------------------------
COUT
IRQ sec
rts
*--------------------------------------
CLOSE clc
rts
*--------------------------------------
GETINFO >LDYA L.DEVINFO
clc
rts
*--------------------------------------
SELECT 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
clc
rts
*--------------------------------------
* SETPIXEL
* PULLB = Mode
* 00000001=B/W
* 00000010=16 colors
* 1000000=xor (mono on 1 bit)
* PULLW = X
* PULLB = Y
* PULLB = Color (if not xor)
*--------------------------------------
SETPIXEL sta SET80STORE
>PULLA Pull Mode
and #$FF
bpl SETPIXEL.1
SETPIXEL.XOR >PULLAX A=X.LO,X=X.HI
tay
lda DIV7.hi,x
sta .1+2
lda MOD7.hi,x
sta .2+2
.1 lda DIV7.0,y A=Colx2
eor #1
lsr A=Col, CS=MMem, CC=XMem
pha Save Col
lda #CLRPAGE2>1
asl
sta .3+1
.3 sta CLRPAGE2
>PULLA Pull Y
tax
lda BASEL,x setup line Base Ptr
sta ZPBase
lda BASEH,x
sta ZPBase+1
.2 ldx MOD7.0,y Y=X.LO
ply get back Col
lda (ZPBase),y
eor Mono.Masks,x x = mod 7
sta (ZPBase),y
sta CLR80STORE
rts
*--------------------------------------
SETPIXEL.1 lsr
bcc SETPIXEL.COLOR
>PULLAX A=X.LO,X=X.HI
tay
lda DIV7.hi,x
sta .1+2
lda MOD7.hi,x
sta .2+2
.1 lda DIV7.0,y A=Colx2
eor #1
lsr A=Col, CS=MMem, CC=XMem
pha Save Col
lda #CLRPAGE2>1
asl
sta .3+1
.3 sta CLRPAGE2
>PULLA Pull Y
tax
lda BASEL,x setup line Base Ptr
sta ZPBase
lda BASEH,x
sta ZPBase+1
.2 ldx MOD7.0,y Y=X.LO
ply get back Col
>PULLA Pull Color
lsr
lda (ZPBase),y
bcs .6 set white pixel
and Mono.NMasks,x includes And $7F for mono
sta (ZPBase),y
sta CLR80STORE
rts
.6 and #$7F switch back this byte to mono
ora Mono.Masks,x
sta (ZPBase),y
sta CLR80STORE
rts
*--------------------------------------
SETPIXEL.COLOR >PULLW CX Get X.LO...
>PULLB CY
lda CX
lsr CX+1 divide by 4
ror
lsr CX+1
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)
ldx CY
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
>PULLA get COLOR
asl times 4 to compute index in PIXELS table
asl
tay
lda Color.Masks,x bits in 1st byte to light?
beq .1
and Color.Pixels,y apply color
sta GBYTE
sta SETPAGE2
lda (ZPBase)
and Color.NMasks,x reset existing pixel,
ora GBYTE
sta (ZPBase)
.1 inx
iny
lda Color.Masks,x
beq .2
and Color.Pixels,y apply color
sta GBYTE
sta CLRPAGE2
lda (ZPBase)
and Color.NMasks,x reset existing pixel,
ora GBYTE
sta (ZPBase)
.2 inc ZPBase
inx
iny
lda Color.Masks,x
beq .3
and Color.Pixels,y apply color
sta GBYTE
sta SETPAGE2
lda (ZPBase)
and Color.NMasks,x reset existing pixel,
ora GBYTE
sta (ZPBase)
.3 inx
iny
lda Color.Masks,x
beq .8
and Color.Pixels,y apply color
sta GBYTE
sta CLRPAGE2
lda (ZPBase)
and Color.NMasks,x reset existing pixel,
ora GBYTE
sta (ZPBase)
.8 sta CLR80STORE
rts
*--------------------------------------
GETPIXEL rts
*--------------------------------------
HLINE rts
*--------------------------------------
VLINE rts
*--------------------------------------
FILLREC rts
*--------------------------------------
* BitBlt
* In : YA = Ptr to Job :
* 0 : Operation
* %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
*--------------------------------------
BITBLT >STYA ZPBitBlt
lda (ZPBitBlt)
clc
rts
*--------------------------------------
* Y,A = pPoint
*--------------------------------------
SETCURPOS >STYA ZPBase
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
*--------------------------------------
* Y,A = pCur
*--------------------------------------
SETCUR >STYA ZPBase
ldy #S.CUR-1
.1 lda (ZPBase),y
sta CUR.Buf,y
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
ldx CUR.X
.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)
inx
cpx #32
bne .1
sta CLR80STORE
sec
ror CUR.State
SHOWCUR.RTS clc
rts
*--------------------------------------
HIDECUR bit CUR.State
bpl HIDECUR.RTS
HIDECUR.I
clc
ror CUR.State
HIDECUR.RTS 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 DRV/DHGR.DRV.T
*--------------------------------------
DIV7.hi .BS 3
MOD7.hi .BS 3
Shiftlo.hi .BS 7
Shifthi.hi .BS 7
*--------------------------------------
CX .BS 2
CY .BS 1
COL .BS 1
GBYTE .BS 1
*--------------------------------------
CUR.State .BS 1
CUR.X .BS 2
CUR.Xdiv7 .BS 1
CUR.Xmod7 .BS 1
CUR.Y .BS 2
CUR.Buf .BS S.CUR
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
*--------------------------------------
DEVINFO .DA #S.DEVINFO.TYPE.GFX type of DEVINFO STRUCT
DEVINFO.MODES .DA #%10000011 XOR,16 & B/W
DEVINFO.W .DA 560 X.SIZE
DEVINFO.H .DA 192 Y.SIZE
.LIST ON
*--------------------------------------
DRV.SIZE .EQ *-DRV.CS.START
*--------------------------------------
.LIST OFF
MAN
SAVE DRV/DHGR.DRV.S
ASM