diff --git a/src/macros.a b/src/macros.a index bfe3ed4..f386429 100644 --- a/src/macros.a +++ b/src/macros.a @@ -28,3 +28,12 @@ PARAM = $00 sta .ptr sty .ptr+1 } + +!macro LDPARAM .offset { + ldy #.offset+1 + lda (PARAM),y + pha + dey + lda (PARAM),y + ply +} diff --git a/src/parse.common.a b/src/parse.common.a index c1e65d8..f94b592 100644 --- a/src/parse.common.a +++ b/src/parse.common.a @@ -12,26 +12,20 @@ ; $00/$01 clobbered ; $02/$03 clobbered ; $04/$05 has the address of the next available byte after the okvs +; $FE/$FF clobbered ;------------------------------------------------------------------------------ !zone { ParseKeyValueText +PARAMS_ON_STACK 5 - ldy #1 - lda (PARAM),y - sta .store1 - sta .store2 - iny - lda (PARAM),y - sta .store1+1 - sta .store2+1 - iny - lda (PARAM),y - sta $FE - iny - lda (PARAM),y - sta $FF - iny + +LDPARAM 1 + +STAY .store1 + +STAY .store2 + + +LDPARAM 3 + +STAY $FE + + ldy #5 lda (PARAM),y sta .useMaxLength+1 diff --git a/src/parse.prefs.a b/src/parse.prefs.a index 1e6079b..d29a588 100644 --- a/src/parse.prefs.a +++ b/src/parse.prefs.a @@ -148,15 +148,8 @@ addStringFromStore lda #$80 ; BRA opcode sta .skipOverBooleanLogic +PARAMS_ON_STACK 2 - ldy #1 - lda (PARAM),y - sta .key - pha - iny - lda (PARAM),y - sta .key+1 - tay - pla + +LDPARAM 1 + +STAY .key jsr addString +LDADDR .equals jsr addString diff --git a/src/prodos.a b/src/prodos.a index 2a8a0da..c394634 100644 --- a/src/prodos.a +++ b/src/prodos.a @@ -55,43 +55,30 @@ PRODOSMLI = $BF00 ; [callable] MLI entry point LoadFile +PARAMS_ON_STACK 6 - ldy #$01 - lda (PARAM),y ; lo byte of pathname - sta mliparam+1 - iny - 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 + +LDPARAM 1 + +STAY mliparam+1 ; pathname + +LDPARAM 5 + +STAY mliparam+3 ; ProDOS file buffer jsr _openfile - bcs .exit ; C set on error + bcs .exit ; C set on error - pha ; push file reference number - ldy #$03 - lda (PARAM),y ; lo address of data buffer - sta mliparam+2 - iny - lda (PARAM),y ; hi address of data buffer - sta mliparam+3 + pha ; push file reference number + +LDPARAM 3 + +STAY mliparam+2 ; data buffer lda #$FF - sta mliparam+4 ; max data length (unlimited, YOLO) + sta mliparam+4 ; max data length (unlimited, YOLO) sta mliparam+5 - pla ; pull file reference number + pla ; pull file reference number jsr _readfile - php ; save flags from readfile + php ; save flags from readfile pha - jsr _closefile ; always close whether read worked or not + jsr _closefile ; always close whether read worked or not pla - plp ; restore flags from readfile - ; (so caller gets codes from read attempt, - ; not close) -.exit - rts + plp ; restore flags from readfile + ; (so caller gets codes from read attempt, + ; not close) +.exit rts } ;------------------------------- @@ -186,59 +173,37 @@ LoadDHRFile !zone { SaveFile +PARAMS_ON_STACK $0B - - ldy #$01 - lda (PARAM),y ; lo byte of pathname - sta mliparam+1 - iny - lda (PARAM),y ; hi byte of pathname - sta mliparam+2 - jsr _deletefile ; don't care if this fails + +LDPARAM 1 + +STAY mliparam+1 ; pathname + jsr _deletefile ; don't care if this fails ldy #$03 - lda (PARAM),y ; file type + lda (PARAM),y ; file type sta mliparam+4 - iny - lda (PARAM),y ; lo byte of aux file type - sta mliparam+5 - iny - lda (PARAM),y ; hi byte of aux file type - sta mliparam+6 + +LDPARAM 4 + +STAY mliparam+5 ; aux file type jsr _createfile bcs .exit - ldy #$0A - 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 + +LDPARAM 10 + +STAY mliparam+3 ; PrODOS file buffer jsr _openfile bcs .exit - pha ; push file reference number - ldy #$06 - lda (PARAM),y ; lo address of data buffer - sta mliparam+2 - iny - lda (PARAM),y ; hi address of data buffer - 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 + pha ; push file reference number + +LDPARAM 6 + +STAY mliparam+2 ; data buffer + +LDPARAM 8 + +STAY mliparam+4 ; data length + pla ; pull file reference number jsr _writefile - php ; save flags from writefile + php ; save flags from writefile pha - jsr _closefile ; always close whether write worked or not + jsr _closefile ; always close whether write worked or not pla - plp ; restore flags from write - ; (so caller gets codes from write attempt, - ; not close) -.exit - rts + plp ; restore flags from write + ; (so caller gets codes from write attempt, + ; not close) +.exit rts } ;------------------------------- @@ -256,14 +221,8 @@ SaveFile !zone { SetPrefix +PARAMS_ON_STACK 2 - - ldy #$01 - lda (PARAM),y ; lo byte of pathname - sta mliparam+1 - iny - lda (PARAM),y ; hi byte of pathname - sta mliparam+2 - + +LDPARAM 1 + +STAY mliparam+1 ; pathname jmp _setprefix } @@ -284,14 +243,8 @@ SetPrefix !zone { GetFileInfo +PARAMS_ON_STACK 2 - - ldy #$01 - lda (PARAM),y ; lo byte of pathname - sta mliparam+1 - iny - lda (PARAM),y ; hi byte of pathname - sta mliparam+2 - + +LDPARAM 1 + +STAY mliparam+1 ; pathname jmp _getfileinfo } diff --git a/src/ui.common.a b/src/ui.common.a index 4979496..963ad71 100644 --- a/src/ui.common.a +++ b/src/ui.common.a @@ -8,13 +8,26 @@ ; - CreateCheckbox ; - CreateButton ; - 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 ; 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 ; out: $00/$01 clobbered ; all registers clobbered @@ -31,13 +44,8 @@ CreateButton stx .type +PARAMS_ON_STACK 2 - - ldy #$01 - lda (PARAM),y - sta PARAM0 - iny - lda (PARAM),y - sta PARAM1 + +LDPARAM 1 + +STAY PARAM0 .type=*+1 ldx #$FD ; SMC jsr WeeGUI @@ -48,10 +56,35 @@ CreateButton } ;------------------------------------------------------------------------------ -; PaintTitleBar -; paints the title bar +; CreateDialog +; 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 ;------------------------------------------------------------------------------ !zone { @@ -76,3 +109,29 @@ PaintTitleBar !byte 4 !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 +} diff --git a/src/ui.main.a b/src/ui.main.a index 1a4b89e..06b5402 100644 --- a/src/ui.main.a +++ b/src/ui.main.a @@ -170,19 +170,11 @@ CreateOrDestroyButton ldy #1 lda (PARAM),y sta .viewID - ldy #3 - lda (PARAM),y - pha - dey - lda (PARAM),y - ply + + +LDPARAM 2 +STAY .viewConfigurationRecord - ldy #5 - lda (PARAM),y - pha - dey - lda (PARAM),y - ply + + +LDPARAM 4 +STAY .optionsStoreKey jsr okvs_get diff --git a/src/ui.options.a b/src/ui.options.a index 7ac5cce..28933dc 100644 --- a/src/ui.options.a +++ b/src/ui.options.a @@ -40,8 +40,7 @@ ID_OPTIONS_CANCEL = 7 ; ; in: WeeGUI loaded and initialized ; out: exits via MainScreen -; all registers clobbered -; all flags clobbered +; all registers and flags clobbered ;------------------------------------------------------------------------------ OptionsDialog ldx #$FF @@ -49,20 +48,17 @@ OptionsDialog ldx #WGResetAll ; reset WeeGUI, destroy all views jsr WeeGUI - ldx #WGCreateView ; create frame - +LDADDR kViewFrame - +STAY PARAM0 - jsr WeeGUI - ldx #WGViewSetTitle - +LDADDR kStringFrame - +STAY PARAM0 - jsr WeeGUI + jsr CreateDialog ; create frame and OK/Cancel buttons + !word kViewOptionsFrame + !word kStringOptionsFrame - jsr CreateButton ; create UI controls - !word kViewOK - jsr CreateButton - !word kViewCancel - jsr CreateCheckbox + jsr CreateButton ; create OK button + !word kViewOptionsOK + + jsr CreateButton ; create Cancel button + !word kViewOptionsCancel + + jsr CreateCheckbox ; create other UI controls !word kViewForce40 jsr CreateCheckbox !word kViewForceUpper @@ -92,53 +88,22 @@ OptionsDialog jsr PaintTitleBar ; paint top title bar - ldx #WGSelectView + ldx #WGSelectView ; select frame (required for print routines that follow) lda #ID_OPTIONS_FRAME jsr WeeGUI - ldx #WGSetCursor ; paint static text labels - lda #6 - sta PARAM0 - lda #3 - sta PARAM1 - jsr WeeGUI - ldx #WGPrint - +LDADDR kStringForce40Description - +STAY PARAM0 - jsr WeeGUI - - ldx #WGSetCursor - 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 + jsr PrintAt ; paint static text labels + !byte 6,3 + !word kStringForce40Description + jsr PrintAt + !byte 6,8 + !word kStringForceUpperDescription + jsr PrintAt + !byte 6,13 + !word kStringScriptToFileDescription + jsr PrintAt + !byte 6,18 + !word kStringAutoScriptDescription .runLoop ldx #WGPendingViewAction @@ -198,12 +163,8 @@ SetCheckboxByPref ldy #1 lda (PARAM),y sta .id - iny - lda (PARAM),y - sta .key - iny - lda (PARAM),y - sta .key+1 + +LDPARAM 2 + +STAY .key jsr okvs_get !word gGlobalPrefsStore @@ -231,12 +192,8 @@ SetPrefByCheckbox ldy #1 lda (PARAM),y sta .id - iny - lda (PARAM),y - sta .key - iny - lda (PARAM),y - sta .key+1 + +LDPARAM 2 + +STAY .key ldx #WGSelectView .id=*+1 @@ -258,7 +215,7 @@ SetPrefByCheckbox !byte $FD ; SMC } -kViewFrame +kViewOptionsFrame !byte ID_OPTIONS_FRAME ; view ID !byte 2 ; style (decorated frame) !byte 12 ; left @@ -267,30 +224,24 @@ kViewFrame !byte 19 ; visible height !byte 56 ; width !byte 19 ; height -kStringFrame +kStringOptionsFrame !text "Settings",0 -kViewOK +kViewOptionsOK !byte ID_OPTIONS_OK ; view ID !byte 56 ; left !byte 4 ; top !byte 10 ; width !word callback_options_ok ; callback !word kStringOK ; caption -kStringOK - !byte $0F ; 'P' inverse - !byte 139,0 -kViewCancel +kViewOptionsCancel !byte ID_OPTIONS_CANCEL ; view ID !byte 56 ; left !byte 6 ; top !byte 10 ; width !word callback_options_cancel ; callback !word kStringCancel ; caption -kStringCancel - !byte $03 ; 'C' inverse - !text "ancel",0 kViewForce40 !byte ID_OPTIONS_FORCE40 ; view ID