candy6502

Candy Crush 6502 style

Piece storage:

                red org yel grn blu prp   FREE
                000 001 010 011 100 101  110 111 <- offset
regular pieces:  0   1   2   3   4   5    6   7    00000 000 | offset
  horiz stripe:  8   9   A   B   C   D    E   F    00001 000 | offset
   vert stripe: 10  11  12  13  14  15   16  17    00010 000 | offset
  packet piece: 18  19  1A  1B  1C  1D   1E  1F    00011 000 | offset

This allows easy matching based on the comparison of bits at the end of the byte. Currently 1F is the cursor (a white square), and the others may be used for the one additional super candy piece and possible special effects graphics (static or buffered), for visually exploding candies, etc.

Board layout:

  08 18 28 38 48 58 68 78 88
  07 17 27 37 47 57 67 77 87
  06 16 26 36 46 56 66 76 86
  05 15 25 35 45 55 65 75 85
  04 14 24 34 44 54 64 74 84
  03 13 23 33 43 53 63 73 83
  02 12 22 32 42 52 62 72 82
^ 01 11 21 31 41 51 61 71 81
y 00 10 20 30 40 50 60 70 80
  x>

In memory:

Note that this is rotated 90 degrees anticlockwise from above image! (It doesn't really matter, except in coding physical board layouts)

board offsets aligned at 0x100 boundaries

                 0 1 2 3 4 5 6 7 8 9 A B C D E F
x=0 y=0-8   $00  . . . . . . . . .  <free space>
x=1 y=0-8   $10  . . . . . . . . .  <free space>
x=2 y=0-8   $20  . . . . . . . . .  <free space>
x=3 y=0-8   $30  . . . . . . . . .  <free space>
x=4 y=0-8   $40  . . . . . . . . .  <free space>
x=5 y=0-8   $50  . . . . . . . . .  <free space>
x=6 y=0-8   $60  . . . . . . . . .  <free space>
x=7 y=0-8   $70  . . . . . . . . .  <free space>
x=8 y=0-8   $80  . . . . . . . . .  <free space>
            $90
            $A0
            $B0  <free space>
            $C0
            $D0
            $E0
            $F0

This makes it easy to setup several different memory spaces like this (currently at $7000, $7010, $7020, up to 16).

    (pgm mem)     $7000      $7100      $7200      $7300      $7400
    _________   _________   ________   ________   ________   ________
   |         | |         | |        | |        | |        | |        |
   | board_d | | current | |        | |        | |        | |        |
   |_________| |_________| |________| |________| |________| |________|

board_d:

current:

Todo

How to design a match based on this? Calculate matches, mark matches, (enable user feedback through UI by swapping pieces and/or error out if no matches by this point), perform removal, give required reward pieces, shift board, then repeat this process until out of matches.