diff options
author | UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> | 2023-03-10 16:44:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-10 16:44:25 +0100 |
commit | 3c7f8d25c226510bd391c6b61e89e7f732ce3072 (patch) | |
tree | bd88048f7612af72a2ecd7643d2c4d677fb27a6a /test | |
parent | 80e2732c8f208f3f225a2a5c0e540bc50fceab5d (diff) | |
parent | 877ac831461f35d00e0e0ab7d6afbe93768fc7c6 (diff) |
Merge pull request #27 from UnavailableDev/game-engine
Game engine
Diffstat (limited to 'test')
-rw-r--r-- | test/bin/test_file_read.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/bin/test_file_read.c b/test/bin/test_file_read.c new file mode 100644 index 0000000..b3357ce --- /dev/null +++ b/test/bin/test_file_read.c @@ -0,0 +1,43 @@ + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> + + +#define HH_PPU_VRAM_TMM_SPRITE_SIZE 52 + + +void printData(uint8_t* in) { + for (int i = 0; i < HH_PPU_VRAM_TMM_SPRITE_SIZE; i++) + { + printf("%02x ",in[i]); + } + printf("\n"); +} + +void hh_ppu_load_tilemap() { + char* filename = "tiles.bin"; + FILE* fp = fopen(filename,"rb"); + if (!fp){ + return;//error + } + + fseek(fp, 0, SEEK_END); + int _size = ftell(fp)/HH_PPU_VRAM_TMM_SPRITE_SIZE; + fseek(fp, 0, 0); + // printf("%i",_size); + for (int i = 0; i < _size; i++) { + uint8_t data[HH_PPU_VRAM_TMM_SPRITE_SIZE]; + fread(data,HH_PPU_VRAM_TMM_SPRITE_SIZE,1,fp); + + printData(data); + } + fclose(fp); + +} + + +int main(){ +hh_ppu_load_tilemap(); + return 0; +} |