aboutsummaryrefslogtreecommitdiff
path: root/src/ppusim
diff options
context:
space:
mode:
Diffstat (limited to 'src/ppusim')
-rw-r--r--src/ppusim/sim.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/ppusim/sim.c b/src/ppusim/sim.c
index 7d56d2d..1fceb82 100644
--- a/src/ppusim/sim.c
+++ b/src/ppusim/sim.c
@@ -1,9 +1,12 @@
#include <SDL2/SDL.h>
#include <stdbool.h>
#include <stdlib.h>
+#include <stdio.h>
#include "main.h"
#include "ppu/ppu.h"
+#include "ppu/consts.h"
+#include "ppu/internals.h"
#include "ppusim/mem.h"
#include "ppusim/sim.h"
#include "ppusim/work.h"
@@ -26,7 +29,27 @@ void hh_ppu_init() {
}
void hh_ppu_load_tilemap() {
-
+ char* filename = "tiles.bin";
+ FILE* fp = fopen(filename,"rb");
+ if (!fp){
+ return;//error
+ }
+
+ fseek(fp, 0, SEEK_END);//goto EOF
+ int _size = ftell(fp)/HH_PPU_VRAM_TMM_SPRITE_SIZE;
+ fseek(fp, 0, 0);//goto start of file
+
+ 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);
+
+ hh_s_ppu_vram_data sprite = hh_ppu_2nat_sprite(data);
+ sprite.offset = i*HH_PPU_VRAM_TMM_SPRITE_SIZE;
+ hh_ppu_vram_write(sprite);
+ free(sprite.data);
+ }
+ fclose(fp);
}
void hh_ppu_deinit() {