refactoring: reorganize syntax sugar for segments handling
This commit is contained in:
parent
f67017c9a6
commit
db8707bebf
6
Makefile
6
Makefile
@ -8,7 +8,7 @@ RES=res.bin/amour2.sid res.bin/levels.bin res.bin/unlzg.bin
|
|||||||
all: bin/snake6502.bin bin/snake6502.d64
|
all: bin/snake6502.bin bin/snake6502.d64
|
||||||
|
|
||||||
bin/snake6502.bin: bin/snake.pack.lz
|
bin/snake6502.bin: bin/snake.pack.lz
|
||||||
dasm src/cart.asm -Isrc/ -DVERBOSE=$(VERBOSE) -f3 -sbuild/cart.symbols.txt -obin/snake6502.bin
|
dasm src/cart.asm -Isrc/ -DVERBOSE=$(VERBOSE) -f3 -T1 -sbuild/cart.symbols.txt -obin/snake6502.bin
|
||||||
|
|
||||||
bin/snake6502.d64: bin/loader.prg
|
bin/snake6502.d64: bin/loader.prg
|
||||||
c1541 -format "snake6502,01" d64 bin/snake6502.d64
|
c1541 -format "snake6502,01" d64 bin/snake6502.d64
|
||||||
@ -19,10 +19,10 @@ bin/loader.prg: bin/snake.pack.lz.prg
|
|||||||
dasm src/loader.asm -Isrc/ -DVERBOSE=$(VERBOSE) -f1 -sbuild/loader.sybols.txt -obin/loader.prg
|
dasm src/loader.asm -Isrc/ -DVERBOSE=$(VERBOSE) -f1 -sbuild/loader.sybols.txt -obin/loader.prg
|
||||||
|
|
||||||
bin/snake.prg: bin/snake.pack
|
bin/snake.prg: bin/snake.pack
|
||||||
dasm src/prg.asm -Isrc/ -DVERBOSE=$(VERBOSE) -f1 -sbuild/prg.symbols.txt -obin/snake.prg
|
dasm src/prg.asm -Isrc/ -DVERBOSE=$(VERBOSE) -f1 -T1 -sbuild/prg.symbols.txt -obin/snake.prg
|
||||||
|
|
||||||
bin/snake.pack: env $(ASM) $(RES) bin/explodefont
|
bin/snake.pack: env $(ASM) $(RES) bin/explodefont
|
||||||
dasm src/main.asm -Isrc/ -DSYSTEM=64 -DDEBUG=$(DEBUG) -DVERBOSE=$(VERBOSE) -f3 -sbuild/pack.symbols.txt -obin/snake.pack
|
dasm src/main.asm -Isrc/ -DSYSTEM=64 -DDEBUG=$(DEBUG) -DVERBOSE=$(VERBOSE) -f3 -T1 -sbuild/pack.symbols.txt -obin/snake.pack
|
||||||
|
|
||||||
bin/snake.pack.lz: bin/snake.pack liblzg/src/tools/lzg
|
bin/snake.pack.lz: bin/snake.pack liblzg/src/tools/lzg
|
||||||
liblzg/src/tools/lzg bin/snake.pack > bin/snake.pack.lz
|
liblzg/src/tools/lzg bin/snake.pack > bin/snake.pack.lz
|
||||||
|
13
src/data.asm
13
src/data.asm
@ -1,9 +1,4 @@
|
|||||||
#if VERBOSE = 1
|
SEG.U dataSegment
|
||||||
LASTINIT SET .
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; Data section - Not initialized variables ($CD00 - $CDFF)
|
|
||||||
; ----------------------------------------------------------------------
|
|
||||||
; Number of interrupt
|
; Number of interrupt
|
||||||
; Used as counter to be decremented to do some things less frequently
|
; Used as counter to be decremented to do some things less frequently
|
||||||
irqn:
|
irqn:
|
||||||
@ -70,6 +65,6 @@ XScrollDirection:
|
|||||||
XCharOffset:
|
XCharOffset:
|
||||||
BYTE
|
BYTE
|
||||||
|
|
||||||
#if VERBOSE = 1
|
; Lists for snake head and tail
|
||||||
ECHO "data.asm @ ",LASTINIT,"len:",(. - LASTINIT)
|
listX DS 256
|
||||||
#endif
|
listY DS 256
|
||||||
|
13
src/font.asm
13
src/font.asm
@ -1,7 +1,10 @@
|
|||||||
#if VERBOSE = 1
|
; Character ROM starts at $2000, but SID must reside at $1000 and is
|
||||||
LASTINIT SET .
|
; longer than $1000, then first characters are just ignored, and game
|
||||||
#endif
|
; uses only characters $80-$ff.
|
||||||
|
; Normally, character ROM is 2kB long ($800), but this binary data
|
||||||
|
; is exactly 1kB long ($400), because only the upper chars are defined.
|
||||||
|
|
||||||
|
SEG fontSegment
|
||||||
; char 0x80, 128
|
; char 0x80, 128
|
||||||
BYTE #%00000000
|
BYTE #%00000000
|
||||||
BYTE #%00000000
|
BYTE #%00000000
|
||||||
@ -1282,7 +1285,3 @@ LASTINIT SET .
|
|||||||
BYTE #%10000001
|
BYTE #%10000001
|
||||||
BYTE #%10000001
|
BYTE #%10000001
|
||||||
BYTE #%11111111
|
BYTE #%11111111
|
||||||
|
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "font.asm @ ",LASTINIT,"len:",(. - LASTINIT)
|
|
||||||
#endif
|
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
#if VERBOSE = 1
|
|
||||||
LASTINIT SET .
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SEG programSegment
|
SEG programSegment
|
||||||
statusPlay: ; do Game
|
statusPlay: ; do Game
|
||||||
; Check counter
|
; Check counter
|
||||||
@ -336,9 +332,4 @@ checkEndWallHit:
|
|||||||
sta (tileMem),y
|
sta (tileMem),y
|
||||||
|
|
||||||
skipPauseTests:
|
skipPauseTests:
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "game.asm @ ",LASTINIT,"len:",(. - LASTINIT)
|
|
||||||
#endif
|
|
@ -1,7 +1,4 @@
|
|||||||
#if VERBOSE = 1
|
SEG programSegment
|
||||||
LASTINIT SET .
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; Game is over
|
; Game is over
|
||||||
; ----------------------------------------------------------------------
|
; ----------------------------------------------------------------------
|
||||||
gameover:
|
gameover:
|
||||||
@ -24,7 +21,3 @@ gameover:
|
|||||||
lda #ST_DELAY
|
lda #ST_DELAY
|
||||||
sta status
|
sta status
|
||||||
rts
|
rts
|
||||||
|
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "gameover.asm @ ",LASTINIT,"len:",(. - LASTINIT)
|
|
||||||
#endif
|
|
@ -1,7 +1,4 @@
|
|||||||
#if VERBOSE = 1
|
SEG programSegment
|
||||||
LASTINIT SET .
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; Initialized variables
|
; Initialized variables
|
||||||
; ----------------------------------------------------------------------
|
; ----------------------------------------------------------------------
|
||||||
|
|
||||||
@ -113,7 +110,3 @@ introStringA6:
|
|||||||
; ----------------------------------------------------------------------
|
; ----------------------------------------------------------------------
|
||||||
levelsList:
|
levelsList:
|
||||||
INCBIN "../res.bin/levels.bin"
|
INCBIN "../res.bin/levels.bin"
|
||||||
|
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "initdata.asm @ ",LASTINIT,"len:",(. - LASTINIT)
|
|
||||||
#endif
|
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
#if VERBOSE = 1
|
|
||||||
LASTINIT SET .
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SEG zeropageSegment
|
SEG zeropageSegment
|
||||||
; Generic src/dst copy pointers
|
; Generic src/dst copy pointers
|
||||||
srcPointer DS 2
|
srcPointer DS 2
|
||||||
@ -700,7 +696,3 @@ XScrollInterruptMoveAll SUBROUTINE
|
|||||||
statusMenu SUBROUTINE
|
statusMenu SUBROUTINE
|
||||||
jsr setupXScrollInterrupt
|
jsr setupXScrollInterrupt
|
||||||
rts
|
rts
|
||||||
|
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "intro1.asm @ ",LASTINIT,"len:",(. - LASTINIT)
|
|
||||||
#endif
|
|
@ -1,7 +1,4 @@
|
|||||||
#if VERBOSE = 1
|
SEG programSegment
|
||||||
LASTINIT SET .
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; Reset variables for a new level
|
; Reset variables for a new level
|
||||||
; ----------------------------------------------------------------------
|
; ----------------------------------------------------------------------
|
||||||
levelresetvar:
|
levelresetvar:
|
||||||
@ -35,7 +32,3 @@ clearListLoop:
|
|||||||
bne clearListLoop
|
bne clearListLoop
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "levelreset.asm @ ",LASTINIT,"len:",(. - LASTINIT)
|
|
||||||
#endif
|
|
@ -1,11 +1,9 @@
|
|||||||
#if VERBOSE = 1
|
|
||||||
LASTINIT SET .
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SEG zeropageSegment
|
SEG zeropageSegment
|
||||||
; Pointer to video memory used in the level loading routine
|
; Pointer to video memory used in the level loading routine
|
||||||
levelVideoPointer WORD
|
levelVideoPointer WORD
|
||||||
levelColorPointer WORD
|
levelColorPointer WORD
|
||||||
|
; Pointer to level struct
|
||||||
|
levelPointer WORD
|
||||||
|
|
||||||
SEG programSegment
|
SEG programSegment
|
||||||
; load new level on the screen
|
; load new level on the screen
|
||||||
@ -173,7 +171,3 @@ writeLevelEnd:
|
|||||||
lda #ST_PLAY
|
lda #ST_PLAY
|
||||||
sta status
|
sta status
|
||||||
rts
|
rts
|
||||||
|
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "levels.asm @ ",LASTINIT,"len:",(. - LASTINIT)
|
|
||||||
#endif
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
ptrDstStart WORD
|
ptrDstStart WORD
|
||||||
ptrDstEnd WORD
|
ptrDstEnd WORD
|
||||||
|
|
||||||
|
SEG programSegment
|
||||||
MACRO MEMSET
|
MACRO MEMSET
|
||||||
SEG programSegment
|
|
||||||
clc
|
clc
|
||||||
lda <{1}
|
lda <{1}
|
||||||
sta ptrDstStart
|
sta ptrDstStart
|
||||||
|
83
src/main.asm
83
src/main.asm
@ -1,46 +1,34 @@
|
|||||||
processor 6502
|
processor 6502
|
||||||
|
|
||||||
; Platform specific code
|
|
||||||
; Code yet to be developed, example to use:
|
|
||||||
; ----------------------------------------------------------------------
|
|
||||||
#if SYSTEM = 64
|
|
||||||
; Commodore64 specific code
|
|
||||||
#else
|
|
||||||
; Commodore16 specific code
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; Uninitialized zeropage segment
|
|
||||||
; ----------------------------------------------------------------------
|
|
||||||
SEG.U zeropageSegment
|
SEG.U zeropageSegment
|
||||||
org $02
|
ORG_ZEROPAGE EQU $02
|
||||||
|
org ORG_ZEROPAGE
|
||||||
|
|
||||||
#if VERBOSE = 1
|
|
||||||
; Locations $90-$FF in zeropage are used by kernal
|
|
||||||
ECHO "End of zeropage variables. Space left: ",($90 - .)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; SID tune (previously properly cleaned, see HVSC)
|
|
||||||
; ----------------------------------------------------------------------
|
|
||||||
SEG sidSegment
|
SEG sidSegment
|
||||||
org $1000
|
ORG_SID EQU $1000
|
||||||
sidtune:
|
org ORG_SID
|
||||||
INCBIN "../res.bin/amour2.sid"
|
ORG_FONT EQU $2400
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "top $2000: End of SIDtune at ",.,"Space left:",($2000 - .)
|
|
||||||
ECHO "top $2400: End of SIDtune at ",.,"Space left:",($2400 - .)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; Font Data
|
|
||||||
; ----------------------------------------------------------------------
|
|
||||||
SEG fontSegment
|
SEG fontSegment
|
||||||
org $2400
|
org ORG_FONT
|
||||||
; This binary data that defines the font is exactly 2kB long ($800)
|
ORG_PROGRAM EQU $2800
|
||||||
INCLUDE "font.asm"
|
|
||||||
|
|
||||||
; Program Segment
|
|
||||||
; ----------------------------------------------------------------------
|
|
||||||
SEG programSegment
|
SEG programSegment
|
||||||
org $2800
|
org ORG_PROGRAM
|
||||||
|
|
||||||
|
ORG_DATA EQU $cd00
|
||||||
|
SEG.U dataSegment
|
||||||
|
org ORG_DATA
|
||||||
|
|
||||||
|
; INCLUDE
|
||||||
|
; -----------------------------------------------------------------------------
|
||||||
|
LASTINIT SET ORG_SID
|
||||||
|
INCLUDE "sidtune.asm"
|
||||||
|
ECHO "sidtune : start ",LASTINIT," end ",.," size ",(. - LASTINIT)
|
||||||
|
|
||||||
|
LASTINIT SET ORG_FONT
|
||||||
|
INCLUDE "font.asm"
|
||||||
|
ECHO "font : start ",LASTINIT," end ",.," size ",(. - LASTINIT)
|
||||||
|
|
||||||
|
LASTINIT SET ORG_PROGRAM
|
||||||
INCLUDE "program.asm"
|
INCLUDE "program.asm"
|
||||||
INCLUDE "initdata.asm"
|
INCLUDE "initdata.asm"
|
||||||
INCLUDE "game.asm"
|
INCLUDE "game.asm"
|
||||||
@ -51,30 +39,9 @@ sidtune:
|
|||||||
INCLUDE "multicolor.asm"
|
INCLUDE "multicolor.asm"
|
||||||
INCLUDE "levelreset.asm"
|
INCLUDE "levelreset.asm"
|
||||||
INCLUDE "outro.asm"
|
INCLUDE "outro.asm"
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "End of program segment at:",.
|
|
||||||
ECHO "PACK SIZE:",(. - $1000),"=",[(. - $1000)d]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; Data variables
|
|
||||||
; -----------------
|
|
||||||
SEG.U dataSegment
|
|
||||||
org $cd00
|
|
||||||
INCLUDE "data.asm"
|
INCLUDE "data.asm"
|
||||||
INCLUDE "macro.asm"
|
INCLUDE "macro.asm"
|
||||||
#if VERBOSE = 1
|
ECHO "program : start ",LASTINIT," end ",.," size ",(. - LASTINIT)
|
||||||
ECHO "End of Data segment. Space left:",($ce00 - .)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; Lists
|
|
||||||
; -----------------
|
|
||||||
SEG.U listSegment
|
|
||||||
org $ce00
|
|
||||||
listX DS 256
|
|
||||||
listY DS 256
|
|
||||||
|
|
||||||
; Includes
|
|
||||||
INCLUDE "zeropage.asm"
|
|
||||||
|
|
||||||
;
|
;
|
||||||
; coded 2017, 2018, 2019, 2020, 2021
|
; coded 2017, 2018, 2019, 2020, 2021
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
#if VERBOSE = 1
|
SEG programSegment
|
||||||
LASTINIT SET .
|
|
||||||
#endif
|
|
||||||
|
|
||||||
processor 6502
|
|
||||||
|
|
||||||
multicolor SUBROUTINE
|
multicolor SUBROUTINE
|
||||||
|
|
||||||
; Prepare data struct for MultiColor mode
|
; Prepare data struct for MultiColor mode
|
||||||
@ -43,7 +38,3 @@ multicolorOff:
|
|||||||
and #$ef
|
and #$ef
|
||||||
sta $d016
|
sta $d016
|
||||||
rts
|
rts
|
||||||
|
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "multicolor.asm @ ",LASTINIT,"len:",(. - LASTINIT)
|
|
||||||
#endif
|
|
@ -1,7 +1,4 @@
|
|||||||
#if VERBOSE = 1
|
SEG programSegment
|
||||||
LASTINIT SET .
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; Wait for some delay
|
; Wait for some delay
|
||||||
statusDelay SUBROUTINE
|
statusDelay SUBROUTINE
|
||||||
ldy delay ; load outroDelay and decrement
|
ldy delay ; load outroDelay and decrement
|
||||||
@ -14,7 +11,3 @@ statusDelay SUBROUTINE
|
|||||||
lda delayStatus
|
lda delayStatus
|
||||||
sta status
|
sta status
|
||||||
rts
|
rts
|
||||||
|
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "outro.asm @ ",LASTINIT,"len:",(. - LASTINIT)
|
|
||||||
#endif
|
|
@ -1,9 +1,10 @@
|
|||||||
#if VERBOSE = 1
|
SEG zeropageSegment
|
||||||
LASTINIT SET .
|
; Interrupt counter
|
||||||
#endif
|
counter DS 2
|
||||||
|
|
||||||
; ENTRY OF PROGRAM
|
SEG programSegment
|
||||||
; ----------------------------------------------------------------------
|
; this is the entry point of the program and must stay at this address
|
||||||
|
org $2800
|
||||||
start:
|
start:
|
||||||
; Clear screen, initialize keyboard, restore interrupts
|
; Clear screen, initialize keyboard, restore interrupts
|
||||||
jsr $ff81
|
jsr $ff81
|
||||||
@ -253,7 +254,3 @@ checkEndStatus:
|
|||||||
|
|
||||||
; Go to original system routine
|
; Go to original system routine
|
||||||
jmp $ea31
|
jmp $ea31
|
||||||
|
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "program.asm @ ",LASTINIT,"len:",(. - LASTINIT)
|
|
||||||
#endif
|
|
||||||
|
6
src/sidtune.asm
Normal file
6
src/sidtune.asm
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
SEG sidSegment
|
||||||
|
sidtune:
|
||||||
|
INCBIN "../res.bin/amour2.sid"
|
||||||
|
|
||||||
|
; Note: the SID tune must be properly cleaned (eg. header removed)
|
||||||
|
; See HVSC for .sid music format
|
@ -1,9 +1,3 @@
|
|||||||
#if VERBOSE = 1
|
|
||||||
LASTINIT SET .
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; Subroutines
|
|
||||||
; ----------------------------------------------------------------------
|
|
||||||
SEG zeropageSegment
|
SEG zeropageSegment
|
||||||
; Where is the snake head in video memory? Do math to calculate address
|
; Where is the snake head in video memory? Do math to calculate address
|
||||||
; using pointer at tileMem
|
; using pointer at tileMem
|
||||||
@ -156,6 +150,11 @@ printString SUBROUTINE
|
|||||||
.end:
|
.end:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
SEG zeropageSegment
|
||||||
|
; Pointer for Pointer in the NextPointer routine
|
||||||
|
nextPointerPointer DS 2
|
||||||
|
|
||||||
|
SEG programSegment
|
||||||
; Increment a pointer in the zeropage
|
; Increment a pointer in the zeropage
|
||||||
; Input parameters:
|
; Input parameters:
|
||||||
; nextPointerPointer pointer to the pointer in zeropage
|
; nextPointerPointer pointer to the pointer in zeropage
|
||||||
@ -176,7 +175,3 @@ nextPointer:
|
|||||||
sta (nextPointerPointer),y
|
sta (nextPointerPointer),y
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
#if VERBOSE = 1
|
|
||||||
ECHO "subroutines.asm @ ",LASTINIT,"len:",(. - LASTINIT)
|
|
||||||
#endif
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
; Zero page utility pointers
|
|
||||||
; ----------------------------------------------------------------------
|
|
||||||
SEG zeropageSegment
|
|
||||||
; Pointer to level struct
|
|
||||||
levelPointer DS 2
|
|
||||||
|
|
||||||
; Pointer for Pointer in the NextPointer routine
|
|
||||||
nextPointerPointer DS 2
|
|
||||||
|
|
||||||
; Pointer to string for strlen routine
|
|
||||||
strlenString DS 2
|
|
||||||
|
|
||||||
; Interrupt counter
|
|
||||||
counter DS 2
|
|
||||||
|
|
||||||
; Note: Locations $90-$FF in zeropage are used by kernal
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user