first level draft - level txt parser

This commit is contained in:
giomba 2020-04-02 01:13:10 +02:00
parent 70b2b7ad47
commit f628645740
10 changed files with 147 additions and 21 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
bin/ bin/
build/ build/
res.bin/
*.prg *.prg
*.out *.out
symbols.txt symbols.txt

View File

@ -1,20 +1,30 @@
.POSIX: .POSIX:
ASM=$(wildcard src/*.asm) ASM=$(wildcard src/*.asm)
RES=$(wildcard res/*) RES=res.bin/amour.sid res.bin/levels.bin
.PHONY: debug env clean .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 dasm src/main.asm -Isrc/ -DSYSTEM=64 -DDEBUG=0 -obin/snake.prg
clean: clean:
rm -rf {build,bin} rm -rf {build,bin,res.bin}
env: 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 g++ -o bin/explodefont util/explodefont.cpp
dasm src/main.asm -Isrc/ -DSYSTEM=64 -DDEBUG=1 -sbuild/symbols.txt -obin/snake.prg 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

56
res.org/levels.txt Normal file
View File

@ -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

View File

@ -18,6 +18,9 @@ SNAKE_COLOR = 13
; Food features ; Food features
FOOD_TILE = 90 FOOD_TILE = 90
FOOD_COLOR = 11 FOOD_COLOR = 11
; Wall features
WALL_TILE = 91
WALL_COLOR = 11
; Strings ; Strings
; ---------------------------------------------------------------------- ; ----------------------------------------------------------------------

View File

@ -239,13 +239,6 @@ genFoodY: ; calculate `random` modulo 22 (22 = SCREEN_H - 1)
cmp snakeY cmp snakeY
beq genFood beq genFood
foodOK: foodOK:
; debug -- print choosen X,Y for food
; ldy #$18
; lda calcTileX
; jsr printByte
; ldy #$1b
; lda calcTileY
; jsr printByte
ldy #0 ldy #0
jsr calcTileMem ; calc food address in memory jsr calcTileMem ; calc food address in memory
@ -277,6 +270,12 @@ checkSelfEat:
jmp gameover jmp gameover
checkEndSelfEat: checkEndSelfEat:
checkWallHit:
cmp #WALL_TILE
bne checkEndWallHit
jmp gameover
checkEndWallHit:
; Draw snake head ; Draw snake head
ldy #0 ldy #0
lda snakeX ; calc char address in video memory, and put SNAKE_TILE 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 lda #$20 ; just put a space to erase snake tail tile
sta (tileMem),y sta (tileMem),y
checkLevel:
; TODO
lda #WALL_TILE
sta $460
lda #WALL_COLOR
sta $d860
skipPauseTests: skipPauseTests:
rts rts

View File

@ -37,7 +37,7 @@
SEG sidSegment SEG sidSegment
org $1000 org $1000
sidtune: sidtune:
INCBIN "../res/amour.sid" INCBIN "../res.bin/amour.sid"
#if DEBUG = 1 #if DEBUG = 1
ECHO "End of SIDtune. Space left: ",($2000 - .) ECHO "End of SIDtune. Space left: ",($2000 - .)
#endif #endif

View File

@ -7,7 +7,7 @@ start:
; Disable all interrupts ; Disable all interrupts
sei sei
; Turn off CIA interrupts and (eventually) flush the pending queue ; Turn off CIA interrupts and (possibly) flush the pending queue
ldy #$7f ldy #$7f
sty $dc0d sty $dc0d
sty $dd0d sty $dd0d

View File

@ -909,14 +909,14 @@
BYTE #%10000000 BYTE #%10000000
; character 91 ; character 91
BYTE #%01011010
BYTE #%01101011
BYTE #%10101111
BYTE #%10111110
BYTE #%11101011
BYTE #%10101010
BYTE #%10111011
BYTE #%11111111 BYTE #%11111111
BYTE #%01111111
BYTE #%11110111
BYTE #%11111111
BYTE #%11011111
BYTE #%11111101
BYTE #%01111111
BYTE #%01111111
; character 92 ; character 92
BYTE #%11111011 BYTE #%11111011

50
util/rlevel.cpp Normal file
View File

@ -0,0 +1,50 @@
#include <iostream>
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;
}
}
}
}
}