- New version of WGPrint that handles scrolling and clipping much better

This commit is contained in:
Quinn Dunki 2014-09-01 11:18:36 -07:00
parent 9cbc3e0cf8
commit 3c4eca1681
9 changed files with 1857 additions and 1397 deletions

7
ReadMe.md Normal file
View File

@ -0,0 +1,7 @@
Known issues
------------
- Negative cursor positions unsupported
- Positive scroll values unsupported

View File

@ -13,6 +13,7 @@
70D435B119A0137F001BFD9B /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
70D435B219A013AF001BFD9B /* gui.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = gui.s; sourceTree = "<group>"; };
70D435B419A0141F001BFD9B /* guidemo.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = guidemo.s; sourceTree = "<group>"; };
70E84C3019B4ED4300159159 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
70F1DB4A19A56CDA00321637 /* macros.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = macros.s; sourceTree = "<group>"; };
70F1DB4B19A56D6300321637 /* switches.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = switches.s; sourceTree = "<group>"; };
70F1DB5619A6B02900321637 /* painting.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = painting.s; sourceTree = "<group>"; };
@ -23,6 +24,7 @@
70D435A619A012CF001BFD9B = {
isa = PBXGroup;
children = (
70E84C3019B4ED4300159159 /* README.md */,
70D435B119A0137F001BFD9B /* Makefile */,
70F1DB4A19A56CDA00321637 /* macros.s */,
70F1DB4B19A56D6300321637 /* switches.s */,

2939
gui.lst

File diff suppressed because it is too large Load Diff

48
gui.s
View File

@ -33,20 +33,50 @@ main:
jsr WGPaintView
ldx #4
ldy #3
ldx #5
ldy #0
jsr WGSetCursor
; lda #-4
; jsr WGScrollX
; lda #-3
; jsr WGScrollY
lda #0
jsr WGScrollX
lda #-2
jsr WGScrollY
; lda WG_VIEWCLIP+0
; jsr PRBYTE
; lda WG_VIEWCLIP+1
; jsr PRBYTE
; lda WG_VIEWCLIP+2
; jsr PRBYTE
; lda WG_VIEWCLIP+3
; jsr PRBYTE
; lda WG_VIEWCLIP+4
; jsr PRBYTE
; lda WG_VIEWRECORDS+0
; jsr PRBYTE
; lda WG_VIEWRECORDS+1
; jsr PRBYTE
; lda WG_VIEWRECORDS+2
; jsr PRBYTE
; lda WG_VIEWRECORDS+3
; jsr PRBYTE
; lda WG_VIEWRECORDS+4
; jsr PRBYTE
; lda WG_VIEWRECORDS+5
; jsr PRBYTE
; lda WG_VIEWRECORDS+6
; jsr PRBYTE
; lda WG_VIEWRECORDS+7
; jsr PRBYTE
; lda WG_VIEWRECORDS+8
; jsr PRBYTE
lda #<testStr
sta PARAM0
lda #>testStr
sta PARAM1
jsr WGPrintASCII
jsr WGPrint
; lda #1
; sta PARAM0
@ -119,10 +149,10 @@ read80ColSwitch_40:
testView:
.byte "0007033e130404"
.byte "0007033e13207e" ; 0, 7,3,62,19,126,126
testStr:
.byte "This is a test of the emergency broadcast system. If this had been a real emergency, you would be dead now.",0
.byte "This is a test of the emergency broadcast system.",0; If this had been a real emergency, you would be dead now.",0 ; 107 chars

Binary file not shown.

View File

@ -110,7 +110,11 @@
asl
asl
asl
asl ; Records are 8 bytes wide
asl
asl
asl
asl
asl ; Records are 16 bytes wide
tay
.endmacro
@ -121,7 +125,11 @@
asl
asl
asl
asl ; Records are 8 bytes wide
asl
asl
asl
asl
asl ; Records are 16 bytes wide
tax
.endmacro

View File

@ -33,10 +33,13 @@ CHAR_FLASH = $7f
COUT = $fded
BASCALC = $fbc1
PRBYTE = $fdda
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; System state
WG_CURSORX: ; In screenspace
;
WG_CURSORX: ; In screenspace
.byte 0
WG_CURSORY:
.byte 0
@ -49,27 +52,38 @@ WG_LOCALCURSORY:
WG_ACTIVEVIEW:
.byte 0
WG_VIEWCLIP:
; X0,Y0,X1,Y1. Edges of current window, in view space, right span
.byte 0,0,0,0,0
WG_VIEWRECORDS:
; X, Y, Screen Width, Screen Height, Style, X Offset, Y Offset, View Width, View Height
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
WG_SCRATCHA:
.byte 0
; Video memory lookup table
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Lookup tables
;
; Video memory
TEXTLINES_H:
.byte $04 ;0
.byte $04 ;1

View File

@ -449,12 +449,11 @@ WGStrokeRect_done:
; WGPlot
; Plots a character at current cursor position (assumes 80 cols)
; A: Character to plot
; Side effects: Clobbers SCRATCH0,BASL,BASH
; Side effects: Clobbers S0, BASL,BASH
;
WGPlot:
sta SCRATCH0
SAVE_AXY
SAVE_ZPS
ldx WG_CURSORY
lda TEXTLINES_L,x ; Compute video memory address of point
@ -488,7 +487,6 @@ WGPlot_xOdd:
sta (BASL),y
WGPlot_done:
RESTORE_ZPS
RESTORE_AXY
rts
@ -571,12 +569,7 @@ WGPrintASCII_loop:
iny
clc
lda #1
adc WG_CURSORX
sta WG_CURSORX
lda #0
adc WG_CURSORY
sta WG_CURSORY
inc WG_CURSORX
jmp WGPrintASCII_loop
WGPrintASCII_done:
@ -591,14 +584,124 @@ WGPrintASCII_done:
; cursor position. Clips to current view.
; PARAM0: String pointer, LSB
; PARAM1: String pointer, MSB
; Side effects: Clobbers BASL,BASH
; Side effects: Clobbers SA,BASL,BASH
;
WGPrint:
SAVE_AXY
SAVE_ZPS
jsr WGStrLen ; We'll need the length of the string
sta SCRATCH1
LDX_ACTIVEVIEW ; Cache view width for later
inx
inx
inx
inx
inx
inx
inx
lda WG_VIEWRECORDS,x
sta WG_SCRATCHA
inx ; Leave X pointing at view height, for later quick access
ldy #0
WGPrint_lineLoopFirst: ; Calculating start of first line is slightly different
lda WG_LOCALCURSORY
cmp WG_VIEWCLIP+1
bcc WGPrint_skipToEndFirst ; This line is above the clip box
lda WG_LOCALCURSORX ; Find start of line within clip box
cmp WG_VIEWCLIP+0
bcs WGPrint_visibleChars
lda WG_VIEWCLIP+0
sec ; Line begins before left clip plane
sbc WG_LOCALCURSORX
tay ; Advance string index and advance cursor into clip box
lda WG_VIEWCLIP+0
sta WG_LOCALCURSORX
bra WGPrint_visibleChars
WGPrint_skipToEndFirst:
lda WG_SCRATCHA ; Skip string index ahead by distance to EOL
sec
sbc WG_LOCALCURSORX
cmp SCRATCH1
bcs WGPrint_done
tay
lda WG_SCRATCHA ; Skip cursor ahead to EOL
sta WG_LOCALCURSORX
bra WGPrint_nextLine
WGPrint_skipToEnd:
tya ; Skip string index ahead by distance to EOL
clc
adc WG_SCRATCHA
tay
lda WG_SCRATCHA ; Skip cursor ahead to EOL
sta WG_LOCALCURSORX
bra WGPrint_nextLine
WGPrint_lineLoop:
lda WG_LOCALCURSORY
cmp WG_VIEWCLIP+1
bcc WGPrint_skipToEnd ; This line is above the clip box
lda WG_LOCALCURSORX ; Find start of line within clip box
cmp WG_VIEWCLIP+0
bcs WGPrint_visibleChars
tya
clc
adc WG_VIEWCLIP+0 ; Jump ahead by left span
tay
lda WG_VIEWCLIP+0 ; Set cursor to left edge of visible area
sta WG_LOCALCURSORX
WGPrint_visibleChars:
jsr WGSyncGlobalCursor
WGPrint_charLoop:
lda (PARAM0),y ; Draw current character
beq WGPrint_done
ora #$80
jsr WGPlot
iny
inc WG_CURSORX ; Advance cursors
inc WG_LOCALCURSORX
lda WG_LOCALCURSORX
cmp WG_SCRATCHA ; Check for wrap boundary
beq WGPrint_nextLine
cmp WG_VIEWCLIP+2 ; Check for right clip plane
beq WGPrint_endVisible
bra WGPrint_charLoop
WGPrint_endVisible:
tya
clc
adc WG_VIEWCLIP+4 ; Advance string index by right span
cmp SCRATCH1
bcs WGPrint_done
tay
WGPrint_nextLine:
inc WG_LOCALCURSORY ; Advance cursor
lda WG_LOCALCURSORY
cmp WG_VIEWCLIP+3 ; Check for bottom clip plane
beq WGPrint_done
cmp WG_VIEWRECORDS,x ; Check for bottom of view
beq WGPrint_done
lda #0 ; Wrap to next line
sta WG_LOCALCURSORX
jmp WGPrint_lineLoop
WGPrint_done:
RESTORE_ZPS

71
views.s
View File

@ -11,8 +11,8 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGCreateView
; Creates a new view
; PARAM0: Pointer to configuration string (LSB)
; PARAM1: Pointer to configuration string (MSB)
; PARAM0: Pointer to ASCII configuration string (LSB)
; PARAM1: Pointer to ASCII configuration string (MSB)
;
; Configuration string: "STXXYYSWSHVWVH"
; ST: (4:4) Style:ID
@ -122,18 +122,18 @@ WGPaintView_done:
; A: ID
;
WGSelectView:
SAVE_AY
SAVE_AXY
sta WG_ACTIVEVIEW
LDY_ACTIVEVIEW
; Initialize cursor to local origin
lda #0
sta WG_LOCALCURSORX
sta WG_LOCALCURSORY
jsr cacheClipPlanes ; View changed, so clipping cache is stale
WGSelectView_done:
RESTORE_AY
RESTORE_AXY
rts
@ -216,6 +216,8 @@ WGScrollX:
adc WG_VIEWRECORDS,y
sta WG_VIEWRECORDS,y
jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale
WGScrollX_done:
ply
rts
@ -242,8 +244,65 @@ WGScrollY:
adc WG_VIEWRECORDS,y
sta WG_VIEWRECORDS,y
jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale
WGScrollY_done:
ply
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; cacheClipPlanes
; Internal routine to cache the clipping planes for the view
;
cacheClipPlanes:
SAVE_AY
; Compute clip planes in view space
LDY_ACTIVEVIEW
iny ; Left edge
iny
iny
iny
iny
lda WG_VIEWRECORDS,y
eor #$ff
inc
sta WG_VIEWCLIP+0
dey ; Right edge
dey
dey
clc
adc WG_VIEWRECORDS,y
sta WG_VIEWCLIP+2
iny ; Right span (distance from window edge to view edge, in viewspace
iny
iny
iny
iny
lda WG_VIEWRECORDS,y
sec
sbc WG_VIEWCLIP+2
sta WG_VIEWCLIP+4
dey ; Top edge
lda WG_VIEWRECORDS,y
eor #$ff
inc
sta WG_VIEWCLIP+1
dey ; Bottom edge
dey
dey
clc
adc WG_VIEWRECORDS,y
sta WG_VIEWCLIP+3
RESTORE_AY
rts