Claude Code entry · Commodore 64
Dino Christmas Village — Claude Version

Collect presents around the village and deliver them to the houses before the timer runs out.
Play the game
Download the PRG or D64 for your Commodore 64 emulator or C64 Ultimate. For the disk, enter LOAD"*",8, then RUN, as specified in Claude’s included README.
Use a joystick in port 2. Press Fire to start, pick up a nearby present, or deliver it at a house showing a present sign.
Source code
src/game.asm
// ===========================================================================
// game.asm - level setup, player, collision, presents, houses, timer, HUD
// ===========================================================================
// ---------------------------------------------------------------------------
// clearScreen - spaces everywhere, colour 0 (hires black text)
// ---------------------------------------------------------------------------
clearScreen:
ldx #0
cls1: lda #32
sta SCREEN,x
sta SCREEN+250,x
sta SCREEN+500,x
sta SCREEN+750,x
lda #0
sta COLRAM,x
sta COLRAM+250,x
sta COLRAM+500,x
sta COLRAM+750,x
inx
cpx #250
bne cls1
rts
// ---------------------------------------------------------------------------
// setCell - zpPtr / zpCol = row cellRow, column cellCol
// ---------------------------------------------------------------------------
setCell:
ldx cellRow
lda rowLo,x
clc
adc cellCol
sta zpPtr
sta zpCol
lda rowHi,x
adc #0
sta zpPtr+1
clc // colour RAM = screen + $d400
adc #>(COLRAM-SCREEN)
sta zpCol+1
rts
// ---------------------------------------------------------------------------
// putChar - A = char, Y = colour, at cellRow/cellCol
// ---------------------------------------------------------------------------
putChar:
pha
tya
pha
jsr setCell
ldy #0
pla
sta (zpCol),y
pla
sta (zpPtr),y
rts
// ---------------------------------------------------------------------------
// sprinkleSnow - A = number of snow flecks, playfield rows 2-24
// ---------------------------------------------------------------------------
sprinkleSnow:
sta tmp6
ss1: jsr rand
and #$3f
cmp #40
bcs ss1
sta cellCol
ss2: jsr rand
and #$1f
cmp #23
bcs ss2
adc #2
sta cellRow
jsr rand
and #$03
tax
lda snowChars,x
ldy snowCols,x
jsr putChar
dec tmp6
bne ss1
rts
snowChars: .byte CH_SNOW1, CH_SNOW2, CH_SNOW3, CH_SNOW1
snowCols: .byte COL_SNOW1, COL_SNOW2, COL_SNOW3, COL_SNOW1
// ---------------------------------------------------------------------------
// drawStamp - X = stamp id, cellCol/cellRow = top left, objCol = colour
// ---------------------------------------------------------------------------
drawStamp:
lda stampLo,x
sta zpSrc
lda stampHi,x
sta zpSrc+1
ldy #0
lda (zpSrc),y
sta stampW
iny
lda (zpSrc),y
sta stampH
lda #0 // stampN = w * h
ldx stampH
dsm1: clc
adc stampW
dex
bne dsm1
sta stampN
lda #2
sta srcIdx
dsRow: jsr setCell
lda #0
sta tmp5 // column within stamp
dsCol: ldy srcIdx
lda (zpSrc),y
beq dsSkip
sta tmp4
tya
clc
adc stampN
tay
lda (zpSrc),y
cmp #$ff
bne dsC1
lda objCol
dsC1: ldy tmp5
sta (zpCol),y
lda tmp4
sta (zpPtr),y
dsSkip: inc srcIdx
inc tmp5
lda tmp5
cmp stampW
bne dsCol
inc cellRow
dec stampH
bne dsRow
rts
// ---------------------------------------------------------------------------
// drawObjects - zpSrc2 list in tmp2/tmp3: stamp,col,row,colour ... $ff
// ---------------------------------------------------------------------------
drawObjects:
ldy #0
lda (tmp2),y
cmp #$ff
beq doEnd
cmp #ST_FENCEH
bcs doFence
pha
iny
lda (tmp2),y
sta cellCol
iny
lda (tmp2),y
sta cellRow
iny
lda (tmp2),y
sta objCol
pla
tax
jsr drawStamp
doNext: lda tmp2
clc
adc #4
sta tmp2
bcc drawObjects
inc tmp3
jmp drawObjects
doEnd: rts
doFence:
sta tmp7 // $80 horizontal, $81 vertical
iny
lda (tmp2),y
sta cellCol
iny
lda (tmp2),y
sta cellRow
iny
lda (tmp2),y
sta tmp6
dfLoop: lda #CH_FENCE
ldy #COL_FENCE
jsr putChar
lda tmp7
cmp #ST_FENCEH
bne dfV
inc cellCol
jmp dfN
dfV: inc cellRow
dfN: dec tmp6
bne dfLoop
jmp doNext
// ---------------------------------------------------------------------------
// initLevel
// ---------------------------------------------------------------------------
initLevel:
lda #0
sta $d015
jsr clearScreen
ldx level
lda lvSeed,x
sta rnd
lda #90
jsr sprinkleSnow
ldx level
lda lvObjLo,x
sta tmp2
lda lvObjHi,x
sta tmp3
jsr drawObjects
// houses
ldx level
lda lvHouses,x
sta numHouses
lda lvHouseLo,x
sta zpSrc
lda lvHouseHi,x
sta zpSrc+1
ldx #0
ldy #0
ilH: lda (zpSrc),y
sta hCol,x
iny
lda (zpSrc),y
sta hRow,x
iny
lda (zpSrc),y
sta hNeed,x
iny
stx tmp0
sty tmp1
jsr drawHouseSign
ldx tmp0
ldy tmp1
inx
cpx numHouses
bne ilH
// presents
ldx level
lda lvPresLo,x
sta presPtr
lda lvPresHi,x
sta presPtr+1
lda lvTotal,x
sta total
lda lvActive,x
sta tmp0
lda #0
sta nextSpawn
sta delivered
ldx #MAX_SLOTS-1
ilP0: sta pState,x
dex
bpl ilP0
ldx #0
ilP1: cpx tmp0
beq ilP2
jsr spawnPresent
inx
jmp ilP1
ilP2:
// player
ldx level
lda lvStartXLo,x
sta dinoXLo
lda lvStartXHi,x
sta dinoXHi
lda lvStartY,x
sta dinoY
lda #0
sta facing
sta animCnt
sta animFrame
sta secCount
lda #$ff
sta carrying
lda lvTime,x
sta timeLo
lda lvTimeHi,x
sta timeHi
jsr drawHudStatic
jsr drawHud
jsr setSprites
rts
// ---------------------------------------------------------------------------
// spawnPresent - X = slot; takes the next present from the level list
// ---------------------------------------------------------------------------
spawnPresent:
lda nextSpawn
cmp total
bcc sp1
lda #0
sta pState,x
rts
sp1: asl
asl
tay
lda (presPtr),y
sta pXLo,x
iny
lda (presPtr),y
sta pXHi,x
iny
lda (presPtr),y
sta pY,x
iny
lda (presPtr),y
sta pColr,x
lda #1
sta pState,x
inc nextSpawn
rts
// ---------------------------------------------------------------------------
// drawHouseSign - X = house: gift icon + number still needed, or two ticks
// ---------------------------------------------------------------------------
drawHouseSign:
lda hRow,x
sec
sbc #1
sta cellRow
lda hCol,x
clc
adc #2
sta cellCol
lda hNeed,x
beq dhsDone
stx tmp3
lda #CH_GIFT
ldy #COL_GIFT
jsr putChar
inc cellCol
ldx tmp3
lda hNeed,x
ora #$30
ldy #0
jmp putChar
dhsDone:
lda #CH_TICK
ldy #COL_TICK
jsr putChar
inc cellCol
lda #CH_TICK
ldy #COL_TICK
jmp putChar
// ---------------------------------------------------------------------------
// setSprites - write all sprite registers (called just after raster 251)
// ---------------------------------------------------------------------------
setSprites:
lda facing
asl
ora animFrame
asl
clc
adc #SP_DINO_R0
sta SPRPTR+1
clc
adc #1
sta SPRPTR+0
lda dinoXLo
sta $d000
sta $d002
lda dinoY
sta $d001
sta $d003
lda #$03 // sprites 0 and 1 on
sta tmp0
lda #$00
sta tmp1 // x msb bits
lda dinoXHi
beq ssN
lda #$03
sta tmp1
ssN: ldx #0
lda #4 // bit for sprite 2
sta tmp2
ssLoop: lda pState,x
beq ssOff
txa
asl
tay // y = slot*2 -> sprite (slot+2) register
lda #SP_PRESENT
sta SPRPTR+2,x
lda pColr,x
sta $d029,x
lda pState,x
cmp #2
beq ssCarry
lda pXLo,x
sta $d004,y
lda pY,x
sta $d005,y
lda pXHi,x
jmp ssMsb
ssCarry:
lda dinoXLo
sta $d004,y
lda dinoY
sec
sbc #16
sta $d005,y
lda dinoXHi
ssMsb: beq ssOn
lda tmp1
ora tmp2
sta tmp1
ssOn: lda tmp0
ora tmp2
sta tmp0
ssOff: asl tmp2
inx
cpx #MAX_SLOTS
bne ssLoop
lda tmp1
sta $d010
lda tmp0
sta $d015
rts
// ---------------------------------------------------------------------------
// movePlayer - joystick movement with character based wall collision
// ---------------------------------------------------------------------------
movePlayer:
lda #0
sta moving
lda joy
and #$04
beq mpR
lda #1 // left
sta facing
lda dinoXLo
sec
sbc #SPEED
sta chkXLo
lda dinoXHi
sbc #0
sta chkXHi
bne mpLok // high byte 1: x >= 256, inside
lda chkXLo
cmp #XMIN
bcc mpV
mpLok: jsr tryX
jmp mpV
mpR: lda joy
and #$08
beq mpV
lda #0 // right
sta facing
lda dinoXLo
clc
adc #SPEED
sta chkXLo
lda dinoXHi
adc #0
sta chkXHi
beq mpRok
lda chkXLo
cmp #<(XMAX+1)
bcs mpV
mpRok: jsr tryX
mpV: lda joy
and #$01
beq mpD
lda dinoY
sec
sbc #SPEED
cmp #YMIN
bcc mpAnim
jsr tryY
jmp mpAnim
mpD: lda joy
and #$02
beq mpAnim
lda dinoY
clc
adc #SPEED
cmp #YMAX+1
bcs mpAnim
jsr tryY
mpAnim: lda moving
beq mpStill
inc animCnt
lda animCnt
cmp #6
bcc mpDone
lda #0
sta animCnt
lda animFrame
eor #1
sta animFrame
mpDone: rts
mpStill:
lda #0
sta animFrame
rts
tryX: lda dinoY
sta chkY
jsr blocked
bcs txNo
lda chkXLo
sta dinoXLo
lda chkXHi
sta dinoXHi
lda #1
sta moving
txNo: rts
tryY: sta chkY
lda dinoXLo
sta chkXLo
lda dinoXHi
sta chkXHi
jsr blocked
bcs tyNo
lda chkY
sta dinoY
lda #1
sta moving
tyNo: rts
// ---------------------------------------------------------------------------
// blocked - is the dinosaur's feet box at chkX/chkY touching a solid char?
// carry set = blocked. Four corner points are tested.
// ---------------------------------------------------------------------------
blocked:
ldx #3
blLoop: lda chkXLo // column = (x - 24 + ox) / 8
sec
sbc feetSubX,x
sta tmp0
lda chkXHi
sbc #0
lsr
ror tmp0
lsr tmp0
lsr tmp0
lda tmp0
cmp #40
bcs blYes
sta cellCol
lda chkY // row = (y - 50 + oy) / 8
sec
sbc feetSubY,x
lsr
lsr
lsr
cmp #2
bcc blYes
cmp #25
bcs blYes
tay
lda rowLo,y
sta zpPtr
lda rowHi,y
sta zpPtr+1
ldy cellCol
lda (zpPtr),y
jsr isSolid
bcs blYes
dex
bpl blLoop
clc
rts
blYes: sec
rts
// offsets: 24-ox and 50-oy for feet points (5,14) (18,14) (5,20) (18,20)
feetSubX: .byte 24-5, 24-18, 24-5, 24-18
feetSubY: .byte 50-14, 50-14, 50-20, 50-20
// isSolid - A = screen code; carry set if solid
isSolid:
cmp #32
beq isNo
cmp #64
bcc isYes
cmp #128
bcs isYes
isNo: clc
rts
isYes: sec
rts
// ---------------------------------------------------------------------------
// handleFire - pick up a present or deliver the one being carried
// ---------------------------------------------------------------------------
handleFire:
lda firePress
bne hf0
rts
hf0: lda carrying
bmi tryPickup
// ---- delivery: feet centre cell must be in front of a door
lda dinoXLo
sec
sbc #24-11
sta tmp0
lda dinoXHi
sbc #0
lsr
ror tmp0
lsr tmp0
lsr tmp0 // tmp0 = feet column
lda dinoY
sec
sbc #50-20
lsr
lsr
lsr
sta tmp1 // tmp1 = feet row
ldx #0
hfH: cpx numHouses
beq hfNone
lda hNeed,x
beq hfHn
lda hCol,x // col >= hCol+1 and col <= hCol+4
clc
adc #1
cmp tmp0
beq hfC1
bcs hfHn
hfC1: clc
adc #3
cmp tmp0
bcc hfHn
lda hRow,x // row >= hRow+5 and row <= hRow+6
clc
adc #5
cmp tmp1
beq hfR1
bcs hfHn
hfR1: clc
adc #1
cmp tmp1
bcc hfHn
jmp deliver
hfHn: inx
jmp hfH
hfNone: lda #SFX_BUZZ
jmp sfxPlay
deliver:
dec hNeed,x
jsr drawHouseSign
ldx carrying
lda #0
sta pState,x
jsr spawnPresent
lda #$ff
sta carrying
inc delivered
lda #$00 // +100 points
sta tmp0
lda #$01
sta tmp1
jsr addScore
lda #SFX_DELIVER
jmp sfxPlay
tryPickup:
ldx #0
tpL: lda pState,x
cmp #1
bne tpN
lda dinoXLo // |dinoX - presentX| < 14
sec
sbc pXLo,x
sta tmp0
lda dinoXHi
sbc pXHi,x
beq tpXc // 0..255 to the right
cmp #$ff
bne tpN // 256 or more away
lda tmp0 // -255..-1: negate low byte
eor #$ff
clc
adc #1
beq tpN // exactly -256
sta tmp0
tpXc: lda tmp0
cmp #14
bcs tpN
lda dinoY // |dinoY - presentY| < 16
sec
sbc pY,x
bcs tpYp
eor #$ff
adc #1
tpYp: cmp #16
bcs tpN
lda #2
sta pState,x
stx carrying
lda #SFX_PICKUP
jmp sfxPlay
tpN: inx
cpx #MAX_SLOTS
bne tpL
lda #SFX_BUZZ
jmp sfxPlay
// ---------------------------------------------------------------------------
// addScore - adds BCD tmp1:tmp0 to the score
// ---------------------------------------------------------------------------
addScore:
sed
clc
lda score0
adc tmp0
sta score0
lda score1
adc tmp1
sta score1
lda score2
adc #0
sta score2
cld
rts
// ---------------------------------------------------------------------------
// updateTimer - one second every 50 (PAL) / 60 (NTSC) frames
// ---------------------------------------------------------------------------
updateTimer:
inc secCount
lda secCount
cmp secFrames
bcc utDone
lda #0
sta secCount
jsr decTime
lda timeHi
bne utDone
lda timeLo
cmp #$11
bcs utDone
lda #SFX_TICK
jsr sfxPlay
utDone: rts
decTime:
sed
sec
lda timeLo
sbc #1
sta timeLo
lda timeHi
sbc #0
sta timeHi
cld
rts
// ---------------------------------------------------------------------------
// HUD - row 0: SCORE 000000 TIME 000 DELIVERED 00/00
// ---------------------------------------------------------------------------
drawHudStatic:
ldx #<txtHud
ldy #>txtHud
jsr printText
ldx #39
dhs1: lda #CH_GARLAND
sta SCREEN+40,x
lda #COL_GARLAND
sta COLRAM+40,x
dex
bpl dhs1
ldx #<txtLevel
ldy #>txtLevel
jsr printText
lda level
clc
adc #$31
sta SCREEN+40+22
lda #2
sta COLRAM+40+22
lda total
jsr toDec
stx SCREEN+35
sta SCREEN+36
rts
drawHud:
ldx #6
jsr printScore
lda timeHi
and #$0f
ora #$30
sta SCREEN+18
lda timeLo
ldx #19
jsr printBcd
ldy #0 // timer turns red for the last 10 seconds
lda timeHi
bne dh1
lda timeLo
cmp #$10
bcs dh1
ldy #2
dh1: sty COLRAM+18
sty COLRAM+19
sty COLRAM+20
lda delivered
jsr toDec
stx SCREEN+32
sta SCREEN+33
rts
// printScore - 6 digits at SCREEN+X
printScore:
lda score2
jsr printBcd
inx
inx
lda score1
jsr printBcd
inx
inx
lda score0
jmp printBcd
// printBcd - two BCD digits of A at SCREEN+X, SCREEN+X+1
printBcd:
pha
lsr
lsr
lsr
lsr
ora #$30
sta SCREEN,x
pla
and #$0f
ora #$30
sta SCREEN+1,x
rts
// toDec - A (0-99) -> X = tens screen code, A = units screen code
toDec: ldx #$30
td1: cmp #10
bcc td2
sbc #10
inx
jmp td1
td2: ora #$30
rts
// ---------------------------------------------------------------------------
// printText - X/Y = pointer to: col, row, colour, text..., 0
// ---------------------------------------------------------------------------
printText:
stx zpSrc
sty zpSrc+1
ldy #0
lda (zpSrc),y
sta cellCol
iny
lda (zpSrc),y
sta cellRow
iny
lda (zpSrc),y
sta tmp4
jsr setCell
lda zpSrc
clc
adc #3
sta zpSrc
bcc pt0
inc zpSrc+1
pt0: ldy #0
pt1: lda (zpSrc),y
beq pt2
sta (zpPtr),y
lda tmp4
sta (zpCol),y
iny
jmp pt1
pt2: rts
src/gen/charset.asm
// Generated by tools/gfx_gen.py - do not edit by hand
// 256 characters: 0-63 font, 64-127 walkable tiles, 128-255 solid tiles
* = $2000 "Charset"
charset:
.byte $00,$00,$00,$00,$00,$00,$00,$00,$3c,$66,$66,$7e,$66,$66,$66,$00
.byte $7c,$66,$66,$7c,$66,$66,$7c,$00,$3c,$66,$60,$60,$60,$66,$3c,$00
.byte $7c,$66,$66,$66,$66,$66,$7c,$00,$7e,$60,$60,$7c,$60,$60,$7e,$00
.byte $7e,$60,$60,$7c,$60,$60,$60,$00,$3c,$66,$60,$7e,$66,$66,$3e,$00
.byte $66,$66,$66,$7e,$66,$66,$66,$00,$3c,$18,$18,$18,$18,$18,$3c,$00
.byte $1e,$0c,$0c,$0c,$0c,$6c,$38,$00,$cc,$d8,$f0,$e0,$f0,$d8,$cc,$00
.byte $60,$60,$60,$60,$60,$60,$7e,$00,$c6,$ee,$d6,$c6,$c6,$c6,$c6,$00
.byte $c6,$e6,$f6,$de,$ce,$c6,$c6,$00,$3c,$66,$66,$66,$66,$66,$3c,$00
.byte $7c,$66,$66,$7c,$60,$60,$60,$00,$3c,$66,$66,$66,$6c,$66,$3e,$00
.byte $7c,$66,$66,$7c,$78,$6c,$66,$00,$3c,$66,$60,$3c,$06,$66,$3c,$00
.byte $7e,$18,$18,$18,$18,$18,$18,$00,$66,$66,$66,$66,$66,$66,$3c,$00
.byte $c6,$c6,$c6,$c6,$6c,$38,$10,$00,$c6,$c6,$c6,$d6,$fe,$ee,$c6,$00
.byte $c6,$6c,$38,$38,$6c,$c6,$c6,$00,$cc,$cc,$78,$30,$30,$30,$30,$00
.byte $7e,$06,$0c,$18,$30,$60,$7e,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$18,$18,$18,$18,$18,$00,$18,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$18,$18,$30,$00,$00,$00,$00,$00
.byte $0c,$18,$30,$30,$30,$18,$0c,$00,$30,$18,$0c,$0c,$0c,$18,$30,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$38,$18,$30,$00,$00,$00,$00,$3c,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$38,$38,$00,$06,$0c,$0c,$18,$30,$30,$60,$00
.byte $3c,$66,$66,$66,$66,$66,$3c,$00,$18,$38,$18,$18,$18,$18,$3c,$00
.byte $3c,$66,$06,$1c,$30,$60,$7e,$00,$3c,$66,$06,$1c,$06,$66,$3c,$00
.byte $18,$38,$78,$d8,$fc,$18,$18,$00,$7e,$60,$7c,$06,$06,$66,$3c,$00
.byte $1c,$30,$60,$7c,$66,$66,$3c,$00,$7e,$06,$0c,$18,$30,$30,$30,$00
.byte $3c,$66,$66,$3c,$66,$66,$3c,$00,$3c,$66,$66,$3e,$06,$0c,$38,$00
.byte $00,$18,$18,$00,$18,$18,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$3c,$66,$06,$1c,$18,$00,$18,$00
.byte $00,$0c,$00,$00,$00,$00,$30,$00,$00,$00,$00,$c0,$00,$00,$00,$0c
.byte $00,$00,$00,$00,$00,$00,$3c,$ff,$00,$c0,$f3,$3f,$1c,$10,$00,$00
.byte $0c,$0c,$ff,$3c,$3c,$c3,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $08,$2a,$aa,$28,$28,$aa,$28,$28,$41,$14,$aa,$b6,$b6,$96,$b6,$aa
.byte $03,$03,$0c,$0c,$cc,$f0,$30,$00,$00,$00,$00,$00,$00,$08,$80,$88
.byte $00,$00,$02,$08,$80,$00,$00,$20,$02,$20,$00,$00,$00,$00,$00,$82
.byte $80,$08,$00,$00,$00,$00,$00,$08,$00,$00,$80,$20,$02,$00,$00,$20
.byte $00,$00,$00,$00,$00,$20,$02,$82,$95,$99,$95,$95,$95,$99,$95,$aa
.byte $55,$59,$55,$95,$55,$59,$55,$aa,$56,$5a,$56,$96,$56,$5a,$56,$aa
.byte $bf,$bf,$bf,$af,$bf,$bf,$bf,$af,$aa,$be,$be,$aa,$be,$be,$aa,$00
.byte $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$af,$ff,$ff,$ff,$af
.byte $fe,$fe,$fe,$fe,$fe,$fe,$fe,$fe,$aa,$95,$99,$99,$95,$95,$99,$99
.byte $aa,$56,$66,$66,$56,$56,$66,$66,$bf,$bf,$bf,$af,$bf,$bf,$bf,$aa
.byte $ff,$ff,$ff,$ff,$ff,$ff,$ff,$aa,$95,$95,$95,$99,$99,$95,$95,$aa
.byte $7e,$7e,$56,$66,$66,$56,$56,$aa,$fe,$fe,$fe,$fe,$fe,$fe,$fe,$aa
.byte $00,$00,$00,$00,$00,$02,$80,$88,$00,$00,$00,$00,$08,$00,$00,$20
.byte $00,$00,$00,$08,$00,$00,$00,$82,$00,$00,$20,$00,$00,$00,$00,$08
.byte $02,$80,$00,$00,$00,$00,$00,$20,$80,$02,$00,$00,$00,$00,$00,$82
.byte $00,$00,$08,$00,$00,$00,$00,$08,$00,$00,$00,$20,$00,$00,$00,$20
.byte $00,$00,$00,$00,$20,$00,$00,$82,$00,$00,$00,$00,$00,$80,$02,$02
.byte $fe,$fe,$fe,$ae,$fe,$fe,$fe,$ae,$ff,$ff,$ff,$af,$ff,$ff,$ff,$aa
.byte $fe,$fe,$fe,$ae,$fe,$fe,$fe,$aa,$00,$00,$0f,$03,$00,$03,$0f,$00
.byte $3c,$ff,$ff,$ff,$ff,$c3,$00,$00,$00,$00,$f0,$c0,$00,$c0,$f0,$00
.byte $00,$00,$02,$02,$0b,$0a,$02,$0b,$28,$be,$ff,$df,$ff,$3c,$ff,$df
.byte $00,$00,$80,$80,$e0,$a0,$80,$e0,$0b,$2f,$2f,$28,$0b,$2f,$2f,$bf
.byte $ff,$ff,$ff,$3f,$ff,$df,$ff,$ff,$e0,$78,$f8,$28,$f8,$f8,$f8,$7e
.byte $bf,$9f,$bf,$aa,$00,$00,$00,$02,$ff,$ff,$df,$aa,$aa,$aa,$aa,$aa
.byte $fe,$fe,$fe,$aa,$00,$00,$00,$80,$0a,$0a,$2a,$08,$22,$80,$80,$20
.byte $a0,$a0,$a8,$20,$20,$42,$02,$08,$15,$95,$80,$82,$80,$80,$20,$28
.byte $54,$56,$42,$42,$02,$82,$08,$28,$80,$80,$80,$80,$80,$80,$20,$0a
.byte $02,$82,$02,$02,$82,$02,$08,$a0,$aa,$be,$be,$be,$aa,$28,$28,$28
.byte $28,$18,$24,$28,$18,$24,$28,$28,$28,$28,$28,$28,$28,$28,$aa,$aa
.byte $00,$00,$00,$00,$02,$02,$2a,$95,$00,$00,$00,$aa,$55,$55,$55,$55
.byte $00,$00,$00,$80,$60,$60,$6a,$55,$00,$00,$00,$00,$00,$00,$a8,$02
.byte $00,$00,$00,$00,$00,$00,$00,$0a,$95,$95,$80,$80,$80,$bf,$bf,$bf
.byte $55,$55,$00,$00,$00,$ff,$ff,$ff,$02,$02,$a8,$80,$80,$80,$80,$a8
.byte $2f,$2f,$2f,$2f,$2f,$2f,$2f,$2f,$fe,$fe,$fe,$ff,$ff,$ff,$fc,$fc
.byte $af,$af,$af,$ff,$ff,$ff,$00,$00,$ff,$ff,$ff,$ff,$ff,$ff,$00,$00
.byte $fe,$fe,$fe,$fe,$fe,$fe,$02,$02,$00,$00,$00,$00,$00,$00,$00,$02
.byte $00,$00,$00,$02,$0b,$0b,$ab,$ff,$2f,$2f,$2f,$af,$ff,$ff,$ff,$ff
.byte $fc,$ff,$ff,$ff,$fe,$fe,$fe,$ff,$00,$ff,$ff,$ff,$aa,$00,$a0,$f8
.byte $00,$ff,$ff,$ff,$aa,$00,$00,$00,$02,$a8,$80,$80,$00,$00,$00,$00
.byte $00,$00,$00,$00,$0a,$2f,$2f,$2f,$02,$2a,$bf,$bf,$bf,$ff,$ff,$ff
.byte $ff,$ff,$ff,$ff,$ff,$c0,$c0,$c0,$ff,$ff,$ff,$ff,$ff,$03,$03,$03
.byte $f8,$fa,$ff,$ff,$ff,$ff,$ff,$ff,$00,$aa,$ff,$ff,$ff,$ea,$e0,$e0
.byte $00,$00,$80,$80,$80,$00,$00,$00,$2f,$2f,$2f,$0a,$00,$00,$00,$00
.byte $ff,$ff,$ff,$bf,$bf,$bf,$2a,$02,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0
.byte $00,$00,$00,$00,$00,$00,$03,$03,$0f,$0f,$0f,$0f,$0f,$0f,$ff,$ff
.byte $e0,$e0,$e0,$e0,$e0,$e0,$e0,$e0,$02,$02,$02,$02,$02,$02,$02,$02
.byte $ff,$ff,$ff,$ff,$ff,$ff,$ff,$fa,$c0,$ff,$ff,$ff,$ff,$ff,$ff,$aa
.byte $03,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$fa,$f8,$f8,$f8,$f8,$f8,$f8
.byte $e0,$80,$00,$00,$00,$00,$00,$00,$02,$02,$02,$02,$2a,$bf,$bf,$bf
.byte $f8,$f8,$f8,$f8,$f8,$f8,$f8,$f8,$2a,$00,$00,$00,$00,$00,$00,$00
.byte $aa,$00,$00,$00,$00,$00,$00,$00,$a0,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
src/gen/consts.asm
// Generated by tools/gfx_gen.py - do not edit by hand
.const CH_FENCE = $80
.const CH_GARLAND = $43
.const CH_GIFT = $81
.const CH_SNOW1 = $40
.const CH_SNOW2 = $41
.const CH_SNOW3 = $42
.const CH_STAR = $44
.const CH_TICK = $82
.const COL_FENCE = $08
.const COL_GARLAND = $0d
.const COL_GIFT = $0f
.const COL_SNOW1 = $0b
.const COL_SNOW2 = $0b
.const COL_SNOW3 = $0b
.const COL_STAR = $0f
.const COL_TICK = $0d
.const SP_DINO_L0 = $a4
.const SP_DINO_L1 = $a6
.const SP_DINO_R0 = $a0
.const SP_DINO_R1 = $a2
.const SP_DOUT_L0 = $a5
.const SP_DOUT_L1 = $a7
.const SP_DOUT_R0 = $a1
.const SP_DOUT_R1 = $a3
.const SP_PRESENT = $a8
.const ST_HOUSE = 0
.const ST_WORKSHOP = 1
.const ST_TREE = 2
.const ST_SNOWMAN = 3
.const ST_LAMP = 4
.const ST_BIGDINO = 5
.const ST_FENCEH = $80
.const ST_FENCEV = $81
.const TUNE_TITLE = 0
.const TUNE_GAME = 1
.const TUNE_WIN = 2
.const TUNE_LOSE = 3
.const NUM_LEVELS = 3
src/gen/levels.asm
// Generated by tools/gfx_gen.py - do not edit by hand
lvTime:
.byte $90,$75,$60
lvTimeHi:
.byte $00,$00,$00
lvHouses:
.byte $03,$04,$05
lvTotal:
.byte $05,$08,$0a
lvActive:
.byte $05,$04,$03
lvStartXLo:
.byte $a8,$a8,$a8
lvStartXHi:
.byte $00,$00,$00
lvStartY:
.byte $8c,$84,$84
lvSeed:
.byte $5a,$3c,$77
lvObjLo:
.byte <lv1Obj,<lv2Obj,<lv3Obj
lvObjHi:
.byte >lv1Obj,>lv2Obj,>lv3Obj
lvHouseLo:
.byte <lv1House,<lv2House,<lv3House
lvHouseHi:
.byte >lv1House,>lv2House,>lv3House
lvPresLo:
.byte <lv1Pres,<lv2Pres,<lv3Pres
lvPresHi:
.byte >lv1Pres,>lv2Pres,>lv3Pres
// ---- level 1 ----
lv1Obj: // stamp,col,row,colour | $80/$81 fence,col,row,len | $ff
.byte ST_WORKSHOP,15,3,13
.byte ST_HOUSE,2,4,10
.byte ST_HOUSE,32,4,14
.byte ST_HOUSE,17,16,12
.byte ST_TREE,10,3,8
.byte ST_TREE,27,3,8
.byte ST_TREE,1,14,8
.byte ST_TREE,36,14,8
.byte ST_TREE,9,19,8
.byte ST_TREE,29,19,8
.byte ST_SNOWMAN,13,11,8
.byte ST_LAMP,8,10,8
.byte ST_LAMP,31,10,8
.byte ST_FENCEH,0,24,8
.byte ST_FENCEH,32,24,8
.byte $ff
lv1House: // col,row,presents needed
.byte 2,4,2
.byte 32,4,2
.byte 17,16,1
lv1Pres: // sprite x lo, x hi, y, colour
.byte $98,0,$7b,6
.byte $c0,0,$7b,4
.byte $38,0,$bb,5
.byte $20,1,$bb,14
.byte $e0,0,$93,8
// ---- level 2 ----
lv2Obj: // stamp,col,row,colour | $80/$81 fence,col,row,len | $ff
.byte ST_WORKSHOP,15,3,10
.byte ST_HOUSE,1,4,14
.byte ST_HOUSE,33,4,12
.byte ST_HOUSE,1,16,13
.byte ST_HOUSE,33,16,11
.byte ST_TREE,10,4,8
.byte ST_TREE,27,4,8
.byte ST_TREE,18,18,8
.byte ST_TREE,12,14,8
.byte ST_TREE,25,14,8
.byte ST_SNOWMAN,8,11,8
.byte ST_SNOWMAN,30,11,8
.byte ST_LAMP,15,11,8
.byte ST_LAMP,24,11,8
.byte ST_FENCEH,8,21,8
.byte ST_FENCEH,24,21,8
.byte $ff
lv2House: // col,row,presents needed
.byte 1,4,2
.byte 33,4,2
.byte 1,16,2
.byte 33,16,2
lv2Pres: // sprite x lo, x hi, y, colour
.byte $98,0,$7b,6
.byte $c0,0,$7b,4
.byte $70,0,$db,5
.byte $e8,0,$db,14
.byte $a8,0,$e3,8
.byte $40,0,$93,3
.byte $18,1,$93,7
.byte $b0,0,$a3,10
// ---- level 3 ----
lv3Obj: // stamp,col,row,colour | $80/$81 fence,col,row,len | $ff
.byte ST_WORKSHOP,15,3,14
.byte ST_HOUSE,1,3,10
.byte ST_HOUSE,33,3,13
.byte ST_HOUSE,1,15,12
.byte ST_HOUSE,33,15,11
.byte ST_HOUSE,17,17,10
.byte ST_TREE,9,3,8
.byte ST_TREE,28,3,8
.byte ST_TREE,12,18,8
.byte ST_TREE,25,18,8
.byte ST_SNOWMAN,9,11,8
.byte ST_SNOWMAN,29,11,8
.byte ST_LAMP,14,12,8
.byte ST_LAMP,25,12,8
.byte ST_FENCEH,0,11,7
.byte ST_FENCEH,33,11,7
.byte ST_FENCEV,12,8,3
.byte ST_FENCEV,27,8,3
.byte ST_FENCEH,7,23,9
.byte ST_FENCEH,24,23,9
.byte $ff
lv3House: // col,row,presents needed
.byte 1,3,2
.byte 33,3,2
.byte 1,15,2
.byte 33,15,2
.byte 17,17,2
lv3Pres: // sprite x lo, x hi, y, colour
.byte $98,0,$7b,6
.byte $c0,0,$7b,4
.byte $48,0,$db,5
.byte $10,1,$db,14
.byte $28,0,$8b,8
.byte $30,1,$8b,3
.byte $a8,0,$9b,7
.byte $60,0,$a3,10
.byte $f8,0,$a3,13
.byte $b0,0,$e3,6
src/gen/sound_data.asm
// Generated by tools/gfx_gen.py - do not edit by hand
// SID frequencies, C2..B6 (index 0 = C2); note byte n in tunes -> index n-1
freqPalLo:
.byte $5a,$9c,$e2,$2d,$7b,$cf,$27,$85,$e8,$51,$c1,$37,$b4,$38,$c4,$59
.byte $f7,$9d,$4e,$0a,$d0,$a2,$81,$6d,$67,$70,$89,$b2,$ed,$3b,$9c,$13
.byte $a0,$45,$02,$da,$ce,$e0,$11,$64,$da,$76,$39,$26,$40,$89,$04,$b4
.byte $9c,$c0,$23,$c8,$b4,$eb,$72,$4c,$80,$12,$08,$68
freqPalHi:
.byte $04,$04,$04,$05,$05,$05,$06,$06,$06,$07,$07,$08,$08,$09,$09,$0a
.byte $0a,$0b,$0c,$0d,$0d,$0e,$0f,$10,$11,$12,$13,$14,$15,$17,$18,$1a
.byte $1b,$1d,$1f,$20,$22,$24,$27,$29,$2b,$2e,$31,$34,$37,$3a,$3e,$41
.byte $45,$49,$4e,$52,$57,$5c,$62,$68,$6e,$75,$7c,$83
freqNtscLo:
.byte $31,$71,$b4,$fc,$48,$98,$ed,$48,$a7,$0c,$78,$e9,$62,$e2,$69,$f8
.byte $90,$30,$db,$8f,$4e,$19,$f0,$d3,$c4,$c3,$d1,$f0,$1f,$61,$b6,$1e
.byte $9d,$32,$df,$a6,$88,$86,$a3,$e0,$3f,$c2,$6b,$3d,$3a,$64,$be,$4c
.byte $0f,$0c,$46,$bf,$7d,$84,$d6,$7a,$73,$c8,$7d,$97
freqNtscHi:
.byte $04,$04,$04,$04,$05,$05,$05,$06,$06,$07,$07,$07,$08,$08,$09,$09
.byte $0a,$0b,$0b,$0c,$0d,$0e,$0e,$0f,$10,$11,$12,$13,$15,$16,$17,$19
.byte $1a,$1c,$1d,$1f,$21,$23,$25,$27,$2a,$2c,$2f,$32,$35,$38,$3b,$3f
.byte $43,$47,$4b,$4f,$54,$59,$5e,$64,$6a,$70,$77,$7e
// tune table: voice1, voice2, wave1, wave2, ad1, sr1, ad2, sr2, loop
tuneV1Lo:
.byte <tune_TITLE_v1,<tune_GAME_v1,<tune_WIN_v1,<tune_LOSE_v1
tuneV1Hi:
.byte >tune_TITLE_v1,>tune_GAME_v1,>tune_WIN_v1,>tune_LOSE_v1
tuneV2Lo:
.byte <tune_TITLE_v2,<tune_GAME_v2,<tune_WIN_v2,<tune_LOSE_v2
tuneV2Hi:
.byte >tune_TITLE_v2,>tune_GAME_v2,>tune_WIN_v2,>tune_LOSE_v2
tuneWave1:
.byte $41,$11,$41,$21
tuneWave2:
.byte $11,$11,$11,$21
tuneAd1:
.byte $09,$08,$09,$0a
tuneSr1:
.byte $84,$63,$a6,$86
tuneAd2:
.byte $08,$08,$09,$0a
tuneSr2:
.byte $60,$50,$a6,$86
tuneLoop:
.byte 1,1,0,0
// note data: note (0 = rest, 1.. = C2 upwards), duration in frames; $ff = end
tune_TITLE_v1:
.byte $29,$14,$29,$14,$29,$28,$29,$14,$29,$14,$29,$28,$29,$14,$2c,$14
.byte $25,$1e,$27,$0a,$29,$50,$2a,$14,$2a,$14,$2a,$1e,$2a,$0a,$2a,$14
.byte $29,$14,$29,$14,$29,$0a,$29,$0a,$29,$14,$27,$14,$27,$14,$29,$14
.byte $27,$28,$2c,$28,$29,$14,$29,$14,$29,$28,$29,$14,$29,$14,$29,$28
.byte $29,$14,$2c,$14,$25,$1e,$27,$0a,$29,$50,$2a,$14,$2a,$14,$2a,$1e
.byte $2a,$0a,$2a,$14,$29,$14,$29,$14,$29,$0a,$29,$0a,$2c,$14,$2c,$14
.byte $2a,$14,$27,$14,$25,$50
.byte $ff
tune_TITLE_v2:
.byte $0d,$14,$08,$14,$0d,$14,$08,$14,$0d,$14,$08,$14,$0d,$14,$08,$14
.byte $0d,$14,$08,$14,$0d,$14,$08,$14,$0d,$14,$08,$14,$0d,$14,$08,$14
.byte $12,$14,$0d,$14,$12,$14,$0d,$14,$0d,$14,$08,$14,$0d,$14,$08,$14
.byte $14,$14,$0f,$14,$14,$14,$0f,$14,$14,$14,$0f,$14,$14,$14,$0f,$14
.byte $0d,$14,$08,$14,$0d,$14,$08,$14,$0d,$14,$08,$14,$0d,$14,$08,$14
.byte $0d,$14,$08,$14,$0d,$14,$08,$14,$0d,$14,$08,$14,$0d,$14,$08,$14
.byte $12,$14,$0d,$14,$12,$14,$0d,$14,$0d,$14,$08,$14,$0d,$14,$08,$14
.byte $14,$14,$0f,$14,$14,$14,$0f,$14,$0d,$14,$08,$14,$0d,$14,$08,$14
.byte $ff
tune_GAME_v1:
.byte $2c,$1b,$2a,$09,$29,$12,$27,$12,$25,$12,$27,$12,$29,$12,$25,$12
.byte $27,$09,$29,$09,$2a,$09,$27,$09,$29,$1b,$27,$09,$25,$12,$24,$12
.byte $25,$24,$2c,$1b,$2a,$09,$29,$12,$27,$12,$25,$12,$27,$12,$29,$12
.byte $25,$12,$27,$09,$29,$09,$2a,$09,$27,$09,$29,$1b,$27,$09,$25,$12
.byte $24,$12,$25,$24,$27,$1b,$29,$09,$2a,$12,$27,$12,$29,$1b,$2a,$09
.byte $2c,$12,$27,$12,$29,$09,$2b,$09,$2c,$12,$2e,$09,$30,$09,$31,$12
.byte $30,$12,$2e,$12,$2c,$24,$2c,$1b,$2a,$09,$29,$12,$27,$12,$25,$12
.byte $27,$12,$29,$12,$25,$12,$2e,$09,$2e,$09,$2e,$09,$2e,$09,$2c,$1b
.byte $2a,$09,$29,$12,$27,$12,$25,$24
.byte $ff
tune_GAME_v2:
.byte $0d,$12,$08,$12,$0d,$12,$08,$12,$12,$12,$0d,$12,$12,$12,$0d,$12
.byte $14,$12,$0f,$12,$14,$12,$0f,$12,$0d,$12,$08,$12,$0d,$12,$08,$12
.byte $0d,$12,$08,$12,$0d,$12,$08,$12,$12,$12,$0d,$12,$12,$12,$0d,$12
.byte $14,$12,$0f,$12,$14,$12,$0f,$12,$0d,$12,$08,$12,$0d,$12,$08,$12
.byte $14,$12,$0f,$12,$14,$12,$0f,$12,$0d,$12,$08,$12,$0d,$12,$08,$12
.byte $0f,$12,$0a,$12,$0f,$12,$0a,$12,$14,$12,$0f,$12,$14,$12,$0f,$12
.byte $0d,$12,$08,$12,$0d,$12,$08,$12,$12,$12,$0d,$12,$12,$12,$0d,$12
.byte $12,$12,$0d,$12,$12,$12,$0d,$12,$0d,$12,$08,$12,$0d,$12,$08,$12
.byte $ff
tune_WIN_v1:
.byte $25,$07,$29,$07,$2c,$07,$31,$15,$2c,$07,$31,$31
.byte $ff
tune_WIN_v2:
.byte $19,$07,$19,$07,$1d,$07,$20,$15,$1d,$07,$20,$31
.byte $ff
tune_LOSE_v1:
.byte $20,$1b,$1f,$1b,$1e,$1b,$1d,$51
.byte $ff
tune_LOSE_v2:
.byte $0d,$1b,$0c,$1b,$0b,$1b,$0a,$51
.byte $ff
src/gen/sprites.asm
// Generated by tools/gfx_gen.py - do not edit by hand
* = $2800 "Sprites"
sprites:
// DINO_R0
.byte $00,$0f,$c0,$00,$3f,$f4,$00,$15,$50,$00,$2a,$a0,$00,$aa,$a8,$00,$aa,$a8,$00,$a9,$54
.byte $00,$aa,$a0,$02,$a8,$00,$0a,$aa,$00,$2a,$aa,$a0,$aa,$96,$80,$aa,$95,$80,$2a,$95,$80
.byte $0a,$96,$80,$0a,$aa,$00,$0a,$aa,$00,$0a,$0a,$00,$0a,$0a,$00,$2a,$2a,$00,$00,$00,$00
.byte $00
// DOUT_R0
.byte $00,$30,$3c,$00,$40,$02,$00,$40,$0c,$00,$c0,$0c,$01,$03,$02,$01,$00,$02,$01,$00,$02
.byte $03,$00,$0c,$0c,$03,$f0,$30,$00,$f0,$c0,$00,$08,$00,$00,$30,$00,$00,$20,$c0,$00,$20
.byte $30,$00,$20,$10,$00,$c0,$10,$00,$80,$10,$f0,$80,$30,$b0,$80,$40,$c0,$80,$3f,$3f,$00
.byte $00
// DINO_R1
.byte $00,$0f,$c0,$00,$3f,$f4,$00,$15,$50,$00,$2a,$a0,$00,$aa,$a8,$00,$aa,$a8,$00,$a9,$54
.byte $00,$aa,$a0,$02,$a8,$00,$0a,$aa,$00,$2a,$aa,$a0,$aa,$96,$80,$aa,$95,$80,$2a,$95,$80
.byte $0a,$96,$80,$0a,$aa,$00,$0a,$aa,$00,$0a,$02,$80,$28,$02,$80,$28,$0a,$80,$00,$00,$00
.byte $00
// DOUT_R1
.byte $00,$30,$3c,$00,$40,$02,$00,$40,$0c,$00,$c0,$0c,$01,$03,$02,$01,$00,$02,$01,$00,$02
.byte $03,$00,$0c,$0c,$03,$f0,$30,$00,$f0,$c0,$00,$08,$00,$00,$30,$00,$00,$20,$c0,$00,$20
.byte $30,$00,$20,$10,$00,$c0,$10,$00,$c0,$30,$fc,$20,$43,$0c,$20,$42,$10,$20,$3c,$0f,$c0
.byte $00
// DINO_L0
.byte $03,$f0,$00,$1f,$fc,$00,$05,$54,$00,$0a,$a8,$00,$2a,$aa,$00,$2a,$aa,$00,$15,$6a,$00
.byte $0a,$aa,$00,$00,$2a,$80,$00,$aa,$a0,$0a,$aa,$a8,$02,$96,$aa,$02,$56,$aa,$02,$56,$a8
.byte $02,$96,$a0,$00,$aa,$a0,$00,$aa,$a0,$00,$a0,$a0,$00,$a0,$a0,$00,$a8,$a8,$00,$00,$00
.byte $00
// DOUT_L0
.byte $3c,$0c,$00,$40,$02,$00,$30,$02,$00,$30,$03,$00,$40,$c0,$80,$40,$00,$80,$40,$00,$80
.byte $30,$00,$c0,$0f,$c0,$30,$0f,$00,$0c,$10,$00,$03,$0c,$00,$00,$04,$00,$00,$04,$00,$03
.byte $04,$00,$0c,$03,$00,$08,$01,$00,$08,$01,$0f,$08,$01,$0d,$0c,$01,$03,$02,$00,$fc,$fc
.byte $00
// DINO_L1
.byte $03,$f0,$00,$1f,$fc,$00,$05,$54,$00,$0a,$a8,$00,$2a,$aa,$00,$2a,$aa,$00,$15,$6a,$00
.byte $0a,$aa,$00,$00,$2a,$80,$00,$aa,$a0,$0a,$aa,$a8,$02,$96,$aa,$02,$56,$aa,$02,$56,$a8
.byte $02,$96,$a0,$00,$aa,$a0,$00,$aa,$a0,$02,$80,$a0,$02,$80,$28,$02,$a0,$28,$00,$00,$00
.byte $00
// DOUT_L1
.byte $3c,$0c,$00,$40,$02,$00,$30,$02,$00,$30,$03,$00,$40,$c0,$80,$40,$00,$80,$40,$00,$80
.byte $30,$00,$c0,$0f,$c0,$30,$0f,$00,$0c,$10,$00,$03,$0c,$00,$00,$04,$00,$00,$04,$00,$03
.byte $04,$00,$0c,$03,$00,$08,$03,$00,$08,$04,$3f,$0c,$04,$30,$c2,$04,$08,$42,$03,$f0,$3c
.byte $00
// PRESENT
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$03,$00,$c0,$00,$c3,$00,$00,$3c,$00
.byte $0a,$be,$a0,$0a,$be,$a0,$0a,$be,$a0,$0f,$ff,$f0,$0a,$be,$a0,$0a,$be,$a0,$0a,$be,$a0
.byte $0a,$be,$a0,$0a,$be,$a0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00
src/gen/stamps.asm
// Generated by tools/gfx_gen.py - do not edit by hand
stampLo:
.byte <stamp_HOUSE,<stamp_WORKSHOP,<stamp_TREE,<stamp_SNOWMAN,<stamp_LAMP,<stamp_BIGDINO
stampHi:
.byte >stamp_HOUSE,>stamp_WORKSHOP,>stamp_TREE,>stamp_SNOWMAN,>stamp_LAMP,>stamp_BIGDINO
stamp_HOUSE: // 6 x 5
.byte 6,5
.byte $83,$84,$85,$86,$87,$88
.byte $89,$8a,$8a,$8a,$8a,$8b
.byte $8c,$8d,$8e,$8f,$8d,$90
.byte $8c,$8e,$91,$92,$8e,$90
.byte $93,$94,$95,$96,$94,$97
.byte $08,$08,$08,$08,$08,$08
.byte $08,$08,$08,$08,$08,$08
.byte $ff,$0f,$ff,$ff,$0f,$ff
.byte $ff,$ff,$08,$08,$ff,$ff
.byte $ff,$ff,$08,$0f,$ff,$ff
stamp_WORKSHOP: // 10 x 6
.byte 10,6
.byte $98,$99,$9a,$9b,$9c,$9d,$9e,$9f,$a0,$a1
.byte $89,$8a,$8a,$8a,$8a,$8a,$8a,$8a,$8a,$8b
.byte $8c,$17,$0f,$12,$0b,$13,$08,$0f,$10,$a2
.byte $8c,$8d,$8d,$8f,$8e,$8e,$8f,$8d,$8d,$a2
.byte $8c,$8e,$8e,$8f,$91,$92,$8f,$8e,$8e,$a2
.byte $93,$94,$94,$a3,$95,$96,$a3,$94,$94,$a4
.byte $08,$08,$08,$08,$08,$08,$08,$08,$08,$08
.byte $08,$08,$08,$08,$08,$08,$08,$08,$08,$08
.byte $ff,$02,$02,$02,$02,$02,$02,$02,$02,$ff
.byte $ff,$0f,$0f,$ff,$ff,$ff,$ff,$0f,$0f,$ff
.byte $ff,$ff,$ff,$ff,$08,$08,$ff,$ff,$ff,$ff
.byte $ff,$ff,$ff,$ff,$08,$0f,$ff,$ff,$ff,$ff
stamp_TREE: // 3 x 4
.byte 3,4
.byte $a5,$a6,$a7
.byte $a8,$a9,$aa
.byte $ab,$ac,$ad
.byte $ae,$af,$b0
.byte $0f,$0f,$0f
.byte $0d,$0d,$0d
.byte $0d,$0d,$0d
.byte $0d,$0d,$0d
stamp_SNOWMAN: // 2 x 3
.byte 2,3
.byte $b1,$b2
.byte $b3,$b4
.byte $b5,$b6
.byte $08,$08
.byte $08,$08
.byte $08,$08
stamp_LAMP: // 1 x 3
.byte 1,3
.byte $b7
.byte $b8
.byte $b9
.byte $0f
.byte $08
.byte $08
stamp_BIGDINO: // 10 x 9
.byte 10,9
.byte $00,$00,$00,$00,$ba,$bb,$bb,$bc,$bd,$00
.byte $00,$00,$00,$be,$bf,$c0,$c0,$c0,$c1,$00
.byte $00,$00,$00,$c2,$8e,$c3,$c4,$c5,$c6,$00
.byte $00,$c7,$c8,$c9,$8e,$ca,$cb,$cc,$cd,$00
.byte $ce,$cf,$8e,$8e,$d0,$d1,$d2,$d3,$d4,$00
.byte $d5,$d6,$8e,$8e,$d7,$d8,$d9,$da,$00,$00
.byte $00,$db,$8e,$dc,$dd,$de,$df,$e0,$00,$00
.byte $00,$e1,$8e,$e2,$e1,$8e,$e2,$00,$00,$00
.byte $00,$e3,$e4,$e5,$e3,$e4,$e5,$00,$00,$00
.byte $00,$00,$00,$00,$08,$08,$08,$08,$08,$00
.byte $00,$00,$00,$08,$0d,$0d,$0d,$0d,$08,$00
.byte $00,$00,$00,$0d,$0d,$0d,$0d,$0d,$0d,$00
.byte $00,$08,$0d,$0d,$0d,$0d,$0d,$0d,$08,$00
.byte $0d,$0d,$0d,$0d,$0d,$0d,$0d,$0d,$08,$00
.byte $0d,$0d,$0d,$0d,$0d,$0d,$0d,$0d,$00,$00
.byte $00,$08,$0d,$0d,$0d,$0d,$0d,$0d,$00,$00
.byte $00,$0d,$0d,$0d,$0d,$0d,$0d,$00,$00,$00
.byte $00,$08,$08,$08,$08,$08,$08,$00,$00,$00
src/gen/tables.asm
// Generated by tools/gfx_gen.py - do not edit by hand
rowLo:
.byte $00,$28,$50,$78,$a0,$c8,$f0,$18,$40,$68,$90,$b8,$e0,$08,$30,$58,$80,$a8,$d0,$f8,$20,$48,$70,$98,$c0
rowHi:
.byte $04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$06,$06,$06,$06,$06,$06,$06,$07,$07,$07,$07,$07
src/main.asm
// ===========================================================================
// DINO CHRISTMAS VILLAGE
// Commodore 64 - KickAssembler source
//
// Build: java -jar KickAss.jar src/main.asm -o build/dinoxmas.prg
//
// Memory map
// $0002-$008f zero page variables
// $0400-$07e7 screen $07f8-$07ff sprite pointers
// $0801-$1fff BASIC stub + program code
// $2000-$27ff character set (VIC bank 0, $d018 = $18)
// $2800-$2a7f sprites (pointers $a0-$a9)
// $3000- text, level data, map stamps, music data, tables
//
// Runs with BASIC/KERNAL ROM left in place ($01 = $37) but never calls
// them. Interrupts are disabled for the whole game; timing comes from
// polling the raster line, so PAL and NTSC machines both work (the timer
// uses 50 or 60 frames per second depending on the detected system).
// ===========================================================================
#import "gen/consts.asm"
// ---------------------------------------------------------------- hardware
.const SCREEN = $0400
.const SPRPTR = $07f8
.const COLRAM = $d800
.const VIC = $d000
.const SID = $d400
.const CIA1_PRA = $dc00
.const CIA1_DDRA = $dc02
// ---------------------------------------------------------------- zero page
.const zpPtr = $02 // 2 bytes general screen pointer
.const zpSrc = $04 // 2 bytes data pointer
.const zpCol = $06 // 2 bytes colour RAM pointer
.const tmp0 = $08
.const tmp1 = $09
.const tmp2 = $0a
.const tmp3 = $0b
.const tmp4 = $0c
.const tmp5 = $0d
.const tmp6 = $0e
.const tmp7 = $0f
.const frame = $10
.const joy = $11 // active high: 1 up 2 down 4 left 8 right 16 fire
.const joyPrev = $12
.const firePress = $13
.const isNtsc = $14
.const secFrames = $15
.const secCount = $16
.const level = $17
.const score0 = $18 // BCD, lowest two digits
.const score1 = $19
.const score2 = $1a
.const timeLo = $1b // BCD seconds, tens and units
.const timeHi = $1c // BCD seconds, hundreds
.const delivered = $1d
.const total = $1e
.const nextSpawn = $1f
.const carrying = $20 // $ff = nothing, else present slot
.const dinoXLo = $21
.const dinoXHi = $22
.const dinoY = $23
.const facing = $24 // 0 right, 1 left
.const animCnt = $25
.const animFrame = $26
.const moving = $27
.const numHouses = $28
.const rnd = $29
.const chkXLo = $2a
.const chkXHi = $2b
.const chkY = $2c
.const objCol = $2d
.const stampW = $2e
.const stampH = $2f
.const pState = $30 // 6 present slots: 0 off, 1 on ground, 2 carried
.const pXLo = $36
.const pXHi = $3c
.const pY = $42
.const pColr = $48
.const hCol = $50 // 5 houses
.const hRow = $55
.const hNeed = $5a
.const mPtr = $60 // music pointers voice1 $60/61, voice2 $62/63
.const mCnt = $64 // stride 2: $64 voice1, $66 voice2
.const mWave = $68 // stride 2: $68, $6a
.const mStart = $6c // 4 bytes: loop start pointers
.const mOn = $70
.const mTune = $71
.const sPtr = $72 // sfx pointer
.const sOn = $74
.const presPtr = $75 // 2 bytes, current level present list
.const cellRow = $77
.const cellCol = $78
.const srcIdx = $79
.const stampN = $7a
.const blinkCnt = $7b
.const titleDir = $7c
// ---------------------------------------------------------------- game constants
.const XMIN = 20
.const XMAX = 324
.const YMIN = 52
.const YMAX = 228
.const SPEED = 2
.const MAX_SLOTS = 6
// sound effect numbers
.const SFX_PICKUP = 0
.const SFX_DELIVER = 1
.const SFX_TICK = 2
.const SFX_BUZZ = 3
.const SFX_SPAWN = 4
.const SFX_BONUS = 5
.encoding "screencode_upper"
BasicUpstart2(start)
// ===========================================================================
// Entry point
// ===========================================================================
start:
sei
cld
ldx #$ff
txs
lda #$7f // switch off all CIA interrupt sources
sta $dc0d
sta $dd0d
lda $dc0d
lda $dd0d
lda #$00
sta $d01a // no VIC interrupts
lda #$ff
sta $d019
lda #<nmiHandler // RESTORE key does nothing
sta $0318
lda #>nmiHandler
sta $0319
lda #$00
sta CIA1_DDRA // port A as input: clean joystick 2 reads
sta $dc03
jsr detectSystem
jsr sidInit
jsr vicInit
lda #$00
sta joy
sta joyPrev
jmp titleScreen
nmiHandler:
rti
// ---------------------------------------------------------------------------
// detectSystem - find the last raster line: PAL $137, NTSC $105/$106
// ---------------------------------------------------------------------------
detectSystem:
ds1: lda $d012
ds2: cmp $d012
beq ds2
bmi ds1
cmp #$20
bcc dsNtsc
lda #0
sta isNtsc
lda #50
sta secFrames
ldx #59
dsPal: lda freqPalLo,x
sta freqLo,x
lda freqPalHi,x
sta freqHi,x
dex
bpl dsPal
rts
dsNtsc: lda #1
sta isNtsc
lda #60
sta secFrames
ldx #59
dsN1: lda freqNtscLo,x
sta freqLo,x
lda freqNtscHi,x
sta freqHi,x
dex
bpl dsN1
rts
// ---------------------------------------------------------------------------
vicInit:
lda $dd02
ora #$03
sta $dd02
lda $dd00
ora #$03 // VIC bank 0 ($0000-$3fff)
sta $dd00
lda #$06
sta $d020
lda #$01 // white snow
sta $d021
lda #$02 // shared multicolour 1: red
sta $d022
lda #$00 // shared multicolour 2: black
sta $d023
lda #$1b
sta $d011
lda #$18 // multicolour text, 40 columns
sta $d016
lda #$18 // screen $0400, charset $2000
sta $d018
lda #$00
sta $d015
sta $d017
sta $d01d
sta $d01b
lda #%11111110 // sprite 0 = hires outline, rest multicolour
sta $d01c
lda #$01
sta $d025
lda #$02
sta $d026
lda #$00
sta $d027
lda #$05
sta $d028
rts
// ---------------------------------------------------------------------------
// waitFrame - returns once per frame at raster line 251 (below playfield)
// ---------------------------------------------------------------------------
waitFrame:
wf1: lda $d012
cmp #251
beq wf1
wf2: lda $d012
cmp #251
bne wf2
lda $d011
bmi wf2
inc frame
rts
// ---------------------------------------------------------------------------
// readJoy - joystick port 2
// ---------------------------------------------------------------------------
readJoy:
lda joy
sta joyPrev
lda CIA1_PRA
eor #$ff
and #$1f
sta joy
and #$10
beq rjNo
lda joyPrev
and #$10
bne rjNo
lda #1
sta firePress
rts
rjNo: lda #0
sta firePress
rts
// ---------------------------------------------------------------------------
// rand - 8 bit LFSR
// ---------------------------------------------------------------------------
rand: lda rnd
asl
bcc rnd1
eor #$1d
rnd1: sta rnd
rts
// ===========================================================================
// Title screen
// ===========================================================================
titleScreen:
jsr drawTitle
lda #TUNE_TITLE
jsr musicStart
jsr waitRelease
tLoop: jsr waitFrame
jsr titleSprites
jsr readJoy
jsr soundUpdate
jsr titleAnim
lda firePress
beq tLoop
// ===========================================================================
// New game
// ===========================================================================
lda #0
sta level
sta score0
sta score1
sta score2
newLevel:
jsr initLevel
lda #TUNE_GAME
jsr musicStart
jsr waitRelease
gLoop: jsr waitFrame
jsr setSprites
jsr readJoy
jsr movePlayer
jsr handleFire
jsr updateTimer
jsr drawHud
jsr soundUpdate
lda delivered
cmp total
beq levelDone
lda timeLo
ora timeHi
bne gLoop
jsr gameOverScreen
jmp titleScreen
levelDone:
jsr setSprites
jsr levelComplete
inc level
lda level
cmp #NUM_LEVELS
bcs allDone
jmp newLevel
allDone:
jsr victoryScreen
jmp titleScreen
// ---------------------------------------------------------------------------
// waitRelease - wait until fire is released (keeps the sound running)
// ---------------------------------------------------------------------------
waitRelease:
wr1: jsr waitFrame
jsr soundUpdate
jsr readJoy
lda joy
and #$10
bne wr1
lda #0
sta firePress
rts
// ---------------------------------------------------------------------------
// waitFire - ignore fire for ~1 second, then wait for a fresh press
// ---------------------------------------------------------------------------
waitFire:
lda #50
sta blinkCnt
wfa: jsr waitFrame
jsr soundUpdate
jsr readJoy
dec blinkCnt
bne wfa
jsr waitRelease
wfb: jsr waitFrame
jsr soundUpdate
jsr readJoy
lda firePress
beq wfb
rts
#import "game.asm"
#import "screens.asm"
#import "sound.asm"
// ===========================================================================
// Data
// ===========================================================================
* = $3000 "Data"
#import "text.asm"
#import "gen/tables.asm"
#import "gen/stamps.asm"
#import "gen/levels.asm"
#import "gen/sound_data.asm"
freqLo: .fill 60, 0
freqHi: .fill 60, 0
#import "gen/charset.asm"
#import "gen/sprites.asm"
src/screens.asm
// ===========================================================================
// screens.asm - title, level complete, game over, victory
// ===========================================================================
// ---------------------------------------------------------------------------
// drawTitle
// ---------------------------------------------------------------------------
drawTitle:
lda #0
sta $d015
jsr clearScreen
lda #$a5
sta rnd
lda #70
jsr sprinkleSnow
ldx #39 // garland rows 0 and 3, drifts on row 14
dt1: lda #CH_GARLAND
sta SCREEN,x
sta SCREEN+3*40,x
lda #COL_GARLAND
sta COLRAM,x
sta COLRAM+3*40,x
lda #CH_SNOW3
sta SCREEN+14*40,x
lda #COL_SNOW3
sta COLRAM+14*40,x
lda #32
sta SCREEN+1*40,x
sta SCREEN+2*40,x
sta SCREEN+15*40,x
sta SCREEN+16*40,x
sta SCREEN+17*40,x
sta SCREEN+18*40,x
sta SCREEN+19*40,x
sta SCREEN+20*40,x
sta SCREEN+21*40,x
sta SCREEN+22*40,x
sta SCREEN+23*40,x
sta SCREEN+24*40,x
dex
bpl dt1
lda #<titleObjects
sta tmp2
lda #>titleObjects
sta tmp3
jsr drawObjects
ldx #0
dt2: lda titleTexts,x
ldy titleTexts+1,x
beq dt3
stx tmp0
tax
jsr printText
ldx tmp0
inx
inx
jmp dt2
dt3: lda #XMIN+10
sta dinoXLo
lda #0
sta dinoXHi
sta facing
sta titleDir
sta animFrame
sta animCnt
lda #157
sta dinoY
rts
titleObjects:
.byte ST_BIGDINO, 1, 5, 13
.byte ST_WORKSHOP, 13, 8, 13
.byte ST_HOUSE, 25, 9, 10
.byte ST_TREE, 32, 10, 8
.byte ST_TREE, 36, 10, 8
.byte ST_LAMP, 31, 11, 8
.byte ST_SNOWMAN, 23, 11, 8
.byte $ff
titleTexts:
.word txtTitle, txtPress, txtHelp1, txtHelp2, txtHelp3, txtJoy, txtMerry, 0
// ---------------------------------------------------------------------------
// titleAnim - flashing "PRESS FIRE" and a dinosaur strolling along
// ---------------------------------------------------------------------------
titleAnim:
lda frame
lsr
lsr
lsr
and #$07
tax
lda flashCols,x
ldx #18
ta1: sta COLRAM+16*40+11,x
dex
bpl ta1
// walk
lda titleDir
bne taLeft
lda #0
sta facing
inc dinoXLo
bne taR1
inc dinoXHi
taR1: lda dinoXHi
beq taAn
lda dinoXLo
cmp #<XMAX
bcc taAn
lda #1
sta titleDir
jmp taAn
taLeft: lda #1
sta facing
lda dinoXLo
bne taL1
dec dinoXHi
taL1: dec dinoXLo
lda dinoXHi
bne taAn
lda dinoXLo
cmp #XMIN
bcs taAn
lda #0
sta titleDir
taAn: lda #1
sta moving
inc animCnt
lda animCnt
cmp #8
bcc taDone
lda #0
sta animCnt
lda animFrame
eor #1
sta animFrame
taDone: rts
flashCols: .byte 2, 2, 8, 7, 5, 5, 6, 4
// titleSprites - only the strolling dinosaur
titleSprites:
lda #0
ldx #MAX_SLOTS-1
tsp1: sta pState,x
dex
bpl tsp1
jmp setSprites
// ---------------------------------------------------------------------------
// drawBox - clears rows 7..17, columns 5..34 and frames them with garland
// ---------------------------------------------------------------------------
drawBox:
lda #7
sta cellRow
db1: lda #5
sta cellCol
jsr setCell
ldy #29
lda cellRow
cmp #7
beq dbG
cmp #17
beq dbG
db2: lda #32
sta (zpPtr),y
lda #0
sta (zpCol),y
dey
bpl db2
jmp db3
dbG: lda #CH_GARLAND
sta (zpPtr),y
lda #COL_GARLAND
sta (zpCol),y
dey
bpl dbG
db3: inc cellRow
lda cellRow
cmp #18
bne db1
rts
// hidePresents - clear the present slots and switch all sprites off
hidePresents:
lda #0
ldx #MAX_SLOTS-1
hp1: sta pState,x
dex
bpl hp1
lda #$ff
sta carrying
jsr waitFrame
lda #0
sta $d015
rts
// ---------------------------------------------------------------------------
// levelComplete - MERRY CHRISTMAS!, time bonus count-down, level bonus
// ---------------------------------------------------------------------------
levelComplete:
jsr hidePresents
lda #TUNE_WIN
jsr musicStart
jsr drawBox
ldx #<txtMerry2
ldy #>txtMerry2
jsr printText
ldx #<txtLvDone
ldy #>txtLvDone
jsr printText
lda level
clc
adc #$31
sta SCREEN+11*40+20
ldx #<txtTimeBonus
ldy #>txtTimeBonus
jsr printText
ldx #<txtLvBonus
ldy #>txtLvBonus
jsr printText
ldx #<txtScoreBox
ldy #>txtScoreBox
jsr printText
lda #40 // let the fanfare start
sta blinkCnt
lc0: jsr waitFrame
jsr soundUpdate
dec blinkCnt
bne lc0
// remaining seconds x 10, counted down
lc1: lda timeLo
ora timeHi
beq lc2
jsr waitFrame
jsr decTime
lda #$10
sta tmp0
lda #$00
sta tmp1
jsr addScore
lda frame
and #$01
bne lc1b
lda #SFX_BONUS
jsr sfxPlay
lc1b: jsr soundUpdate
jsr drawHud
jsr printScoreBox
jmp lc1
lc2: // level bonus 1000
lda #$00
sta tmp0
lda #$10
sta tmp1
jsr addScore
lda #SFX_DELIVER
jsr sfxPlay
jsr drawHud
ldx #<txtLvBonus2
ldy #>txtLvBonus2
jsr printText
jsr printScoreBoxAll
ldx #<txtContinue
ldy #>txtContinue
jsr printText
jsr waitFire
rts
// printScoreBox - score digits into the box line (row 15, column 22)
printScoreBoxAll:
printScoreBox:
lda score2
jsr boxBcd
lda score1
jsr boxBcd2
lda score0
jmp boxBcd3
boxBcd: ldx #0
jmp boxW
boxBcd2:
ldx #2
jmp boxW
boxBcd3:
ldx #4
boxW: pha
lsr
lsr
lsr
lsr
ora #$30
sta SCREEN+15*40+22,x
pla
and #$0f
ora #$30
sta SCREEN+15*40+23,x
rts
// ---------------------------------------------------------------------------
// gameOverScreen
// ---------------------------------------------------------------------------
gameOverScreen:
jsr hidePresents
lda #TUNE_LOSE
jsr musicStart
jsr drawBox
ldx #<txtGameOver
ldy #>txtGameOver
jsr printText
ldx #<txtTimesUp
ldy #>txtTimesUp
jsr printText
ldx #<txtScoreBox
ldy #>txtScoreBox
jsr printText
jsr printScoreBoxAll
ldx #<txtRestart
ldy #>txtRestart
jsr printText
jsr waitFire
rts
// ---------------------------------------------------------------------------
// victoryScreen - after the last level
// ---------------------------------------------------------------------------
victoryScreen:
jsr hidePresents
lda #TUNE_TITLE
jsr musicStart
jsr drawBox
ldx #<txtMerry2
ldy #>txtMerry2
jsr printText
ldx #<txtAllDone1
ldy #>txtAllDone1
jsr printText
ldx #<txtAllDone2
ldy #>txtAllDone2
jsr printText
ldx #<txtScoreBox
ldy #>txtScoreBox
jsr printText
jsr printScoreBoxAll
ldx #<txtRestart
ldy #>txtRestart
jsr printText
jsr waitFire
rts
src/sound.asm
// ===========================================================================
// sound.asm - SID music (voices 1+2) and sound effects (voice 3)
// ===========================================================================
sidInit:
lda #0
ldx #$18
si1: sta SID,x
dex
bpl si1
lda #$00 // pulse width 50% on all voices
sta SID+$02
sta SID+$09
sta SID+$10
lda #$08
sta SID+$03
sta SID+$0a
sta SID+$11
lda #$00 // voice 3: instant attack, full sustain
sta SID+$13
lda #$f3
sta SID+$14
lda #$0f
sta SID+$18
lda #0
sta mOn
sta sOn
rts
soundUpdate:
jsr musicUpdate
jmp sfxUpdate
// ---------------------------------------------------------------------------
// musicStart - A = tune number
// ---------------------------------------------------------------------------
musicStart:
sta mTune
tax
lda #0
sta mOn
lda tuneV1Lo,x
sta mPtr
sta mStart
lda tuneV1Hi,x
sta mPtr+1
sta mStart+1
lda tuneV2Lo,x
sta mPtr+2
sta mStart+2
lda tuneV2Hi,x
sta mPtr+3
sta mStart+3
lda tuneWave1,x
sta mWave
and #$fe
sta SID+$04
lda tuneWave2,x
sta mWave+2
and #$fe
sta SID+$0b
lda tuneAd1,x
sta SID+$05
lda tuneSr1,x
sta SID+$06
lda tuneAd2,x
sta SID+$0c
lda tuneSr2,x
sta SID+$0d
lda #2
sta mCnt
sta mCnt+2
lda #1
sta mOn
rts
musicStop:
lda #0
sta mOn
lda mWave
and #$fe
sta SID+$04
lda mWave+2
and #$fe
sta SID+$0b
rts
musicUpdate:
lda mOn
beq muDone
ldx #0
jsr voiceUpdate
lda mOn
beq muDone
ldx #2
jsr voiceUpdate
muDone: rts
// voiceUpdate - X = 0 (voice 1) or 2 (voice 2)
voiceUpdate:
ldy sidOff,x
dec mCnt,x
lda mCnt,x
cmp #1
bne vu1
lda mWave,x // release one frame before the next note
and #$fe
sta SID+$04,y
rts
vu1: cmp #0
beq vuFetch
rts
vuFetch:
lda (mPtr,x)
cmp #$ff
bne vuNote
ldy mTune // end of tune
lda tuneLoop,y
beq vuStop
lda mStart,x
sta mPtr,x
lda mStart+1,x
sta mPtr+1,x
ldy sidOff,x
jmp vuFetch
vuStop: jmp musicStop
vuNote: sta tmp7
inc mPtr,x
bne vu2
inc mPtr+1,x
vu2: lda (mPtr,x)
sta mCnt,x
inc mPtr,x
bne vu3
inc mPtr+1,x
vu3: lda tmp7
beq vuRest
stx tmp6
tax
lda freqLo-1,x
sta SID+$00,y
lda freqHi-1,x
sta SID+$01,y
ldx tmp6
lda mWave,x
sta SID+$04,y
rts
vuRest: lda mWave,x
and #$fe
sta SID+$04,y
rts
sidOff: .byte 0, 0, 7
// ---------------------------------------------------------------------------
// sfxPlay - A = effect number (voice 3)
// ---------------------------------------------------------------------------
sfxPlay:
tax
lda sfxLo,x
sta sPtr
lda sfxHi,x
sta sPtr+1
lda #1
sta sOn
rts
sfxUpdate:
lda sOn
beq sfDone
ldy #0
lda (sPtr),y
beq sfEnd
sta SID+$0f
lda #0
sta SID+$0e
iny
lda (sPtr),y
sta SID+$12
lda sPtr
clc
adc #2
sta sPtr
bcc sfDone
inc sPtr+1
sfDone: rts
sfEnd: lda #0
sta SID+$12
sta sOn
rts
sfxLo: .byte <sfxPickup, <sfxDeliver, <sfxTick, <sfxBuzz, <sfxSpawn, <sfxBonus
sfxHi: .byte >sfxPickup, >sfxDeliver, >sfxTick, >sfxBuzz, >sfxSpawn, >sfxBonus
// frequency high byte, waveform control ... 0
sfxPickup: .byte $10,$11, $14,$11, $18,$11, $1c,$11, $20,$11, $28,$11, $30,$11, $38,$11, $40,$11, 0
sfxDeliver: .byte $22,$41, $22,$41, $22,$41, $2b,$41, $2b,$41, $2b,$41
.byte $33,$41, $33,$41, $33,$41, $45,$41, $45,$41, $45,$41, $45,$41, $45,$41, $45,$41, 0
sfxTick: .byte $50,$81, $30,$81, 0
sfxBuzz: .byte $05,$21, $05,$21, $04,$21, $04,$21, $03,$21, $03,$21, 0
sfxSpawn: .byte $50,$11, $60,$11, $50,$11, $60,$11, 0
sfxBonus: .byte $38,$11, $40,$11, 0
src/text.asm
// ===========================================================================
// text.asm - all on-screen text. Format: column, row, colour, text, 0
// Colours below 8 are hires characters (the multicolour charset keeps
// text crisp that way).
// ===========================================================================
txtHud: .byte 0, 0, 6
.text "SCORE 000000 TIME 000 DELIVERED 00/00"
.byte 0
txtLevel: .byte 15, 1, 0
.text " LEVEL 1 "
.byte 0
// ---- title -----------------------------------------------------------------
txtTitle: .byte 9, 1, 2
.text "DINO CHRISTMAS VILLAGE"
.byte 0
txtPress: .byte 11, 16, 2
.text "PRESS FIRE TO START"
.byte 0
txtHelp1: .byte 1, 18, 6
.text "COLLECT PRESENTS AROUND THE VILLAGE"
.byte 0
txtHelp2: .byte 1, 19, 6
.text "AND DELIVER THEM TO THE HOUSES BEFORE"
.byte 0
txtHelp3: .byte 1, 20, 6
.text "THE TIME RUNS OUT!"
.byte 0
txtJoy: .byte 0, 22, 0
.text "JOYSTICK PORT 2 - FIRE: PICK UP/DELIVER"
.byte 0
txtMerry: .byte 5, 24, 5
.text "MERRY CHRISTMAS FROM THE DINOS!"
.byte 0
// ---- level complete / game over / victory boxes ----------------------------
txtMerry2: .byte 12, 9, 2
.text "MERRY CHRISTMAS!"
.byte 0
txtLvDone: .byte 14, 11, 5
.text "LEVEL 1 COMPLETE"
.byte 0
txtTimeBonus: .byte 7, 12, 0
.text "TIME BONUS SECONDS X 10"
.byte 0
txtLvBonus: .byte 7, 13, 0
.text "LEVEL BONUS"
.byte 0
txtLvBonus2: .byte 7, 13, 0
.text "LEVEL BONUS 1000"
.byte 0
txtScoreBox: .byte 7, 15, 6
.text "SCORE 000000"
.byte 0
txtContinue: .byte 7, 16, 2
.text "PRESS FIRE TO CONTINUE"
.byte 0
txtGameOver: .byte 15, 9, 2
.text "GAME OVER"
.byte 0
txtTimesUp: .byte 10, 11, 0
.text "THE CLOCK RAN OUT..."
.byte 0
txtRestart: .byte 8, 16, 2
.text "PRESS FIRE TO PLAY AGAIN"
.byte 0
txtAllDone1: .byte 8, 11, 5
.text "EVERY PRESENT DELIVERED!"
.byte 0
txtAllDone2: .byte 8, 12, 0
.text "YOU SAVED CHRISTMAS, DINO!"
.byte 0