dual version: prg + cartridge (8k)

This commit is contained in:
giomba 2020-09-15 14:57:10 +02:00
parent 8b8cb19651
commit d61a7bf284
19 changed files with 233 additions and 45 deletions

View File

@ -3,10 +3,16 @@
ASM=$(wildcard src/*.asm)
RES=res.bin/amour.sid res.bin/levels.bin
ifeq "$(CARTRIDGE)" "1"
FORMAT:=3
else
FORMAT:=1
endif
.PHONY: debug env clean
bin/snake.prg: env $(ASM) $(RES)
dasm src/main.asm -Isrc/ -DSYSTEM=64 -DDEBUG=0 -sbuild/symbols.txt -obin/snake.prg
bin/snake.prg: env $(ASM) $(RES) bin/explodefont
dasm src/main.asm -Isrc/ -DSYSTEM=64 -DDEBUG=$(DEBUG) -DVERBOSE=$(VERBOSE) -DCARTRIDGE=$(CARTRIDGE) -f$(FORMAT) -sbuild/symbols.txt -obin/snake.prg
clean:
rm -rf {build,bin,res.bin}
@ -14,9 +20,8 @@ clean:
env:
mkdir -p {build,bin,res.bin}
debug: env $(ASM) $(RES)
bin/explodefont: util/explodefont.cpp
g++ -o bin/explodefont util/explodefont.cpp
dasm src/main.asm -Isrc/ -DSYSTEM=64 -DDEBUG=1 -sbuild/symbols.txt -obin/snake.prg
res.bin/amour.sid:
cp res.org/amour.sid res.bin/amour.sid

View File

@ -13,10 +13,13 @@ You need the GNU compiler collection and the [dasm](https://dasm-assembler.githu
```
$ make
```
You can also make it output useful extra info with:
```
$ make debug
```
You can also define the following environment variables:
```$ DEBUG=1 make``` build with debugging artifacts
```$ VERBOSE=1 make``` output useful info during compilation
```$ CARTRIDGE=1 make``` produces an 8K bin ready to be burnt to an *PROM
## Developer docs
### Memory map
@ -25,10 +28,10 @@ Address | PRG | Description
```$0000 - $0001``` | no | hardware
```$0002 - $00FF``` | no | zero page pointers
```$0100 - $07FF``` | no | *free ram*
```$0800 - $0FFF``` | yes | initialized data segment (incl. const) + BASIC autostart
```$1000 - $1FFF``` | yes | SID tune
```$0800 - $0FFF``` | yes | autostart (BASIC or cartridge) + Low Program Segment
```$1000 - $1FFF``` | yes | SID tune + Middle Program Segment
```$2000 - $27FF``` | yes | custom char
```$2800 - $xxxx``` | yes | program logic (only needed part used)
```$2800 - $xxxx``` | yes | High Program Segment (only needed part used)
```$xxxx - $CCFF``` | no | *free ram*
```$CD00 - $CDFF``` | no | data segment (not-initialized vars)
```$CE00 - $CEFF``` | no | list X
@ -36,6 +39,8 @@ Address | PRG | Description
```$D000 - $DFFF``` | no | I/O
```$E000 - $FFFF``` | no | Kernal
Note: program (code) segments have been put in all possible free spots in order to squeeze the game into an 8K cartridge.
### Custom charset
Index | Description
----------------|-------------
@ -45,3 +50,8 @@ Index | Description
```$50 - $5F``` | hex digits, reversed
```$60 - ``` | game tiles
### Cartridge
Cartridge version is at $8000 and simply copies itself back at $800.
Cartridge version can not be built with DEBUG=1 flag due to size constraints.

View File

@ -1,2 +1,17 @@
; 10 SYS10240 ($2800) BASIC autostart
BYTE #$0b,#$08,#$0a,#$00,#$9e,#$31,#$30,#$32,#$34,#$30,#$00,#$00,#$00
#if VERBOSE = 1
LASTINIT SET .
#endif
; this is at $801
; and it MUST be exactly at this location in order to autostart
; 10 SYS2060 ($80c) BASIC autostart
BYTE #$0b,#$08,#$0a,#$00,#$9e,#$32,#$30,#$36,#$31,#$00,#$00,#$00
; this is at (2061 dec)=($80d)
; and it MUST be exactly after the above BASIC statement
. = $80d
jmp start
#if VERBOSE = 1
ECHO "basic.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

47
src/cart.asm Normal file
View File

@ -0,0 +1,47 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
cartridge SUBROUTINE
WORD #$8009
WORD #$801a
; CBM80 in PETSCII (cartridge signature for autostart)
BYTE #$c3,#$c2,#$cd,#$38,#$30
.coldstart:
sei
stx $d016
jsr $fda3
jsr $fd50
jsr $fd15
jsr $ff5b
cli
.warmstart:
; Copy cartridge content into proper memory location
ldx #$20
lda #$0
tay
sta srcPointer
sta dstPointer
lda #>cartridgeStart
sta srcPointer + 1
lda #$08
sta dstPointer + 1
.loop:
lda (srcPointer),y
sta (dstPointer),y
iny
bne .loop
inc srcPointer + 1
inc dstPointer + 1
dex
bne .loop
jmp start
#if VERBOSE = 1
ECHO "cart.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
; Data section - Not initialized variables ($CD00 - $CDFF)
; ----------------------------------------------------------------------
; Number of interrupt
@ -50,3 +54,6 @@ delayStatus:
score:
WORD
#if VERBOSE = 1
ECHO "data.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
statusPlay: ; do Game
; Check counter
ldx irqn
@ -334,4 +338,6 @@ skipPauseTests:
rts
#if VERBOSE = 1
ECHO "game.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
; Game is over
; ----------------------------------------------------------------------
gameover:
@ -21,4 +25,6 @@ gameover:
sta status
rts
#if VERBOSE = 1
ECHO "gameover.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
; Initialized variables
; ----------------------------------------------------------------------
@ -95,3 +99,6 @@ noMoreLevelsString:
levelsList:
INCBIN "../res.bin/levels.bin"
#if VERBOSE = 1
ECHO "initdata.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
; Currently statusIntro0 is the same as statusIntro1
; statusIntro1 has just been reserved for future use
statusIntro0:
@ -77,4 +81,6 @@ status1okset:
; For now, just return.
rts
#if VERBOSE = 1
ECHO "intro1.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
; Intro reset
; ----------------------------------------------------------------------
introreset:
@ -44,4 +48,6 @@ introresetColorShade
rts
#if VERBOSE = 1
ECHO "introreset.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
; Reset variables for a new level
; ----------------------------------------------------------------------
levelresetvar:
@ -32,3 +36,6 @@ clearListLoop:
rts
#if VERBOSE = 1
ECHO "levelreset.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
; load new level on the screen
statusLevelTitle SUBROUTINE
jsr clearScreen
@ -162,3 +166,6 @@ writeLevelEnd:
sta status
rts
#if VERBOSE = 1
ECHO "levels.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -15,21 +15,38 @@
org $02
INCLUDE "zeropage.asm"
#if DEBUG = 1
#if VERBOSE = 1
; Locations $90-$FF in zeropage are used by kernal
ECHO "End of zeropage variables. Space left: ",($90 - .)
#endif
; Initialized segments
; ----------------------------------------------------------------------
SEG constSegment
SEG autostartSegment
#if CARTRIDGE = 0
org $801
INCLUDE "basic.asm" ; BASIC must stay at this address
INCLUDE "initdata.asm"
#if DEBUG = 1
ECHO "End of Initialized Data (const) + Basic Segment. Space left: ",($1000 - .)
INCLUDE "basic.asm" ; BASIC _MUST_ stay at this address
#else
org $800
INCLUDE "cart.asm"
#endif
INCLUDE "initdata.asm"
; Program "Segment" Low
; ----------------------------------------------------------------------
; You just have to fill this empty space, don't you think so? ;-)
INCLUDE "game.asm"
INCLUDE "gameover.asm"
INCLUDE "introreset.asm"
INCLUDE "program.asm"
INCLUDE "subroutines.asm"
INCLUDE "levels.asm"
INCLUDE "intro1.asm"
; Note: some code had to be included at an higher address
#if VERBOSE = 1
ECHO "End of Low Program Segment. Space left:",($1000 - .)
#endif
; SID tune (previously properly cleaned, see HVSC)
; ----------------------------------------------------------------------
@ -37,8 +54,14 @@
org $1000
sidtune:
INCBIN "../res.bin/amour.sid"
#if DEBUG = 1
ECHO "End of SIDtune. Space left: ",($2000 - .)
#if VERBOSE = 1
ECHO "End of SIDtune at ",.
#endif
INCLUDE "multicolor.asm"
INCLUDE "levelreset.asm"
INCLUDE "outro.asm"
#if VERBOSE = 1
ECHO "End of Middle Program Segment. Space left:",($2000 - .)
#endif
; Font Data
@ -49,40 +72,36 @@ sidtune:
tggsFont:
INCLUDE "tggs.asm"
; Include program
; Program Segment High
; ----------------------------------------------------------------------
SEG programSegment
org $2800
jmp start
INCLUDE "game.asm"
INCLUDE "gameover.asm"
INCLUDE "levelreset.asm"
INCLUDE "introreset.asm"
INCLUDE "intro1.asm"
INCLUDE "multicolor.asm"
INCLUDE "outro.asm"
INCLUDE "program.asm"
INCLUDE "subroutines.asm"
INCLUDE "levels.asm"
#if DEBUG = 1
ECHO "End of program at: ",.,"Space left:",($cd00 - .)
#if VERBOSE = 1
ECHO "End of High Program Segment at: ",.,"Space left:",($cd00 - .)
#endif
#if DEBUG = 1
#if VERBOSE = 1
#if CARTRIDGE = 0
; +2 because of PRG header
ECHO "PRG size:",([. - $801 + 2]d),"dec"
#else
ECHO "BIN size:",([. - $800]d),"dec"
#endif
#endif
; Uninitialized segments
; ----------------------------------------------------------------------
; Cartridge locations
; -------------------
SEG.U cartridgeSegment
org $8000
cartridgeStart:
; Data variables
; -----------------
SEG.U dataSegment
org $cd00
INCLUDE "data.asm"
# if DEBUG = 1
#if VERBOSE = 1
ECHO "End of Data segment. Space left:",($ce00 - .)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
processor 6502
multicolor SUBROUTINE
@ -39,3 +43,7 @@ multicolorOff:
and #$ef
sta $d016
rts
#if VERBOSE = 1
ECHO "multicolor.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
; Wait for some delay
statusDelay SUBROUTINE
ldy delay ; load outroDelay and decrement
@ -11,3 +15,6 @@ statusDelay SUBROUTINE
sta status
rts
#if VERBOSE = 1
ECHO "outro.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
; ENTRY OF PROGRAM
; ----------------------------------------------------------------------
start:
@ -186,4 +190,6 @@ checkEndStatus:
; Go to original system routine
jmp $ea31
#if VERBOSE = 1
ECHO "program.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
; Subroutines
; ----------------------------------------------------------------------
@ -161,3 +165,6 @@ nextPointer:
rts
#if VERBOSE = 1
ECHO "subroutines.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -1,3 +1,7 @@
#if VERBOSE = 1
LASTINIT SET .
#endif
; char 0x0, 0
BYTE #%00000000
BYTE #%00000000
@ -2558,3 +2562,7 @@
BYTE #%11100001
BYTE #%01010101
BYTE #%00000000
#if VERBOSE = 1
ECHO "tggs.asm @ ",LASTINIT,"len:",(. - LASTINIT)
#endif

View File

@ -22,6 +22,10 @@ nextPointerPointer DS 2
; Pointer to string for strlen routine
strlenString DS 2
; Generic src/dst copy pointers
srcPointer DS 2
dstPointer DS 2
; Note: Locations $90-$FF in zeropage are used by kernal