Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sound DA: Add a cancel button #775

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 41 additions & 7 deletions desk.acc/sounds.s
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ dialog_result:
rts
.endproc ; MarkDirty

;;; Cancel any changes, restore saved proc
.proc DoCancel
lda #$00
sta dialog_result
lda original_index
jsr InstallIndex
jmp Exit
.endproc

;;; ============================================================
;;; Resources
;;; ============================================================
Expand Down Expand Up @@ -127,6 +136,9 @@ nextwinfo: .addr 0
DEFINE_BUTTON ok_button_rec, kDAWindowId, res_string_button_ok, kGlyphReturn, kDAWidth - kMarginX - kButtonWidth, kDAHeight - kMarginY - kButtonHeight
DEFINE_BUTTON_PARAMS ok_button_params, ok_button_rec

DEFINE_BUTTON cancel_button_rec, kDAWindowId, res_string_button_cancel,, kDAWidth - kMarginX - kButtonWidth - kMarginX - kButtonWidth, kDAHeight - kMarginY - kButtonHeight
DEFINE_BUTTON_PARAMS cancel_button_params, cancel_button_rec

DEFINE_LABEL alert_sound, res_string_label_alert, kMarginX, kMarginY+kTextHeight
kLabelWidth = 105

Expand Down Expand Up @@ -227,6 +239,8 @@ proc_table:

selected_index:
.byte $FF
original_index:
.byte $FF

;;; ============================================================

Expand All @@ -250,6 +264,8 @@ grafport_win: .tag MGTK::GrafPort
jsr DrawWindow

jsr SearchForCurrent
; keep it around in case we want to cancel
sta original_index
jsr ListSetSelection

MGTK_CALL MGTK::FlushEvents
Expand Down Expand Up @@ -295,8 +311,8 @@ grafport_win: .tag MGTK::GrafPort

cmp #CHAR_ESCAPE
IF_EQ
BTK_CALL BTK::Flash, ok_button_params
jmp Exit
BTK_CALL BTK::Flash, cancel_button_params
jmp DoCancel
END_IF

cmp #CHAR_RETURN
Expand Down Expand Up @@ -356,14 +372,23 @@ grafport_win: .tag MGTK::GrafPort
jmp InputLoop
END_IF

MGTK_CALL MGTK::InRect, cancel_button_rec::rect
cmp #MGTK::inrect_inside
IF_EQ
BTK_CALL BTK::Track, cancel_button_params
beq :+
jmp InputLoop
: jmp DoCancel
END_IF

;; ----------------------------------------

jmp InputLoop
.endproc ; HandleDialogClick

;;; ============================================================

.proc PlayIndex
.proc InstallIndex
ptr := $06

;; Look up routine
Expand All @@ -374,10 +399,7 @@ grafport_win: .tag MGTK::GrafPort
;; Put routine into location
jsr Install

;; Play it
JSR_TO_MAIN JUMP_TABLE_BELL

jmp MarkDirty
rts

.proc Install
ldax ptr
Expand All @@ -400,6 +422,17 @@ grafport_win: .tag MGTK::GrafPort
rts
.endproc ; Install

.endproc ; InstallIndex

;;; ============================================================

.proc PlayIndex
jsr InstallIndex

;; Play it
JSR_TO_MAIN JUMP_TABLE_BELL

jmp MarkDirty
.endproc ; PlayIndex

;;; ============================================================
Expand Down Expand Up @@ -438,6 +471,7 @@ grafport_win: .tag MGTK::GrafPort
MGTK_CALL MGTK::MoveTo, alert_sound_label_pos
param_call DrawString, alert_sound_label_str

BTK_CALL BTK::Draw, cancel_button_params
BTK_CALL BTK::Draw, ok_button_params

;; List Box
Expand Down