- Fixed parameter-less AppleSoft commands

- Added support for struct parameters in AppleSoft
- Added &HOME
- Renamed &VIEW to &WINDOW
- Separated style and ID bytes in view creation
- View state, callbacks, and title pointers are now initialized
- NULL pointers are handled in window titles
- Added function to restore a valid cursor state for AppleSoft upon API exit
This commit is contained in:
Quinn Dunki 2014-09-16 14:04:05 -07:00
parent 5da9ea899b
commit 7207675b35
6 changed files with 141 additions and 32 deletions

View File

@ -22,6 +22,7 @@ GETNUM = $e746 ; Gets an 8-bit, stores it X, skips past a comma
ERR_UNDEFINEDFUNC = 224
ERR_SYNTAX = 16
ERR_ENDOFDATA = 5
ERR_TOOLONG = 176
MAXCMDLEN = 14
@ -62,7 +63,7 @@ WGAmpersand:
WGAmpersand_parseLoop:
txa
beq WGAmpersand_parseFail ; Check for end-of-statement (CHRGET handles : and EOL)
beq WGAmpersand_matchStart ; Check for end-of-statement (CHRGET handles : and EOL)
cmp #'('
beq WGAmpersand_matchStart
@ -190,6 +191,57 @@ WGAmpersandIntArguments_done:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGAmpersandStructArgument
; Buffers integer arguments for current command into a struct
; TXTPTR: Start of argument list (after opening parenthesis)
; OUT PARAM0/1 : Pointer to struct containing int values
WGAmpersandStructArgument:
SAVE_AXY
ldy #0
phy ; Can't rely on Applesoft routines to be register-safe
lda #'('
jsr SYNCHR ; Expect opening parenthesis
WGAmpersandStructArguments_loop:
jsr GETBYT
txa
ply
sta WGAmpersandCommandBuffer,y
phy
jsr CHRGOT
cmp #')' ; All done!
beq WGAmpersandStructArguments_cleanup
jsr CHKCOM ; Verify parameter separator
ply
iny
phy
cpy #WGAmpersandCommandBufferEnd-WGAmpersandCommandBuffer ; Check for too many arguments
bne WGAmpersandStructArguments_loop
WGAmpersandStructArguments_fail:
ldx #ERR_TOOLONG
jsr ERROR
bra WGAmpersandStructArguments_done
WGAmpersandStructArguments_cleanup:
jsr CHRGET ; Consume closing parenthesis
WGAmpersandStructArguments_done:
ply
lda #<WGAmpersandCommandBuffer
sta PARAM0
lda #>WGAmpersandCommandBuffer
sta PARAM1
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGAmpersandStrArgument
@ -256,25 +308,62 @@ WGAmpersandStrArguments_done:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGAmpersand_VIEW
; Create a view
;
WGAmpersand_VIEW:
jsr WGAmpersandStrArguments
; WGAmpersand_HOME
; Clears the screen
; &HOME
WGAmpersand_HOME:
jsr WGClearScreen
jsr WGBottomCursor
jsr WGCreateView
jsr WGPaintView
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGAmpersand_DESK
; Render the desktop
;
; &DESK
WGAmpersand_DESK:
jsr WGDesktop
jsr WGBottomCursor
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGAmpersand_WINDOW
; Create a view
; &WINDOW(id,style,x,y,width,height,canvas width,canvas height)
WGAmpersand_WINDOW:
jsr WGAmpersandStructArgument
jsr WGCreateView
jsr WGPaintView
jsr WGBottomCursor
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGBottomCursor
; Leave the cursor state in a place that Applesoft is happy with
;
WGBottomCursor:
SAVE_AY
lda #0
sta CH
sta OURCH
lda #23
sta CV
sta OURCV
lda TEXTLINES_H+23
sta BASH
lda TEXTLINES_L+23
sta BASL
RESTORE_AY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -291,12 +380,16 @@ WGAmpersandCommandBufferEnd:
; Jump table for ampersand commands.
; Each row is 16 bytes (14 for name, 2 for address)
WGAmpersandCommandTable:
.byte "VIEW",0,0,0,0,0,0,0,0,0,0
.addr WGAmpersand_VIEW
.byte $97,0,0,0,0,0,0,0,0,0,0,0,0,0 ; HOME
.addr WGAmpersand_HOME
.byte "DESK",0,0,0,0,0,0,0,0,0,0
.addr WGAmpersand_DESK
.byte "WINDOW",0,0,0,0,0,0,0,0
.addr WGAmpersand_WINDOW
WGAmpersandCommandTableEnd:

2
gui.s
View File

@ -271,7 +271,7 @@ read80ColSwitch_40:
testView:
.byte $10,7,3,62,18,80,25
.byte 0,1,7,3,62,18,80,25
testCheck:
.byte 1,16,4

Binary file not shown.

View File

@ -27,3 +27,6 @@ KBD = $c000 ; Read
KBDSTRB = $c010 ; Read/Write
RDVBLBAR = $C019 ; Read bit 7 (active low)
OURCH = $057b ; 80 col cursor position (H)
OURCV = $05fb ; 80 col cursor position (V)

44
views.s
View File

@ -15,7 +15,8 @@
; PARAM1: Pointer to configuration struct (MSB)
;
; Configuration struct:
; ST: (4:4) Style:ID
; ID: View ID (0-f)
; ST: Style
; XX: Screen X origin
; YY: Screen Y origin
; SW: Screen width
@ -29,22 +30,17 @@ WGCreateView:
ldy #0
lda (PARAM0),y
pha
and #%00001111 ; Find our new view record
jsr WGSelectView
jsr WGSelectView ; Find our new view record
asl
asl
asl
asl ; Records are 8 bytes wide
tax
pla ; Cache style nybble for later
lsr
lsr
lsr
lsr
pha
iny
lda (PARAM0),y
pha ; Cache style byte for later
iny
lda (PARAM0),y
@ -85,6 +81,18 @@ WGCreateView:
lda (PARAM0),y
sta WG_VIEWRECORDS,x ; View Height
lda #0
inx ; Initialize state
sta WG_VIEWRECORDS,x
inx
sta WG_VIEWRECORDS,x ; Initialize callback
inx
sta WG_VIEWRECORDS,x
inx
sta WG_VIEWRECORDS,x ; Initialize title
inx
sta WG_VIEWRECORDS,x
WGCreateView_done:
RESTORE_ZPS
RESTORE_AXY
@ -99,7 +107,7 @@ WGCreateView_done:
; PARAM1: Pointer to configuration struct (MSB)
;
; Configuration struct:
; ST: (4:4) Reserved:ID
; ID: View ID (0-f)
; XX: Screen X origin
; YY: Screen Y origin
;
@ -110,8 +118,7 @@ WGCreateCheckbox:
ldy #0
lda (PARAM0),y
and #%00001111 ; Find our new view record
jsr WGSelectView
jsr WGSelectView ; Find our new view record
asl
asl
asl
@ -171,7 +178,7 @@ WGCreateCheckbox_done:
; PARAM1: Pointer to configuration struct (MSB)
;
; Configuration struct:
; ST: (4:4) Reserved:ID
; ID: View ID (0-f)
; XX: Screen X origin
; YY: Screen Y origin
; BW: Button width
@ -182,8 +189,7 @@ WGCreateButton:
ldy #0
lda (PARAM0),y
and #%00001111 ; Find our new view record
jsr WGSelectView
jsr WGSelectView ; Find our new view record
asl
asl
asl
@ -428,7 +434,13 @@ paintWindowTitle:
sta PARAM0
lda WG_VIEWRECORDS+12,y
sta PARAM1
bne paintWindowTitle_compute
paintWindowTitle_checkNull:
lda PARAM0
beq paintWindowTitle_done
paintWindowTitle_compute:
jsr WGStrLen ; Compute centering offset for title
lsr
sta SCRATCH1

View File

@ -9,10 +9,11 @@
; Reserved locations
INVERSE = $32
BASL = $28
BASH = $29
INVERSE = $32 ; Text output state
CH = $24 ; Cursor X pos
CV = $25 ; Cursor Y pos
BASL = $28 ; Current video memory line
BASH = $29 ; Current video memory line
; Zero page locations we use (unused by Monitor, Applesoft, or ProDOS)
PARAM0 = $06