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:
parent
70b041cf14
commit
299eee1257
@ -5,101 +5,47 @@ multicolor SUBROUTINE
|
||||
; Prepare data struct for MultiColor mode
|
||||
; ----------------------------------------------------------------------
|
||||
multicolorInit:
|
||||
; Deactivate interrupt
|
||||
; This is needed to avoid calls from I/O while dealing with bank
|
||||
; 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
|
||||
; Make font higher half the inverse of lower one
|
||||
; TODO: merge these edits with actual font binary
|
||||
ldx #$00
|
||||
.tggsCopy
|
||||
dex
|
||||
lda .tggsFont,x
|
||||
sta $3800,x
|
||||
lda tggsFont,x
|
||||
eor #$ff
|
||||
sta $3c00,x
|
||||
lda .tggsFont + $100,x
|
||||
sta $3900,x
|
||||
sta $2400,x
|
||||
lda tggsFont + $100,x
|
||||
eor #$ff
|
||||
sta $3d00,x
|
||||
lda .tggsFont + $200,x
|
||||
sta $3a00,x
|
||||
sta $2500,x
|
||||
lda tggsFont + $200,x
|
||||
eor #$ff
|
||||
sta $3e00,x
|
||||
lda .tggsFont + $300,x
|
||||
sta $3b00,x
|
||||
sta $2600,x
|
||||
lda tggsFont + $300,x
|
||||
eor #$ff
|
||||
sta $3f00,x
|
||||
sta $2700,x
|
||||
cpx #$0
|
||||
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
|
||||
.editLoop:
|
||||
dex
|
||||
lda .multicolorSnakeTile,x
|
||||
sta $3800 + SNAKE_TILE * 8,x
|
||||
sta tggsFont + SNAKE_TILE * 8,x
|
||||
lda .multicolorFoodTile,x
|
||||
sta $3800 + FOOD_TILE * 8,x
|
||||
sta tggsFont + FOOD_TILE * 8,x
|
||||
; lda .multicolorOtherTile,x
|
||||
; sta $3800 + SOME_TILE * 8,x
|
||||
; sta tggsFont + SOME_TILE * 8,x
|
||||
; ...
|
||||
cpx #$0
|
||||
bne .editLoop
|
||||
|
||||
; Put ROM away from CPU address space, and re-enable I/O
|
||||
; lda $1
|
||||
; ora #$4
|
||||
; sta $1
|
||||
|
||||
; 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
|
||||
; Tell VIC-II to use:
|
||||
; - screen text memory at $400 = $400 * 1
|
||||
; - characters ROM at $2000 = $400 * 8
|
||||
lda #$18
|
||||
sta $d018
|
||||
|
||||
; Re-enable interrupts and return
|
||||
cli
|
||||
rts
|
||||
|
||||
; Activate multicolor mode
|
||||
@ -144,5 +90,4 @@ multicolorOff:
|
||||
BYTE #%00100000
|
||||
BYTE #%00100000
|
||||
BYTE #%10000000
|
||||
.tggsFont
|
||||
INCBIN "tggs.font"
|
||||
|
||||
|
69
snake.asm
69
snake.asm
@ -25,19 +25,11 @@ printIntroString = $a3
|
||||
introScreenStart = $fb
|
||||
|
||||
org $801
|
||||
. = $801 ; 10 SYS9216 ($2400) BASIC autostart
|
||||
BYTE #$0b,#$08,#$0a,#$00,#$9e,#$39,#$32,#$31,#$36,#$00,#$00,#$00
|
||||
|
||||
; SID tune (previously properly cleaned, see HVSC)
|
||||
; ----------------------------------------------------------------------
|
||||
. = $1000
|
||||
sidtune:
|
||||
INCBIN "snake.sid"
|
||||
. = $801 ; 10 SYS10240 ($2800) BASIC autostart
|
||||
BYTE #$0b,#$08,#$0a,#$00,#$9e,#$31,#$30,#$32,#$34,#$30,#$00,#$00,#$00
|
||||
|
||||
; Data section
|
||||
; ----------------------------------------------------------------------
|
||||
. = $2100
|
||||
|
||||
; Number of interrupt
|
||||
; Used as counter to be decremented to do some things less frequently
|
||||
irqn:
|
||||
@ -128,34 +120,40 @@ intro2string:
|
||||
intro3string:
|
||||
BYTE "(C) 2018"
|
||||
BYTE #0
|
||||
colorshade: ; a gradient of dark-bright-dark, with only hi-res colors (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
|
||||
; 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
|
||||
colorshade: ; a gradient of dark-bright-dark (40 columns)
|
||||
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
|
||||
scoreString:
|
||||
BYTE "POINTS"
|
||||
BYTE #0
|
||||
|
||||
#if DEBUG = 1
|
||||
ECHO "End of Data. Space left: ",($e00 - .)
|
||||
#endif
|
||||
|
||||
; List
|
||||
; ----------------------------------------------------------------------
|
||||
. = $2200
|
||||
. = $e00
|
||||
listX:
|
||||
|
||||
. = $2300
|
||||
. = $f00
|
||||
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
|
||||
; ----------------------------------------------------------------------
|
||||
. = $2400
|
||||
. = $2800
|
||||
start:
|
||||
; Clear screen, initialize keyboard, restore interrupts
|
||||
jsr $ff81
|
||||
@ -288,6 +286,16 @@ upperbarLoop:
|
||||
lda #5
|
||||
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
|
||||
|
||||
; Intro reset
|
||||
@ -393,6 +401,10 @@ checkEndStatus:
|
||||
|
||||
; Play music
|
||||
jsr sidtune + 3
|
||||
jsr sidtune + 3
|
||||
jsr sidtune + 3
|
||||
jsr sidtune + 3
|
||||
jsr sidtune + 3
|
||||
|
||||
; Increase random value
|
||||
inc random
|
||||
@ -975,6 +987,9 @@ printIntroEnd:
|
||||
; ______________________________________________________________________
|
||||
INCLUDE "multicolor.asm"
|
||||
|
||||
#if DEBUG = 1
|
||||
ECHO "Program ends at: ",.
|
||||
#endif
|
||||
;
|
||||
; coded during december 2017
|
||||
; by giomba -- giomba at glgprograms.it
|
||||
|
Loading…
Reference in New Issue
Block a user