;license:MIT ;(c) 2019 by qkumba ;(c) 2020 by 4am ; ; animated title screen ; ; Public functions: ; - TitlePage ; initialtitlechar = $FC titlechar = $FD ;------------------------------------------------------------------------------ ; TitlePage ; display animated title page until keypress or completion ; ; in: none ; out: C = 0 if animation completed ; C = 1 if key was pressed to exit animation prematurely ;------------------------------------------------------------------------------ TitlePage jsr Home lda #$01 sta GlobalLeftMargin jsr GetTime ; clock users can have a little randomness, as a treat lda $BF90 eor $BF91 eor $BF92 eor $BF93 and #31 lsr clc adc #$41 sta RevealStartingChar sta initialtitlechar @outerloop sta titlechar ; init RNG ldy #1 sty @rnd1+1 dey sty @rnd2+1 ; iterate @loop ldy @rnd1+1 ldx @rnd2+1 lsr @rnd2+1 ror @rnd1+1 bcc + ; feedback polynomial form #$0041 for period of 127 lda @rnd1+1 eor #$41 sta @rnd1+1 + cpy #$76 bcs @loop ldx #0 dey tya - cmp #$0D bcc + inx sec sbc #$0D bne - + tay cpy #$03 bcc @random cpy #$0A bcs @random cpx #$03 beq @line1 cpx #$04 beq @line2 cpx #$05 beq @line3 @random lda titlechar jmp + ; can't use a BNE because will actually be 0 the third time around @line1 lda sTitleLine1-2, y bne + @line2 lda sTitleLine2-2, y bne + @line3 lda sTitleLine3-2, y + jsr DrawLargeCharacter lda titlechar beq + inc titlechar lda titlechar and #$7F cmp #$5B bcc + lda titlechar sbc #$19 sta titlechar + ; wait while checking for keypress lda #$38 jsr WaitForKeyWithTimeout bmi @prematureexit ; exit condition @rnd2 lda #0 ; SMC ; bne @loop @rnd1 lda #0 ; SMC cmp #1 bne @loop ldx #4 jsr LongWaitForKeyWithTimeout bmi @prematureexit lda titlechar beq @phase2 lda initialtitlechar ora #$80 bit titlechar +LBPL @outerloop lda #$00 jmp @outerloop @prematureexit sec +HIDE_NEXT_BYTE @exit clc rts @phase2 ldy #$03 -- ldx #$02 - jsr ScrollUp dex bne - iny cpy #$0A bne -- beq @exit ; always branches