From de84c69fe968f03e0fe9fde1fd8ecbaa148619a7 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Fri, 8 Sep 2017 01:00:58 -0700 Subject: [PATCH] Calc: more procs and comments --- desk.acc/calculator.s | 58 +++++++++++++++++++++++++++++++++++++------ inc/applesoft.inc | 2 ++ 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/desk.acc/calculator.s b/desk.acc/calculator.s index c59bcfa..f214c46 100644 --- a/desk.acc/calculator.s +++ b/desk.acc/calculator.s @@ -55,6 +55,8 @@ save_stack: .byte 0 jmp XFER .endproc +;;; ================================================== + .proc exit_da lda LCBANK1 lda LCBANK1 @@ -63,6 +65,8 @@ save_stack: .byte 0 rts .endproc +;;; ================================================== + call_init: lda ROMIN2 jmp L0D18 @@ -108,6 +112,9 @@ L0878: lda #0 routine_end := * .endproc +;;; ================================================== + + L089D: .byte 0 L089E: sta L08D1 lda L0CBD @@ -126,6 +133,9 @@ L089E: sta L08D1 L08C4: rts +;;; ================================================== +;;; Call Params (and other data) + .proc button_state_params state: .byte 0 .endproc @@ -180,6 +190,8 @@ L08D4: .byte $80 row5_top := 83 row5_bot := row5_top+button_height ; 92 + border_lt := 1 ; border width pixels (left/top) + border_br := 2 ; (bottom/right) L08D5: .byte $00 @@ -583,6 +595,9 @@ L0CE6: .byte $00,$00,$02,$00,$06,$00,$0E,$00 .byte $78,$00,$78,$00,$70,$01,$70,$01 .byte $01,$01 +;;; ================================================== +;;; DA Init + L0D18: sta ALTZPON lda LCBANK1 lda LCBANK1 @@ -649,6 +664,10 @@ loop: lda copied_to_b0-1,x lda #'C' jsr process_key A2D_CALL $24, L0CE6 + ;; fall through + +;;; ================================================== +;;; Input Loop input_loop: A2D_CALL $2A, button_state_params @@ -660,9 +679,12 @@ input_loop: L0DDC: cmp #$03 bne input_loop - jsr L0E6F + jsr L0E6F ; key jmp input_loop +;;; ================================================== +;;; On Click + on_click: lda LCBANK1 lda LCBANK1 @@ -681,7 +703,7 @@ ignore_click: : lda get_mouse_params::elem cmp #A2D_ELEM_CLIENT ; Client area? bne :+ - jsr L0E95 ; try to translate click into key + jsr map_click_to_button ; try to translate click into key bcc ignore_click jmp process_key @@ -711,7 +733,7 @@ loop: lda routine,x jmp zp_stash .proc routine -L0E4A: sta RAMRDOFF + sta RAMRDOFF sta RAMWRTOFF jmp exit_da .endproc @@ -729,6 +751,9 @@ L0E4A: sta RAMRDOFF jsr L084C rts +;;; ================================================== +;;; On Key Press + .proc L0E6F lda keydown bne bail @@ -751,7 +776,13 @@ bail: .endproc L0E94: rts ; used by prev/next proc -L0E95: lda #window_id +;;; ================================================== +;;; Try to map a click to a button + +;;; If a button was clicked, carry is set and accum has key char + +.proc map_click_to_button + lda #window_id sta button_state_params::state A2D_CALL $46, button_state_params lda clickx+1 ; ensure high bits of coords are 0 @@ -760,9 +791,6 @@ L0E95: lda #window_id lda clicky ; click y ldx clickx ; click x - border_lt := 1 ; border width pixels (left/top) - border_br := 2 ; (bottom/right) - .proc find_button_row cmp #row1_top+border_lt - 1 ; row 1 ? (- 1 is bug in original?) bcc miss @@ -879,6 +907,14 @@ miss: clc miss: clc rts .endproc +.endproc + +;;; ================================================== +;;; Handle Key + +;;; Accumulator is set to key char. Also used by +;;; click handlers (button is mapped to key char) +;;; and during initialization (by sending 'C', etc) .proc process_key cmp #'C' ; Clear? @@ -1197,7 +1233,7 @@ post: ldx #