first level draft - level txt parser

compression
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/
build/
res.bin/
*.prg
*.out
symbols.txt

View File

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

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_TILE = 90
FOOD_COLOR = 11
; Wall features
WALL_TILE = 91
WALL_COLOR = 11
; Strings
; ----------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

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;
}
}
}
}
}