From e82bbdf78a0ef6e1d13b6d54be4e739928458285 Mon Sep 17 00:00:00 2001 From: 4am Date: Tue, 17 Apr 2018 16:16:45 -0400 Subject: [PATCH] refactor out ClearPendingInput and use before and after all run loops --- src/pitchdark.a | 6 ++---- src/ui.artwork.a | 6 ++---- src/ui.common.a | 16 ++++++++++++++++ src/ui.options.a | 6 ++---- src/ui.versions.a | 6 ++---- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/pitchdark.a b/src/pitchdark.a index 735cceb..b9820f4 100644 --- a/src/pitchdark.a +++ b/src/pitchdark.a @@ -64,16 +64,14 @@ MainScreen ldx #$FF txs jsr PaintMain ; create all WeeGUI views (UI elements) and paint them - bit $C010 ; clear keyboard strobe - ldx #WGClearPendingClick ; clear WeeGUI mouse strobe - jsr WeeGUI + jsr ClearPendingInput .mainRunLoop jsr RepaintMainIfDirty ldx #WGPendingViewAction jsr WeeGUI ; handle mouse movement and clicks lda $C000 bpl .mainRunLoop - bit $C010 + jsr ClearPendingInput jsr HandleKey ; handle keypresses bra .mainRunLoop diff --git a/src/ui.artwork.a b/src/ui.artwork.a index d3df663..714299a 100644 --- a/src/ui.artwork.a +++ b/src/ui.artwork.a @@ -51,9 +51,7 @@ DisplayArtwork sta $C054 sta $C050 - bit $C010 ; clear keyboard strobe - ldx #WGClearPendingClick ; clear WeeGUI mouse strobe - jsr WeeGUI + jsr ClearPendingInput .runLoop ldx #WGPendingClick jsr WeeGUI @@ -62,7 +60,7 @@ DisplayArtwork lda $C000 bpl .runLoop + sta $C051 ; back to text - rts + jmp ClearPendingInput .error jmp SoftBell } diff --git a/src/ui.common.a b/src/ui.common.a index a98a1ba..7bacb3e 100644 --- a/src/ui.common.a +++ b/src/ui.common.a @@ -6,6 +6,7 @@ ; Public functions ; - HardResetWeeGUI ; - ExitWeeGUI +; - ClearPendingInput ; - CreateRadio ; - CreateCheckbox ; - CreateButton @@ -71,6 +72,21 @@ ExitWeeGUI jmp WeeGUI } +;------------------------------------------------------------------------------ +; ClearPendingInput +; clears keyboard strobe and WeeGUI mouse click queue +; +; in: WeeGUI initialized +; out: A,Y preserved +; X clobbered +;------------------------------------------------------------------------------ +!zone { +ClearPendingInput + bit $C010 ; clear keyboard strobe + ldx #WGClearPendingClick ; clear WeeGUI mouse strobe + jmp WeeGUI +} + ;------------------------------------------------------------------------------ ; CreateRadio/CreateCheckbox/CreateButton ; creates a WeeGUI UI control with the 'raw title' option set diff --git a/src/ui.options.a b/src/ui.options.a index 524ff1f..fbf0c6f 100644 --- a/src/ui.options.a +++ b/src/ui.options.a @@ -104,15 +104,13 @@ OptionsDialog !byte 6,18 !word kStringAutoScriptDescription - bit $C010 ; clear keyboard strobe - ldx #WGClearPendingClick ; clear WeeGUI mouse strobe - jsr WeeGUI + jsr ClearPendingInput .runLoop ldx #WGPendingViewAction jsr WeeGUI ; handle mouse movement and clicks lda $C000 bpl .runLoop - bit $C010 + jsr ClearPendingInput jsr HandleOptionsKey ; handle keypresses bra .runLoop diff --git a/src/ui.versions.a b/src/ui.versions.a index d72e32b..b3ffa28 100644 --- a/src/ui.versions.a +++ b/src/ui.versions.a @@ -162,15 +162,13 @@ iNumVersions=*+1 !word gVersionsStore !word PrintVersionLabelCallback - bit $C010 ; clear keyboard strobe - ldx #WGClearPendingClick ; clear WeeGUI mouse strobe - jsr WeeGUI + jsr ClearPendingInput .runLoop ldx #WGPendingViewAction jsr WeeGUI ; handle mouse movement and clicks lda $C000 bpl .runLoop - bit $C010 + jsr ClearPendingInput jsr HandleVersionsKey ; handle keypresses bra .runLoop