CreateDialog, PrintAt, LDPARAM macro refactor

This commit is contained in:
4am 2018-04-02 14:38:05 -04:00
parent c7089393d5
commit 84cafe4c7f
7 changed files with 166 additions and 215 deletions

View File

@ -28,3 +28,12 @@ PARAM = $00
sta .ptr sta .ptr
sty .ptr+1 sty .ptr+1
} }
!macro LDPARAM .offset {
ldy #.offset+1
lda (PARAM),y
pha
dey
lda (PARAM),y
ply
}

View File

@ -12,26 +12,20 @@
; $00/$01 clobbered ; $00/$01 clobbered
; $02/$03 clobbered ; $02/$03 clobbered
; $04/$05 has the address of the next available byte after the okvs ; $04/$05 has the address of the next available byte after the okvs
; $FE/$FF clobbered
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
!zone { !zone {
ParseKeyValueText ParseKeyValueText
+PARAMS_ON_STACK 5 +PARAMS_ON_STACK 5
ldy #1 +LDPARAM 1
lda (PARAM),y +STAY .store1
sta .store1 +STAY .store2
sta .store2
iny +LDPARAM 3
lda (PARAM),y +STAY $FE
sta .store1+1
sta .store2+1 ldy #5
iny
lda (PARAM),y
sta $FE
iny
lda (PARAM),y
sta $FF
iny
lda (PARAM),y lda (PARAM),y
sta .useMaxLength+1 sta .useMaxLength+1

View File

@ -148,15 +148,8 @@ addStringFromStore
lda #$80 ; BRA opcode lda #$80 ; BRA opcode
sta .skipOverBooleanLogic sta .skipOverBooleanLogic
+PARAMS_ON_STACK 2 +PARAMS_ON_STACK 2
ldy #1 +LDPARAM 1
lda (PARAM),y +STAY .key
sta .key
pha
iny
lda (PARAM),y
sta .key+1
tay
pla
jsr addString jsr addString
+LDADDR .equals +LDADDR .equals
jsr addString jsr addString

View File

@ -55,43 +55,30 @@ PRODOSMLI = $BF00 ; [callable] MLI entry point
LoadFile LoadFile
+PARAMS_ON_STACK 6 +PARAMS_ON_STACK 6
ldy #$01 +LDPARAM 1
lda (PARAM),y ; lo byte of pathname +STAY mliparam+1 ; pathname
sta mliparam+1 +LDPARAM 5
iny +STAY mliparam+3 ; ProDOS file buffer
lda (PARAM),y ; hi byte of pathname
sta mliparam+2
ldy #$05
lda (PARAM),y ; lo byte of ProDOS file buffer
sta mliparam+3
iny
lda (PARAM),y ; hi byte of ProDOS file buffer
sta mliparam+4
jsr _openfile jsr _openfile
bcs .exit ; C set on error bcs .exit ; C set on error
pha ; push file reference number pha ; push file reference number
ldy #$03 +LDPARAM 3
lda (PARAM),y ; lo address of data buffer +STAY mliparam+2 ; data buffer
sta mliparam+2
iny
lda (PARAM),y ; hi address of data buffer
sta mliparam+3
lda #$FF lda #$FF
sta mliparam+4 ; max data length (unlimited, YOLO) sta mliparam+4 ; max data length (unlimited, YOLO)
sta mliparam+5 sta mliparam+5
pla ; pull file reference number pla ; pull file reference number
jsr _readfile jsr _readfile
php ; save flags from readfile php ; save flags from readfile
pha pha
jsr _closefile ; always close whether read worked or not jsr _closefile ; always close whether read worked or not
pla pla
plp ; restore flags from readfile plp ; restore flags from readfile
; (so caller gets codes from read attempt, ; (so caller gets codes from read attempt,
; not close) ; not close)
.exit .exit rts
rts
} }
;------------------------------- ;-------------------------------
@ -186,59 +173,37 @@ LoadDHRFile
!zone { !zone {
SaveFile SaveFile
+PARAMS_ON_STACK $0B +PARAMS_ON_STACK $0B
+LDPARAM 1
ldy #$01 +STAY mliparam+1 ; pathname
lda (PARAM),y ; lo byte of pathname jsr _deletefile ; don't care if this fails
sta mliparam+1
iny
lda (PARAM),y ; hi byte of pathname
sta mliparam+2
jsr _deletefile ; don't care if this fails
ldy #$03 ldy #$03
lda (PARAM),y ; file type lda (PARAM),y ; file type
sta mliparam+4 sta mliparam+4
iny +LDPARAM 4
lda (PARAM),y ; lo byte of aux file type +STAY mliparam+5 ; aux file type
sta mliparam+5
iny
lda (PARAM),y ; hi byte of aux file type
sta mliparam+6
jsr _createfile jsr _createfile
bcs .exit bcs .exit
ldy #$0A +LDPARAM 10
lda (PARAM),y ; lo byte of ProDOS file buffer +STAY mliparam+3 ; PrODOS file buffer
sta mliparam+3
iny
lda (PARAM),y ; hi byte of ProDOS file buffer
sta mliparam+4
jsr _openfile jsr _openfile
bcs .exit bcs .exit
pha ; push file reference number pha ; push file reference number
ldy #$06 +LDPARAM 6
lda (PARAM),y ; lo address of data buffer +STAY mliparam+2 ; data buffer
sta mliparam+2 +LDPARAM 8
iny +STAY mliparam+4 ; data length
lda (PARAM),y ; hi address of data buffer pla ; pull file reference number
sta mliparam+3
iny
lda (PARAM),y ; lo data length
sta mliparam+4
iny
lda (PARAM),y ; hi data length
sta mliparam+5
pla ; pull file reference number
jsr _writefile jsr _writefile
php ; save flags from writefile php ; save flags from writefile
pha pha
jsr _closefile ; always close whether write worked or not jsr _closefile ; always close whether write worked or not
pla pla
plp ; restore flags from write plp ; restore flags from write
; (so caller gets codes from write attempt, ; (so caller gets codes from write attempt,
; not close) ; not close)
.exit .exit rts
rts
} }
;------------------------------- ;-------------------------------
@ -256,14 +221,8 @@ SaveFile
!zone { !zone {
SetPrefix SetPrefix
+PARAMS_ON_STACK 2 +PARAMS_ON_STACK 2
+LDPARAM 1
ldy #$01 +STAY mliparam+1 ; pathname
lda (PARAM),y ; lo byte of pathname
sta mliparam+1
iny
lda (PARAM),y ; hi byte of pathname
sta mliparam+2
jmp _setprefix jmp _setprefix
} }
@ -284,14 +243,8 @@ SetPrefix
!zone { !zone {
GetFileInfo GetFileInfo
+PARAMS_ON_STACK 2 +PARAMS_ON_STACK 2
+LDPARAM 1
ldy #$01 +STAY mliparam+1 ; pathname
lda (PARAM),y ; lo byte of pathname
sta mliparam+1
iny
lda (PARAM),y ; hi byte of pathname
sta mliparam+2
jmp _getfileinfo jmp _getfileinfo
} }

View File

@ -8,13 +8,26 @@
; - CreateCheckbox ; - CreateCheckbox
; - CreateButton ; - CreateButton
; - PaintTitleBar ; - PaintTitleBar
; - PrintAt
; ;
; Public constants
; - kStringOK
; - kStringCancel
;
kStringOK
!byte $0F ; 'O' inverse
!byte 139,0
kStringCancel
!byte $03 ; 'C' inverse
!text "ancel",0
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; CreateRadio/CreateCheckbox/CreateButton ; CreateRadio/CreateCheckbox/CreateButton
; creates a WeeGUI UI control with the 'raw title' option set ; creates a WeeGUI UI control with the 'raw title' option set
; ;
; in: stack contains 2 bytes of parameters: ; in: WeeGUI loaded and initialized
; stack contains 2 bytes of parameters:
; +1 [word] pointer to WeeGUI view configuration block ; +1 [word] pointer to WeeGUI view configuration block
; out: $00/$01 clobbered ; out: $00/$01 clobbered
; all registers clobbered ; all registers clobbered
@ -31,13 +44,8 @@ CreateButton
stx .type stx .type
+PARAMS_ON_STACK 2 +PARAMS_ON_STACK 2
+LDPARAM 1
ldy #$01 +STAY PARAM0
lda (PARAM),y
sta PARAM0
iny
lda (PARAM),y
sta PARAM1
.type=*+1 .type=*+1
ldx #$FD ; SMC ldx #$FD ; SMC
jsr WeeGUI jsr WeeGUI
@ -48,10 +56,35 @@ CreateButton
} }
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; PaintTitleBar ; CreateDialog
; paints the title bar ; creates a WeeGUI decorated frame view
; ;
; in: none ; in: WeeGUI loaded and initialized
; stack contains 8 bytes of parameters:
; +1 [word] address of WeeGUI view configuration block for frame
; +3 [word] address of null-terminated string for frame title
; out: $00/$01 clobbered
; all registers clobbered
;------------------------------------------------------------------------------
!zone {
CreateDialog
+PARAMS_ON_STACK 4
+LDPARAM 1
+STAY PARAM0
ldx #WGCreateView ; create frame
jsr WeeGUI
+LDPARAM 3
+STAY PARAM0
ldx #WGViewSetTitle ; set frame title
jmp WeeGUI
}
;------------------------------------------------------------------------------
; PaintTitleBar
; paints the title bar on the top line
;
; in: WeeGUI loaded and initialized
; out: all registers and flags clobbered ; out: all registers and flags clobbered
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
!zone { !zone {
@ -76,3 +109,29 @@ PaintTitleBar
!byte 4 !byte 4
!raw "ark ",0 !raw "ark ",0
} }
;------------------------------------------------------------------------------
; PrintAt
; print a null-terminated string at a specified position
;
; in: WeeGUI loaded and initialized
; stack contains 4 bytes of parameters:
; +1 [byte] X coordinate (relative to selected view)
; +2 [byte] Y coordinate (relative to selected view)
; +3 [word] address of null-terminated string
; out: WeeGUI local cursor positioned after string
; $00/$01 clobbered
; all registers and flags clobbered
;------------------------------------------------------------------------------
!zone {
PrintAt
+PARAMS_ON_STACK 4
+LDPARAM 1
+STAY PARAM0
ldx #WGSetCursor
jsr WeeGUI
+LDPARAM 3
+STAY PARAM0
ldx #WGPrint
jmp WeeGUI
}

View File

@ -170,19 +170,11 @@ CreateOrDestroyButton
ldy #1 ldy #1
lda (PARAM),y lda (PARAM),y
sta .viewID sta .viewID
ldy #3
lda (PARAM),y +LDPARAM 2
pha
dey
lda (PARAM),y
ply
+STAY .viewConfigurationRecord +STAY .viewConfigurationRecord
ldy #5
lda (PARAM),y +LDPARAM 4
pha
dey
lda (PARAM),y
ply
+STAY .optionsStoreKey +STAY .optionsStoreKey
jsr okvs_get jsr okvs_get

View File

@ -40,8 +40,7 @@ ID_OPTIONS_CANCEL = 7
; ;
; in: WeeGUI loaded and initialized ; in: WeeGUI loaded and initialized
; out: exits via MainScreen ; out: exits via MainScreen
; all registers clobbered ; all registers and flags clobbered
; all flags clobbered
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
OptionsDialog OptionsDialog
ldx #$FF ldx #$FF
@ -49,20 +48,17 @@ OptionsDialog
ldx #WGResetAll ; reset WeeGUI, destroy all views ldx #WGResetAll ; reset WeeGUI, destroy all views
jsr WeeGUI jsr WeeGUI
ldx #WGCreateView ; create frame jsr CreateDialog ; create frame and OK/Cancel buttons
+LDADDR kViewFrame !word kViewOptionsFrame
+STAY PARAM0 !word kStringOptionsFrame
jsr WeeGUI
ldx #WGViewSetTitle
+LDADDR kStringFrame
+STAY PARAM0
jsr WeeGUI
jsr CreateButton ; create UI controls jsr CreateButton ; create OK button
!word kViewOK !word kViewOptionsOK
jsr CreateButton
!word kViewCancel jsr CreateButton ; create Cancel button
jsr CreateCheckbox !word kViewOptionsCancel
jsr CreateCheckbox ; create other UI controls
!word kViewForce40 !word kViewForce40
jsr CreateCheckbox jsr CreateCheckbox
!word kViewForceUpper !word kViewForceUpper
@ -92,53 +88,22 @@ OptionsDialog
jsr PaintTitleBar ; paint top title bar jsr PaintTitleBar ; paint top title bar
ldx #WGSelectView ldx #WGSelectView ; select frame (required for print routines that follow)
lda #ID_OPTIONS_FRAME lda #ID_OPTIONS_FRAME
jsr WeeGUI jsr WeeGUI
ldx #WGSetCursor ; paint static text labels jsr PrintAt ; paint static text labels
lda #6 !byte 6,3
sta PARAM0 !word kStringForce40Description
lda #3 jsr PrintAt
sta PARAM1 !byte 6,8
jsr WeeGUI !word kStringForceUpperDescription
ldx #WGPrint jsr PrintAt
+LDADDR kStringForce40Description !byte 6,13
+STAY PARAM0 !word kStringScriptToFileDescription
jsr WeeGUI jsr PrintAt
!byte 6,18
ldx #WGSetCursor !word kStringAutoScriptDescription
lda #6
sta PARAM0
lda #8
sta PARAM1
jsr WeeGUI
ldx #WGPrint
+LDADDR kStringForceUpperDescription
+STAY PARAM0
jsr WeeGUI
ldx #WGSetCursor
lda #6
sta PARAM0
lda #13
sta PARAM1
jsr WeeGUI
ldx #WGPrint
+LDADDR kStringScriptToFileDescription
+STAY PARAM0
jsr WeeGUI
ldx #WGSetCursor
lda #6
sta PARAM0
lda #18
sta PARAM1
jsr WeeGUI
ldx #WGPrint
+LDADDR kStringAutoScriptDescription
+STAY PARAM0
jsr WeeGUI
.runLoop .runLoop
ldx #WGPendingViewAction ldx #WGPendingViewAction
@ -198,12 +163,8 @@ SetCheckboxByPref
ldy #1 ldy #1
lda (PARAM),y lda (PARAM),y
sta .id sta .id
iny +LDPARAM 2
lda (PARAM),y +STAY .key
sta .key
iny
lda (PARAM),y
sta .key+1
jsr okvs_get jsr okvs_get
!word gGlobalPrefsStore !word gGlobalPrefsStore
@ -231,12 +192,8 @@ SetPrefByCheckbox
ldy #1 ldy #1
lda (PARAM),y lda (PARAM),y
sta .id sta .id
iny +LDPARAM 2
lda (PARAM),y +STAY .key
sta .key
iny
lda (PARAM),y
sta .key+1
ldx #WGSelectView ldx #WGSelectView
.id=*+1 .id=*+1
@ -258,7 +215,7 @@ SetPrefByCheckbox
!byte $FD ; SMC !byte $FD ; SMC
} }
kViewFrame kViewOptionsFrame
!byte ID_OPTIONS_FRAME ; view ID !byte ID_OPTIONS_FRAME ; view ID
!byte 2 ; style (decorated frame) !byte 2 ; style (decorated frame)
!byte 12 ; left !byte 12 ; left
@ -267,30 +224,24 @@ kViewFrame
!byte 19 ; visible height !byte 19 ; visible height
!byte 56 ; width !byte 56 ; width
!byte 19 ; height !byte 19 ; height
kStringFrame kStringOptionsFrame
!text "Settings",0 !text "Settings",0
kViewOK kViewOptionsOK
!byte ID_OPTIONS_OK ; view ID !byte ID_OPTIONS_OK ; view ID
!byte 56 ; left !byte 56 ; left
!byte 4 ; top !byte 4 ; top
!byte 10 ; width !byte 10 ; width
!word callback_options_ok ; callback !word callback_options_ok ; callback
!word kStringOK ; caption !word kStringOK ; caption
kStringOK
!byte $0F ; 'P' inverse
!byte 139,0
kViewCancel kViewOptionsCancel
!byte ID_OPTIONS_CANCEL ; view ID !byte ID_OPTIONS_CANCEL ; view ID
!byte 56 ; left !byte 56 ; left
!byte 6 ; top !byte 6 ; top
!byte 10 ; width !byte 10 ; width
!word callback_options_cancel ; callback !word callback_options_cancel ; callback
!word kStringCancel ; caption !word kStringCancel ; caption
kStringCancel
!byte $03 ; 'C' inverse
!text "ancel",0
kViewForce40 kViewForce40
!byte ID_OPTIONS_FORCE40 ; view ID !byte ID_OPTIONS_FORCE40 ; view ID