Reorganized memory

Now program takes less space in RAM.
All variables, costants and Lists are moved before the SID song,
in a previously unused space (BASIC RAM).
SID song edit has been changed:
	- same song but slightly different
	- takes up a bit less than 4k
	- more catchy :-)
	- perfectly fits in $1000-$2000 and allows...
...the new custom charset to be put at $2000!
	- Taken TGGS font and properly customized with tiles
Now actual program starts at $2800.

Also added some useful code for assembler to output debug infos when
assembling with -DDEBUG=1

In the meanwhile discovered tremendous subtle bug due to uninitialized
structure (listX and listY). Fixed.

Memory map now is:
	+-------------------------------+
0000	| things in zero page		|
	|	and low RAM		|
	+-------------------------------+
0800	| BASIC autostart		|
	| then data (variables,		|
	|	costants and strings)	|	<-- this can be done better using segments. Reminder for the future.
	|				|
	+-------------------------------+
0E00	| listX				|
	+-------------------------------+
0F00	| listY				|
	+-------------------------------+
1000	| SID song			|
	|				|
	|				|
	+-------------------------------+
2000	| TGGS Custom font charset	|
	|				|
	+-------------------------------+
2800	| ACTUAL CODE			|
	|				|	<-- plus some garbage data, see above (segments TODO)
	.				.
	.				.
This commit is contained in:
giomba 2018-09-10 21:39:53 +02:00
parent 70b041cf14
commit 299eee1257
5 changed files with 63 additions and 103 deletions

BIN
amour.sid Normal file

Binary file not shown.

View File

@ -5,101 +5,47 @@ multicolor SUBROUTINE
; Prepare data struct for MultiColor mode ; Prepare data struct for MultiColor mode
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
multicolorInit: multicolorInit:
; Deactivate interrupt ; Make font higher half the inverse of lower one
; This is needed to avoid calls from I/O while dealing with bank ; TODO: merge these edits with actual font binary
; switching (I/O addresses are the same)
sei
; Put char ROM in CPU address space
; It becomes visible at $d000
; This overrides I/O
; lda $1
; and #$fb
; sta $1
; Copy ROM original content from $d000 to $3800
; ldx #0
;.copyLoop:
; lda $d000,x
; sta $3800,x
; lda $d100,x
; sta $3900,x
; lda $d200,x
; sta $3a00,x
; lda $d300,x
; sta $3b00,x
; lda $d400,x
; sta $3c00,x
; lda $d500,x
; sta $3d00,x
; lda $d600,x
; sta $3e00,x
; lda $d700,x
; sta $3f00,x
; inx
; bne .copyLoop
; Copy The GGS Font and
; make higher half the inverse of lower one
ldx #$00 ldx #$00
.tggsCopy .tggsCopy
dex dex
lda .tggsFont,x lda tggsFont,x
sta $3800,x
eor #$ff eor #$ff
sta $3c00,x sta $2400,x
lda .tggsFont + $100,x lda tggsFont + $100,x
sta $3900,x
eor #$ff eor #$ff
sta $3d00,x sta $2500,x
lda .tggsFont + $200,x lda tggsFont + $200,x
sta $3a00,x
eor #$ff eor #$ff
sta $3e00,x sta $2600,x
lda .tggsFont + $300,x lda tggsFont + $300,x
sta $3b00,x
eor #$ff eor #$ff
sta $3f00,x sta $2700,x
cpx #$0 cpx #$0
bne .tggsCopy bne .tggsCopy
; Edit character definitions in RAM (using previous defined table) ; Alter character definitions in RAM (using previous defined table)
; TODO: merge these edits with actual font binary
ldx #$8 ldx #$8
.editLoop: .editLoop:
dex dex
lda .multicolorSnakeTile,x lda .multicolorSnakeTile,x
sta $3800 + SNAKE_TILE * 8,x sta tggsFont + SNAKE_TILE * 8,x
lda .multicolorFoodTile,x lda .multicolorFoodTile,x
sta $3800 + FOOD_TILE * 8,x sta tggsFont + FOOD_TILE * 8,x
; lda .multicolorOtherTile,x ; lda .multicolorOtherTile,x
; sta $3800 + SOME_TILE * 8,x ; sta tggsFont + SOME_TILE * 8,x
; ... ; ...
cpx #$0 cpx #$0
bne .editLoop bne .editLoop
; Put ROM away from CPU address space, and re-enable I/O ; Tell VIC-II to use:
; lda $1 ; - screen text memory at $400 = $400 * 1
; ora #$4 ; - characters ROM at $2000 = $400 * 8
; sta $1 lda #$18
; Set foreground color in [8-F] to all locations to enable multicolor mode for every single char
; ldx #0
; lda #$d
;colorLoop:
; sta $d800,x
; sta $d900,x
; sta $da00,x
; sta $db00,x
; inx
; bne colorLoop
; Tell VIC-II to read characters from $3800 = 0xe * 0x400
lda $d018
ora #$0e
sta $d018 sta $d018
; Re-enable interrupts and return
cli
rts rts
; Activate multicolor mode ; Activate multicolor mode
@ -144,5 +90,4 @@ multicolorOff:
BYTE #%00100000 BYTE #%00100000
BYTE #%00100000 BYTE #%00100000
BYTE #%10000000 BYTE #%10000000
.tggsFont
INCBIN "tggs.font"

View File

@ -25,19 +25,11 @@ printIntroString = $a3
introScreenStart = $fb introScreenStart = $fb
org $801 org $801
. = $801 ; 10 SYS9216 ($2400) BASIC autostart . = $801 ; 10 SYS10240 ($2800) BASIC autostart
BYTE #$0b,#$08,#$0a,#$00,#$9e,#$39,#$32,#$31,#$36,#$00,#$00,#$00 BYTE #$0b,#$08,#$0a,#$00,#$9e,#$31,#$30,#$32,#$34,#$30,#$00,#$00,#$00
; SID tune (previously properly cleaned, see HVSC)
; ----------------------------------------------------------------------
. = $1000
sidtune:
INCBIN "snake.sid"
; Data section ; Data section
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
. = $2100
; 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:
@ -128,34 +120,40 @@ intro2string:
intro3string: intro3string:
BYTE "(C) 2018" BYTE "(C) 2018"
BYTE #0 BYTE #0
colorshade: ; a gradient of dark-bright-dark, with only hi-res colors (40 columns) colorshade: ; a gradient of dark-bright-dark (40 columns)
BYTE #5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5,#5 HEX 0b 0b 0b 0b 0b 0c 0c 0c 0c 0c 05 05 05 0d 0d 0d 0d 07 07 07 07 07 07 0d 0d 0d 0d 05 05 05 0c 0c 0c 0c 0c 0b 0b 0b 0b 0b
; BYTE #6,#6,#6
; BYTE #2,#2,#2,#2
; BYTE #5,#5,#5,#5
; BYTE #7,#7,#7,#7
; BYTE #3,#3,#3,#3
; BYTE #1,#1,#1,#1
; BYTE #3,#3,#3,#3
; BYTE #7,#7,#7,#7
; BYTE #5,#5,#5,#5
; BYTE #2,#2,#2,#2
; BYTE #6,#6,#6
scoreString: scoreString:
BYTE "POINTS" BYTE "POINTS"
BYTE #0 BYTE #0
#if DEBUG = 1
ECHO "End of Data. Space left: ",($e00 - .)
#endif
; List ; List
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
. = $2200 . = $e00
listX: listX:
. = $f00
. = $2300
listY: listY:
; SID tune (previously properly cleaned, see HVSC)
; ----------------------------------------------------------------------
. = $1000
sidtune:
INCBIN "amour.sid"
#if DEBUG = 1
ECHO "End of SIDtune. Space left: ",($2000 - .)
#endif
. = $2000
; This binary data that defines the font is exactly 2kB long ($800)
tggsFont:
INCBIN "tggs.font"
; ENTRY OF PROGRAM ; ENTRY OF PROGRAM
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------
. = $2400 . = $2800
start: start:
; Clear screen, initialize keyboard, restore interrupts ; Clear screen, initialize keyboard, restore interrupts
jsr $ff81 jsr $ff81
@ -288,6 +286,16 @@ upperbarLoop:
lda #5 lda #5
sta length ; Length of the list sta length ; Length of the list
; Clear snake lists X and Y
lda #$0
ldx #$ff
clearListLoop:
dex
sta listX,x
sta listY,y
cpx #$0
bne clearListLoop
rts rts
; Intro reset ; Intro reset
@ -393,6 +401,10 @@ checkEndStatus:
; Play music ; Play music
jsr sidtune + 3 jsr sidtune + 3
jsr sidtune + 3
jsr sidtune + 3
jsr sidtune + 3
jsr sidtune + 3
; Increase random value ; Increase random value
inc random inc random
@ -975,6 +987,9 @@ printIntroEnd:
; ______________________________________________________________________ ; ______________________________________________________________________
INCLUDE "multicolor.asm" INCLUDE "multicolor.asm"
#if DEBUG = 1
ECHO "Program ends at: ",.
#endif
; ;
; coded during december 2017 ; coded during december 2017
; by giomba -- giomba at glgprograms.it ; by giomba -- giomba at glgprograms.it

BIN
snake.sid

Binary file not shown.

BIN
tggs.font

Binary file not shown.