2018-06-20 22:58:05 +00:00
|
|
|
;license:MIT
|
|
|
|
;(c) 2018 by 4am
|
|
|
|
;
|
|
|
|
; User interface - views and paint routines for credits screen
|
|
|
|
;
|
|
|
|
; Public functions
|
|
|
|
; - CreditsDialog
|
|
|
|
;
|
|
|
|
|
2018-07-06 22:29:15 +00:00
|
|
|
ID_CREDITS = 0
|
2018-06-20 22:58:05 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; CreditsDialog
|
|
|
|
; call WeeGUI to create and paint credits screen, and run to completion
|
|
|
|
;
|
|
|
|
; in: WeeGUI initialized
|
|
|
|
; out: exits via MainScreen
|
|
|
|
; all registers and flags clobbered
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
CreditsDialog
|
|
|
|
ldx #$FF
|
|
|
|
txs
|
|
|
|
|
2018-07-06 22:29:15 +00:00
|
|
|
jsr LoadCredits ; fetch contents from file
|
|
|
|
jsr ClearPendingInput
|
2018-06-20 22:58:05 +00:00
|
|
|
|
2018-07-06 22:29:15 +00:00
|
|
|
@creditsOuterLoop
|
|
|
|
lda #5
|
|
|
|
sta currentSection
|
2018-06-20 22:58:05 +00:00
|
|
|
|
2018-07-06 22:29:15 +00:00
|
|
|
@creditsInnerLoop
|
|
|
|
lda #$20 ; fade to white
|
|
|
|
jsr TextFizzle
|
|
|
|
jsr @ExitOnAnyInput
|
2018-06-20 22:58:05 +00:00
|
|
|
|
2018-07-06 22:29:15 +00:00
|
|
|
lda #' ' ; fade to black
|
|
|
|
jsr TextFizzle
|
|
|
|
jsr @ExitOnAnyInput
|
2018-06-20 22:58:05 +00:00
|
|
|
|
2018-07-06 22:29:15 +00:00
|
|
|
ldx currentSection ; set up border frame
|
|
|
|
lda kCreditsTop,x
|
|
|
|
sta kViewCreditsTop
|
|
|
|
lda kCreditsHeight,x
|
|
|
|
sta kViewCreditsVisibleHeight
|
|
|
|
sta kViewCreditsHeight
|
2018-06-20 22:58:05 +00:00
|
|
|
|
2018-07-06 22:29:15 +00:00
|
|
|
jsr HardResetWeeGUI
|
|
|
|
ldx #WGCreateView
|
|
|
|
+LDADDR kViewCredits
|
2018-06-20 22:58:05 +00:00
|
|
|
+STAY PARAM0
|
2018-07-06 22:29:15 +00:00
|
|
|
jsr WeeGUI ; create border frame
|
2018-06-20 22:58:05 +00:00
|
|
|
|
|
|
|
ldx #WGSelectView
|
2018-07-06 22:29:15 +00:00
|
|
|
lda #ID_CREDITS
|
2018-06-20 22:58:05 +00:00
|
|
|
jsr WeeGUI
|
2018-07-06 22:29:15 +00:00
|
|
|
ldx #WGPaintView
|
|
|
|
jsr WeeGUI ; paint border frame
|
|
|
|
jsr PaintCredits ; paint text
|
|
|
|
jsr @ExitOnAnyInput
|
|
|
|
|
|
|
|
ldx currentSection ; wait a variable period of time
|
|
|
|
lda kCreditsHeight,x ; based on the number of lines of text
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
tay
|
|
|
|
- lda #0
|
|
|
|
jsr WAIT
|
|
|
|
jsr @ExitOnAnyInput
|
|
|
|
dey
|
|
|
|
bpl -
|
2018-06-20 22:58:05 +00:00
|
|
|
|
2018-07-06 22:29:15 +00:00
|
|
|
dec currentSection
|
|
|
|
lda currentSection
|
|
|
|
bpl @creditsInnerLoop
|
|
|
|
bra @creditsOuterLoop
|
|
|
|
|
|
|
|
@ExitOnAnyInput
|
|
|
|
jsr AnyKeyOrClick
|
|
|
|
bcs @exit
|
|
|
|
rts
|
|
|
|
@exit
|
|
|
|
jmp MainScreen
|
2018-06-20 22:58:05 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; internal functions
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
2018-07-06 22:29:15 +00:00
|
|
|
; LoadCredits
|
|
|
|
; load credits from file and convert it for use by WeeGUI
|
|
|
|
;
|
|
|
|
; NOTE: this routine assumes there are no more than 6 sections of credits.
|
|
|
|
; Section 1 starts at the beginning of the file.
|
|
|
|
; Sections 1-5 end with the '~' character.
|
|
|
|
; Sections 2-6 start at the first non-0x0D character after the '~' delimiter.
|
|
|
|
; Section 6 ends with '[' character (not '~')
|
|
|
|
; Text is stored on disk with high bit off.
|
|
|
|
; Each line must be no more than 40 characters.
|
|
|
|
; Parsing would obviously be easier if these constraints were different,
|
|
|
|
; but I like the way the file looks.
|
2018-06-20 22:58:05 +00:00
|
|
|
;
|
2018-07-06 22:29:15 +00:00
|
|
|
; in: WeeGUI initialized
|
|
|
|
; out: exits to caller
|
|
|
|
; all registers and flags clobbered
|
2018-06-20 22:58:05 +00:00
|
|
|
;------------------------------------------------------------------------------
|
2018-07-06 22:29:15 +00:00
|
|
|
LoadCredits
|
|
|
|
jsr LoadFile ; load credits file at $2000
|
|
|
|
!word kCreditsFilename
|
|
|
|
!word kCreditsBuffer
|
|
|
|
!word kProDOSFileBuffer
|
|
|
|
|
|
|
|
+LDADDR kCreditsBuffer
|
|
|
|
+STAY $FE ; ($FE) points to start of data buffer
|
|
|
|
ldy #$00 ; index into ($FE) pointing to current character
|
|
|
|
ldx #$0C ; (= 6 x 2) index into creditsSectionPointers array
|
|
|
|
lda ($FE)
|
|
|
|
bra @saveSectionPointer
|
|
|
|
|
|
|
|
@convertSectionLoop
|
|
|
|
jsr IncAndGetChar
|
|
|
|
@convertSectionNoInc
|
|
|
|
cmp #$7E ; '~' ends the section
|
|
|
|
beq @skipSectionDelimiter
|
|
|
|
cmp #$5B ; '[' ends the parsing
|
|
|
|
beq @exit
|
|
|
|
cmp #$0D ; CR -> 0x00 (WeeGUI wants null-terminated strings)
|
|
|
|
beq @null
|
|
|
|
ora #$80 ; all other characters -> set high bit
|
|
|
|
+HIDE_NEXT_2_BYTES
|
|
|
|
@null lda #$00
|
|
|
|
sta ($FE),y
|
|
|
|
bra @convertSectionLoop
|
|
|
|
|
|
|
|
; We found the start of a new section, so skip to the first character on the next line
|
|
|
|
@skipSectionDelimiter
|
|
|
|
jsr IncAndGetChar
|
|
|
|
cmp #$0D ; CR
|
|
|
|
beq @skipSectionDelimiter
|
|
|
|
|
|
|
|
; We are at the start of a section, so save this address in the creditsSectionPointers array
|
|
|
|
@saveSectionPointer
|
|
|
|
pha
|
|
|
|
tya
|
|
|
|
clc
|
|
|
|
adc $FE
|
|
|
|
sta creditsSectionPointers-2,x
|
|
|
|
lda $FF
|
|
|
|
bcc +
|
|
|
|
inc
|
|
|
|
+ sta creditsSectionPointers-1,x
|
2018-06-20 22:58:05 +00:00
|
|
|
pla
|
2018-07-06 22:29:15 +00:00
|
|
|
dex
|
|
|
|
dex
|
|
|
|
bpl @convertSectionNoInc
|
|
|
|
@exit
|
|
|
|
rts
|
2018-06-20 22:58:05 +00:00
|
|
|
|
2018-07-06 22:29:15 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; PaintCredits
|
|
|
|
; paint one section of credits on the screen
|
|
|
|
;
|
|
|
|
; in: WeeGUI initialized
|
|
|
|
; out: exits to caller
|
|
|
|
; all registers and flags clobbered
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
PaintCredits
|
|
|
|
lda currentSection
|
|
|
|
asl
|
|
|
|
tax
|
|
|
|
lda creditsSectionPointers,x
|
|
|
|
sta $FE
|
|
|
|
lda creditsSectionPointers+1,x
|
|
|
|
sta $FF ; ($FE) points to start of data buffer
|
|
|
|
ldy #0 ; index into ($FE) pointing to current character
|
|
|
|
stz @VTAB ; line number within WeeGUI view
|
|
|
|
@printLine
|
|
|
|
lda #1
|
|
|
|
sta PARAM0
|
|
|
|
inc @VTAB
|
|
|
|
@VTAB=*+1
|
|
|
|
lda #$FD
|
|
|
|
sta PARAM1
|
|
|
|
ldx #WGSetCursor
|
|
|
|
jsr WeeGUI ; set cursor to start of this line
|
|
|
|
tya
|
|
|
|
clc
|
|
|
|
adc $FE
|
|
|
|
sta PARAM0
|
|
|
|
lda $FF
|
|
|
|
bcc +
|
|
|
|
inc
|
|
|
|
+ sta PARAM1 ; calculate exact start of text for this line
|
|
|
|
lda (PARAM0) ; skip blank lines
|
|
|
|
beq @skipNull
|
|
|
|
ldx #WGPrint ; otherwise print it
|
2018-06-20 22:58:05 +00:00
|
|
|
jsr WeeGUI
|
2018-07-06 22:29:15 +00:00
|
|
|
@skipToNextLine
|
|
|
|
jsr IncAndGetChar
|
|
|
|
bne @notNull
|
|
|
|
@skipNull
|
|
|
|
jsr IncAndGetChar
|
|
|
|
bra @printLine
|
|
|
|
@notNull
|
|
|
|
cmp #$7E ; '~' ends section
|
|
|
|
beq @exit
|
|
|
|
cmp #$5B ; '[' ends section
|
|
|
|
bne @skipToNextLine
|
|
|
|
@exit
|
|
|
|
rts
|
2018-06-20 22:58:05 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
2018-07-06 22:29:15 +00:00
|
|
|
; internal data
|
|
|
|
|
|
|
|
kCreditsFilename
|
|
|
|
!byte 11
|
|
|
|
!raw "CREDITS.TXT"
|
|
|
|
|
|
|
|
currentSection ; used by PaintCredits
|
|
|
|
!byte $FD
|
|
|
|
|
|
|
|
creditsSectionPointers ; [array of word] address of start of each page of credits
|
|
|
|
!word $FDFD
|
|
|
|
!word $FDFD
|
|
|
|
!word $FDFD
|
|
|
|
!word $FDFD
|
|
|
|
!word $FDFD
|
|
|
|
!word $FDFD
|
|
|
|
|
|
|
|
kCreditsTop ; [array of byte] top row to draw border for each section of credits
|
|
|
|
!byte 7 ; note: stored here in reverse order compared to the credits file
|
|
|
|
!byte 2
|
|
|
|
!byte 6
|
|
|
|
!byte 8
|
|
|
|
!byte 8
|
|
|
|
!byte 8
|
|
|
|
|
|
|
|
kCreditsHeight ; [array of byte] height of bounding box for each section of credits
|
|
|
|
!byte 10 ; note: stored here in reverse order compared to the credits file
|
|
|
|
!byte 20
|
|
|
|
!byte 12
|
|
|
|
!byte 8
|
|
|
|
!byte 9
|
|
|
|
!byte 8
|
|
|
|
|
|
|
|
kViewCredits
|
|
|
|
!byte ID_CREDITS ; view ID
|
|
|
|
!byte 1 ; style
|
|
|
|
!byte 19 ; left
|
|
|
|
kViewCreditsTop
|
|
|
|
!byte $FD ; top (SMC)
|
|
|
|
!byte 42 ; visible width
|
|
|
|
kViewCreditsVisibleHeight
|
|
|
|
!byte $FD ; visible height (SMC)
|
|
|
|
!byte 42 ; width
|
|
|
|
kViewCreditsHeight
|
|
|
|
!byte $FD ; height (SMC)
|