diff --git a/src/ds.puzzle.a b/src/ds.puzzle.a index 6c1dc69..0558062 100644 --- a/src/ds.puzzle.a +++ b/src/ds.puzzle.a @@ -126,6 +126,15 @@ CheckForTargetWord sec rts +FindLetterInColumn +; in: A = letter (0x41..0x5A) +; Y = logical column to search +; out: C clear if letter was found in given column +; C set if letter was not found +; TODO maybe calculate how far to scroll and return that? + sec + rts + ScrollPuzzleDown ; in: Y = logical column to scroll ; out: C clear if puzzle was scrolled down diff --git a/src/million.a b/src/million.a index 1b2ead8..ec1b836 100644 --- a/src/million.a +++ b/src/million.a @@ -16,7 +16,10 @@ row = $FD FirstMover !pseudopc $4000 { Start + +DEBUGWAIT jsr TitlePage + lda #$0A + sta GlobalLeftMargin lda #7 jsr InitPuzzle @@ -49,15 +52,24 @@ PlayEventLoop - lda $c000 bpl - bit $c010 - cmp #$8B ; up arrow + and #$7F + cmp #$0B ; up arrow beq EventUpArrow - cmp #$8A ; down arrow + cmp #$0A ; down arrow beq EventDownArrow - cmp #$88 ; left arrow + cmp #$08 ; left arrow beq EventLeftArrow - cmp #$95 ; right arrow + cmp #$15 ; right arrow beq EventRightArrow - jmp PlayEventLoop + cmp #$61 + bcc + + and #$DF ++ cmp #$41 + bcc + + cmp #$5B + bcs + + jsr EventLetter ++ jmp PlayEventLoop EventUpArrow ldy selected_logical_column @@ -112,6 +124,13 @@ EventRightArrow jsr DrawColumnSelectionIndicator jmp PlayEventLoop +EventLetter + ldy selected_logical_column + jsr FindLetterInColumn + bcs @exit + ; TODO +@exit rts + puzzleline1 !raw "PRTFELE" puzzleline2 diff --git a/src/ui.font.a b/src/ui.font.a index 9a48619..ca4f691 100644 --- a/src/ui.font.a +++ b/src/ui.font.a @@ -23,7 +23,7 @@ } DrawCharacter -; A contains character (0x41..0x5A) +; A contains character (0x41..0x5A) or 0x00 ; X contains logical line number (0x00..0x08) ; Y contains logical column number (0x00..0x0C) ; HGR row is (0x16 * X) @@ -34,9 +34,10 @@ DrawCharacter ; clobbers A/all flags ; clobbers $ED..$F7 sta original_char + beq + and #$7F sec - sbc #$41 + sbc #$40 bpl + rts + sta char diff --git a/src/ui.font.data.a b/src/ui.font.data.a index 13bae60..4fd5972 100644 --- a/src/ui.font.data.a +++ b/src/ui.font.data.a @@ -1,5 +1,6 @@ ; This file is automatically generated LeftFontRow0 + !byte $80 ; space !byte $80 ; A !byte $80 ; B !byte $80 ; C @@ -27,6 +28,7 @@ LeftFontRow0 !byte $80 ; Y !byte $80 ; Z LeftFontRow1 + !byte $80 ; space !byte $FC ; A !byte $FE ; B !byte $E0 ; C @@ -54,6 +56,7 @@ LeftFontRow1 !byte $BF ; Y !byte $FC ; Z LeftFontRow2 + !byte $80 ; space !byte $FC ; A !byte $FE ; B !byte $F8 ; C @@ -81,6 +84,7 @@ LeftFontRow2 !byte $BF ; Y !byte $FC ; Z LeftFontRow3 + !byte $80 ; space !byte $FC ; A !byte $FE ; B !byte $FC ; C @@ -108,6 +112,7 @@ LeftFontRow3 !byte $BF ; Y !byte $FC ; Z LeftFontRow4 + !byte $80 ; space !byte $F0 ; A !byte $B8 ; B !byte $BC ; C @@ -135,6 +140,7 @@ LeftFontRow4 !byte $9C ; Y !byte $9C ; Z LeftFontRow5 + !byte $80 ; space !byte $F0 ; A !byte $B8 ; B !byte $9E ; C @@ -162,6 +168,7 @@ LeftFontRow5 !byte $B8 ; Y !byte $9C ; Z LeftFontRow6 + !byte $80 ; space !byte $B0 ; A !byte $F8 ; B !byte $8E ; C @@ -189,6 +196,7 @@ LeftFontRow6 !byte $F0 ; Y !byte $9C ; Z LeftFontRow7 + !byte $80 ; space !byte $B8 ; A !byte $F8 ; B !byte $8E ; C @@ -216,6 +224,7 @@ LeftFontRow7 !byte $F0 ; Y !byte $C0 ; Z LeftFontRow8 + !byte $80 ; space !byte $F8 ; A !byte $F8 ; B !byte $8E ; C @@ -243,6 +252,7 @@ LeftFontRow8 !byte $E0 ; Y !byte $E0 ; Z LeftFontRow9 + !byte $80 ; space !byte $F8 ; A !byte $B8 ; B !byte $8E ; C @@ -270,6 +280,7 @@ LeftFontRow9 !byte $C0 ; Y !byte $E0 ; Z LeftFontRow10 + !byte $80 ; space !byte $FC ; A !byte $B8 ; B !byte $9E ; C @@ -297,6 +308,7 @@ LeftFontRow10 !byte $C0 ; Y !byte $B0 ; Z LeftFontRow11 + !byte $80 ; space !byte $9C ; A !byte $B8 ; B !byte $BC ; C @@ -324,6 +336,7 @@ LeftFontRow11 !byte $C0 ; Y !byte $98 ; Z LeftFontRow12 + !byte $80 ; space !byte $BF ; A !byte $FE ; B !byte $FC ; C @@ -351,6 +364,7 @@ LeftFontRow12 !byte $F8 ; Y !byte $FC ; Z LeftFontRow13 + !byte $80 ; space !byte $BF ; A !byte $FE ; B !byte $F8 ; C @@ -378,6 +392,7 @@ LeftFontRow13 !byte $F8 ; Y !byte $FC ; Z LeftFontRow14 + !byte $80 ; space !byte $BF ; A !byte $FE ; B !byte $E0 ; C @@ -405,6 +420,7 @@ LeftFontRow14 !byte $F8 ; Y !byte $FC ; Z LeftFontRow15 + !byte $80 ; space !byte $80 ; A !byte $80 ; B !byte $80 ; C @@ -432,6 +448,7 @@ LeftFontRow15 !byte $80 ; Y !byte $80 ; Z RightFontRow0 + !byte $80 ; space !byte $80 ; A !byte $80 ; B !byte $80 ; C @@ -459,6 +476,7 @@ RightFontRow0 !byte $80 ; Y !byte $80 ; Z RightFontRow1 + !byte $80 ; space !byte $83 ; A !byte $87 ; B !byte $BB ; C @@ -486,6 +504,7 @@ RightFontRow1 !byte $FE ; Y !byte $9F ; Z RightFontRow2 + !byte $80 ; space !byte $87 ; A !byte $8F ; B !byte $BF ; C @@ -513,6 +532,7 @@ RightFontRow2 !byte $FE ; Y !byte $9F ; Z RightFontRow3 + !byte $80 ; space !byte $87 ; A !byte $9F ; B !byte $BF ; C @@ -540,6 +560,7 @@ RightFontRow3 !byte $FE ; Y !byte $8F ; Z RightFontRow4 + !byte $80 ; space !byte $87 ; A !byte $9C ; B !byte $BC ; C @@ -567,6 +588,7 @@ RightFontRow4 !byte $9C ; Y !byte $8E ; Z RightFontRow5 + !byte $80 ; space !byte $8E ; A !byte $9C ; B !byte $B8 ; C @@ -594,6 +616,7 @@ RightFontRow5 !byte $9E ; Y !byte $86 ; Z RightFontRow6 + !byte $80 ; space !byte $8E ; A !byte $8F ; B !byte $B8 ; C @@ -621,6 +644,7 @@ RightFontRow6 !byte $8F ; Y !byte $83 ; Z RightFontRow7 + !byte $80 ; space !byte $8E ; A !byte $8F ; B !byte $80 ; C @@ -648,6 +672,7 @@ RightFontRow7 !byte $87 ; Y !byte $81 ; Z RightFontRow8 + !byte $80 ; space !byte $9F ; A !byte $9F ; B !byte $80 ; C @@ -675,6 +700,7 @@ RightFontRow8 !byte $87 ; Y !byte $80 ; Z RightFontRow9 + !byte $80 ; space !byte $9F ; A !byte $B8 ; B !byte $80 ; C @@ -702,6 +728,7 @@ RightFontRow9 !byte $83 ; Y !byte $9C ; Z RightFontRow10 + !byte $80 ; space !byte $9F ; A !byte $B8 ; B !byte $80 ; C @@ -729,6 +756,7 @@ RightFontRow10 !byte $83 ; Y !byte $9C ; Z RightFontRow11 + !byte $80 ; space !byte $B8 ; A !byte $B8 ; B !byte $B8 ; C @@ -756,6 +784,7 @@ RightFontRow11 !byte $83 ; Y !byte $9C ; Z RightFontRow12 + !byte $80 ; space !byte $FE ; A !byte $BF ; B !byte $BF ; C @@ -783,6 +812,7 @@ RightFontRow12 !byte $9F ; Y !byte $9F ; Z RightFontRow13 + !byte $80 ; space !byte $FE ; A !byte $9F ; B !byte $BF ; C @@ -810,6 +840,7 @@ RightFontRow13 !byte $9F ; Y !byte $9F ; Z RightFontRow14 + !byte $80 ; space !byte $FE ; A !byte $8F ; B !byte $8F ; C @@ -837,6 +868,7 @@ RightFontRow14 !byte $9F ; Y !byte $9F ; Z RightFontRow15 + !byte $80 ; space !byte $80 ; A !byte $80 ; B !byte $80 ; C diff --git a/src/ui.title.a b/src/ui.title.a index 099eac8..3438916 100644 --- a/src/ui.title.a +++ b/src/ui.title.a @@ -1,4 +1,153 @@ +;license:MIT +;(c) 2019 by qkumba +;(c) 2020 by 4am +; + +titlechar = $FD +titleline1 + !raw "MILLION" +titleline2 + !raw "PERFECT" +titleline3 + !raw "LETTERS" + TitlePage + jsr Home + bit GFXMODE + lda #$00 + sta GlobalLeftMargin + lda #$41 + +@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 + ;lda @rnd2+1 + ;eor #$00 + ;sta @rnd2+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 titleline1-3, y + bne + +@line2 lda titleline2-3, y + bne + +@line3 lda titleline3-3, y ++ jsr DrawCharacter + 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 #3 +- lda #$00 + jsr WaitForKeyWithTimeout + bmi @prematureexit + dex + bne - + + lda titlechar + beq @phase2 + lda #$C1 + bit titlechar + +LBPL @outerloop + lda #$00 + jmp @outerloop + +@prematureexit + jsr Home + bit GFXMODE +@exit + +DEBUGWAIT + rts +@phase2 + ldy #$03 +-- ldx #$03 +- jsr ScrollUp + dex + bne - + iny + cpy #$0A + bne -- + beq @exit ; always branches + +WaitForKeyWithTimeout +; in: A = timeout length (like standard $FCA8 wait routine) +; out: A clobbered +; X/Y preserved + sec +@wait1 pha +@wait2 sbc #1 + bne @wait2 + pla + bit $C000 + bmi @exit + sbc #1 + bne @wait1 +@exit rts + + +OldTitlePage jsr Home ;TODO add logical-width parameter jsr DrawThinLines