aboutsummaryrefslogtreecommitdiff
path: root/test/bin/test_file_read.c
blob: df933958bb44e0f5ca9a85d9563d98e2c8488630 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#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 = "slime.bin";
	FILE* fp = fopen(filename,"rb");
	if (!fp){
		return;//error
	}

	int sprite_size = (16 * 16);
	fseek(fp, 0, SEEK_END);
	int _size = ftell(fp)/sprite_size;
	rewind(fp);
	// printf("%i",_size);
	for (int i = 0; i < _size; i++) {
		uint8_t data[sprite_size];
		fread(data,1,sprite_size,fp);
		
		printData(data);
	}
	fclose(fp);

}


int main(){
hh_ppu_load_tilemap();
    return 0;
}