Skip to content

Instantly share code, notes, and snippets.

@iznax
Last active Mar 10, 2019
Embed
What would you like to do?
Match 3 game for 6502 emulator
;
; MATCH 3 Game
;
; (c) 2018 - Paul C. Isaac
;
; Match three or more tiles of the same color
; horizontally to collapse blocks and score points.
; This 6502 assembly code runs in Easy6502 simulator
; Game renders to a 32 x 32 pixel 16 color screen
; Controls:
; WASD = move up,left,down,right
; Shift+WASD = swap direction
Start:
JSR Randomize
JSR PrintScore
loop:
JSR Refresh
JSR DrawCursor
JSR HandleInput
JSR TryDrop
JSR Match
LDA NewScore
BEQ loop
DEC NewScore
JSR AddToScore
JSR PrintScore
JMP loop
Delay:
RTS ; Easy6502 is slower than 6502asm and doesn't need delays
LDA #0
del:
PHA
JSR DrawGame
PLA
CLC
ADC #1
CMP #16
BNE del
RTS
;-------------------------------------
Buffer: ;7x4 grid
Buff1: dcb 4,3,2,1,2,3,4
Buff2: dcb 1,2,3,4,3,2,1
Buff3: dcb 4,3,2,1,2,3,4
Buff4: dcb 1,2,3,4,3,2,1
Dirty: ;7 bits per line
Dirty1: dcb 0
Dirty2: dcb 0
Dirty3: dcb 0
Dirty4: dcb 0
Bits: dcb 1,2,4,8,16,32,64,128
SetDirty:
LDA #1
STA Changed
SetDirtyNoChange:
; X = 0..6 tile col
; Y = 0..3 tile row
; Preserve X,Y
LDA Dirty,Y
ORA Bits,X
STA Dirty,Y
RTS
ResetDirty:
LDA #0
BEQ setz
AllDirty:
LDA #$7F ; All 7-bits = columns 0..6
setz:
STA Dirty1
STA Dirty2
STA Dirty3
STA Dirty4
RTS
;-------------------------------------
Refresh:
; Modify A,X,Y
; refresh_X
; refresh_Y
; dirty_bits
LDY #3 ; rows-1
STY refresh_Y
rechk:
LDY refresh_Y
LDA Dirty,Y
BNE cleanup
resume:
DEC refresh_Y
BPL rechk
JMP ResetDirty
cleanup:
; A = bits
; Y = row
; Modifiy
; refresh_X
; dirty_bits
STA dirty_bits
LDX Times7,Y ; tile index
LDA #7 ; columns
STA refresh_X
across:
LSR dirty_bits
BCC nobit
;X = tile index
JSR DrawTileByIndex
nobit:
INX ; next tile index
DEC refresh_X
BNE across
JMP resume
;--------------------------------------
Randomize:
LDX #27 ;7*4-1
LDA Random
rloop:
AND #63
TAY
LDA Scramble,Y
STA Buffer,X
INY
TYA
DEX
BPL rloop
LDA #1
STA Changed
JMP AllDirty
Scramble:
; random sequence of tiles with no triples
dcb 1,3,4,3,2,2,4,3
dcb 1,2,3,2,4,4,2,1
dcb 2,4,3,1,2,1,4,1
dcb 1,4,2,3,1,3,3,4
dcb 4,1,3,2,1,2,3,4
dcb 1,3,4,3,4,2,3,2
dcb 2,4,1,3,2,1,3,4
dcb 2,3,4,1,4,1,2,1
;--------------------------------------
DrawGame:
LDX #27 ; ScreenTiles (7*4) - 1
xdraw:
JSR DrawTileByIndex
DEX
BPL xdraw
RTS
;--------------------------------------
DrawCursor:
LDX SelectX
LDY SelectY
JSR GetScreenPosition
LDA #<mask01
STA source_lo
LDA #>mask01
STA source_hi
JMP Mask4x6
;--------------------------------------
HandleInput:
LDX SelectX
LDY SelectY
JSR SetDirtyNoChange
LDA Keypress
BEQ nokey
CMP #$61 ; a
BEQ moveLeft
CMP #$64 ; d
BEQ moveRight
CMP #$77 ; w
BEQ moveUp
CMP #$73 ; s
BEQ moveDown
CMP #$41 ; A
BEQ shiftLeft
CMP #$44 ; D
BEQ shiftRight
CMP #$57 ; W
BEQ shiftUp
CMP #$53 ; S
BEQ shiftDown
nokey:
RTS
moveLeft:
DEX
BPL doMove
INX
doMove:
STX SelectX
STY SelectY
JSR ClearKey
JMP Refresh
moveRight:
INX
CPX #7
BNE doMove
DEX
JMP doMove
moveUp:
DEY
BPL doMove
INY
JMP doMove
moveDown:
INY
CPY #4
BNE doMove
DEY
JMP doMove
shiftLeft:
CPX #0
BEQ noShift
JSR ToIndex
STA shift0
DEX
STA shift1
DEC shift1
JMP doShift
shiftRight:
CPX #6
BEQ noShift
JSR ToIndex
STA shift0
INX
STA shift1
INC shift1
JMP doShift
shiftUp:
CPY #0
BEQ noShift
JSR ToIndex
STA shift0
DEY
SEC
SBC #7
STA shift1
JMP doShift
shiftDown:
CPY #3
BEQ noShift
JSR ToIndex
STA shift0
INY
CLC
ADC #7
STA shift1
JMP doShift
noShift:
;JMP ClearKey
ClearKey:
LDA #0
STA Keypress
RTS
doShift:
STX SelectX
STY SelectY
JSR SetDirty
LDX shift0
LDY shift1
LDA Buffer,X
PHA
LDA Buffer,Y
STA Buffer,X
PLA
STA Buffer,Y
JSR ClearKey
JMP Refresh
shift0: dcb 0 ; source index
shift1: dcb 0 ; target index
ToIndex:
; Preserve X,Y
; Modify zindex
; Return (A) = X+Y*7
TXA
STY zindex ;X
CLC
ADC zindex ;X+Y*1
ADC zindex ;X+Y*2
ADC zindex ;X+Y*3
ADC zindex ;X+Y*4
ADC zindex ;X+Y*5
ADC zindex ;X+Y*6
ADC zindex ;X+Y*7
RTS
;--------------------------------------
Draw4X:
; X = tile height in pixels
; ($2) source lo/hi
; ($4) screen lo/hi
JSR DrawPixels
JSR NextLine
DEX
BNE Draw4X
RTS
Mask4x6:
LDA #6
Mask4xA:
TAY
maskloop:
TYA
PHA
JSR MaskPixels
JSR NextLine
PLA
TAY
DEY
BNE maskloop
RTS
;--------------------------------------
NextLine:
LDA source_lo
CLC
ADC #4 ; Pixel Width
STA source_lo
;TODO: ensure tiles don't cross $FF boundaries?
LDA source_hi
ADC #0
STA source_hi
LDA screen_lo
CLC
ADC #32 ; Screen Width
STA screen_lo
LDA screen_hi
ADC #0
STA screen_hi
RTS
;--------------------------------------
GetScreenPosition:
; Input
; X = screen column
; Y = screen row
; Output
; pos_x,pos_y
; screen_lo,screen_hi
LDA SlotX,X
TAX
LDA SlotY,Y
TAY
JMP ScreenXY
;=> screen_lo/hi
SlotX: dcb 2, 6,10,14,18,22,26,0,0,0
SlotY: dcb 6,12,18,24, 0, 0, 0,0,0,0
;--------------------------------------
DrawTileByIndex:
;Input
; X = slot index 0..27 (7x4)
;Preserve X
;Modify $2,$3,$4,$5
LDA SlotScreenLo,X
STA screen_lo
LDA SlotScreenHi,X
STA screen_hi
LDA Buffer,X
;JSR GetTile
STA source_lo ; Tile*1
ASL ; Tile*2
ADC source_lo ; Tile*3
ASL ; Tile*6
ASL ; Tile*12
ASL ; Tile*24
STA source_lo
LDA #>TilePage
STA source_hi
;=> source_lo/hi
;LDX #6
;JMP Draw4X
LDY #0
;JSR DrawPixels
;JSR NextLine
JSR DrawPixelsNextLine
JSR DrawPixelsNextLine
JSR DrawPixelsNextLine
JSR DrawPixelsNextLine
JSR DrawPixelsNextLine
JMP DrawPixelsNextLine
; Y=0 $0200
; Y=1 $0220
; Y=2 $0240
; Y=3 $0260
; Y=4 $0280
; Y=5 $02A0
; Y=6 $02C0 *
; Y=7 $02E0
; Y=8 $0300
; Y=9 $0320
; Y=10 $0340
; Y=11 $0360
; Y=12 $0380 *
; Y=13 $03A0
; Y=14 $03C0
; Y=15 $03E0
; Y=16 $0400
; Y=17 $0420
; Y=18 $0440 *
; Y=19 $0460
; Y=20 $0480
; Y=21 $04A0
; Y=22 $04C0
; Y=23 $04E0
; Y=24 $0500 *
; Y=25 $0520
; Y=26 $0540
; Y=27 $0560
; Y=28 $0580
; Y=29 $05A0
; Y=30 $05C0 xx
; Y=31 $05E0 xx
SlotScreenLo:
dcb $C2,$C6,$CA,$CE,$D2,$D6,$DA
dcb $82,$86,$8A,$8E,$92,$96,$9A
dcb $42,$46,$4A,$4E,$52,$56,$5A
dcb $02,$06,$0A,$0E,$12,$16,$1A
SlotScreenHi:
dcb $02,$02,$02,$02,$02,$02,$02
dcb $03,$03,$03,$03,$03,$03,$03
dcb $04,$04,$04,$04,$04,$04,$04
dcb $05,$05,$05,$05,$05,$05,$05
;--------------------------------------
ScreenXY:
; Input
; X = screen x
; Y = screen y
; Output
; screen_lo,screen_hi
STX screen_lo
JSR MulY32
LDA mul_lo
CLC
;#<Screen=0
ADC screen_lo
STA screen_lo
LDA mul_hi
ADC #>Screen
STA screen_hi
RTS
GetTile:
; Input
; A = tile index [0..10]
; Preserve: X,Y
; Result
; ($2) = source_lo,source_hi
JSR MulA24 ; tile size = (4x6) = 24 pixels
LDA mul_lo
CLC
ADC #<tile00
STA source_lo
LDA mul_hi
ADC #>tile00
STA source_hi
RTS
; Optimized modify [Y]
; TAY
; LDA tile_lo,Y
; STA source_lo
; LDA tile_hi,Y
; STA source_hi
; RTS
;--------------------------------------
PrintScore:
LDX #9
STX $1E
LDA ScoreHi
LSR
LSR
LSR
LSR
LDY #1
JSR print_digit
LDA $1E
CLC
ADC #4
STA $1E
TAX
LDA ScoreHi
AND #15
LDY #1
JSR print_digit
LDA $1E
CLC
ADC #4
STA $1E
TAX
LDA ScoreLo
LSR
LSR
LSR
LSR
LDY #1
JSR print_digit
LDA $1E
CLC
ADC #4
STA $1E
TAX
LDA ScoreLo
AND #15
LDY #1
JMP print_digit
;--------------------------------------
print_hex:
;A = $00..$FF value to display
PHA
AND #15
LDX #6 ; column #2
LDY #0
JSR print_digit
PLA
LSR
LSR
LSR
LSR
LDX #2 ; column #1
LDY #0
JMP print_digit
; Inputs: X,Y
; A = 0..F hex digit to display
; X = 0..31 screen column
; Y = screen row
print_digit:
PHA
JSR ScreenXY
;=> screen_lo/hi
PLA
JSR GetFont
;=> source_lo/hi
LDX #5
JMP Draw4X
;--------------------------------------
Times7:
dcb 0,7,14,21,28,35,42,49
Times5:
dcb 0, 5,10,15,20,25,30,35
dcb 40,45,50,55,60,65,70,75
dcb 80,85,90,95
MulX20:
; Inputs: X
; Return: A = X*20
; ($) = mul_lo/hi
LDA #0
STA mul_hi
LDA Times5,X
ASL
ROL mul_hi
ASL
ROL mul_hi
STA mul_lo
RTS
GetFont:
; A = font index
; Modify: A,X,mul_lo/hi
; Result: source_lo/hi
AND #15 ;Clamp 0..15
TAX
JSR MulX20 ;4x5 bitmap
LDA mul_lo
CLC
ADC #<FontPage
STA source_lo
LDA mul_hi
ADC #>FontPage
STA source_hi
RTS
; Draw 4 pixels in a row
; ($2) src texels
; ($4) dst screen
; Modifies A,Y registers
DrawPixels:
LDY #0
LDA ($2),Y
STA ($4),Y
INY
LDA ($2),Y
STA ($4),Y
INY
LDA ($2),Y
STA ($4),Y
INY
LDA ($2),Y
STA ($4),Y
RTS
DrawPixelsNextLine:
;LDY #0
LDA ($2),Y
STA ($4),Y
INY
LDA ($2),Y
STA ($4),Y
INY
LDA ($2),Y
STA ($4),Y
INY
LDA ($2),Y
STA ($4),Y
INY
LDA $4
CLC
ADC #28 ;32-4
STA $4
LDA $5
ADC #0
STA $5
RTS
MaskPixels:
LDY #0
LDA ($2),Y
BMI mask1
STA ($4),Y
mask1:
INY
LDA ($2),Y
BMI mask2
STA ($4),Y
mask2:
INY
LDA ($2),Y
BMI mask3
STA ($4),Y
mask3:
INY
LDA ($2),Y ;source lo/hi
BMI mask4
STA ($4),Y ;screen lo/hi
mask4:
RTS
;--------------------------------------
MulY32:
;Inputs: Y = 0..31
;Preserve: X,Y
;Return: ($) = Y*32
;Modify: mul_lo, mul_hi
; A = mul_lo
TYA
ASL
ASL
ASL
ASL
STA mul_lo
LDA #0
ROL
ASL mul_lo
ROL
STA mul_hi
RTS
MulA24:
;Inputs: A = 0..10 (tile index)
;Preserve: X,Y
;Modify: mul_lo, mul_hi
;Return: ($) = A*24
; A = mul_lo
STA mul_lo ; Y*1
LDA #0 ; if Y<=10 then HI always zero
STA mul_hi
LDA mul_lo ; Y*1
ASL ; Y*2
ADC mul_lo ; Y*3
ASL ; Y*6
ASL ; Y*12
ASL ; Y*24
STA mul_lo
RTS
MulXY: ;SLOW!
; Inputs: X,Y
; Return: ($) = X*Y
; (mul_lo, mul_hi)
LDA #0
STA mul_lo
STA mul_hi
CPX #0
BEQ xend
xmul:
TYA
CLC
ADC mul_lo
STA mul_lo
LDA #0
ADC mul_hi
STA mul_hi
DEX
BNE xmul
xend:
RTS
;--------------------------------------
pops:
pop1: dcb 0
pop2: dcb 0
pop3: dcb 0
pop4: dcb 0
Match:
LDA SkipMatch
BNE skipped
;A=0
LDX Changed
BEQ skipped
STA Changed ; A=0
STA Popped ; A=0
LDA #<Buffer
STA match_lo
LDA #>Buffer
STA match_hi
LDX #0 ; column
mRow:
LDY #0
STY matches
mCol:
ASL matches
LDA (match_lo),Y
INY
CMP #0
BEQ mzero
CMP (match_lo),Y
BNE mzero
INC matches
mzero:
CPY #6
BNE mCol
LDY matches
LDA Triples,Y
STA pops,X
LDA match_lo
CLC
ADC #7
STA match_lo
LDA match_hi
ADC #0
STA match_hi
INX
CPX #4
BNE mRow
DoPops:
LDY #3
dotop:
LDA pops,Y
BEQ nextPop
popy:
LDX #6
nox:
LSR
BCC noy
PHA
JSR PopXY
PLA
noy:
DEX
BPL nox
nextPop:
DEY
BPL dotop
skipped:
RTS
PopXY:
; X = tile col
; Y = tile row
TXA
PHA
JSR ToIndex
TAX
LDA #0
STA Buffer,X
INC NewScore
INC Popped
PLA
TAX
JMP SetDirty ; NoChange?
;--------------------------------------
AddToScore:
;Inputs None
;Preserve X,Y
SED
LDA #5
CLC
ADC ScoreLo
STA ScoreLo
LDA #0
ADC ScoreHi
STA ScoreHi
CLD
RTS
;--------------------------------------
; Blocks above an empty black space fall/drop and refill at the top.
SkipMatch: dcb 0
dropping: dcb 0
dropY: dcb 0,0,0,0,0,0,0,0
; Indexed by non-zero blocks in a column
; Bit (8) Row(0)
; Bit (4) Row(1)
; Bit (2) Row(2)
; Bit (1) Row(3)
DropTable:
dcb 0 ; 0000
dcb 0 ; 0001
dcb 3 ; 0010
dcb 0 ; 0011
dcb 2 ; 0100
dcb 2 ; 0101
dcb 3 ; 0110
dcb 0 ; 0111
dcb 1 ; 1000
dcb 1 ; 1001
dcb 3 ; 1010
dcb 1 ; 1011
dcb 2 ; 1100
dcb 2 ; 1101
dcb 3 ; 1110
dcb 128 ; 1111
TryDrop:
LDA Popped ;Are there any empty tiles?
BEQ dropEnd
LDX #0 ; column
STX dropping
STX SkipMatch
STX Popped
tryX:
LDA #0
STA $A ; bits 0000
LDA Buff1,X
CLC
SBC #0 ; C=0(zero) C=1 non-zero
ROL $A ;Carry flag into zero page
LDA Buff2,X
SBC #0 ; -1 when C=0
ROL $A
LDA Buff3,X
SBC #0 ; -1 when C=0
ROL $A
LDA Buff4,X
SBC #0 ; -1 when C=0
ROL $A
LDY $A ; index = bit for each row
LDA DropTable,Y
STA dropY,X
BMI nodrop
INC dropping
nodrop:
INX
CPX #7
BNE tryX
LDA dropping
BNE Fall
dropEnd:
RTS
Fall:
LDX #6
chkFall:
STX $A ;column
LDA dropY,X
BMI nextFall
TAY
BNE dropXY
drop0:
;New tile drops from top of screen
JSR RandomTile
STA Buffer,X
JSR SetDirty ; X,Y
nextFall:
LDX $A ;column
DEX
BPL chkFall
stopFall:
LDA #1
STA SkipMatch ;TODO: not needed if only drop0?
STA Popped
RTS
dropXY:
; X = column
; Y = row
JSR ToIndex
STA $9 ; bot
JSR SetDirty
DEY
JSR ToIndex
STA $8 ; top
JSR SetDirty
dropIt:
LDX $8 ; top
LDY $9 ; bot
LDA Buffer,X
STA Buffer,Y
LDA #0 ; empty tile
STA Buffer,X
;lda #1
;sta SkipMatch
;sta Popped
JMP nextFall
RandomTile:
; Returns (A) = 1..4
; Preserve X,Y
LDA Random
AND #3 ;[0..3]
CLC
ADC #1 ;[1..4]
RTS
;--------------------------------------
Triples:
dcb 0 // 000000
dcb 0 // 000001
dcb 0 // 000010
dcb 7 // 000011 ----AAA = 1+2+4
dcb 0 // 000100
dcb 0 // 000101
dcb 14 // 000110 ---AAA- = 2+4+8
dcb 15 // 000111 ---AAAA = 1+2+4+8
dcb 0 // 001000
dcb 0 // 001001
dcb 0 // 001010
dcb 7 // 001011 --xxAAA = 1+2+4
dcb 28 // 001100 --AAA-- = 4+8+16
dcb 28 // 001101 --AAAxx = 4+8+16
dcb 30 // 001110 --AAAA- = 2+4+8+16
dcb 31 // 001111 --AAAAA = 1+2+4+8+16
dcb 0 // 010000
dcb 0 // 010001
dcb 0 // 010010
dcb 7 // 010011 -xx-AAA = 1+2+4
dcb 0 // 010100
dcb 0 // 010101
dcb 14 // 010110 -xxAAA- = 2+4+8
dcb 15 // 010111 -xxAAAA = 1+2+4+8
dcb 56 // 011000 -AAA--- = 8+16+32
dcb 56 // 011001 -AAA-xx
dcb 56 // 011010 -AAAxx-
dcb 63 // 011011 -AAABBB = 1+2+4+8+16+32
dcb 60 // 011100 -AAAA-- = 4+8+16+32
dcb 60 // 011101 -AAAAxx = 4+8+16+32
dcb 62 // 011110 -AAAAA- = 2+4+8+16+32
dcb 126 // 011111 -AAAAAA
dcb 0 // 100000
dcb 0 // 100001
dcb 0 // 100010
dcb 7 // 100011 xx--AAA
dcb 0 // 100100
dcb 0 // 100101
dcb 14 // 100110 xx-AAA- 2+4+8
dcb 15 // 100111 xx-AAAA 1+2+4+8
dcb 0 // 101000
dcb 0 // 101001
dcb 0 // 101010
dcb 7 // 101011 xxooAAA 1+2+4
dcb 28 // 101100 xxAAA--
dcb 28 // 101101 xxAAAxx 4+8+16
dcb 30 // 101110 xxAAAA- 2+4+8+16
dcb 31 // 101111 xxAAAAA 1+2+4+8+16
dcb 112 // 110000 AAA---- 16+32+64
dcb 112 // 110001 AAA--xx
dcb 112 // 110010 AAA-xx-
dcb 123 // 110011 AAA-AAA
dcb 112 // 110100 AAAxx--
dcb 112 // 110101 AAAooxx
dcb 126 // 110110 AAABBB- 2+4+8 + 16+32+64
dcb 127 // 110111 AAABBBB
dcb 120 // 111000 AAAA--- 8+16+32+64
dcb 120 // 111001 AAAA-xx
dcb 120 // 111010 AAAAxx-
dcb 127 // 111011 AAAABBB
dcb 124 // 111100 AAAAA-- 4+8+16+32+64
dcb 124 // 111101 AAAAAxx
dcb 126 // 111110 AAAAAA-
dcb 127 // 111111 AAAAAAA
;--------------------------------------
; Font Table
*= $8000
FontPage:
; start at $00 page boundary
; to simplify address calculation
; Array of 4x6 pixel tiles = 24 bytes
font0:
dcb $0,$E,$0,$0
dcb $E,$0,$E,$0
dcb $E,$0,$E,$0
dcb $E,$0,$E,$0
dcb $0,$E,$0,$0
font1:
dcb $0,$E,$0,$0
dcb $E,$E,$0,$0
dcb $0,$E,$0,$0
dcb $0,$E,$0,$0
dcb $E,$E,$E,$0
font2:
dcb $E,$E,$0,$0
dcb $0,$0,$E,$0
dcb $0,$E,$0,$0
dcb $E,$0,$0,$0
dcb $E,$E,$E,$0
font3:
dcb $E,$E,$0,$0
dcb $0,$0,$E,$0
dcb $0,$E,$0,$0
dcb $0,$0,$E,$0
dcb $E,$E,$0,$0
font4:
dcb $E,$0,$E,$0
dcb $E,$0,$E,$0
dcb $E,$E,$E,$0
dcb $0,$0,$E,$0
dcb $0,$0,$E,$0
font5:
dcb $E,$E,$E,$0
dcb $E,$0,$0,$0
dcb $E,$E,$0,$0
dcb $0,$0,$E,$0
dcb $E,$E,$0,$0
font6:
dcb $0,$E,$E,$0
dcb $E,$0,$0,$0
dcb $E,$E,$0,$0
dcb $E,$0,$E,$0
dcb $0,$E,$0,$0
font7:
dcb $E,$E,$E,$0
dcb $0,$0,$E,$0
dcb $0,$E,$0,$0
dcb $0,$E,$0,$0
dcb $0,$E,$0,$0
font8:
dcb $0,$E,$0,$0
dcb $E,$0,$E,$0
dcb $0,$E,$0,$0
dcb $E,$0,$E,$0
dcb $E,$E,$E,$0
font9:
dcb $0,$E,$0,$0
dcb $E,$0,$E,$0
dcb $0,$E,$E,$0
dcb $0,$0,$E,$0
dcb $0,$0,$E,$0
fontA:
dcb $0,$E,$0,$0
dcb $E,$0,$E,$0
dcb $E,$E,$E,$0
dcb $E,$0,$E,$0
dcb $E,$0,$E,$0
fontB:
dcb $E,$E,$0,$0
dcb $E,$0,$E,$0
dcb $E,$E,$0,$0
dcb $E,$0,$E,$0
dcb $E,$E,$0,$0
fontC:
dcb $0,$E,$E,$0
dcb $E,$0,$0,$0
dcb $E,$0,$0,$0
dcb $E,$0,$0,$0
dcb $0,$E,$E,$0
fontD:
dcb $E,$E,$0,$0
dcb $E,$0,$E,$0
dcb $E,$0,$E,$0
dcb $E,$0,$E,$0
dcb $E,$E,$0,$0
fontE:
dcb $E,$E,$E,$0
dcb $E,$0,$0,$0
dcb $E,$E,$0,$0
dcb $E,$0,$0,$0
dcb $E,$E,$E,$0
fontF:
dcb $E,$E,$E,$0
dcb $E,$0,$0,$0
dcb $E,$E,$0,$0
dcb $E,$0,$0,$0
dcb $E,$0,$0,$0
fontX:
dcb $E,$E,$E,$E
dcb $E,$E,$E,$E
dcb $E,$E,$E,$E
dcb $E,$E,$E,$E
dcb $E,$E,$E,$E
;--------------------------------------
*= $8400
TilePage:
; start at $00 page boundary
; to simplify address calculation
; 4x6 bitmap tiles
tile00:
dcb $0,$0,$0,$0
dcb $0,$0,$0,$0
dcb $0,$0,$0,$0
dcb $0,$0,$0,$0
dcb $0,$0,$0,$0
dcb $0,$0,$0,$0
tile01:
dcb $0,$0,$0,$0
dcb $0,$0,$E,$0
dcb $0,$E,$3,$E
dcb $0,$E,$3,$E
dcb $0,$E,$3,$E
dcb $0,$0,$E,$0
tile02:
dcb $0,$0,$0,$0
dcb $0,$0,$2,$0
dcb $0,$2,$4,$2
dcb $0,$2,$4,$2
dcb $0,$2,$4,$2
dcb $0,$0,$2,$0
tile03:
dcb $0,$0,$0,$0
dcb $0,$0,$9,$0
dcb $0,$9,$A,$9
dcb $0,$9,$A,$9
dcb $0,$9,$A,$9
dcb $0,$0,$9,$0
tile04:
dcb $0,$0,$0,$0
dcb $0,$0,$C,$0
dcb $0,$C,$1,$C
dcb $0,$C,$1,$C
dcb $0,$C,$1,$C
dcb $0,$0,$C,$0
;--------------------------------------
*= $8600
mask01:
dcb $ff,$ff,$ff,$ff
dcb $ff,$ff,$ff,$ff
dcb $ff,$01,$ff,$01
dcb $ff,$ff,$ff,$ff
dcb $ff,$01,$ff,$01
dcb $ff,$ff,$ff,$ff
mask02:
dcb $ff,$01,$ff,$03
dcb $01,$ff,$01,$ff
dcb $ff,$01,$ff,$01
dcb $01,$ff,$01,$ff
dcb $ff,$01,$ff,$01
dcb $01,$ff,$01,$ff
;--------------------------------------
;
; Zero Page Usage
;
; $00 xxx
; $01 xxx
; $02 source lo
; $03 source hi
; $04 screen lo = DrawPixel, DrawCursor, GetFont
; $05 screen hi = ...
; ...
; $08 ix
; $09 iy
; $0A TryDrop
; $0B matches
; ...
; $10 SelectX
; $11 SelectY
; $12 NewScore
; $13 Changed
; $14 Popped
; ...
; ...
; $20 mul_lo
; $21 mul_hi
; ...
; $30 match_lo
; $31 match_hi
; $34 zindex = ToIndex
; ...
; $36 refresh_X
; $37 refresh_Y
; $38 dirty_bits
; ...
; $FE System Random
; $FF System Keypress
define source_lo $2
define source_hi $3
define screen_lo $4
define screen_hi $5
define matches $b
; Cursor coordinates (0..6) x (0..3)
define SelectX $10
define SelectY $11
; Counter of how many points to add to score
define NewScore $12
;Flag set whenever tiles are moved and Matching needs to be evaluated
define Changed $13
;Flag set whenever tiles are popped and TryDrop needs to be evaluated
define Popped $14
; 16-bit decimal value = (0000-9999)
define ScoreLo $18
define ScoreHi $19
; 16-bit result of multiply operations
define mul_lo $20
define mul_hi $21
define match_lo $30
define match_hi $31
define zindex $34
define refresh_X $36
define refresh_Y $37
define dirty_bits $38
; System memory
define Random $fe
define Keypress $ff
;Define only works for 0..255 values?
*= $200
Screen:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment