mirror of
https://github.com/blondie7575/WeeGUI.git
synced 2025-03-03 17:30:17 +00:00
- Added unit test for text scrolling and clipping
This commit is contained in:
parent
3c4eca1681
commit
ef8035f244
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
/WeeGUI.xcodeproj/project.xcworkspace/xcuserdata/
|
||||
|
||||
/WeeGUI.xcodeproj/xcuserdata/
|
||||
|
||||
/gui.lst
|
||||
|
@ -5,3 +5,8 @@ Known issues
|
||||
- Negative cursor positions unsupported
|
||||
- Positive scroll values unsupported
|
||||
|
||||
|
||||
To Do:
|
||||
------
|
||||
|
||||
- Make scanning support lower case
|
||||
|
53
gui.s
53
gui.s
@ -20,27 +20,30 @@
|
||||
|
||||
main:
|
||||
jsr begin80cols
|
||||
jsr WGClearScreen
|
||||
jmp tortureTestPrint
|
||||
;jmp tortureTestRects
|
||||
|
||||
lda #<testView
|
||||
sta PARAM0
|
||||
lda #>testView
|
||||
sta PARAM1
|
||||
jsr WGCreateView
|
||||
; jsr WGClearScreen
|
||||
|
||||
lda #0
|
||||
jsr WGSelectView
|
||||
; lda #<testView
|
||||
; sta PARAM0
|
||||
; lda #>testView
|
||||
; sta PARAM1
|
||||
; jsr WGCreateView
|
||||
|
||||
jsr WGPaintView
|
||||
; lda #0
|
||||
; jsr WGSelectView
|
||||
|
||||
ldx #5
|
||||
ldy #0
|
||||
jsr WGSetCursor
|
||||
; jsr WGPaintView
|
||||
|
||||
lda #0
|
||||
jsr WGScrollX
|
||||
lda #-2
|
||||
jsr WGScrollY
|
||||
; ldx #5
|
||||
; ldy #0
|
||||
; jsr WGSetCursor
|
||||
|
||||
; lda #0
|
||||
; jsr WGScrollX
|
||||
; lda #-2
|
||||
; jsr WGScrollY
|
||||
|
||||
; lda WG_VIEWCLIP+0
|
||||
; jsr PRBYTE
|
||||
@ -72,11 +75,11 @@ main:
|
||||
; lda WG_VIEWRECORDS+8
|
||||
; jsr PRBYTE
|
||||
|
||||
lda #<testStr
|
||||
sta PARAM0
|
||||
lda #>testStr
|
||||
sta PARAM1
|
||||
jsr WGPrint
|
||||
; lda #<testStr
|
||||
; sta PARAM0
|
||||
; lda #>testStr
|
||||
; sta PARAM1
|
||||
; jsr WGPrint
|
||||
|
||||
; lda #1
|
||||
; sta PARAM0
|
||||
@ -148,11 +151,11 @@ read80ColSwitch_40:
|
||||
.include "memory.s"
|
||||
|
||||
|
||||
testView:
|
||||
.byte "0007033e13207e" ; 0, 7,3,62,19,126,126
|
||||
;testView:
|
||||
; .byte "0007033e13207e" ; 0, 7,3,62,19,126,126
|
||||
|
||||
testStr:
|
||||
.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
|
||||
;testStr:
|
||||
; .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
|
||||
|
||||
|
||||
|
||||
|
BIN
guidemo.dsk
BIN
guidemo.dsk
Binary file not shown.
4
macros.s
4
macros.s
@ -138,8 +138,8 @@
|
||||
lda #$80
|
||||
macroWaitVBLToFinish:
|
||||
bit RDVBLBAR
|
||||
bmi tortureTestRectsWaitVBLToFinish
|
||||
bmi macroWaitVBLToFinish
|
||||
macroWaitVBLToStart:
|
||||
bit RDVBLBAR
|
||||
bpl tortureTestRectsWaitVBLToStart
|
||||
bpl macroWaitVBLToStart
|
||||
.endmacro
|
||||
|
88
painting.s
88
painting.s
@ -62,6 +62,7 @@ WGFillRect:
|
||||
clc ; Compute bottom edge
|
||||
lda PARAM1
|
||||
adc PARAM3
|
||||
dec
|
||||
tax
|
||||
|
||||
WGFillRect_vertLoop:
|
||||
@ -491,93 +492,6 @@ WGPlot_done:
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; WGPrintASCII
|
||||
; Prints a null-terminated ASCII string at the current view's
|
||||
; cursor position. Clips to current view
|
||||
; PARAM0: String pointer, LSB
|
||||
; PARAM1: String pointer, MSB
|
||||
; Side effects: Clobbers BASL,BASH
|
||||
;
|
||||
WGPrintASCII:
|
||||
SAVE_AXY
|
||||
SAVE_ZPS
|
||||
|
||||
jsr WGSyncGlobalCursor
|
||||
|
||||
LDY_ACTIVEVIEW
|
||||
|
||||
iny ; Clip to upper extent
|
||||
lda WG_CURSORY
|
||||
cmp WG_VIEWRECORDS,y
|
||||
bcc WGPrintASCII_done
|
||||
|
||||
lda WG_VIEWRECORDS,y ; Clip to lower extent
|
||||
iny
|
||||
iny
|
||||
clc
|
||||
adc WG_VIEWRECORDS,y
|
||||
dec
|
||||
cmp WG_CURSORY
|
||||
bcc WGPrintASCII_done
|
||||
|
||||
jsr WGStrLen ; We'll need the length of the string to clip horizontally
|
||||
sta SCRATCH0
|
||||
|
||||
dey ; Clip left/right extents
|
||||
dey
|
||||
dey
|
||||
lda WG_CURSORX ; startIndex = -(globalX - windowStartX)
|
||||
sec
|
||||
sbc WG_VIEWRECORDS,y
|
||||
eor #$ff
|
||||
inc
|
||||
bmi WGPrintASCII_leftEdgeStart
|
||||
cmp SCRATCH0
|
||||
bcs WGPrintASCII_done ; Entire string is left of window
|
||||
|
||||
tax ; Starting mid-string on the left
|
||||
lda WG_VIEWRECORDS,y
|
||||
sta WG_CURSORX
|
||||
txa
|
||||
bra WGPrintASCII_findRightEdge
|
||||
|
||||
WGPrintASCII_leftEdgeStart:
|
||||
lda #0
|
||||
|
||||
WGPrintASCII_findRightEdge:
|
||||
pha ; Stash start index
|
||||
|
||||
lda WG_VIEWRECORDS,y
|
||||
iny
|
||||
iny
|
||||
clc
|
||||
adc WG_VIEWRECORDS,y
|
||||
tax
|
||||
dex
|
||||
ply ; End cursor in X, start index in Y
|
||||
|
||||
WGPrintASCII_loop:
|
||||
cpx WG_CURSORX
|
||||
bcc WGPrintASCII_done ; Hit the right edge of the window
|
||||
lda (PARAM0),y
|
||||
beq WGPrintASCII_done ; Hit the end of the string
|
||||
ora #$80
|
||||
jsr WGPlot
|
||||
|
||||
iny
|
||||
clc
|
||||
inc WG_CURSORX
|
||||
jmp WGPrintASCII_loop
|
||||
|
||||
WGPrintASCII_done:
|
||||
RESTORE_ZPS
|
||||
RESTORE_AXY
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; WGPrint
|
||||
; Prints a null-terminated Apple string at the current view's
|
||||
|
220
unit_test.s
220
unit_test.s
@ -8,6 +8,132 @@
|
||||
; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved.
|
||||
;
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; tortureTestPrint
|
||||
; Prints strings in a range of positions and scrolling offsets
|
||||
;
|
||||
; Stack:
|
||||
; Curr Scroll X
|
||||
; Curr Scroll Y
|
||||
; Delta X
|
||||
; Delta Y
|
||||
tortureTestPrint:
|
||||
jsr WGClearScreen
|
||||
|
||||
lda #0 ; Initialize
|
||||
jsr WGScrollX
|
||||
jsr WGScrollY
|
||||
|
||||
tortureTestPrint_init:
|
||||
lda #<testPrintView
|
||||
sta PARAM0
|
||||
lda #>testPrintView
|
||||
sta PARAM1
|
||||
jsr WGCreateView
|
||||
|
||||
lda #0
|
||||
jsr WGSelectView
|
||||
jsr WGPaintView
|
||||
|
||||
lda #0
|
||||
pha
|
||||
pha
|
||||
lda #-1
|
||||
pha
|
||||
pha
|
||||
|
||||
tsx
|
||||
inx
|
||||
|
||||
tortureTestPrint_loop:
|
||||
phx
|
||||
ldx #0 ; Initialize
|
||||
ldy #0
|
||||
jsr WGSetCursor
|
||||
plx
|
||||
|
||||
inx ; Grab current delta X
|
||||
lda $0100,x
|
||||
inx
|
||||
inx
|
||||
clc
|
||||
adc $0100,x ; Add Scroll X
|
||||
sta $0100,x
|
||||
beq tortureTestPrint_flipDeltaX ; Check for bounce
|
||||
cmp #-5
|
||||
beq tortureTestPrint_flipDeltaX
|
||||
bra tortureTestPrint_continueX
|
||||
|
||||
tortureTestPrint_flipDeltaX:
|
||||
dex
|
||||
dex
|
||||
lda $0100,x
|
||||
eor #$ff
|
||||
inc
|
||||
sta $0100,x
|
||||
inx
|
||||
inx
|
||||
|
||||
tortureTestPrint_continueX:
|
||||
lda $0100,x
|
||||
jsr WGScrollX ; Apply current X scroll
|
||||
dex
|
||||
dex
|
||||
dex
|
||||
|
||||
lda $0100,x ; Grab current delta Y
|
||||
inx
|
||||
inx
|
||||
clc
|
||||
adc $0100,x ; Add Scroll Y
|
||||
sta $0100,x
|
||||
beq tortureTestPrint_flipDeltaY ; Check for bounce
|
||||
cmp #-5
|
||||
beq tortureTestPrint_flipDeltaY
|
||||
bra tortureTestPrint_continueY
|
||||
|
||||
tortureTestPrint_flipDeltaY:
|
||||
dex
|
||||
dex
|
||||
lda $0100,x
|
||||
eor #$ff
|
||||
inc
|
||||
sta $0100,x
|
||||
inx
|
||||
inx
|
||||
|
||||
tortureTestPrint_continueY:
|
||||
lda $0100,x
|
||||
jsr WGScrollY
|
||||
dex
|
||||
dex
|
||||
|
||||
tortureTestPrint_print:
|
||||
VBL_SYNC
|
||||
jsr WGEraseViewContents
|
||||
|
||||
lda #<testStr
|
||||
sta PARAM0
|
||||
lda #>testStr
|
||||
sta PARAM1
|
||||
|
||||
jsr WGPrint
|
||||
jsr WGPrint
|
||||
|
||||
; jmp tortureTestPrint_lock
|
||||
jsr delayShort
|
||||
jmp tortureTestPrint_loop
|
||||
|
||||
tortureTestPrint_reset:
|
||||
pla
|
||||
pla
|
||||
jmp tortureTestPrint_init
|
||||
|
||||
tortureTestPrint_lock:
|
||||
jmp tortureTestPrint_lock
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; tortureTestRects
|
||||
; Strokes and paints rectangles of many different geometries
|
||||
@ -20,6 +146,8 @@
|
||||
tortureTestRects:
|
||||
jsr WGClearScreen
|
||||
|
||||
tortureTestRectsEven:
|
||||
|
||||
lda #38 ; Initialize
|
||||
pha
|
||||
lda #11
|
||||
@ -29,8 +157,7 @@ tortureTestRects:
|
||||
lda #2
|
||||
pha
|
||||
|
||||
tortureTestRectsLoop:
|
||||
|
||||
tortureTestRectsEvenLoop:
|
||||
jsr WGClearScreen
|
||||
|
||||
tsx
|
||||
@ -41,7 +168,7 @@ tortureTestRectsLoop:
|
||||
inc
|
||||
sta $0100,x
|
||||
cmp #25
|
||||
bcs tortureTestRectsDone
|
||||
bcs tortureTestRectsEvenDone
|
||||
|
||||
inx ; Load Width, then modify
|
||||
lda $0100,x
|
||||
@ -68,18 +195,93 @@ tortureTestRectsLoop:
|
||||
dec
|
||||
sta $0100,x
|
||||
|
||||
; ldx #'Q'+$80
|
||||
; jsr WGFillRect
|
||||
ldx #'Q'+$80
|
||||
jsr WGFillRect
|
||||
jsr WGStrokeRect
|
||||
|
||||
; jsr delayShort
|
||||
jsr delayShort
|
||||
jsr delayShort
|
||||
jsr delayShort
|
||||
|
||||
jmp tortureTestRectsLoop
|
||||
jmp tortureTestRectsEvenLoop
|
||||
|
||||
tortureTestRectsDone:
|
||||
tortureTestRectsEvenDone:
|
||||
pla
|
||||
pla
|
||||
pla
|
||||
pla
|
||||
jmp tortureTestRects
|
||||
|
||||
tortureTestRectsOdd:
|
||||
|
||||
lda #37 ; Initialize
|
||||
pha
|
||||
lda #11
|
||||
pha
|
||||
lda #2
|
||||
pha
|
||||
lda #2
|
||||
pha
|
||||
|
||||
tortureTestRectsOddLoop:
|
||||
jsr WGClearScreen
|
||||
|
||||
tsx
|
||||
inx
|
||||
lda $0100,x ; Load Height, then modify
|
||||
sta PARAM3
|
||||
inc
|
||||
inc
|
||||
sta $0100,x
|
||||
cmp #25
|
||||
bcs tortureTestRectsOddDone
|
||||
|
||||
inx ; Load Width, then modify
|
||||
lda $0100,x
|
||||
sta PARAM2
|
||||
inc
|
||||
inc
|
||||
inc
|
||||
inc
|
||||
inc
|
||||
inc
|
||||
sta $0100,x
|
||||
|
||||
inx ; Load Y, then modify
|
||||
lda $0100,x
|
||||
sta PARAM1
|
||||
dec
|
||||
sta $0100,x
|
||||
|
||||
inx ; Load X, then modify
|
||||
lda $0100,x
|
||||
sta PARAM0
|
||||
dec
|
||||
dec
|
||||
dec
|
||||
sta $0100,x
|
||||
|
||||
ldx #'Q'+$80
|
||||
jsr WGFillRect
|
||||
jsr WGStrokeRect
|
||||
|
||||
jsr delayShort
|
||||
jsr delayShort
|
||||
jsr delayShort
|
||||
|
||||
jmp tortureTestRectsOddLoop
|
||||
|
||||
tortureTestRectsOddDone:
|
||||
pla
|
||||
pla
|
||||
pla
|
||||
pla
|
||||
|
||||
jmp tortureTestRectsEven
|
||||
|
||||
|
||||
|
||||
testPrintView:
|
||||
.byte "000F061E0A287E" ; 0, 7,3,62,19,75,126
|
||||
|
||||
testStr:
|
||||
.byte "This is a test of the emergency broadcast system. If this had been a real emergency, you would be dead now. Amusingly, it can be noted that if this had been a real emergency, and you were now a steaming pile of ash, there would of course be nobody.",0; to read this message. That begs any number",0; of extistential questions about this very text.",0
|
||||
|
@ -89,6 +89,7 @@ scanHexDigitDone:
|
||||
; PARAM1: Pointer to string (MSB)
|
||||
; Y: Offset into string
|
||||
; Out A: 8-bit hex value
|
||||
; Y: One past what we scanned
|
||||
; Side effects: Clobbers Y and S0
|
||||
;
|
||||
scanHex8:
|
||||
|
90
views.s
90
views.s
@ -29,6 +29,7 @@ WGCreateView:
|
||||
|
||||
ldy #0
|
||||
jsr scanHex8
|
||||
lda #0
|
||||
pha
|
||||
|
||||
and #%00001111 ; Find our new view record
|
||||
@ -116,6 +117,76 @@ WGPaintView_done:
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; WGEraseView
|
||||
; Erases the current view (including decoration)
|
||||
;
|
||||
WGEraseView:
|
||||
SAVE_AY
|
||||
SAVE_ZPP
|
||||
|
||||
LDY_ACTIVEVIEW
|
||||
|
||||
lda WG_VIEWRECORDS,y ; Fetch the record
|
||||
dec
|
||||
sta PARAM0
|
||||
iny
|
||||
lda WG_VIEWRECORDS,y
|
||||
dec
|
||||
sta PARAM1
|
||||
iny
|
||||
lda WG_VIEWRECORDS,y
|
||||
inc
|
||||
inc
|
||||
sta PARAM2
|
||||
iny
|
||||
lda WG_VIEWRECORDS,y
|
||||
inc
|
||||
inc
|
||||
sta PARAM3
|
||||
|
||||
ldx #' '+$80
|
||||
jsr WGFillRect
|
||||
|
||||
WGEraseView_done:
|
||||
RESTORE_ZPP
|
||||
RESTORE_AY
|
||||
rts
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; WGEraseViewContents
|
||||
; Erases the contents of the current view (interior contents only)
|
||||
;
|
||||
WGEraseViewContents:
|
||||
SAVE_AXY
|
||||
SAVE_ZPP
|
||||
|
||||
LDY_ACTIVEVIEW
|
||||
|
||||
lda WG_VIEWRECORDS,y ; Fetch the record
|
||||
sta PARAM0
|
||||
iny
|
||||
lda WG_VIEWRECORDS,y
|
||||
sta PARAM1
|
||||
iny
|
||||
lda WG_VIEWRECORDS,y
|
||||
sta PARAM2
|
||||
iny
|
||||
lda WG_VIEWRECORDS,y
|
||||
sta PARAM3
|
||||
|
||||
ldx #' '+$80
|
||||
jsr WGFillRect
|
||||
|
||||
WGEraseViewContents_done:
|
||||
RESTORE_ZPP
|
||||
RESTORE_AXY
|
||||
rts
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; WGSelectView
|
||||
; Selects the active view
|
||||
@ -199,23 +270,20 @@ WGSyncGlobalCursor_done:
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; WGScrollX
|
||||
; Scrolls the current view horizontally
|
||||
; A: Delta to scroll
|
||||
; A: New scroll amount
|
||||
; Side effects: Clobbers A
|
||||
;
|
||||
WGScrollX:
|
||||
phy
|
||||
pha
|
||||
LDY_ACTIVEVIEW
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
pla
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
clc
|
||||
adc WG_VIEWRECORDS,y
|
||||
sta WG_VIEWRECORDS,y
|
||||
|
||||
jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale
|
||||
|
||||
WGScrollX_done:
|
||||
@ -226,7 +294,7 @@ WGScrollX_done:
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; WGScrollY
|
||||
; Scrolls the current view vertically
|
||||
; A: Delta to scroll
|
||||
; A: New scroll amount
|
||||
; Side effects: Clobbers A
|
||||
;
|
||||
WGScrollY:
|
||||
@ -240,8 +308,6 @@ WGScrollY:
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
clc
|
||||
adc WG_VIEWRECORDS,y
|
||||
sta WG_VIEWRECORDS,y
|
||||
|
||||
jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale
|
||||
|
Loading…
x
Reference in New Issue
Block a user