Calculator: remove offscreen flag

This commit is contained in:
Joshua Bell
2018-04-07 00:33:15 -07:00
parent 8866631110
commit 4db53ea196

View File

@@ -70,26 +70,14 @@ call_init:
.proc redraw_screen_and_window .proc redraw_screen_and_window
;; Redraw the desktop (by copying trampoline to ZP) ;; Redraw the desktop (by copying trampoline to ZP)
zp_stash := $20 zp_routine := $20
lda LCBANK1 COPY_BYTES sizeof_routine+1, routine, zp_routine
lda LCBANK1 jsr zp_routine
COPY_BYTES sizeof_routine+1, routine, zp_stash
jsr zp_stash
lda LCBANK1
lda LCBANK1
bit offscreen_flag ; if was offscreen, don't bother redrawing
bmi :+
DESKTOP_CALL DT_REDRAW_ICONS DESKTOP_CALL DT_REDRAW_ICONS
;; Redraw window after event_kind_drag ;; Redraw window after event_kind_drag
lda #da_window_id jsr draw_content
jsr check_visibility_and_draw_window
MGTK_CALL MGTK::GetWinPort, getwinport_params
MGTK_CALL MGTK::SetPort, grafport
rts rts
.proc routine .proc routine
@@ -103,37 +91,6 @@ call_init:
sizeof_routine := * - routine sizeof_routine := * - routine
.endproc .endproc
;;; ============================================================
;; Set when the client area is offscreen and
;; should not be painted.
offscreen_flag:
.byte 0
;; Called after window event_kind_drag is complete
;; (called with window_id in A)
.proc check_visibility_and_draw_window
sta getwinport_params_window_id
lda openwindow_params_top
cmp #screen_height - 1
bcc :+
lda #$80
sta offscreen_flag
rts
: lda #0
sta offscreen_flag
MGTK_CALL MGTK::GetWinPort, getwinport_params
MGTK_CALL MGTK::SetPort, grafport
lda getwinport_params_window_id
cmp #da_window_id
bne :+
jmp draw_background
: rts
.endproc
;;; ============================================================ ;;; ============================================================
;;; Call Params (and other data) ;;; Call Params (and other data)
@@ -179,7 +136,7 @@ goaway: .byte 0
.endproc .endproc
.proc getwinport_params .proc getwinport_params
window_id: .byte 0 window_id: .byte da_window_id
.addr grafport .addr grafport
.endproc .endproc
getwinport_params_window_id := getwinport_params::window_id getwinport_params_window_id := getwinport_params::window_id
@@ -712,13 +669,12 @@ init: sta ALTZPON
MGTK_CALL MGTK::SetZP1, preserve_zp_params MGTK_CALL MGTK::SetZP1, preserve_zp_params
MGTK_CALL MGTK::OpenWindow, winfo MGTK_CALL MGTK::OpenWindow, winfo
MGTK_CALL MGTK::InitPort, grafport MGTK_CALL MGTK::InitPort, grafport
MGTK_CALL MGTK::SetPort, grafport ; set clipping bounds? MGTK_CALL MGTK::SetPort, grafport
MGTK_CALL MGTK::FlushEvents MGTK_CALL MGTK::FlushEvents
jsr reset_buffer2 jsr reset_buffer2
lda #da_window_id jsr draw_content
jsr check_visibility_and_draw_window
jsr reset_buffers_and_display jsr reset_buffers_and_display
lda #'=' ; last operation lda #'=' ; last operation
@@ -801,8 +757,9 @@ ignore_click:
rts rts
: lda findwindow_params::which_area : lda findwindow_params::which_area
cmp #MGTK::Area::content ; Client area? cmp #MGTK::Area::content ; Content area?
bne :+ bne :+
jsr map_click_to_button ; try to translate click into key jsr map_click_to_button ; try to translate click into key
bcc ignore_click bcc ignore_click
jmp process_key jmp process_key
@@ -819,10 +776,10 @@ exit: MGTK_CALL MGTK::CloseWindow, closewindow_params
.proc do_close .proc do_close
;; Copy following routine to ZP and invoke it ;; Copy following routine to ZP and invoke it
zp_stash := $20 zp_routine := $20
COPY_BYTES sizeof_routine+1, routine, zp_stash COPY_BYTES sizeof_routine+1, routine, zp_routine
jmp zp_stash jmp zp_routine
.proc routine .proc routine
sta RAMRDOFF sta RAMRDOFF
@@ -1341,14 +1298,18 @@ end: jsr display_buffer1
.endproc .endproc
.proc depress_button .proc depress_button
stxy invert_addr
stxy inrect_params
stxy restore_addr
MGTK_CALL MGTK::GetWinPort, getwinport_params
cmp #MGTK::error_window_obscured
bne :+
rts
: MGTK_CALL MGTK::SetPort, grafport
button_state := $FC button_state := $FC
stx invert_addr
stx inrect_params
stx restore_addr
sty invert_addr+1
sty inrect_params+1
sty restore_addr+1
MGTK_CALL MGTK::SetPattern, black_pattern MGTK_CALL MGTK::SetPattern, black_pattern
MGTK_CALL MGTK::SetPenMode, penmode_xor MGTK_CALL MGTK::SetPenMode, penmode_xor
sec sec
@@ -1422,8 +1383,10 @@ loop: lda #' '
; fall through ; fall through
.endproc .endproc
.proc display_buffer1 .proc display_buffer1
bit offscreen_flag MGTK_CALL MGTK::GetWinPort, getwinport_params
bmi end cmp #MGTK::error_window_obscured
beq end
MGTK_CALL MGTK::SetPort, grafport
ldxy #text_buffer1 ldxy #text_buffer1
jsr pre_display_buffer jsr pre_display_buffer
MGTK_CALL MGTK::DrawText, drawtext_params1 MGTK_CALL MGTK::DrawText, drawtext_params1
@@ -1431,8 +1394,10 @@ end: rts
.endproc .endproc
.proc display_buffer2 .proc display_buffer2
bit offscreen_flag MGTK_CALL MGTK::GetWinPort, getwinport_params
bmi end cmp #MGTK::error_window_obscured
beq end
MGTK_CALL MGTK::SetPort, grafport
ldxy #text_buffer2 ldxy #text_buffer2
jsr pre_display_buffer jsr pre_display_buffer
MGTK_CALL MGTK::DrawText, drawtext_params2 MGTK_CALL MGTK::DrawText, drawtext_params2
@@ -1456,7 +1421,13 @@ end: rts
;;; ============================================================ ;;; ============================================================
;;; Draw the window contents (background, buttons) ;;; Draw the window contents (background, buttons)
.proc draw_background .proc draw_content
MGTK_CALL MGTK::GetWinPort, getwinport_params
cmp #MGTK::error_window_obscured
bne :+
rts
: MGTK_CALL MGTK::SetPort, grafport
;; Frame ;; Frame
MGTK_CALL MGTK::HideCursor MGTK_CALL MGTK::HideCursor
MGTK_CALL MGTK::SetPattern, background_pattern MGTK_CALL MGTK::SetPattern, background_pattern
@@ -1466,10 +1437,7 @@ end: rts
MGTK_CALL MGTK::SetPattern, white_pattern MGTK_CALL MGTK::SetPattern, white_pattern
MGTK_CALL MGTK::PaintRect, clear_display_params MGTK_CALL MGTK::PaintRect, clear_display_params
MGTK_CALL MGTK::SetTextBG, settextbg_params MGTK_CALL MGTK::SetTextBG, settextbg_params
;; fall through
.endproc
.proc draw_buttons
;; Buttons ;; Buttons
ptr := $FA ptr := $FA
@@ -1531,10 +1499,6 @@ draw_title_bar:
: stx title_bar_bitmap::viewloc::ycoord+1 : stx title_bar_bitmap::viewloc::ycoord+1
MGTK_CALL MGTK::SetPortBits, screen_port ; set clipping rect to whole screen MGTK_CALL MGTK::SetPortBits, screen_port ; set clipping rect to whole screen
MGTK_CALL MGTK::PaintBits, title_bar_bitmap ; Draws decoration in title bar MGTK_CALL MGTK::PaintBits, title_bar_bitmap ; Draws decoration in title bar
lda #da_window_id
sta getwinport_params::window_id
MGTK_CALL MGTK::GetWinPort, getwinport_params
MGTK_CALL MGTK::SetPort, grafport
MGTK_CALL MGTK::ShowCursor MGTK_CALL MGTK::ShowCursor
jsr display_buffer2 jsr display_buffer2
rts rts
@@ -1545,10 +1509,14 @@ draw_title_bar:
lda LCBANK1 lda LCBANK1
lda LCBANK1 lda LCBANK1
jsr reset_buffers_and_display jsr reset_buffers_and_display
bit offscreen_flag
bmi :+ MGTK_CALL MGTK::GetWinPort, getwinport_params
cmp #MGTK::error_window_obscured
beq :+
MGTK_CALL MGTK::SetPort, grafport
MGTK_CALL MGTK::MoveTo, error_pos MGTK_CALL MGTK::MoveTo, error_pos
MGTK_CALL MGTK::DrawText, error_string MGTK_CALL MGTK::DrawText, error_string
: jsr reset_buffer1_and_state : jsr reset_buffer1_and_state
lda #'=' lda #'='
sta calc_op sta calc_op