aboutsummaryrefslogtreecommitdiff
path: root/src/engine/draw_screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/draw_screen.c')
-rw-r--r--src/engine/draw_screen.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/engine/draw_screen.c b/src/engine/draw_screen.c
index c4f3389..205d4b6 100644
--- a/src/engine/draw_screen.c
+++ b/src/engine/draw_screen.c
@@ -19,7 +19,6 @@ uint8_t hh_world_to_tile(vec2 pos){
return tile;
}
-
// remeber old value to know which part to update.
vec2 previousViewport = { .x = 0, .y = 0 };
void hh_draw_screen(vec_cor viewport){
@@ -60,3 +59,51 @@ void hh_setup_screen(){
}
free(tile);
}
+
+void hh_setup_startingScreen(){
+ int size = 300; // 40 x as tiles 30 y as tiles
+ FILE* level = fopen("../test/bin/startingScreen.bin", "rb"); /* open binary file */
+ if (!level) { /* check if file opened successfully */
+ fprintf(stderr, "Error: Failed to open file.\n");
+ return;
+ }
+ fseek(level, (0* sizeof(int)) + sizeof(int), SEEK_SET);
+ int* tile = (int*)malloc(size*sizeof(int));
+ fread(tile, sizeof(int), size, level); // read 1 tile from binary
+
+ fclose(level);
+
+ for(int BAM_index = 0; BAM_index < size; BAM_index++){
+ hh_ppu_update_background(BAM_index, (hh_s_ppu_loc_bam_entry){
+ .horizontal_flip = false,
+ .vertical_flip = false,
+ .palette_index = hh_get_palette(tile[BAM_index]),
+ .tilemap_index = tile[BAM_index],
+ });
+ }
+ free(tile);
+}
+
+void hh_setup_shopScreen(){
+ int size = 300; // 40 x as tiles 30 y as tiles
+ FILE* level = fopen("../test/bin/shopScreen.bin", "rb"); /* open binary file */
+ if (!level) { /* check if file opened successfully */
+ fprintf(stderr, "Error: Failed to open file.\n");
+ return;
+ }
+ fseek(level, (0* sizeof(int)) + sizeof(int), SEEK_SET);
+ int* tile = (int*)malloc(size*sizeof(int));
+ fread(tile, sizeof(int), size, level); // read 1 tile from binary
+
+ fclose(level);
+
+ for(int BAM_index = 0; BAM_index < size; BAM_index++){
+ hh_ppu_update_background(BAM_index, (hh_s_ppu_loc_bam_entry){
+ .horizontal_flip = false,
+ .vertical_flip = false,
+ .palette_index = hh_get_palette(tile[BAM_index]),
+ .tilemap_index = tile[BAM_index],
+ });
+ }
+ free(tile);
+}