2019-06-26 02:44:39 +00:00
|
|
|
;license:MIT
|
|
|
|
;(c) 2018-9 by 4am
|
|
|
|
;
|
|
|
|
; common UI functions
|
|
|
|
;
|
|
|
|
; Public functions
|
2019-07-04 02:27:46 +00:00
|
|
|
; - WaitForKeyFor30Seconds
|
2019-07-03 22:31:50 +00:00
|
|
|
; - GetOffscreenAddress
|
2019-07-04 02:27:46 +00:00
|
|
|
; - LoadTitleOffscreen
|
|
|
|
; - LoadCoverOffscreen
|
2019-07-03 22:31:50 +00:00
|
|
|
; - DrawSearchBarOffscreen
|
2019-07-10 17:37:59 +00:00
|
|
|
; - ClearOffscreen
|
2019-07-03 22:31:50 +00:00
|
|
|
; - ShowOtherPage
|
|
|
|
; - ToggleOffscreenPage
|
2019-07-04 02:27:46 +00:00
|
|
|
; - CoverFade
|
2019-07-03 22:31:50 +00:00
|
|
|
; - ResetInputTimeout
|
2019-06-26 02:44:39 +00:00
|
|
|
; - SoftBell
|
|
|
|
; - Home
|
|
|
|
; - BlankHGR
|
|
|
|
; - BlankDHGR
|
2019-09-06 19:21:38 +00:00
|
|
|
; - IsSearchKey
|
2019-07-03 22:31:50 +00:00
|
|
|
|
|
|
|
; Public variables
|
|
|
|
; - OffscreenPage
|
|
|
|
; - UILine1
|
|
|
|
; - UILine2
|
|
|
|
; - VisibleGameCount (set during init)
|
2019-06-26 02:44:39 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
!zone {
|
2019-07-04 02:27:46 +00:00
|
|
|
|
2019-07-03 22:31:50 +00:00
|
|
|
OffscreenPage
|
|
|
|
!byte 1 ; 0 = currently showing HGR page 2
|
|
|
|
; (so offscreen is page 1 @ $2000)
|
|
|
|
; 1 = currently showing HGR page 1
|
|
|
|
; (so offscreen is page 2 @ $4000)
|
|
|
|
|
|
|
|
UILine1
|
|
|
|
!byte 0,0,0,0,0,0,0,0,0,0
|
|
|
|
!byte 0,0,0,0,0,0,0,0,0,0
|
|
|
|
!byte 0,0,0,0,0,0,0,0,0,0
|
|
|
|
!byte 0,0,0,0,0,0,0,0,0,0
|
|
|
|
UILine2
|
2019-07-08 18:10:11 +00:00
|
|
|
!byte 0,0,0,0,0,0,0,0,0,0
|
|
|
|
!byte 0,0,0,0,0,0,0,0,0,0
|
|
|
|
!byte 0,0,0,0,0,0,0,0,0,0
|
|
|
|
!byte 0
|
|
|
|
UI_ToPlay
|
|
|
|
!byte 0,0,0,0,0,0,0,0,0
|
|
|
|
|
|
|
|
Instructions
|
|
|
|
!text "[Type to search, "
|
|
|
|
!byte $0B
|
|
|
|
!text " to browse] "
|
2019-07-03 22:31:50 +00:00
|
|
|
VisibleGameCount
|
2019-07-08 18:10:11 +00:00
|
|
|
!text "000 games"
|
|
|
|
ReturnToPlay
|
|
|
|
!byte $0D
|
|
|
|
!text " to play"
|
2019-07-03 22:31:50 +00:00
|
|
|
|
|
|
|
GetOffscreenAddress
|
|
|
|
; in: none
|
|
|
|
; out: A = high byte of offscreen HGR page (#$20 or #$40)
|
|
|
|
; preserves X/Y
|
|
|
|
lda OffscreenPage
|
|
|
|
beq +
|
|
|
|
lda #$40
|
|
|
|
rts
|
|
|
|
+ lda #$20
|
|
|
|
rts
|
|
|
|
|
2019-07-04 02:27:46 +00:00
|
|
|
LoadTitleOffscreen
|
|
|
|
; clobbers all
|
|
|
|
+LDADDR .TitleFile
|
|
|
|
bne + ; Always branches, because Y is loaded
|
|
|
|
; last with the high byte of the address,
|
|
|
|
; which is never 0. I miss my 65c02.
|
|
|
|
LoadCoverOffscreen
|
|
|
|
; clobbers all
|
|
|
|
+LDADDR .CoverFile
|
|
|
|
+
|
|
|
|
jsr SetPath
|
|
|
|
jsr GetOffscreenAddress
|
|
|
|
sta +
|
|
|
|
jsr LoadFileAt
|
|
|
|
!byte $00
|
|
|
|
+ !byte $FD ; SMC
|
|
|
|
rts
|
|
|
|
.TitleFile
|
|
|
|
!byte 5
|
|
|
|
!text "TITLE"
|
|
|
|
.CoverFile
|
|
|
|
!byte 5
|
|
|
|
!text "COVER"
|
|
|
|
|
|
|
|
CoverFade
|
|
|
|
; clobbers all
|
|
|
|
jsr LoadCoverOffscreen
|
|
|
|
jsr ShowOtherPage
|
|
|
|
lda OffscreenPage
|
|
|
|
bne +
|
|
|
|
jsr LoadCoverOffscreen
|
|
|
|
jsr ShowOtherPage
|
|
|
|
+
|
|
|
|
; load transition effect code at $6000
|
|
|
|
+LDADDR kFXDirectory
|
|
|
|
jsr SetPath
|
|
|
|
+LDADDR @CoverFadeFile
|
|
|
|
jsr AddToPath
|
|
|
|
jsr LoadFile
|
|
|
|
jmp $6000 ; exit via loaded code
|
|
|
|
@CoverFadeFile
|
|
|
|
!byte 9
|
|
|
|
!text "COVERFADE"
|
|
|
|
|
2019-07-03 22:31:50 +00:00
|
|
|
DrawSearchBarOffscreen
|
|
|
|
; clobbers all
|
|
|
|
LDA #22 ; draw visible search bar
|
|
|
|
sta VTAB
|
|
|
|
lda OffscreenPage
|
|
|
|
ror ; draw on offscreen page
|
|
|
|
+LDADDR UILine1
|
|
|
|
jsr Draw40Chars
|
|
|
|
lda OffscreenPage
|
|
|
|
ror ; draw on offscreen page
|
|
|
|
+LDADDR UILine2
|
|
|
|
jmp Draw40Chars
|
|
|
|
|
|
|
|
ShowOtherPage
|
|
|
|
; in: none
|
|
|
|
; out: A = new value of OffscreenPage
|
|
|
|
; preserves X/Y
|
|
|
|
jsr ToggleOffscreenPage
|
|
|
|
bne +
|
|
|
|
bit PAGE2 ; show page 2
|
|
|
|
rts
|
|
|
|
+ bit PAGE1 ; show page 1
|
|
|
|
rts
|
|
|
|
|
|
|
|
ToggleOffscreenPage
|
|
|
|
; in: none
|
|
|
|
; out: A = new value of OffscreenPage
|
|
|
|
; preserves X/Y
|
|
|
|
lda OffscreenPage
|
|
|
|
eor #$01
|
|
|
|
sta OffscreenPage
|
|
|
|
rts
|
|
|
|
|
|
|
|
ResetInputTimeout
|
|
|
|
; clobbers X, preserves A/Y
|
|
|
|
ldx #$16
|
|
|
|
stx Timeout
|
|
|
|
stx Timeout+1
|
|
|
|
stx Timeout+2
|
2019-09-06 19:21:38 +00:00
|
|
|
bit CLEARKBD
|
2019-07-03 22:31:50 +00:00
|
|
|
rts
|
2019-06-26 02:44:39 +00:00
|
|
|
|
2019-07-04 02:27:46 +00:00
|
|
|
WaitForKeyFor30Seconds
|
|
|
|
lda KBD
|
|
|
|
bmi @gotKey
|
|
|
|
|
|
|
|
inc RNDSEED+1 ; these are only ever incremented, never
|
|
|
|
bne + ; reset (may be used as a pseudorandom
|
|
|
|
inc RNDSEED ; seed)
|
|
|
|
+
|
|
|
|
dec Timeout ; these are a 3-byte timeout counter
|
|
|
|
bne WaitForKeyFor30Seconds; that counts down from a number set
|
|
|
|
dec Timeout+1 ; in .ResetInputTimeout and reset
|
|
|
|
bne WaitForKeyFor30Seconds; on every keypress (whether or not
|
|
|
|
dec Timeout+2 ; the key leads to an action)
|
|
|
|
bne WaitForKeyFor30Seconds
|
|
|
|
jsr CoverFade ; no input for ~30 seconds, switch to
|
|
|
|
jmp MegaAttractMode ; mega-attract mode
|
|
|
|
@gotKey rts
|
|
|
|
|
2019-06-26 02:44:39 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; SoftBell
|
|
|
|
; yell at the user, but, like, gently
|
|
|
|
;
|
|
|
|
; in: none
|
2019-09-07 18:15:53 +00:00
|
|
|
; out: C clear
|
|
|
|
; Y preserved
|
|
|
|
; A=0
|
|
|
|
; X=0
|
|
|
|
; all flags preserved
|
2019-06-26 02:44:39 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
SoftBell
|
|
|
|
ldx #32
|
|
|
|
- lda #2
|
|
|
|
jsr @wait
|
2019-06-27 14:55:07 +00:00
|
|
|
bit SPEAKER
|
2019-06-26 02:44:39 +00:00
|
|
|
lda #33
|
|
|
|
jsr @wait
|
2019-06-27 14:55:07 +00:00
|
|
|
bit SPEAKER
|
2019-06-26 02:44:39 +00:00
|
|
|
dex
|
|
|
|
bne -
|
2019-09-07 18:15:53 +00:00
|
|
|
clc
|
2019-06-26 02:44:39 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; Home
|
|
|
|
; clear and display text screen (HARDER THAN IT SOUNDS)
|
|
|
|
;
|
|
|
|
; in: none
|
|
|
|
; out: $0106..$011F clobbered
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
Home
|
2019-06-27 13:51:17 +00:00
|
|
|
lda MachineStatus
|
2019-06-26 02:44:39 +00:00
|
|
|
and #SUPPORTS_SHR
|
|
|
|
beq @noSHR
|
2019-06-27 14:55:07 +00:00
|
|
|
lda NEWVIDEO
|
2019-06-30 17:59:06 +00:00
|
|
|
and #$3F
|
|
|
|
sta NEWVIDEO ; get out of SHR mode and linear mode
|
2019-06-28 03:42:01 +00:00
|
|
|
lda #$F0
|
|
|
|
sta TBCOLOR ; white text on black background
|
|
|
|
lda #$00
|
|
|
|
sta CLOCKCTL ; black border
|
2019-06-28 03:50:25 +00:00
|
|
|
sta CLOCKCTL ; set twice for VidHD
|
2019-06-26 02:44:39 +00:00
|
|
|
@noSHR
|
|
|
|
ldx #(@end-@start-1)
|
|
|
|
- lda @start,x
|
|
|
|
sta $106,x
|
|
|
|
dex
|
|
|
|
bpl -
|
|
|
|
jmp $106
|
|
|
|
@start
|
|
|
|
; this will be run from main memory
|
|
|
|
+READ_ROM_NO_WRITE
|
2019-06-27 14:55:07 +00:00
|
|
|
sta CLR80VID ; get out of DHGR mode
|
|
|
|
sta DHIRESOFF ; get out of DHGR mode
|
|
|
|
jsr ROM_TEXT ; TEXT
|
|
|
|
jsr ROM_HOME ; HOME
|
2019-06-26 02:44:39 +00:00
|
|
|
+READ_RAM1_WRITE_RAM1
|
|
|
|
rts
|
|
|
|
@end
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; BlankHGR
|
|
|
|
; clear and show HGR page 1 without flickering
|
|
|
|
;
|
|
|
|
; in: none
|
|
|
|
; out: text page clobbered (but screen holes preserved)
|
|
|
|
; $2000..$3FFF cleared
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
BlankHGR
|
|
|
|
jsr Home
|
|
|
|
jsr .ClearHGR1 ; clear hi-res screen 1
|
2019-06-27 15:37:23 +00:00
|
|
|
bit PAGE1 ; show hi-res screen 1 (now blank)
|
|
|
|
+HGR_MODE
|
2019-06-26 02:44:39 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; BlankDHGR
|
|
|
|
; clear and show DHGR page 1 without flickering
|
|
|
|
;
|
|
|
|
; in: none
|
|
|
|
; out: text page clobbered (but screen holes preserved)
|
|
|
|
; $2000..$3FFF/main and /aux cleared
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
BlankDHGR
|
|
|
|
jsr Home
|
|
|
|
jsr .ClearHGR1 ; clear hi-res screen 1
|
2019-06-27 14:55:07 +00:00
|
|
|
sta WRITEAUXMEM
|
2019-06-26 02:44:39 +00:00
|
|
|
jsr .ClearHGR1 ; clear hi-res screen 1 in auxmem
|
2019-06-27 14:55:07 +00:00
|
|
|
sta WRITEMAINMEM
|
|
|
|
sta SET80VID
|
2019-06-27 15:37:23 +00:00
|
|
|
bit PAGE1
|
|
|
|
+HGR_MODE
|
2019-06-27 14:55:07 +00:00
|
|
|
sta DHIRESON
|
2019-06-26 02:44:39 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
ExecuteTransitionAndWait
|
|
|
|
+STAY @j+1
|
|
|
|
@j jsr $FDFD ; SMC call transition effect code
|
|
|
|
ldx #$20 ; picture is showing so now we wait
|
|
|
|
- lda #0
|
|
|
|
jsr WaitForKeyWithTimeout
|
|
|
|
bmi +
|
|
|
|
dex
|
|
|
|
bpl -
|
|
|
|
+ rts
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
2019-09-06 19:21:38 +00:00
|
|
|
; ClearOffscreen
|
|
|
|
; clear $2000..$3FFF or $4000..$5FFF, depending on which HGR page is not
|
|
|
|
; visible right now
|
2019-06-27 15:37:23 +00:00
|
|
|
; does not change HGR mode
|
2019-06-26 02:44:39 +00:00
|
|
|
;
|
|
|
|
; in: none
|
2019-09-06 19:21:38 +00:00
|
|
|
; out: $2000..$3FFF or $4000..$5FFF cleared
|
2019-06-26 02:44:39 +00:00
|
|
|
; A = 0
|
|
|
|
; X = 0
|
|
|
|
; Y = 0
|
|
|
|
; Z = 1
|
|
|
|
;------------------------------------------------------------------------------
|
2019-07-10 17:37:59 +00:00
|
|
|
ClearOffscreen
|
|
|
|
jsr GetOffscreenAddress
|
|
|
|
+HIDE_NEXT_2_BYTES
|
2019-06-26 02:44:39 +00:00
|
|
|
.ClearHGR1
|
2019-07-10 17:37:59 +00:00
|
|
|
lda #$20
|
|
|
|
sta @a+2
|
2019-06-26 02:44:39 +00:00
|
|
|
ldx #$20
|
2019-07-10 17:37:59 +00:00
|
|
|
lda #$80
|
|
|
|
ldy #0
|
2019-06-26 02:44:39 +00:00
|
|
|
@a sta $2000,y
|
|
|
|
iny
|
|
|
|
bne @a
|
|
|
|
inc @a+2
|
|
|
|
dex
|
|
|
|
bne @a
|
|
|
|
rts
|
2019-09-06 19:21:38 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; IsSearchKey
|
|
|
|
; test whether accumulator contains a key that might trigger a new textrank
|
|
|
|
; search
|
|
|
|
;
|
|
|
|
; in: A = key
|
|
|
|
; out: A &= 0x7F
|
|
|
|
; Y preserved
|
|
|
|
; X clobbered
|
|
|
|
; Z = 1 if this is a search key
|
|
|
|
; Z = 0 if this is not a search key
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
IsSearchKey
|
|
|
|
and #$7F ; strip high bit for search characters
|
|
|
|
cmp #$30 ; control keys and punctuation ignored
|
|
|
|
bcc @badkey
|
|
|
|
cmp #$3A ; numbers are good input
|
|
|
|
bcc @goodkey
|
|
|
|
cmp #$41 ; more punctuation (also ignored)
|
|
|
|
bcc @badkey
|
|
|
|
cmp #$5B ; uppercase letters are good input
|
|
|
|
bcs +
|
|
|
|
ora #$20 ; convert uppercase letters to lowercase
|
|
|
|
bne @goodkey ; always branches
|
|
|
|
|
|
|
|
+ cmp #$61 ; more punctuation (also ignored)
|
|
|
|
bcc @badkey
|
|
|
|
cmp #$7B ; lowercase letters are good input
|
|
|
|
bcc @goodkey
|
|
|
|
@badkey
|
|
|
|
ldx #1
|
|
|
|
rts
|
|
|
|
@goodkey
|
|
|
|
ldx #0
|
|
|
|
rts
|
|
|
|
|
2019-06-26 02:44:39 +00:00
|
|
|
}
|