diff options
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/draw_screen.c | 9 | ||||
-rw-r--r-- | src/engine/draw_screen.h | 2 | ||||
-rw-r--r-- | src/engine/sprite_controller.c | 4 | ||||
-rw-r--r-- | src/engine/sprite_controller.h | 32 |
4 files changed, 31 insertions, 16 deletions
diff --git a/src/engine/draw_screen.c b/src/engine/draw_screen.c index fed2cfa..0c31bf6 100644 --- a/src/engine/draw_screen.c +++ b/src/engine/draw_screen.c @@ -2,8 +2,8 @@ #include "engine/sprite_controller.h" uint8_t hh_world_to_tile(vec2 pos){ - - FILE* level = fopen("../test/bin/level1_test.bin", "rb"); /* open binary file */ + //TODO: remove magic file name here + FILE* level = fopen("static/level1_test.bin", "rb"); /* open binary file */ if (!level) { /* check if file opened successfully */ fprintf(stderr, "Error: Failed to open file.\n"); return 0; @@ -39,9 +39,10 @@ void hh_draw_screen(vec_cor viewport){ void hh_setup_screen(){ //(HH_map_size_X*HH_map_size_Y) int size = 2400; // max X = 40 en max Y = 80 - FILE* level = fopen("../test/bin/level1_test.bin", "rb"); /* open binary file */ + //TODO: remove magic file name here + FILE* level = fopen("static/level1_test.bin", "rb"); /* open binary file */ if (!level) { /* check if file opened successfully */ - fprintf(stderr, "Error: Failed to open file.\n"); + fprintf(stderr, "Error: Failed to open level file.\n"); return; } fseek(level, (0* sizeof(int)) + sizeof(int), SEEK_SET); diff --git a/src/engine/draw_screen.h b/src/engine/draw_screen.h index d3abca6..95765e5 100644 --- a/src/engine/draw_screen.h +++ b/src/engine/draw_screen.h @@ -3,6 +3,7 @@ // every function call for drawing the screen goes here. #include "engine/maths.h" +#include "ppu/consts.h" #include "ppu/ppu.h" #include <stdio.h> @@ -19,7 +20,6 @@ uint8_t hh_world_to_tile(vec2 pos); void hh_draw_screen(vec2 viewport); /** @brief send data to BAM memory from binary level */ void hh_setup_screen(); - /** @brief send black screen to background memory */ void hh_clear_screen(); /** @brief clears all sprite data */ diff --git a/src/engine/sprite_controller.c b/src/engine/sprite_controller.c index 5d93cf8..b38b647 100644 --- a/src/engine/sprite_controller.c +++ b/src/engine/sprite_controller.c @@ -10,11 +10,13 @@ uint8_t hh_get_palette(uint8_t tile_idx) { } void hh_setup_palettes(){ + //TODO: use simpler function for (int idx = 0; idx < HH_PPU_PALETTE_COUNT; idx++) { for (int col = 0; col < HH_PPU_PALETTE_COLOR_COUNT; col++) { hh_ppu_update_color(idx,col,hh_g_palette[idx][col]); } - } + } + // hh_ppu_update_palette_table(hh_g_palette); } bool hh_colidable(uint8_t tile_idx){ diff --git a/src/engine/sprite_controller.h b/src/engine/sprite_controller.h index fbb230c..fc6d3d3 100644 --- a/src/engine/sprite_controller.h +++ b/src/engine/sprite_controller.h @@ -11,15 +11,27 @@ //TODO: pack data inside of sprite_palette LUT //HH_PPU_PALETTE_COUNT -#define HH_SPRITE_COUNT 40 -#define HH_PAL_IDX_SKY 0 +#define HH_SPRITE_COUNT 80 +#define HH_PAL_IDX_SKY 512 #define HH_PAL_IDX_BRICK 1 const static uint8_t hh_g_sprite_palette[HH_SPRITE_COUNT] = { + //TODO: make a buffer of 16 no-collider sprites (instead of the current 1) 0,1,1,1,1,1,1,1,1,1, //1+9 1,1,1,1,1,1,1,1,1,1, //6+4 1,1,1,1,1,1,1,1,1, //9 - 7,7,7,2,7,7,1,2,7 + 7,7,7,2,7,7,1,2,7, + 7,7,7,7, //?? + + 7,6,6,6,6,6,6,6, //baskets + 7,7,7,7,7,7,7,7,7,7, //shop + 7,7,7,7,7, //shop + 6,6,6,6,6, //(hi-)score + + 3,3,3,3,3,3, //title_screen icon + 6,6,6,6,/*6,6,6,6,6,6, //title_screen large letters + 6,6,6,6,*/ //other palettes here: + // [HH_PAL_IDX_SKY] = 0, }; @@ -51,13 +63,13 @@ const static hh_ppu_loc_palette_table_t hh_g_palette = { {0x0,0x0,0x0}, {0x0,0x0,0x0}, {0x0,0x0,0x0}}, - {//player + {//player //TODO: use one less color && update player indexed sprites {0x0,0x0,0x0}, {0x1,0x1,0x1}, {0x4,0x2,0x5}, - {0x7,0x3,0x6}, - {0x1,0x1,0x3}, - {0xe,0xe,0xe}, + {0x7,0x3,0x7}, + {0xe,0xe,0xe}, + {0xe,0xe,0xe}, //elemental {0x0,0x0,0x0}, {0x0,0x0,0x0}}, { @@ -69,7 +81,7 @@ const static hh_ppu_loc_palette_table_t hh_g_palette = { {0x0,0x0,0x0}, {0x0,0x0,0x0}, {0x0,0x0,0x0}}, - { + {//elemental {0x0,0x0,0x0}, {0x0,0x0,0x0}, {0x0,0x0,0x0}, @@ -79,7 +91,7 @@ const static hh_ppu_loc_palette_table_t hh_g_palette = { {0x0,0x0,0x0}, {0x0,0x0,0x0}}, {//white - {0xf,0xf,0xf}, + {0x1,0x2,0x3}, {0xf,0xf,0xf}, {0xf,0xf,0xf}, {0xf,0xf,0xf}, @@ -87,7 +99,7 @@ const static hh_ppu_loc_palette_table_t hh_g_palette = { {0xf,0xf,0xf}, {0xf,0xf,0xf}, {0xf,0xf,0xf}}, - { + {//Dev palette (7) {0x0,0xf,0xf}, {0xf,0xf,0xf}, {0xf,0x0,0xf}, |