diff --git a/Makefile b/Makefile index 0884463..83198cd 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ all: $(PRG).wav cc6502 --core=6502 -O2 --list-file=$(@:%.o=obj/%.lst) --char-is-unsigned --pedantic-errors -o obj/$@ $< $(PRG).hex: $(OBJS) +# (cd obj ; ln6502 -g ../linker-files/linker.scm $^ -o ../out/$@ $(LIBS) -l --cross-reference --cstartup=tk2k --no-automatic-placement-rules --output-format intel-hex --hosted) (cd obj ; ln6502 -g ../linker-files/linker.scm $^ -o ../out/$@ $(LIBS) -l --cross-reference --cstartup=tk2k --no-automatic-placement-rules --output-format intel-hex) $(PRG).bin: $(PRG).hex diff --git a/linker-files/linker.scm b/linker-files/linker.scm index d35ced4..a359652 100644 --- a/linker-files/linker.scm +++ b/linker-files/linker.scm @@ -6,8 +6,10 @@ (memory program (address (#x801 . #x1fff)) (type ram) (section (programStart #x801) (startup #x80e) code)) (memory displayPage1 (address (#x2000 . #x3fff)) (type ram)) - (memory datamem (address (#x4000 . #x91ff)) (type ram) (section idata cdata data_init_table)) ;;; usermem goes from 0x4000 to 0x9FFFF (included), we are splitting it - (memory upperData (address (#x9200 . #x9fff)) (section cstack zdata data heap)) +;;; (memory datamem (address (#x4000 . #x91ff)) (type ram) (section cstack zdata heap)) ;;; usermem goes from 0x4000 to 0x9FFFF (included), we are splitting it +;;; (memory upperData (address (#x9200 . #x9fff)) (section switch idata cdata data data_init_table)) + (memory datamem (address (#x4000 . #x91ff)) (type ram) (section cstack zdata data heap)) ;;; usermem goes from 0x4000 to 0x9FFFF (included), we are splitting it + (memory upperData (address (#x9200 . #x9fff)) (section switch idata cdata data_init_table)) (memory displayPage2 (address (#xa000 . #xbfff)) (type ram)) (memory io (address (#xc000 . #xc0ff)) (type ram)) (memory rombank (address (#xc100 . #xffff)) (type rom)) diff --git a/src/game_logic.c b/src/game_logic.c index 71ac5af..3b532b0 100644 --- a/src/game_logic.c +++ b/src/game_logic.c @@ -83,7 +83,6 @@ game_state step_game(step_direction dir) { column_step = 1; row_step = GRID_SIDE; break; - break; case RIGHT: start_offset = GRID_SIDE - 1; column_step = -1; diff --git a/src/game_logic.h b/src/game_logic.h index 7b4b297..761c0b7 100644 --- a/src/game_logic.h +++ b/src/game_logic.h @@ -6,7 +6,7 @@ #define GRID_SIDE 5 typedef enum { - UP, + UP = 0, DOWN, LEFT, RIGHT diff --git a/src/main.c b/src/main.c index b62d4bd..88b6f40 100644 --- a/src/main.c +++ b/src/main.c @@ -8,6 +8,7 @@ #include "mem_map.h" #include "input.h" #include "game_logic.h" +#include "game_graphics.h" void __low_level_init(void); @@ -25,13 +26,38 @@ void __low_level_init(void) { } __task int main(void) { - key k; + game_state state; + + while(1){ // Outer loop + reset_game(); + draw_game_background(); + + while(1) { // Game loop + lfsr_update(); + + switch(read_kb()) { + case K_UP: + state = step_game(UP); + break; + case K_DOWN: + state = step_game(DOWN); + break; + case K_LEFT: + state = step_game(LEFT); + break; + case K_RIGHT: + state = step_game(RIGHT); + break; + default: + continue; // Do nothing, loop again + } - reset_game(); - - while(1){ - lfsr_update(); - k = read_kb(); + // If we have finished, break out of this loop + if(state.done) break; + + add_random_tile(); + } + }; return 0;