Kernel 0.9.1 : DHGR Driver, BitBLT

This commit is contained in:
Rémy GIBERT 2017-11-23 17:51:52 +01:00
parent f7b519729b
commit 6bb1a4d46b
15 changed files with 339 additions and 202 deletions

Binary file not shown.

Binary file not shown.

63
.Tools/ShiftTables.cmd Normal file
View File

@ -0,0 +1,63 @@
@echo off
title Kernel DOC generator
COLOR 2A
prompt ]
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
mode con:cols=80 lines=24
cls
echo Apple //e
(echo.)>SHIFT.L1.TXT
set /a B=0
set SHIFT= .DA
:LOOP1
call :ToBin %B%
set SHIFT=%SHIFT% #%Output:~2,6%%Output:~0,1%
set /a B+=1
set /a MOD=B%%4
if "%MOD%" EQU "0" (
echo %SHIFT%
set SHIFT= .DA
)
if "%B%" NEQ "128" goto LOOP1
echo.
echo (I know, this batch is stupid ;-)
echo.
pause
exit 0
:ToBin
SET Output=
SET CurrentValue=64
SET InputValue=%1
:TopLoop
IF !CurrentValue! LEQ !InputValue! (
SET Output=!Output!1
SET /A InputValue=!InputValue!-!CurrentValue!
) ELSE (
SET Output=!Output!0
)
If !CurrentValue! EQU 1 GOTO :EOF
SET /A CurrentValue=!CurrentValue!/2
Goto TopLoop

View File

@ -197,9 +197,7 @@ WRITE bit bEscMode
bcc COUT.Ctrl
ora INVFLG
ldx CH
ldy CV
jsr SetCharAtXY
jsr SetCharAtCurPos
*--------------------------------------
FS ldx CH
cpx #79
@ -224,9 +222,7 @@ DEL ldx CH
.3 lda #$20
ora INVFLG
ldx CH
ldy CV
jmp SetCharAtXY
jmp SetCharAtCurPos
*--------------------------------------
COUT.Ctrl ldx #CtrlChars.Cnt-1
@ -291,7 +287,10 @@ COUT.ExecEscSeq stz EscSeqParamCnt
.1 inx
lda EscSeq,x
jsr IsDigit
cmp #'0'
bcc .2
cmp #'9'+1
bcs .2
dec bEscSeqInNum
@ -487,32 +486,35 @@ SCROLL.UP ldx SCROLLTOP
inx
jsr SETUP.L2X
jsr COPY.L2toL1
jsr COPY.XtoL1
cpx SCROLLBOT
bne .1
*--------------------------------------
CLREOL ldx CH
ldy #80
CLREOL ldy CH Start
ldx #80 End
bra CLR
CLRLINE ldx #0
ldy #80
CLRLINE ldy #0 Start
ldx #80 End
bra CLR
CLRSOL ldx #0
ldy CH
CLRSOL ldy #0 Start
ldx CH End
CLR sty .2+1
CLR stx .2+1
ldx CV
.1 lda #" "
ldy CV
jsr SetCharAtXY X,Y unmodified
inx
.2 cpx #$ff Self Modified
phy
jsr SetCharAtYX X unmodified
ply
iny
.2 cpy #$ff Self Modified
bne .1
clc
rts
*--------------------------------------
@ -522,9 +524,7 @@ SCROLL.DN ldx SCROLLBOT
dex
jsr SETUP.L2X
jsr COPY.L2toL1
jsr COPY.XtoL1
cpx SCROLLTOP
bne .1
@ -667,77 +667,73 @@ CURBLNK lda A2osX.ASCREEN
CURBLNK1 lda CURON
bne CURBLNK.OFF
ldx CH
ldy CV
jsr GetCharAtXY
jsr GetCharAtCurPos
sta CURCHAR
and #$80
ldx CH
ldy CV
eor #" "
jsr SetCharAtXY
bra CUREXIT
CURBLNK.OFF ldx CH
ldy CV
lda CURCHAR
jsr SetCharAtXY
CUREXIT lda CURON
CURBLNK.OFF lda CURCHAR
CUREXIT jsr SetCharAtCurPos
lda CURON
eor #CURSOR.BLINK.SPEED
sta CURON
CUREXIT.RTS rts
*--------------------------------------
SetCharAtXY cmp #$40
SetCharAtCurPos ldy CH
ldx CV
*--------------------------------------
SetCharAtYX cmp #$40
bcc .10
cmp #$5F
bcs .10
and #$3F
.10 php
pha
txa
lsr
.10 pha
jsr SETUP.L1X
tya
lsr
tay
pla
bcs .1
php
sei
sta SETWRITEAUX
.1 clc
adc BASEL,y
sta ZPBaseL1
lda BASEH,y
sta ZPBaseL1+1
pla
sta (ZPBaseL1)
sta (ZPBaseL1),y
sta CLRWRITEAUX
plp
clc
rts
.1 sta (ZPBaseL1),y
rts
*--------------------------------------
GetCharAtXY php
txa
lsr
GetCharAtCurPos ldy CH
ldx CV
*--------------------------------------
GetCharAtYX jsr SETUP.L1X
bcs .1
tya
lsr
tay
bcs .1
php
sei
sta SETREADAUX
.1 clc
adc BASEL,y
sta ZPBaseL1
lda BASEH,y
sta ZPBaseL1+1
lda (ZPBaseL1)
lda (ZPBaseL1),y
sta CLRREADAUX
plp
rts
.1 lda (ZPBaseL1),y
rts
*--------------------------------------
SETUP.L1X lda BASEL,x
@ -746,29 +742,23 @@ SETUP.L1X lda BASEL,x
sta ZPBaseL1+1
rts
*--------------------------------------
SETUP.L2X lda BASEL,x
COPY.XtoL1 lda BASEL,x
sta ZPBaseL2
lda BASEH,x
sta ZPBaseL2+1
rts
*--------------------------------------
COPY.L2toL1 php
php
sei
sta SETWRITEAUX
sta SETREADAUX
ldy #39
jsr .1
.1 lda (ZPBaseL2),y
sta (ZPBaseL1),y
dey
bpl .1
sta CLRWRITEAUX
sta CLRREADAUX
plp
ldy #39
.1 ldy #39
.2 lda (ZPBaseL2),y
sta (ZPBaseL1),y
@ -776,13 +766,6 @@ COPY.L2toL1 php
bpl .2
rts
*--------------------------------------
IsDigit cmp #'0'
bcc .9
cmp #'9'+1
rts cc if ok, cs if not
.9 sec
rts
*--------------------------------------
Decimal.Out stz DecimalBuffer
stz DecimalBuffer+1
@ -899,9 +882,9 @@ DEVSTAT .DA #S.DSTAT.S.WRITE+S.DSTAT.S.READ
.DA #S.DSTAT.T.CHAR
.DA #0
.DA $0900
ENQ.String >CSTR "A2osXTERM"
ENQ.String >CSTR "XTERM"
SB.IS.TTYPE .DA #IAC,#SB,#TELOPT.TTYPE,#SB.IS
.AS 'A2osXTERM'
.AS 'XTERM'
.DA #IAC,#SE
SB.IS.TTYPE.LEN .EQ *-SB.IS.TTYPE
*--------------------------------------

View File

@ -43,19 +43,19 @@ BITBLT >LDYA CB.CACHE+S.CB.SrcPtr
pha
tya
clc
adc ZPBMDataPtr
sta ZPBMDataPtr
adc ZPBMDataPtr0
sta ZPBMDataPtr0
pla
pha
adc ZPBMDataPtr+1
sta ZPBMDataPtr+1
adc ZPBMDataPtr0+1
sta ZPBMDataPtr0+1
tya
adc BM.Cache+S.BM.MASK.OFS
sta ZPBMMaskPtr
sta ZPBMMaskPtr0
pla
adc BM.Cache+S.BM.MASK.OFS+1
sta ZPBMMaskPtr+1
sta ZPBMMaskPtr0+1
lda CB.Cache+S.CB.X1
pha
@ -72,18 +72,18 @@ BITBLT >LDYA CB.CACHE+S.CB.SrcPtr
pha
clc
adc ZPBMDataPtr
sta ZPBMDataPtr
adc ZPBMDataPtr0
sta ZPBMDataPtr0
bcc .3
inc ZPBMDataPtr+1
inc ZPBMDataPtr0+1
.3 pla
adc ZPBMMaskPtr
sta ZPBMMaskPtr
adc ZPBMMaskPtr0
sta ZPBMMaskPtr0
bcc .4
inc ZPBMMaskPtr+1
inc ZPBMMaskPtr0+1
.4 lda S.CB.X2
sec
@ -106,11 +106,98 @@ BITBLT >LDYA CB.CACHE+S.CB.SrcPtr
adc BLT.DX+1
jsr LBUF.SetBounds2YA
.5 lda BLT.BMBitOfs
sta BLT.BMBitOfsL
lda S.CB.Y2
sec
sbc S.CB.Y1
sta BLT.DY
.6 jsr BLT.Get7BMBits
lda BLT.BMBitOfs
sta BLT.BMBitOfsL
lda LBUF.C1
sta BLT.ScreenC
>LDYA ZPBMDataPtr0
>STYA ZPBMDataPtr
>LDYA ZPBMMaskPtr0
>STYA ZPBMMaskPtr
ldx BLT.SCRBitOfs
beq BITBLT.LOOP
ldy Shift.L.LO,x X = 1->6
sty ZPShiftPtr
ldy Shift.L.HI,x X = 1->6
sty ZPShiftPtr+1
BITBLT.LOOP ldx BLT.SCRBitOfs
bne .2
.1 jsr BLT.Get7BMDBits we have 0xxxxxxxx in A
ldx BLT.ScreenC
sta LBUF.DATA,x
inc BLT.ScreenC
cpx LBUF.C2
bne .1
bra BITBLT.DRAW
.2 jsr BLT.Get7BMDBits we have 0xxxxxxxx in A
pha save it for 2nd part
ldx BLT.SCRBitOfs
and Mask7BitsH,x 0000xxxx, keep col1 bits only
tay
lda (ZPShiftPtr),y make 0xxxx000
ldy BLT.ScreenC
ora LBUF.DATA,y
sta LBUF.DATA,y
pla
inc BLT.ScreenC
cpy LBUF.C2
beq BITBLT.DRAW
and Mask7BitsL,x 0yyy0000
tay
lda (ZPShiftPtr),y 00000yyy
ldy BLT.ScreenC
sta LBUF.DATA,y
inc BLT.ScreenC
cpy LBUF.C2
bne .2
BITBLT.DRAW ldy S.CB.Y1
jsr LBUF.DrawAtY
inc S.CB.Y1
lda ZPBMDataPtr0
clc
adc BM.Cache+S.BM.RowBytes
sta ZPBMDataPtr0
bcc .6
inc ZPBMDataPtr0+1
.6 lda ZPBMMaskPtr0
clc
adc BM.Cache+S.BM.RowBytes
sta ZPBMMaskPtr0
bcc .7
inc ZPBMMaskPtr0+1
.7 dec BLT.DY
bne BITBLT.LOOP
clc
rts
*--------------------------------------
@ -121,39 +208,39 @@ BITBLT >LDYA CB.CACHE+S.CB.SrcPtr
* LBUF DATA/MASK Bits
* c6543210 c6543210
* ^
* SCRBitOfsL (0->6)
* SCRBitOfs (0->6)
*--------------------------------------
BLT.Get7BMBits lda (ZPBMDataPtr)
BLT.Get7BMDBits lda (ZPBMDataPtr)
ldx BLT.BMBitOfsL
beq BLT.Get7BMBits0 done! and no need to advance ZPBMDataPtr
lsr Range 0->127
dex Range 0->6
beq BLT.Get7BMBits1
beq BLT.Get7BMBits0 OFS=0, done! and no need to advance ZPBMDataPtr
lsr OFS=1->7, shift one (Range 0->127)
dex OFS 0->6
beq BLT.Get7BMBits1 OFS was 1....done and go to next byte, OFS=0
ldy Shift7.LO-1,x X = 1->6
sty ZPBMShiftPtr+1
ldy Shift7.HI-1,x X = 1->6
sty ZPBMShiftPtr+1
ldy Shift.R.LO,x X = 1->6
sty ZPShiftPtr
and Mask7BitsL,x Get only needed bits
tay
ldy Shift.R.HI,x X = 1->6
sty ZPShiftPtr+1
lda (ZPBMShiftPtr),y
and Mask7BitsL,x Get only left upper X bits
tay xxxxx000
lda (ZPShiftPtr),y shift'em RIGHT 000xxxxx
pha
inc ZPBMDataPtr Next BM data byte
bne .1
bne .2
inc ZPBMDataPtr+1
.1 lda (ZPBMDataPtr)
and Mask7BitsH,x
.2 lda (ZPBMDataPtr) get next byte
and Mask7BitsH,x only first Y bits 000000yy
tay
pla
pla get back right part bits 000xxxxx
ora (ZPBMShiftPtr),y
ora (ZPShiftPtr),y shift right 000000yy and ORA with 000xxxxx=0yyxxxxx
dec BLT.BMBitOfsL X = 1->6, ADD 7 MOD 8.....
rts

View File

@ -57,10 +57,10 @@ HLINE.C16 lda CB.Cache+S.CB.X1
asl
clc
adc L.Color.Pixels
sta ZPPalettePtr
sta .2+1
lda L.Color.Pixels+1
adc #0
sta ZPPalettePtr+1
sta .2+2
ldx LBUF.C1
@ -68,7 +68,7 @@ HLINE.C16 lda CB.Cache+S.CB.X1
and #3 Compute index in Palette (Mod 4)
tay
lda (ZPPalettePtr),y
.2 lda $ffff,y SELF MODIFIED
sta LBUF.DATA,x
cpx LBUF.C2

View File

@ -17,12 +17,12 @@ AUTO 6
*--------------------------------------
ZPCmdPtr .EQ ZPDRV
ZPBasePtr .EQ ZPDRV+2
ZPPalettePtr .EQ ZPDRV+4
ZPBMDataPtr .EQ ZPDRV+6
ZPBMMaskPtr .EQ ZPDRV+8
ZPBMSavePtr .EQ ZPDRV+10
ZPBMShiftPtr .EQ ZPDRV+12
ZPSCRShiftPtr .EQ ZPDRV+14
ZPShiftPtr .EQ ZPDRV+4
ZPBMDataPtr0 .EQ ZPDRV+6
ZPBMMaskPtr0 .EQ ZPDRV+8
ZPBMDataPtr .EQ ZPDRV+10
ZPBMMaskPtr .EQ ZPDRV+12
ZPBMSavePtr .EQ ZPDRV+14
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
@ -147,12 +147,12 @@ J.LBUF.DrawAtY .DA LBUF.DrawAtY.XOR
.DA LBUF.DrawAtY.SET
.DA LBUF.DrawAtY.ORA
.DA LBUF.DrawAtY.AND
L.SHIFT.R2 .DA SHIFT.R2
.DA SHIFT.R3
.DA SHIFT.R4
.DA SHIFT.R5
.DA SHIFT.R6
.DA SHIFT.R7
L.SHIFT .DA SHIFT.L1
.DA SHIFT.L2
.DA SHIFT.L3
.DA SHIFT.L4
.DA SHIFT.L5
.DA SHIFT.L6
L.DSTAT .DA DSTAT
L.Color.Pixels .DA Color.Pixels
.DA 0 end or relocation
@ -164,21 +164,31 @@ STATUS >LDYA L.DSTAT
OPEN sta A2osX.SCRNDEVS+2 DEV.ID in A
ldx #0
ldy #0
.1 lda L.SHIFT.R2,x Get relocated LO BYTE
sta Shift7.LO,y
ldy #1
.1 lda L.SHIFT,x Get relocated LO BYTE
sta Shift.L.LO,y
inx
lda L.SHIFT.R2,x Get relocated HI BYTE
sta Shift7.HI,y
lda L.SHIFT,x Get relocated HI BYTE
sta Shift.L.LO,y
inx
iny
cpy #6 6 LO/HI bytes to set in tables
cpx #12
bne .1
ldx #0 SHIFT.L1 = SHIFT.R6 !!!
ldy #6
.2 lda L.SHIFT,x Get relocated LO BYTE
sta Shift.L.LO,y
inx
lda L.SHIFT,x Get relocated HI BYTE
sta Shift.L.LO,y
inx
dey
bne .2
*--------------------------------------
CONTROL ldy #0
@ -286,11 +296,11 @@ YAMultX stx GBYTE
bne .2
rts
*--------------------------------------
.INB /A2OSX.SRC/DRV/DHGR.DRV.S.PIX
.INB /A2OSX.SRC/DRV/DHGR.DRV.S.LINE
.INB /A2OSX.SRC/DRV/DHGR.DRV.S.RECT
.INB /A2OSX.SRC/DRV/DHGR.DRV.S.BLT
.INB /A2OSX.SRC/DRV/DHGR.DRV.S.LBUF
.INB /A2OSX.SRC/DRV/DHGR.DRV.S.LINE
.INB /A2OSX.SRC/DRV/DHGR.DRV.S.PIX
.INB /A2OSX.SRC/DRV/DHGR.DRV.S.RECT
*--------------------------------------
DRV.CS.END
*--------------------------------------
@ -367,8 +377,10 @@ CONTROL.LCM
.DA #SETDHIRES
.DA #$ff
*--------------------------------------
Shift7.LO .BS 6
Shift7.HI .BS 6
Shift.L.LO .BS 7
Shift.L.HI .BS 7
Shift.R.LO .BS 7
Shift.R.HI .BS 7
*--------------------------------------
CB.CmdLen .DA S.CB.Y1+1 SETPIXEL
.DA S.CB.Y1+1 GETPIXEL
@ -393,8 +405,9 @@ LBUF.DATA .BS 80
BLT.BMBitOfs .BS 1
BLT.BMBitOfsL .BS 1
BLT.SCRBitOfs .BS 1
BLT.SCRBitOfsL .BS 1
BLT.DX .BS 2
BLT.DY .BS 1
BLT.ScreenC .BS 1
*--------------------------------------
GBYTE .BS 1
GWORD .BS 2

View File

@ -171,12 +171,12 @@ MOD7.256 .HS 040506
.HS 00010203040506
.HS 00
*--------------------------------------
SHIFT.R2 .BS 128
SHIFT.R3 .BS 128
SHIFT.R4 .BS 128
SHIFT.R5 .BS 128
SHIFT.R6 .BS 128
SHIFT.R7 .BS 128
SHIFT.L1 .BS 128
SHIFT.L2 .BS 128
SHIFT.L3 .BS 128
SHIFT.L4 .BS 128
SHIFT.L5 .BS 128
SHIFT.L6 .BS 128
*--------------------------------------
BASEL .HS 00.00.00.00.00.00.00.00
.HS 80.80.80.80.80.80.80.80

View File

@ -61,15 +61,13 @@ CUT.T.TEXT .EQ 12
*--------------------------------------
S.CUR.HotPointX .EQ 0
S.CUR.HotPointY .EQ 1
S.CUR.DATA .EQ 2 16x16 bits = 32 bytes
S.CUR.MASK .EQ 34
S.CUR .EQ 66
S.CUR.BM .EQ 2
*--------------------------------------
S.BM.F .EQ 0
S.BM.F.BBP1 .EQ %00000001
S.BM.F.BBP2 .EQ %00000010
S.BM.F.BBP4 .EQ %00001000
S.BM.F.BBP8 .EQ %00010000
S.BM.F.BBP4 .EQ %00000100
S.BM.F.BBP8 .EQ %00001000
S.BM.RowBytes .EQ 1
S.BM.W .EQ 2
S.BM.H .EQ 4

View File

@ -430,8 +430,11 @@ CB.CmdLen .DA S.CB.Y1+1 SETPIXEL
*--------------------------------------
CB.Cache .BS S.CB
*--------------------------------------
CUR.Arrow .DA #0
.DA #0
CUR.Arrow .DA #S.BM.F.BBP1
.DA #2 RowBytes
.DA 12 W
.DA 12 H
.DA CUR.Arrow.MASK-CUR.Arrow
CUR.Arrow.DATA .DA %00000001.000000000
.DA %00000011.000000000
.DA %00000101.000000000
@ -444,10 +447,6 @@ CUR.Arrow.DATA .DA %00000001.000000000
.DA %00000000.000000000
.DA %00000000.000000000
.DA %00000000.000000000
.DA %00000000.000000000
.DA %00000000.000000000
.DA %00000000.000000000
.DA %00000000.000000000
CUR.Arrow.MASK .DA %00000000.000000000
.DA %00000000.000000000
.DA %00000010.000000000
@ -460,16 +459,6 @@ CUR.Arrow.MASK .DA %00000000.000000000
.DA %00000000.000000000
.DA %00000000.000000000
.DA %00000000.000000000
.DA %00000000.000000000
.DA %00000000.000000000
.DA %00000000.000000000
.DA %00000000.000000000
*--------------------------------------
PAT.Arrow .DA #S.BM.F.BBP1
.DA #1 RowBytes
.DA 7 W
.DA 8 H
.DA 0
*--------------------------------------
MAN
SAVE /A2OSX.SRC/LIB/LIBGUI.S

View File

@ -452,7 +452,7 @@ CORE.PSResume ldy #S.PS.PC
*--------------------------------------
TSKMGR.EVENTCNT .BS 1
*--------------------------------------
DevMgr.Stat .DA DevMgr.NUL.Code
DevMgr.Stat .DA DevMgr.FreeMem
DevMgr.Free .DA DevMgr.FreeMem
.DA DevMgr.HiMem
DevMgr.Count .DA #2 NUL,SYS

View File

@ -417,6 +417,17 @@ DevMgr.SYS.ClrEOL
bne .1
.2 rts
*--------------------------------------
DevMgr.SYS.ScrollAux
sta SETREADAUX
.1 lda (ZPDRV+2),y
sta (ZPDRV),y
dey
bpl .1
sta CLRREADAUX
rts
*--------------------------------------
DevMgr.SYS.Scroll
ldx #1
.1 jsr DevMgr.SYS.SetBaseX
@ -427,13 +438,20 @@ DevMgr.SYS.Scroll
lda DevMgr.SYS.BASEH,x
sta ZPDRV+3
ldy #39
php
sei
ldx #DevMgr.SYS.Scroll-DevMgr.SYS.ScrollAux-1
.2 lda DevMgr.SYS.ScrollAux,x
sta $102,x
dex
bpl .2
ldy #39
sta SETWRITEAUX
jsr DevMgr.SYS.ScrollAux
jsr $102
sta CLRWRITEAUX
plp

View File

@ -219,7 +219,7 @@ GO.EXIT.SaveA lda #$ff
plp
GO.EXIT.JMP jmp $FFFF Self Modified
*--------------------------------------
* Called for ProDOS IRQ Manager (LCBNK1)
* Called from ProDOS IRQ Manager (LCBNK1)
* A,X,Y, $FA->$FF Already Saved
* Main RAM,ZP/LC selected
* must begin with CLD

View File

@ -46,12 +46,9 @@ K.IrqHAuxLC sta .12+1
bcs .8
rti
.2
pla pull P
.2 pla pull P
bra *
lda .12+1
.8 jmp (IRQ.OldFFFE)
*--------------------------------------
* Called by :
@ -78,17 +75,17 @@ K.IrqH.TCLOCK ldy IRQ.VBL.n0
clc
rts
*--------------------------------------
K.IrqH.VBL jsr IRQ.VBL.MSM SERVEMOUSE
bcs K.IrqH.DEV Not From Mouse
K.IrqH.VBL jsr IRQ.VBL.MSM SERVEMOUSE
bcs K.IrqH.DEV Not From Mouse
ldx IRQ.VBL.0n
lda $778,x
and #$08 IRQ was caused by VBL ?
beq K.IrqH.DEV
ldx IRQ.VBL.MRM+2 $Cn
ldx IRQ.VBL.MRM+2 $Cn
ldy IRQ.VBL.n0
jsr IRQ.VBL.MRM READMOUSE
jsr IRQ.VBL.MRM READMOUSE
inc CORE.IRQTick

View File

@ -435,17 +435,6 @@ K.SYSCALL.BANK .DA #RRAMWRAMBNK1 $00
.DA 0
.DA 0
*--------------------------------------
DevMgr.SYS.ScrollAux
sta SETREADAUX
.1 lda (ZPDRV+2),y
sta (ZPDRV),y
dey
bpl .1
sta CLRREADAUX
rts
*--------------------------------------
PullP1P2P3 sec
.HS 90 bcc
PullP1P2 clc