Programming the Commodore 64 again: Create a game step by step by Thomsen Jens Christian Ingvartsen

Programming the Commodore 64 again: Create a game step by step by Thomsen Jens Christian Ingvartsen

Author:Thomsen, Jens Christian Ingvartsen [Thomsen, Jens Christian Ingvartsen]
Language: eng
Format: epub, pdf
Published: 2021-01-16T00:00:00+00:00


#region Increment score

;**************************************************************************

;** Increment score

;**************************************************************************

IncrementScore

sed ​ ​ ;** Set decimal mode

clc ​ ​ ;** Clear carry flag

lda Score ​ ;** Load from score variable

adc #1 ​ ;** Add with carry value 1

sta Score ​ ;** Store in score variable

lda Score+1 ​ ;** Load from score variable + 1

adc #0 ​ ;** Add with carry value 0

sta Score+1 ​ ;** Store in score variable + 1

lda Score+2 ​ ;** Load from score variable + 2

adc #0 ​ ;** Add with carry value 0

sta Score+2 ​ ;** Store in score variable + 2

cld ​ ​ ;** Clear decimal mode

rts ​ ​ ;** Return

#endregion

#region Display lives

;**************************************************************************

;** Display lives

;**************************************************************************

DisplayLives

lda Lives ​ ;** Load from lives variable

sta Lives_Score ​ ;** Store in lives score variable

rts ​ ​ ;** Return

#endregion

#region Decrement lives

;**************************************************************************

;** Decrement lives

;************************************************************ **************

DecrementLives

ldx Lives ​ ;** Load from lives variable

dex ​ ​ ;** Decrement x register value with 1

stx Lives ​ ;** Store in lives variable

rts ​ ​ ;** Return

#endregion

#region Play explosion animation

;***************************************

;** Play explosion animation

;***************************************

PlayExplosionAnimation

ldx ExplosionIndex ​ ;** Load from explosion index variable

inx ​ ​ ;** Increment x register with 1

stx ExplosionIndex ​ ;** Store in explosion index variable

cpx #$8F ​ ;** Compare with value $8F

bne @continueExplosion ​ ;** Branch if not equal to @continueExplosion label

ldx #0 ​ ​ ;** Load value 0

stx ExplosionPlaying ​ ;** Store in explosion playing variable

stx SP2X ​ ;** Store in sprite 2 x position address

stx SP2Y ​ ;** Store in sprite 2 y position address

ldx #$8A ​ ;** Load value $8A

stx ExplosionIndex ​ ;** Store in explosion index variable

@continueExplosion

jsr SetCurrentExplosionSprite ​ ;** Gosub to set current explosion sprite

rts ​ ​ ;** Return

#endregion

#region Set current explosion sprite

;***************************************

;** Set current explosion sprite

;***************************************

SetCurrentExplosionSprite

PointToSpriteData ExplosionIndex, SSDP2 ;** Set current explosion sprite

rts ​ ​ ;** Return

#endregion

#region Set current portal sprite

;***************************************

;** Set current portal sprite

;***************************************

SetCurrentPortalSprite

PointToSpriteData PortalIndex, SSDP3 ;** Set current portal sprite

rts ​ ​ ;** Return

#endregion

#region Wait for explosion

;***************************************

;** Wait for explosion

;***************************************

WaitForExplosion

ldx #25 ​ ;** Load value 25

@waitExplosion1

ldy #255 ​ ;** Load value 255

@waitExplosion2

dey ​ ​ ;** Decrement y register with value 1

cpy #0 ​ ;** Compare with value 0

bne @waitExplosion2 ​ ;** Branch if not equal to @waitExplosion2 label

dex ​ ​ ;** Decrement x register with value 1

cpx #0 ​ ;** Compare with value 0

bne @waitExplosion1 ​ ;** Branch if not equal to @waitExplosion1 label

rts ​ ​ ;** Return

#endregion

#region Play explosion sound

;***************************************

;** Play explosion sound

;***************************************

PlayExplosionSound

lda #15 ​ ;** Load value 15

sta SIGVOL ​ ;** Store in volume register

lda #0 ​ ​ ;** Load value 0

sta FRELO1 ​ ;** Store in frequency low byte register

lda #30 ​ ;** Load value 30

sta FREHI1 ​ ;** Store in frequency hi byte register

lda #12 ​ ;** Load value 12

sta ATDCY1 ​ ;** Store in attack/decay register

lda #5 ​ ​ ;** Load value 5

sta SURELI ​ ;** Store in sustain/release register

lda #0 ​ ​ ;** Load value 0

sta VCREG1 ​ ;** Store in pulse waveform register

lda #129 ​ ;** Load value 129

sta VCREG1 ​ ;** Store in pulse waveform register

rts ​ ​ ;** Return

#endregion



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(56008)
What's Done in Darkness by Kayla Perrin(26587)
The Fifty Shades Trilogy & Grey by E L James(19076)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19055)
Shot Through the Heart by Mercy Celeste(18933)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(17107)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(16979)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(16868)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16815)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16440)
The Subtle Art of Not Giving a F*ck by Mark Manson(14350)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14127)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13613)
Scorched Earth by Nick Kyme(12765)
Drei Generationen auf dem Jakobsweg by Stein Pia(10961)
Suna by Ziefle Pia(10886)
Scythe by Neal Shusterman(10333)
International Relations from the Global South; Worlds of Difference; First Edition by Arlene B. Tickner & Karen Smith(9518)
Successful Proposal Strategies for Small Businesses: Using Knowledge Management ot Win Govenment, Private Sector, and International Contracts 3rd Edition by Robert Frey(9364)
This is Going to Hurt by Adam Kay(9171)