From eaadce7b8a36a7d1f0079f072488c199211a79f0 Mon Sep 17 00:00:00 2001 From: 4am Date: Tue, 18 Jun 2019 16:54:15 -0400 Subject: [PATCH] WIP search mode --- src/4cade.a | 1 + src/ui.font.a | 65 ++++++++++++++++++++++++++++++++++++++++ src/ui.search.mode.a | 71 +++++++++++++++++--------------------------- src/ui.sound.a | 43 +++++++++++++++++++++++++++ 4 files changed, 137 insertions(+), 43 deletions(-) create mode 100644 src/ui.sound.a diff --git a/src/4cade.a b/src/4cade.a index c30011d26..5c14304ab 100644 --- a/src/4cade.a +++ b/src/4cade.a @@ -64,6 +64,7 @@ Main !source "src/parse.common.a" !source "src/parse.prefs.a" !source "src/parse.games.a" + !source "src/ui.sound.a" !source "src/ui.font.a" !source "src/ui.font.data.a" gGlobalPrefsStore diff --git a/src/ui.font.a b/src/ui.font.a index 10d7c8d27..c04c1e6f4 100644 --- a/src/ui.font.a +++ b/src/ui.font.a @@ -150,3 +150,68 @@ DrawBuffer dex bpl @loop rts + +InvertChar +; inverts a character already drawn to the screen +; carry bit clear -> draw on page 1 +; carry bit set -> draw on page 2 +; $24 contains textpage column (0..39) (this is the standard HTAB address) +; $25 contains textpage line (0..23) (this is the standard VTAB address) +; HTAB is NOT incremented +; VTAB is NOT incremented +; clobbers A +; preserves X/Y + bcs + + lda #$00 + +HIDE_NEXT_2_BYTES ++ + lda #$60 + sta @pagemask + txa + pha + tya + pha + lda VTAB + asl + asl + asl +; routine to calculate memory address within HGR page +; (routine clobbers A and Y but preserves X) + asl + tay + and #$F0 + bpl @calc1 + ora #$05 +@calc1 bcc @calc2 + ora #$0A +@calc2 asl + asl + sta @hgrlo+1 + tya + and #$0E + adc #$10 + asl @hgrlo+1 + rol +@pagemask=*+1 + eor #$FD ; SMC (0=hi-res page 1, #$60=hi-res page 2) + sta DEST+1 +@hgrlo lda #$FD + clc + adc HTAB + sta DEST + ldx #8 + ldy #0 +- lda (DEST),y + eor #$7F + sta (DEST),y + lda DEST+1 + clc + adc #$04 + sta DEST+1 + dex + bne - + pla + tay + pla + tax + rts diff --git a/src/ui.search.mode.a b/src/ui.search.mode.a index 2a2921687..fc1e47de6 100644 --- a/src/ui.search.mode.a +++ b/src/ui.search.mode.a @@ -8,14 +8,14 @@ ; ; indices into InputDispatchTable +kInputSearchKey= 0 kInputBackspace= 1 kInputEnter = 2 -kInputSearchKey= 3 + InputDispatchTable - !word 0 + !word OnSearchKey !word OnBackspace !word OnEnter - !word OnKey SearchMode jsr Home ; switches to text mode @@ -96,9 +96,9 @@ OnBackspace OnEnter ; TODO - jmp $ff59 + rts -OnKey +OnSearchKey ldx InputLength cpx #MaxInputLength bne + @@ -135,9 +135,12 @@ OnInputChanged jmp Draw40Chars @findMatchingTitle - lda #0 ; reset match count - sta MatchCount ; TextRankCallback will increment this if + ldx #0 ; reset match count + stx MatchCount ; TextRankCallback will increment this if ; there are any matches + stx BestMatchScore + dex + stx BestMatchIndex jsr okvs_iter_values !word gGamesListStore @@ -191,6 +194,24 @@ OnInputChanged sec +LDADDR UILine2 jsr Draw40Chars + dec VTAB + ldx #0 ; highlight matched characters + ldy #0 +- lda (SRC),y + +LOW_ASCII_TO_LOWER + cmp InputBuffer,x + bne + + sec ; on page 2 + jsr InvertChar + inx + cpx InputLength + beq @doneHighlight ++ inc HTAB + iny + cpy #MaxInputLength + bne - + +@doneHighlight bit $C055 ; show page 2 ldx #$20 ; copy back to page 1 @@ -209,42 +230,6 @@ OnInputChanged bit $C054 ; show page 1 rts -;------------------------------------------------------------------------------ -; SoftBell -; -; in: none -; out: all registers and flags preserved -;------------------------------------------------------------------------------ -SoftBell - php - pha - txa - pha - ldx #32 -- lda #2 - jsr Wait - bit $C030 - lda #33 - jsr Wait - bit $C030 - dex - bne - - pla - tax - pla - plp - rts - -Wait ; identical to $FCA8 ROM routine, but ROM is switched out when we need it - sec --- pha -- sbc #1 - bne - - pla - sbc #1 - bne -- - rts - ;------------------------------------------------------------------------------ Cover !byte 5 diff --git a/src/ui.sound.a b/src/ui.sound.a new file mode 100644 index 000000000..d368ca9e3 --- /dev/null +++ b/src/ui.sound.a @@ -0,0 +1,43 @@ +;license:MIT +;(c) 2019 by 4am +; +; sound effects +; +; Public functions +; - SoftBell +; + +;------------------------------------------------------------------------------ +; SoftBell +; +; in: none +; out: all registers and flags preserved +;------------------------------------------------------------------------------ +SoftBell + php + pha + txa + pha + ldx #32 +- lda #2 + jsr @wait + bit $C030 + lda #33 + jsr @wait + bit $C030 + dex + bne - + pla + tax + pla + plp + rts +@wait ; identical to $FCA8 ROM routine, but ROM is switched out when we need it + sec +-- pha +- sbc #1 + bne - + pla + sbc #1 + bne -- + rts