A2osX/SBIN/GUIOSD.S.txt
2017-12-19 16:45:39 +01:00

483 lines
8.9 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.BUILD
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BUILD/SBIN/GUI/GUIOSD
*--------------------------------------
.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/LIBGUI.I
*--------------------------------------
A1L .EQ $3C
A2L .EQ $3E
A4L .EQ $42
TXTPTR .EQ $B8
MoveAux .EQ $C311
XFer .EQ $C314
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #64 SS
.DA #0 ZP
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
.DA 0
*--------------------------------------
CS.INIT
lda #0
sec
rts
*--------------------------------------
CS.RUN clc
rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT clc
rts
*--------------------------------------
CS.END
*--------------------------------------
.PH $0C00
*--------------------------------------
ZPCmdPtr .EQ ZPDRV
ZPDstBMPtr .EQ ZPDRV+2
ZPFontPtr .EQ ZPDRV+4
ZPCharPtr .EQ ZPDRV+6
ZPSrcBMPtr .EQ ZPDRV+8
ZPTmpPtr .EQ ZPDRV+10
*--------------------------------------
* YA =Ptr to S.CB in MAIN
* X = DestBM hMem
*--------------------------------------
GUIOSD >STYA A1L Src Start Address (MAIN)
pha
tya
clc
adc #S.CB
sta A2L Src End Address (MAIN)
pla
adc /S.CB
sta A2L+1
>LDYA CB.Cache
>STYA A4L Dst Address (AUX)
sec Main To Aux
jsr MoveAux
txa
beq .1
jsr GO.GetMemPtr.A
>STYA ZPDstBMPtr
ldx #0
.1 lda (ZPDstBMPtr)
sta DstBM.Cache,x
inc ZPDstBMPtr
bne .2
inc ZPDstBMPtr+1
.2 inx
cpx #S.BM
bne .1
ldx CB.Cache+S.CB.CMD
jmp (J.Cmds,x)
*--------------------------------------
J.Cmds .DA SETPIXEL
.DA GETPIXEL
.DA HLINE
.DA VLINE
.DA FILLRECT
.DA BITBLT
.DA GETRECTBUFSIZE
*--------------------------------------
SETPIXEL >LDYA CB.Cache+S.CB.Y1
ldx DstBM.Cache+S.BM.RowBytes
jsr YAMultX
pha
tya
clc
adc ZPDstBMPtr
sta ZPDstBMPtr
pla
adc ZPDstBMPtr+1
sta ZPDstBMPtr+1
lda CB.Cache+S.CB.MODE
bit #S.CB.MODE.C16
bne SETPIXEL.C16
SETPIXEL.MONO lda CB.Cache+S.CB.X1
pha
and #$7 MOD 7
tax
pla
lsr CB.Cache+S.CB.X1
ror
lsr CB.Cache+S.CB.X1
ror
lsr CB.Cache+S.CB.X1
ror
clc
adc ZPDstBMPtr
sta ZPDstBMPtr
lda CB.Cache+S.CB.X1
adc ZPDstBMPtr+1
sta ZPDstBMPtr+1
lda CB.Cache+S.CB.OP
* cmp #S.CB.OP.XOR
beq SETPIXEL.MONO.XOR
lda CB.Cache+S.CB.COLOR
bne SETPIXEL.MONO.WHITE
SETPIXEL.MONO.BLACK
lda (ZPDstBMPtr)
and Mono.NMasks,x
sta (ZPDstBMPtr)
rts
SETPIXEL.MONO.WHITE
lda (ZPDstBMPtr)
ora Mono.Masks,x
sta (ZPDstBMPtr)
rts
SETPIXEL.MONO.XOR
lda (ZPDstBMPtr)
eor Mono.Masks,x
sta (ZPDstBMPtr)
rts
SETPIXEL.C16
*--------------------------------------
GETPIXEL
*--------------------------------------
HLINE
*--------------------------------------
VLINE
*--------------------------------------
FILLRECT
*--------------------------------------
* BitBlt
* S.CB.X1 : SrcX1 in bitmap/mask
* S.CB.Y1 : SrcY1
* S.CB.SrcW : width
* S.CB.SrcH : height
* S.CB.DstX : Destination X (screen)
* S.CB.DstY : Destination Y (screen)
* S.CB.SrcPtr : pointer to S.BM
* S.CB.SrcPtr+1 = 0, hMem in S.CB.SrcPtr
* S.CB.DstPtr : pointer to Save Buffer
*--------------------------------------
BITBLT >LDYA CB.CACHE+S.CB.SrcPtr
bne BITBLT.1
tya
jsr GO.GetMemPtr.A
BITBLT.1 >STYA ZPSrcBMPtr
*--------------------------------------
* In:
* S.CB.SrcW
* S.CB.SrcH
* Out:
* S.CB.DstPtr : Buffer Size (in bytes)
*--------------------------------------
GETRECTBUFSIZE
*--------------------------------------
* In:
* S.CB.S.CB.FONT : hFont
* S.CB.SrcPtr : Ptr to Text
* S.CB.DstPtr : Buffer Size (in bytes)
* Out:
* A=hBM
*--------------------------------------
DRAWTEXT lda CB.Cache+S.CB.hFONT
jsr GO.GetMemPtr.A
>STYA ZPFontPtr
ldy #S.FON-1
.1 lda (ZPFontPtr),y
sta FON.Cache,y
dey
bpl .1
lda ZPFontPtr
clc
adc #S.FON
sta ZPFontPtr
bcc .2
inc ZPFontPtr+1
.2 >LDYA CB.Cache+S.CB.SrcPtr
>STYA TXTPTR
lda S.BM.F.BBP1
sta DstBM.Cache+S.BM.F
stz DstBM.Cache+S.BM.W
stz DstBM.Cache+S.BM.W+1
lda FON.Cache+S.FON.PixH
sta DstBM.Cache+S.BM.H
stz DstBM.Cache+S.BM.H+1
.3 jsr TXTPTR.GetNext
beq .4
jsr FON.GetChar
lda (ZPCharPtr) Get Char PixelW
sec
adc DstBM.Cache+S.BM.W
sta DstBM.Cache+S.BM.W
bcc .3
inc DstBM.Cache+S.BM.W+1
bra .3
.4 jsr BM.Create
bcs .9
sta .8+1 save hBM, ZPDstBMPtr=BMData
>LDYA CB.Cache+S.CB.SrcPtr
>STYA TXTPTR
stz GWORD reset Col index in BM
stz GWORD+1 reset Bit index in Col
.5 jsr TXTPTR.GetNext
beq .8
jsr FON.GetChar
lda (ZPCharPtr) Char PixW
sta GBYTE
ldy #1 Char ByteW
lda (ZPCharPtr),y
sta GBYTE2
>LDYA ZPDstBMPtr
>STYA ZPTmpPtr
lda FON.Cache+S.FON.PixH
.6 pha
ldx GWORD+1 Get Bit Index for shifting
ldy #2
lda (ZPCharPtr),y
pla
dec
bne .6
bra .5
.8 lda #$ff SELF MODIFIED
clc
.9 rts
*--------------------------------------
FON.GetChar cmp FON.Cache+S.FON.Last
bcc .1
bne .2
.1 sec
sbc FON.Cache+S.FON.First
bcs .3
.2 lda FON.Cache+S.FON.Default
.3 asl
php
clc
adc ZPFontPtr
sta ZPCharPtr
adc ZPFontPtr+1
sta ZPCharPtr+1
plp
bcc .8
inc ZPCharPtr+1
.8 rts
*--------------------------------------
BM.Create lda DstBM.Cache+S.BM.W
ldx DstBM.Cache+S.BM.W+1
bit #7
beq .1
and #7
clc
adc #8
bcc .1
inx
.1 sta DstBM.Cache+S.BM.RowBytes
txa
lsr
ror DstBM.Cache+S.BM.RowBytes
lsr
ror DstBM.Cache+S.BM.RowBytes
lsr
ror DstBM.Cache+S.BM.RowBytes
>LDYA DstBM.Cache+S.BM.H
ldx DstBM.Cache+S.BM.RowBytes
jsr YAMultX
pha
tya
clc
adc #S.BM
tay
pla
adc /S.BM
jsr GO.GetMem.YA
bcs .9
>STYA ZPDstBMPtr
ldy #S.BM-1
.2 lda DstBM.Cache,y
sta (ZPDstBMPtr),y
dey
bpl .2
lda ZPDstBMPtr
* clc
adc #S.BM
sta ZPDstBMPtr
bcc .8
inc ZPDstBMPtr+1
.8 txa hBM
clc
.9 rts
*--------------------------------------
* to move in LC or ZP/STK
*--------------------------------------
TXTPTR.GetNext sta CLRREADAUX
lda (TXTPTR)
sta SETREADAUX
beq .9
inc TXTPTR
bne .9
inc TXTPTR+1
.9 rts
*--------------------------------------
* IN:
* Y,A = num1 (16)
* X = num2 (8)
* OUT:
* Y,A = (Y,A) * X
*--------------------------------------
YAMultX stx GBYTE
sty GWORD
sta GWORD+1
ldy #0 Result LO
tya Result HI
bra .3
.1 pha
tya
clc
adc GWORD
tay
pla
adc GWORD+1
.2 asl GWORD
rol GWORD+1
.3 lsr GBYTE
bcs .1
bne .2
rts
*--------------------------------------
GO.GetMem.YA ldx #SYS.GetMem.YA
.HS 2C BIT ABS
GO.GetMemPtr.A ldx #SYS.GetMemPtr.A
GO.Kernel jmp ($E000,x)
*--------------------------------------
Mono.NMasks .DA #%11111110
.DA #%11111101
.DA #%11111011
.DA #%11110111
.DA #%11101111
.DA #%11011111
.DA #%10111111
.DA #%01111111
*--------------------------------------
Mono.Masks .DA #%00000001
.DA #%00000010
.DA #%00000100
.DA #%00001000
.DA #%00010000
.DA #%00100000
.DA #%01000000
.DA #%10000000
*--------------------------------------
CB.Cache .BS S.CB
FON.Cache .BS S.FON
DstBM.Cache .BS S.BM
GBYTE .BS 1
GBYTE2 .BS 1
GWORD .BS 2
*--------------------------------------
.EP
GUIOSD.END .EQ *
*--------------------------------------
.DUMMY
.OR 0
DS.START
DS.END
.ED
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SBIN/GUI/GUIOSD
ASM