- 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:
parent
5da9ea899b
commit
7207675b35
115
applesoft.s
115
applesoft.s
|
@ -22,6 +22,7 @@ GETNUM = $e746 ; Gets an 8-bit, stores it X, skips past a comma
|
||||||
|
|
||||||
ERR_UNDEFINEDFUNC = 224
|
ERR_UNDEFINEDFUNC = 224
|
||||||
ERR_SYNTAX = 16
|
ERR_SYNTAX = 16
|
||||||
|
ERR_ENDOFDATA = 5
|
||||||
ERR_TOOLONG = 176
|
ERR_TOOLONG = 176
|
||||||
|
|
||||||
MAXCMDLEN = 14
|
MAXCMDLEN = 14
|
||||||
|
@ -62,7 +63,7 @@ WGAmpersand:
|
||||||
|
|
||||||
WGAmpersand_parseLoop:
|
WGAmpersand_parseLoop:
|
||||||
txa
|
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 #'('
|
cmp #'('
|
||||||
beq WGAmpersand_matchStart
|
beq WGAmpersand_matchStart
|
||||||
|
|
||||||
|
@ -190,6 +191,57 @@ WGAmpersandIntArguments_done:
|
||||||
rts
|
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
|
; WGAmpersandStrArgument
|
||||||
|
@ -256,25 +308,62 @@ WGAmpersandStrArguments_done:
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; WGAmpersand_VIEW
|
; WGAmpersand_HOME
|
||||||
; Create a view
|
; Clears the screen
|
||||||
;
|
; &HOME
|
||||||
WGAmpersand_VIEW:
|
WGAmpersand_HOME:
|
||||||
jsr WGAmpersandStrArguments
|
jsr WGClearScreen
|
||||||
|
jsr WGBottomCursor
|
||||||
|
|
||||||
jsr WGCreateView
|
|
||||||
jsr WGPaintView
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; WGAmpersand_DESK
|
; WGAmpersand_DESK
|
||||||
; Render the desktop
|
; Render the desktop
|
||||||
;
|
; &DESK
|
||||||
WGAmpersand_DESK:
|
WGAmpersand_DESK:
|
||||||
jsr WGDesktop
|
jsr WGDesktop
|
||||||
|
jsr WGBottomCursor
|
||||||
rts
|
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.
|
; Jump table for ampersand commands.
|
||||||
; Each row is 16 bytes (14 for name, 2 for address)
|
; Each row is 16 bytes (14 for name, 2 for address)
|
||||||
WGAmpersandCommandTable:
|
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
|
.byte "DESK",0,0,0,0,0,0,0,0,0,0
|
||||||
.addr WGAmpersand_DESK
|
.addr WGAmpersand_DESK
|
||||||
|
|
||||||
|
.byte "WINDOW",0,0,0,0,0,0,0,0
|
||||||
|
.addr WGAmpersand_WINDOW
|
||||||
|
|
||||||
|
|
||||||
WGAmpersandCommandTableEnd:
|
WGAmpersandCommandTableEnd:
|
||||||
|
|
||||||
|
|
2
gui.s
2
gui.s
|
@ -271,7 +271,7 @@ read80ColSwitch_40:
|
||||||
|
|
||||||
|
|
||||||
testView:
|
testView:
|
||||||
.byte $10,7,3,62,18,80,25
|
.byte 0,1,7,3,62,18,80,25
|
||||||
|
|
||||||
testCheck:
|
testCheck:
|
||||||
.byte 1,16,4
|
.byte 1,16,4
|
||||||
|
|
BIN
guidemo.dsk
BIN
guidemo.dsk
Binary file not shown.
|
@ -27,3 +27,6 @@ KBD = $c000 ; Read
|
||||||
KBDSTRB = $c010 ; Read/Write
|
KBDSTRB = $c010 ; Read/Write
|
||||||
|
|
||||||
RDVBLBAR = $C019 ; Read bit 7 (active low)
|
RDVBLBAR = $C019 ; Read bit 7 (active low)
|
||||||
|
|
||||||
|
OURCH = $057b ; 80 col cursor position (H)
|
||||||
|
OURCV = $05fb ; 80 col cursor position (V)
|
||||||
|
|
44
views.s
44
views.s
|
@ -15,7 +15,8 @@
|
||||||
; PARAM1: Pointer to configuration struct (MSB)
|
; PARAM1: Pointer to configuration struct (MSB)
|
||||||
;
|
;
|
||||||
; Configuration struct:
|
; Configuration struct:
|
||||||
; ST: (4:4) Style:ID
|
; ID: View ID (0-f)
|
||||||
|
; ST: Style
|
||||||
; XX: Screen X origin
|
; XX: Screen X origin
|
||||||
; YY: Screen Y origin
|
; YY: Screen Y origin
|
||||||
; SW: Screen width
|
; SW: Screen width
|
||||||
|
@ -29,22 +30,17 @@ WGCreateView:
|
||||||
|
|
||||||
ldy #0
|
ldy #0
|
||||||
lda (PARAM0),y
|
lda (PARAM0),y
|
||||||
pha
|
|
||||||
|
|
||||||
and #%00001111 ; Find our new view record
|
jsr WGSelectView ; Find our new view record
|
||||||
jsr WGSelectView
|
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
asl ; Records are 8 bytes wide
|
asl ; Records are 8 bytes wide
|
||||||
tax
|
tax
|
||||||
|
|
||||||
pla ; Cache style nybble for later
|
iny
|
||||||
lsr
|
lda (PARAM0),y
|
||||||
lsr
|
pha ; Cache style byte for later
|
||||||
lsr
|
|
||||||
lsr
|
|
||||||
pha
|
|
||||||
|
|
||||||
iny
|
iny
|
||||||
lda (PARAM0),y
|
lda (PARAM0),y
|
||||||
|
@ -85,6 +81,18 @@ WGCreateView:
|
||||||
lda (PARAM0),y
|
lda (PARAM0),y
|
||||||
sta WG_VIEWRECORDS,x ; View Height
|
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:
|
WGCreateView_done:
|
||||||
RESTORE_ZPS
|
RESTORE_ZPS
|
||||||
RESTORE_AXY
|
RESTORE_AXY
|
||||||
|
@ -99,7 +107,7 @@ WGCreateView_done:
|
||||||
; PARAM1: Pointer to configuration struct (MSB)
|
; PARAM1: Pointer to configuration struct (MSB)
|
||||||
;
|
;
|
||||||
; Configuration struct:
|
; Configuration struct:
|
||||||
; ST: (4:4) Reserved:ID
|
; ID: View ID (0-f)
|
||||||
; XX: Screen X origin
|
; XX: Screen X origin
|
||||||
; YY: Screen Y origin
|
; YY: Screen Y origin
|
||||||
;
|
;
|
||||||
|
@ -110,8 +118,7 @@ WGCreateCheckbox:
|
||||||
ldy #0
|
ldy #0
|
||||||
lda (PARAM0),y
|
lda (PARAM0),y
|
||||||
|
|
||||||
and #%00001111 ; Find our new view record
|
jsr WGSelectView ; Find our new view record
|
||||||
jsr WGSelectView
|
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
|
@ -171,7 +178,7 @@ WGCreateCheckbox_done:
|
||||||
; PARAM1: Pointer to configuration struct (MSB)
|
; PARAM1: Pointer to configuration struct (MSB)
|
||||||
;
|
;
|
||||||
; Configuration struct:
|
; Configuration struct:
|
||||||
; ST: (4:4) Reserved:ID
|
; ID: View ID (0-f)
|
||||||
; XX: Screen X origin
|
; XX: Screen X origin
|
||||||
; YY: Screen Y origin
|
; YY: Screen Y origin
|
||||||
; BW: Button width
|
; BW: Button width
|
||||||
|
@ -182,8 +189,7 @@ WGCreateButton:
|
||||||
ldy #0
|
ldy #0
|
||||||
lda (PARAM0),y
|
lda (PARAM0),y
|
||||||
|
|
||||||
and #%00001111 ; Find our new view record
|
jsr WGSelectView ; Find our new view record
|
||||||
jsr WGSelectView
|
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
|
@ -428,7 +434,13 @@ paintWindowTitle:
|
||||||
sta PARAM0
|
sta PARAM0
|
||||||
lda WG_VIEWRECORDS+12,y
|
lda WG_VIEWRECORDS+12,y
|
||||||
sta PARAM1
|
sta PARAM1
|
||||||
|
bne paintWindowTitle_compute
|
||||||
|
|
||||||
|
paintWindowTitle_checkNull:
|
||||||
|
lda PARAM0
|
||||||
|
beq paintWindowTitle_done
|
||||||
|
|
||||||
|
paintWindowTitle_compute:
|
||||||
jsr WGStrLen ; Compute centering offset for title
|
jsr WGStrLen ; Compute centering offset for title
|
||||||
lsr
|
lsr
|
||||||
sta SCRATCH1
|
sta SCRATCH1
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
|
|
||||||
; Reserved locations
|
; Reserved locations
|
||||||
|
|
||||||
INVERSE = $32
|
INVERSE = $32 ; Text output state
|
||||||
BASL = $28
|
CH = $24 ; Cursor X pos
|
||||||
BASH = $29
|
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)
|
; Zero page locations we use (unused by Monitor, Applesoft, or ProDOS)
|
||||||
PARAM0 = $06
|
PARAM0 = $06
|
||||||
|
|
Loading…
Reference in New Issue