diff options
author | UnavailableDev <ggwildplay@gmail.com> | 2023-03-10 16:32:50 +0100 |
---|---|---|
committer | UnavailableDev <ggwildplay@gmail.com> | 2023-03-10 16:36:10 +0100 |
commit | 8670e4bb2bdaf46399830d9c4d413705ae01dc40 (patch) | |
tree | 5c95ef958e0ab9beb1e2ccea1ec4d75bfab407cd /test/bin | |
parent | e3e0feb56340a72545b6fd38f22e134cf2e3509a (diff) |
ppusim read sprites from file and put into vram
Diffstat (limited to 'test/bin')
-rw-r--r-- | test/bin/test_file_read.c | 48 |
1 files changed, 48 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..6357feb --- /dev/null +++ b/test/bin/test_file_read.c @@ -0,0 +1,48 @@ + +#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() { + + //TODO: lees bestand in mem + 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]; + // for (int i = 0; i < 255; i++) { + // buffer[i] = 0; //TODO: vullen + fread(data,HH_PPU_VRAM_TMM_SPRITE_SIZE,1,fp); + // } + + printData(data); + } + fclose(fp); + +} + + +int main(){ +hh_ppu_load_tilemap(); + return 0; +} |