aboutsummaryrefslogtreecommitdiff
path: root/src/ppusim/sim.c
diff options
context:
space:
mode:
authorFlenk008 <frenk_0_0@hotmail.com>2023-03-10 20:22:58 +0100
committerGitHub <noreply@github.com>2023-03-10 20:22:58 +0100
commitb707ac24673ec20aa04fcd8dc1c022d36bc3a49a (patch)
treebd88048f7612af72a2ecd7643d2c4d677fb27a6a /src/ppusim/sim.c
parent6bd3372103a97f8cb3183f1a7b0a3cfc3c1e1558 (diff)
parent3c7f8d25c226510bd391c6b61e89e7f732ce3072 (diff)
Merge branch 'lonkaars:dev' into dev
Diffstat (limited to 'src/ppusim/sim.c')
-rw-r--r--src/ppusim/sim.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/ppusim/sim.c b/src/ppusim/sim.c
index 449b78d..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"
@@ -22,6 +25,31 @@ void hh_ppu_init() {
g_hh_ppusim_vram = malloc(sizeof(hh_ppu_data_t) * 0xffff);
memset(g_hh_ppusim_vram, 0x0000, 0xffff);
+ hh_ppu_load_tilemap();
+}
+
+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() {