aboutsummaryrefslogtreecommitdiff
path: root/src/engine/draw_screen.c
diff options
context:
space:
mode:
authorUnavailableDev <ggwildplay@gmail.com>2023-03-15 20:44:06 +0100
committerUnavailableDev <ggwildplay@gmail.com>2023-03-15 20:44:06 +0100
commit623bcb03aead264b412bcba9fed75df22e115fab (patch)
treef71e0eaa78d17f997c275f7ca5b457f11752dc01 /src/engine/draw_screen.c
parent0c3292879774e33dfb3e8c7d787b236876508467 (diff)
added title screen
Diffstat (limited to 'src/engine/draw_screen.c')
-rw-r--r--src/engine/draw_screen.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/engine/draw_screen.c b/src/engine/draw_screen.c
index c4f3389..58553bd 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/tiles.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);
@@ -60,3 +61,27 @@ void hh_setup_screen(){
}
free(tile);
}
+
+void hh_clear_screen(){
+ // (HH_PPU_SCREEN_HEIGHT*HH_PPU_SCREEN_WIDTH)/(HH_PPU_SPRITE_HEIGHT*HH_PPU_SPRITE_WIDTH)
+ for (int i = 0; i < HH_PPU_BG_CANVAS_TILES_H*HH_PPU_BG_CANVAS_TILES_V; i++) {
+ hh_s_ppu_loc_bam_entry temp = {
+ .vertical_flip=false,.horizontal_flip = false,
+ .palette_index = 3,.tilemap_index = 0
+ };
+ hh_ppu_update_background(i,temp);
+ hh_ppu_update_color(3,0,(hh_ppu_rgb_color_t){0x0,0x0,0x0});
+ }
+ hh_ppu_update_aux((hh_s_ppu_loc_aux){
+ .bg_shift_x = 0,
+ .bg_shift_y = 0,
+ .fg_fetch = 0,
+ .sysreset = 0,
+ });
+}
+
+void hh_clear_sprite(){
+ for (int i = 0; i < HH_PPU_FG_SPRITE_COUNT; i++) {
+ hh_ppu_update_sprite(i,(hh_s_ppu_loc_sprite){0});
+ }
+}