diff --git a/.gitignore b/.gitignore index 36a3b8d..abbb2da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ bin/ build/ +res.bin/ *.prg *.out symbols.txt diff --git a/Makefile b/Makefile index 1bb13d7..e29eb52 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,30 @@ .POSIX: ASM=$(wildcard src/*.asm) -RES=$(wildcard res/*) +RES=res.bin/amour.sid res.bin/levels.bin .PHONY: debug env clean -bin/snake.prg: $(ASM) $(RES) | env +bin/snake.prg: env $(ASM) $(RES) dasm src/main.asm -Isrc/ -DSYSTEM=64 -DDEBUG=0 -obin/snake.prg clean: - rm -rf {build,bin} + rm -rf {build,bin,res.bin} env: - mkdir -p {build,bin} + mkdir -p {build,bin,res.bin} -debug: $(ASM) $(RES) | env +debug: $(ASM) $(RES) 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 + +res.bin/levels.bin: bin/level res.org/levels.txt + bin/level < res.org/levels.txt > res.bin/levels.bin + +bin/level: util/rlevel.cpp + g++ -o bin/level util/rlevel.cpp + + diff --git a/res/amour.sid b/res.org/amour.sid similarity index 100% rename from res/amour.sid rename to res.org/amour.sid diff --git a/res.org/levels.txt b/res.org/levels.txt new file mode 100644 index 0000000..03f86ce --- /dev/null +++ b/res.org/levels.txt @@ -0,0 +1,56 @@ +TITLE +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +x x +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +z +TITLE 2 +........................................ +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +..................x..................... +........................................ +z +Z + diff --git a/src/const.asm b/src/const.asm index b9d26ad..a5abdaa 100644 --- a/src/const.asm +++ b/src/const.asm @@ -18,6 +18,9 @@ SNAKE_COLOR = 13 ; Food features FOOD_TILE = 90 FOOD_COLOR = 11 +; Wall features +WALL_TILE = 91 +WALL_COLOR = 11 ; Strings ; ---------------------------------------------------------------------- diff --git a/src/game.asm b/src/game.asm index 4356325..290b99a 100644 --- a/src/game.asm +++ b/src/game.asm @@ -239,13 +239,6 @@ genFoodY: ; calculate `random` modulo 22 (22 = SCREEN_H - 1) cmp snakeY beq genFood foodOK: - ; debug -- print choosen X,Y for food - ; ldy #$18 - ; lda calcTileX - ; jsr printByte - ; ldy #$1b - ; lda calcTileY - ; jsr printByte ldy #0 jsr calcTileMem ; calc food address in memory @@ -277,6 +270,12 @@ checkSelfEat: jmp gameover checkEndSelfEat: +checkWallHit: + cmp #WALL_TILE + bne checkEndWallHit + jmp gameover +checkEndWallHit: + ; Draw snake head ldy #0 lda snakeX ; calc char address in video memory, and put SNAKE_TILE @@ -307,6 +306,13 @@ checkEndSelfEat: lda #$20 ; just put a space to erase snake tail tile sta (tileMem),y +checkLevel: + ; TODO + lda #WALL_TILE + sta $460 + lda #WALL_COLOR + sta $d860 + skipPauseTests: rts diff --git a/src/main.asm b/src/main.asm index b66b88d..9da991e 100644 --- a/src/main.asm +++ b/src/main.asm @@ -37,7 +37,7 @@ SEG sidSegment org $1000 sidtune: - INCBIN "../res/amour.sid" + INCBIN "../res.bin/amour.sid" #if DEBUG = 1 ECHO "End of SIDtune. Space left: ",($2000 - .) #endif diff --git a/src/program.asm b/src/program.asm index 847b2a2..fb411b8 100644 --- a/src/program.asm +++ b/src/program.asm @@ -7,7 +7,7 @@ start: ; Disable all interrupts sei - ; Turn off CIA interrupts and (eventually) flush the pending queue + ; Turn off CIA interrupts and (possibly) flush the pending queue ldy #$7f sty $dc0d sty $dd0d diff --git a/src/tggs.asm b/src/tggs.asm index ba4b251..080dcd0 100644 --- a/src/tggs.asm +++ b/src/tggs.asm @@ -909,14 +909,14 @@ BYTE #%10000000 ; character 91 - BYTE #%01011010 - BYTE #%01101011 - BYTE #%10101111 - BYTE #%10111110 - BYTE #%11101011 - BYTE #%10101010 - BYTE #%10111011 BYTE #%11111111 + BYTE #%01111111 + BYTE #%11110111 + BYTE #%11111111 + BYTE #%11011111 + BYTE #%11111101 + BYTE #%01111111 + BYTE #%01111111 ; character 92 BYTE #%11111011 diff --git a/util/rlevel.cpp b/util/rlevel.cpp new file mode 100644 index 0000000..800f81e --- /dev/null +++ b/util/rlevel.cpp @@ -0,0 +1,50 @@ +#include +using namespace std; + +const int MAXLEN = 64; + +void flush(char last, int count) { + switch(last) { + case 'x': + cout << (char)91; break; + default: + cout << (char)32; break; + } + cout << (char)count; +} + +int main(int argc, char** argv) { + char line[MAXLEN]; + char c; + + while (true) { + cin.getline(line, MAXLEN); + if (line[0] == 'Z') break; + cout << line << '\0'; /* the title */ + int count = 0; + + char last = '\0'; + char current = '\0'; + + while(true) { //for (int i = 0; i < 25; ++i) { + + cin.getline(line, MAXLEN); + if (line[0] == 'z') { + flush(current, count); + break; + } + + for (int j = 0; j < 40; ++j) { + current = line[j]; + if (last == 0) last = current; + if (current != last || count == 255) { + flush(last, count); + last = current; + count = 1; + } else { + ++count; + } + } + } + } +}