aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlenk008 <frenk_0_0@hotmail.com>2023-03-13 18:02:59 +0100
committerFlenk008 <frenk_0_0@hotmail.com>2023-03-13 18:02:59 +0100
commita9ad8e0a8ac5346108f1e2c1a0bf9360fadc20da (patch)
treeb3b772e0fc396aa7d09d8581c61d68b963394ac4 /src
parent4f489426e05fb3b296998b17859d8702cc4f37e1 (diff)
Revert "Merge branch 'dev' of https://github.com/Flenk008/avans-arcade into dev"
This reverts commit 4f489426e05fb3b296998b17859d8702cc4f37e1, reversing changes made to e47f7fa198229b8598b8ab03ef8b2483f7c685bc.
Diffstat (limited to 'src')
-rw-r--r--src/.gitignore1
-rw-r--r--src/engine/TODO/entity.c41
-rw-r--r--src/engine/TODO/entity.h24
-rw-r--r--src/engine/TODO/player_controller.h4
-rw-r--r--src/engine/TODO/sprite_controller.h6
-rw-r--r--src/engine/camera.c34
-rw-r--r--src/engine/camera.h6
-rw-r--r--src/engine/draw_screen.c62
-rw-r--r--src/engine/draw_screen.h16
-rw-r--r--src/engine/engine.c1
-rw-r--r--src/engine/entity.c46
-rw-r--r--src/engine/entity.h57
-rw-r--r--src/engine/maths.c19
-rw-r--r--src/engine/maths.h7
-rw-r--r--src/engine/player_controller.c167
-rw-r--r--src/engine/player_controller.h7
-rw-r--r--src/engine/sprite_controller.c22
-rw-r--r--src/engine/sprite_controller.h106
-rw-r--r--src/makefile8
-rw-r--r--src/ppusim/sim.c11
20 files changed, 84 insertions, 561 deletions
diff --git a/src/.gitignore b/src/.gitignore
index 504b995..d8325cf 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -4,4 +4,3 @@ main.bin
main
main.exe
static/
-*.bin
diff --git a/src/engine/TODO/entity.c b/src/engine/TODO/entity.c
new file mode 100644
index 0000000..fa550d5
--- /dev/null
+++ b/src/engine/TODO/entity.c
@@ -0,0 +1,41 @@
+#include <stdbool.h>
+
+#include "hh_entity.h"
+#include "maths.h"
+
+/*
+ PLAYER: (pos on X)
+ ,___,
+ | |
+ | X |
+ |___|
+
+*/
+
+bool hh_collision(vec2* pos1, vec2* pos2){
+ if (pos2->x == CLAMP(pos2->x,pos1->x,pos1->x+1.0f)){// hit x
+ return true;
+ }
+
+ if (pos2->y == CLAMP(pos2->y,pos1->y,pos1->y+0.99f)){// hit y
+ return true;
+ }
+ return false;
+}
+
+void hh_solve_collision(vec2* pos_environment, hh_entity* entity){
+ if (entity->vec.x > 0.0f){
+ entity->pos.x = MIN(entity->pos.x,pos_environment->x-1.0f);
+ entity->vec.x = 0.0f;
+ } else if (entity->vec.x < 0.0f){
+ entity->pos.x = MAX(entity->pos.x,pos_environment->x+1.0f);
+ entity->vec.x = 0.0f;
+ } else if (entity->vec.y > 0.0f){
+ entity->pos.x = MIN(entity->pos.x,pos_environment->x-1.0f);
+ entity->vec.x = 0.0f;
+ } else if (entity->vec.y < 0.0f){
+ entity->pos.x = MAX(entity->pos.x,pos_environment->x+1.0f);
+ entity->vec.x = 0.0f;
+ }
+}
+
diff --git a/src/engine/TODO/entity.h b/src/engine/TODO/entity.h
new file mode 100644
index 0000000..fdbeb8a
--- /dev/null
+++ b/src/engine/TODO/entity.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <stdint.h>
+
+#include "maths.h"
+
+typedef struct {
+ vec2 pos, vec;
+ bool is_grounded;
+ int8_t hp;
+ //armor/block?
+}hh_entity;
+
+/// @brief detect for collision enity and eviroment
+/// @param pos1 position of environment tile to be checked
+/// @param pos2 position entity
+/// @return true if collision between enity and environment
+bool hh_collision(vec2* pos1, vec2* pos2);
+
+/// @brief solve collisions
+/// @param environment position
+/// @param entity position
+/// @return solved new entity position
+void hh_solve_collision(vec2* pos_environment, hh_entity* entity);
diff --git a/src/engine/TODO/player_controller.h b/src/engine/TODO/player_controller.h
new file mode 100644
index 0000000..1e9b86c
--- /dev/null
+++ b/src/engine/TODO/player_controller.h
@@ -0,0 +1,4 @@
+#include "maths.h"
+#include "hh_entity.h"
+
+// inputs
diff --git a/src/engine/TODO/sprite_controller.h b/src/engine/TODO/sprite_controller.h
new file mode 100644
index 0000000..c1fadff
--- /dev/null
+++ b/src/engine/TODO/sprite_controller.h
@@ -0,0 +1,6 @@
+// handles sprites
+
+// Bg sprites
+
+
+// Fg or entity sprites
diff --git a/src/engine/camera.c b/src/engine/camera.c
deleted file mode 100644
index e756bd4..0000000
--- a/src/engine/camera.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "engine/camera.h"
-
-#include "ppu/consts.h"
-
-
-vec_cor hh_update_camera(vec_cen new, vec2 min, vec2 max){
-
- //TODO: change floating point math to fix point math
- //TODO: fix buggy y-axis ??
-
- // new = vec_cen2cor(new,(vec2){.x=max.x/2,.y=max.y/2});
- new = vec_cen2cor((vec2){.x=new.x+(HH_PPU_SPRITE_WIDTH/2),.y=(new.y+(HH_PPU_SPRITE_HEIGHT/2))*2},(vec2){.x=max.x/2,.y=max.y/2});
- // new.x = new.x << HH_MATH_FIXED_POINT;
- // new.y = new.y << HH_MATH_FIXED_POINT;
- static vec_cor old;
- // old.x = old.x << HH_MATH_FIXED_POINT;
- // old.y = old.y << HH_MATH_FIXED_POINT;
-
- // int16_t some = 0;
- // some = some <<= HH_MATH_FIXED_POINT-1;
-
- new.x = (int)((float)new.x*0.1f + (float)old.x*0.9f);
- new.y = (int)((float)new.y*0.1f + (float)old.y*0.9f);
-
- // old.x = old.x >> HH_MATH_FIXED_POINT;
- // old.y = old.y >> HH_MATH_FIXED_POINT;
-
-
- old.x = CLAMP(new.x,min.x,max.x);
- old.y = CLAMP(new.y,min.y,max.y);
-
- return old;
-}
-
diff --git a/src/engine/camera.h b/src/engine/camera.h
deleted file mode 100644
index b3ffb52..0000000
--- a/src/engine/camera.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-
-#include "engine/maths.h"
-
-vec_cor hh_update_camera(vec_cor new, vec2 min, vec2 max);
-
diff --git a/src/engine/draw_screen.c b/src/engine/draw_screen.c
deleted file mode 100644
index c4f3389..0000000
--- a/src/engine/draw_screen.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "engine/draw_screen.h"
-#include "engine/sprite_controller.h"
-
-uint8_t hh_world_to_tile(vec2 pos){
-
- FILE* level = fopen("../test/bin/level1_test.bin", "rb"); /* open binary file */
- if (!level) { /* check if file opened successfully */
- fprintf(stderr, "Error: Failed to open file.\n");
- return 0;
- }
- int index = ((pos.y/16)*40 + pos.x/16);//TODO: remove magic number(s)
- fseek(level, (index * sizeof(int)) + sizeof(int), SEEK_SET);
- int tile;// = (int*)malloc(sizeof(int));
- fread(&tile, sizeof(int), 1, level); // read 1 tile from binary
-
- fclose(level);
- // int val = tile;
- // free(tile);
- return tile;
-}
-
-
-// remeber old value to know which part to update.
-vec2 previousViewport = { .x = 0, .y = 0 };
-void hh_draw_screen(vec_cor viewport){
- if (viewport.x == previousViewport.x && viewport.y == previousViewport.y) return;
-
- hh_ppu_update_aux((hh_s_ppu_loc_aux){
- .bg_shift_x = viewport.x,
- .bg_shift_y = viewport.y,
- .fg_fetch = 0,
- .sysreset = 0,
- });
-
- // update previous viewport values
- previousViewport = viewport;
-}
-
-void hh_setup_screen(){
- //(HH_map_size_X*HH_map_size_Y)
- int size = 2400; // max X = 40 en max Y = 80
- FILE* level = fopen("../test/bin/level1_test.bin", "rb"); /* open binary file */
- if (!level) { /* check if file opened successfully */
- fprintf(stderr, "Error: Failed to open file.\n");
- return;
- }
- fseek(level, (0* sizeof(int)) + sizeof(int), SEEK_SET);
- int* tile = (int*)malloc(size*sizeof(int));
- fread(tile, sizeof(int), size, level); // read 1 tile from binary
-
- fclose(level);
-
- for(int BAM_index = 0; BAM_index < size; BAM_index++){
- hh_ppu_update_background(BAM_index, (hh_s_ppu_loc_bam_entry){
- .horizontal_flip = false,
- .vertical_flip = false,
- .palette_index = hh_get_palette(tile[BAM_index]),
- .tilemap_index = tile[BAM_index],
- });
- }
- free(tile);
-}
diff --git a/src/engine/draw_screen.h b/src/engine/draw_screen.h
index b181108..4af5865 100644
--- a/src/engine/draw_screen.h
+++ b/src/engine/draw_screen.h
@@ -3,19 +3,7 @@
// every function call for drawing the screen goes here.
#include "engine/maths.h"
-#include "ppu/ppu.h"
-#include <stdio.h>
#include <stdint.h>
-#include <stdlib.h>
-
-
-#define HH_map_size_X 80
-#define HH_map_size_Y 60
-
-/** @brief return a single tile from world binary */
-uint8_t hh_world_to_tile(vec2 pos);
-/** @brief shift to level if viewport changed position */
-void hh_draw_screen(vec2 viewport);
-/** @brief send data to BAM memory from binary level */
-void hh_setup_screen();
+uint16_t hh_world_to_tile(vec2 pos);
+void hh_draw_screen(vec2 viewport); \ No newline at end of file
diff --git a/src/engine/engine.c b/src/engine/engine.c
index 799ee7c..f3410a4 100644
--- a/src/engine/engine.c
+++ b/src/engine/engine.c
@@ -1,4 +1,3 @@
#include "engine/draw_screen.h"
#include "engine/level.h"
#include "engine/maths.h"
-#include "engine/sprite_controller.h"
diff --git a/src/engine/entity.c b/src/engine/entity.c
deleted file mode 100644
index 153e7e1..0000000
--- a/src/engine/entity.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <stdbool.h>
-
-#include "engine/entity.h"
-#include "engine/maths.h"
-
-/*
- PLAYER: (pos on X)
- ,___,
- | |
- | X |
- |___|
-
-*/
-
-bool hh_collision(vec_cor pos1, vec2 pos2){
- if (pos2.x == CLAMP(pos2.x, pos1.x, pos1.x+16)){// hit x
- return true;
- }
-
- if (pos2.y == CLAMP(pos2.y, pos1.y, pos1.y+16)){// hit y
- return true;
- }
- return false;
-}
-
-void hh_solve_collision(vec2 pos_environment, hh_entity* entity){
- if (!hh_collision(pos_environment,entity->pos))
- return;
-
- printf("BONK!/n");
- // if (entity->vel.y > 0){
- // entity->pos.y = MAX(entity->pos.y,pos_environment.y);
- // entity->vel.y = 0;
- // } else {
- // entity->pos.y = MIN(entity->pos.y,pos_environment.y);
- // entity->vel.y = 0;
- // }
- // if (entity->vel.x <= 0){
- // entity->pos.x = MIN(entity->pos.x,pos_environment.x-16);
- // entity->vel.x = 0;
- // } else {
- // entity->pos.x = MAX(entity->pos.x,pos_environment.x+16);
- // entity->vel.x = 0;
- // }
-}
-
diff --git a/src/engine/entity.h b/src/engine/entity.h
deleted file mode 100644
index f45dae2..0000000
--- a/src/engine/entity.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#pragma once
-
-#include <stdint.h>
-#include <stdbool.h>
-
-#include "ppu/types.h"
-
-#include "engine/maths.h"
-
-typedef uint8_t hh_idx_t;
-
-typedef enum {
- fire, ice, poison
-}hh_e_damage_t;
-
-typedef struct {
- hh_s_ppu_loc_fam_entry fam; //screen
- hh_idx_t frame0;
- hh_idx_t palette;
-
-}hh_s_rendering;
-
-typedef struct {
- int8_t hp;
- int8_t dmg;
- hh_e_damage_t dmg_type;
- int8_t speed_x, speed_y;
-
-} hh_s_atributes;
-
-
-typedef struct {
- vec2 pos, vel, vec;
- bool is_grounded;
- int8_t hp;
- int8_t speed;
- hh_s_rendering render;
- //armor/block?
-}hh_entity;
-
-typedef struct {
- hh_entity p;
- hh_s_atributes atr;
-}hh_s_player;
-
-
-/// @brief detect for collision enity and eviroment
-/// @param pos1 position of environment tile to be checked
-/// @param pos2 position entity
-/// @return true if collision between enity and environment
-bool hh_collision(vec2 pos1, vec2 pos2);
-
-/// @brief solve collisions
-/// @param environment position
-/// @param entity position
-/// @return solved new entity position
-void hh_solve_collision(vec2 pos_environment, hh_entity* entity);
diff --git a/src/engine/maths.c b/src/engine/maths.c
deleted file mode 100644
index 475bba2..0000000
--- a/src/engine/maths.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "engine/maths.h"
-
-vec2 vec_add(vec2 a, vec2 b){
- return (vec2){a.x + b.x, a.y + b.y};
-}
-
-vec_cor vec_cen2cor(vec_cen in, vec2 halfDistance){
- return (vec_cor){
- .x = in.x - halfDistance.x,
- .y = in.y - halfDistance.y,
- };
-}
-
-vec_cen vec_cor2cen(vec_cor in, vec2 halfDistance){
- return (vec_cen){
- .x = in.x + halfDistance.x,
- .y = in.y + halfDistance.y,
- };
-}
diff --git a/src/engine/maths.h b/src/engine/maths.h
index bef287e..c7f1b44 100644
--- a/src/engine/maths.h
+++ b/src/engine/maths.h
@@ -3,17 +3,12 @@
// #include <math.h>
typedef struct {
- int32_t x,y;
+ uint32_t x,y;
} vec2;
typedef vec2 vec_cen;//centered
typedef vec2 vec_cor;//left upper corner
-vec2 vec_add(vec2 a, vec2 b);
-
-vec_cor vec_cen2cor(vec_cen in, vec2 halfDistance);
-vec_cor vec_cor2cen(vec_cen in, vec2 halfDistance);
-
//fixed point at decimal 7lsb (world positions in pixels (with fixed decimal point))
#define HH_MATH_FIXED_POINT 7
diff --git a/src/engine/player_controller.c b/src/engine/player_controller.c
deleted file mode 100644
index 6735620..0000000
--- a/src/engine/player_controller.c
+++ /dev/null
@@ -1,167 +0,0 @@
-#include "ppu/types.h"
-#include "engine/camera.h"
-#include "engine/draw_screen.h"
-#include "engine/sprite_controller.h"
-#include "engine/player_controller.h"
-
-#include "demo.h"
-#include <stdio.h>
-
-#include "input.h"
-
-void hh_player_actions() {
- static hh_entity player={
- .hp = 4,
- .speed = 6,
- .is_grounded = false,
- .pos = (vec2){32,32},
- .vel = (vec2){0,0},
- .vec = (vec2){0,0},
- .render = {
- .frame0 = 20,
- .palette = 7,
- .fam = (hh_s_ppu_loc_fam_entry){
- .horizontal_flip = false,
- .vertical_flip = false,
- .palette_index = 7,
- .tilemap_index = 2,
- }
- }
- }, player_new = {0};
-
- // hh_input_read();
- player.vel = (vec2){.x = (-1 * g_hh_controller_p1.dpad_left) + (1 * g_hh_controller_p1.dpad_right),
- .y = (-1 * g_hh_controller_p1.dpad_up) + (1 * g_hh_controller_p1.dpad_down) };
- // const int8_t maa = 3;
- // const int8_t mbb = -3;
- // if (g_hh_controller_p1.dpad_up)
- //
- // if (g_hh_controller_p1.dpad_down)
- //
- // if (g_hh_controller_p1.dpad_left) {
- // player.vel.x += mbb;
- // // g_hh_demo_balls[0].horizontal_flip = true;
- // }
- // if (g_hh_controller_p1.dpad_right) {
- // player.vel.x += maa;
- // // g_hh_demo_balls[0].horizontal_flip = true;
- // }
- // if (g_hh_controller_p1.button_primary /*&& player.is_grounded*/) //JUMP
- // player.vel.y += -6;
- // // // if (g_hh_controller_p1.button_secondary)
-
- // player.render.fam.palette_index = 7;
- // player.render.fam.tilemap_index = 7;
-
- // printf("%x ",player.render.fam.palette_index);
-
- // player.vel.y += 1; //gravity
-
-
- //END OF VECTOR CHANGES
- // player.vel.y = CLAMP(player.vel.y,-32,32);
- // player.vel.x = CLAMP(player.vel.x,-32,32);
-
- player_new.pos = (vec2){
- .x = player.pos.x + player.vel.x,
- .y = player.pos.y + player.vel.y,
- };
-
-
-
- // const uint8_t empty = 0;
- // hh_s_tiles tiles[9];
- // const vec2 tile_offset[9] = {
- // (vec2){-16,-16},(vec2){0,-16},(vec2){+16,-16},
- // (vec2){-16,0}, (vec2){0,0}, (vec2){+16,0},
- // (vec2){-16,+16},(vec2){0,+16},(vec2){+16,+16},
- // };
- // for (int i = 0; i < 9; i++) {
- // vec2 temp_pos = vec_add(player.pos, tile_offset[i]);
- // temp_pos =(vec2){
- // .x = temp_pos.x,
- // .y = temp_pos.y,
- // };
- // hh_s_tiles tile = {
- // .pos = temp_pos,
- // .idx = hh_world_to_tile(temp_pos)
- // };
- // if(hh_colidable(tile.idx)) {
- // tiles[i]=tile;
- // // printf(" collidable near!");
- // } else {
- // tiles[i].idx = 0;
- // }
- // }
- /*
- 012
- 345
- 678
- */
- // for (int i = 0; i < 9; i++)
- // {
- // if (tiles[i].idx != 0){
- // hh_solve_collision(tiles[i].pos, &player);
- // }
- // }
-
- player_new.is_grounded = false;
-
- // solves x collision
- if (player.vel.x <= 0) {
- if (hh_colidable(hh_world_to_tile((vec2){.x=player_new.pos.x + 0, .y=player.pos.y + 0})) ||
- hh_colidable(hh_world_to_tile((vec2){.x=player_new.pos.x + 0, .y=player.pos.y + 15}))) {
- player_new.pos.x = (player_new.pos.x & ~15) + 16,
- player_new.vel.x = 0;
- }
- } else {
- if (hh_colidable(hh_world_to_tile((vec2){.x=player_new.pos.x + 16, .y=player.pos.y + 0})) ||
- hh_colidable(hh_world_to_tile((vec2){.x=player_new.pos.x + 16, .y=player.pos.y + 15}))) {
- player_new.pos.x = player_new.pos.x & ~15, // <-- magic comma, NOT TOUCHY
- player_new.vel.x = 0;
- }
- }
-
- //solves y collision
- if (player.vel.y <= 0) {
- if (hh_colidable(hh_world_to_tile((vec2){.x=player_new.pos.x + 0, .y=player_new.pos.y + 0})) ||
- hh_colidable(hh_world_to_tile((vec2){.x=player_new.pos.x + 0, .y=player_new.pos.y + 15}))) {
- player_new.pos.y = (player_new.pos.y & ~15) + 16,
- player_new.vel.y = 0;
- }
- } else {
- if (hh_colidable(hh_world_to_tile((vec2){.x=player_new.pos.x + 0, .y=player_new.pos.y + 16})) ||
- hh_colidable(hh_world_to_tile((vec2){.x=player_new.pos.x + 16, .y=player_new.pos.y + 15}))) {
- player_new.pos.y = player_new.pos.y & ~15,
- player_new.vel.y = 0;
- player_new.is_grounded = true;
- }
- }
-
- player = player_new;
-
- vec_cor cam_pos;//value in tiles
- // cam_pos = (vec2){0,0};
- cam_pos = hh_update_camera(player.pos,(vec2){0,0},(vec2){.x=20*16,.y=30*16});//TODO: remove magic number(s)
- // printf("%i, %i:%i, %i\n",player.pos.x,player.pos.y,cam_pos.x,cam_pos.y);
- hh_draw_screen(cam_pos);
- // update player sprite on ppu
- player.render.fam.position_x = (player.pos.x-cam_pos.x);
- player.render.fam.position_y = (player.pos.y-cam_pos.y);
-
-
- player.render.fam.tilemap_index = 2;//TODO: these two lines should be redundant
- player.render.fam.palette_index = 7;
- hh_ppu_update_foreground(0, player.render.fam);
-
-
- hh_s_ppu_loc_fam_entry sprite = {
- .position_x = 16,
- .position_y = 16,
- .palette_index = 7,
- .tilemap_index = 2,
- };
- hh_ppu_update_foreground(1, sprite);
-
-}
-
diff --git a/src/engine/player_controller.h b/src/engine/player_controller.h
deleted file mode 100644
index 400c18e..0000000
--- a/src/engine/player_controller.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma once
-
-#include "engine/maths.h"
-#include "engine/entity.h"
-// inputs
-
-void hh_player_actions();
diff --git a/src/engine/sprite_controller.c b/src/engine/sprite_controller.c
deleted file mode 100644
index 5d93cf8..0000000
--- a/src/engine/sprite_controller.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <stdint.h>
-
-#include "engine/sprite_controller.h"
-#include "ppu/types.h"
-#include "ppu/consts.h"
-#include "ppu/ppu.h"
-
-uint8_t hh_get_palette(uint8_t tile_idx) {
- return hh_g_sprite_palette[tile_idx];
-}
-
-void hh_setup_palettes(){
- for (int idx = 0; idx < HH_PPU_PALETTE_COUNT; idx++) {
- for (int col = 0; col < HH_PPU_PALETTE_COLOR_COUNT; col++) {
- hh_ppu_update_color(idx,col,hh_g_palette[idx][col]);
- }
- }
-}
-
-bool hh_colidable(uint8_t tile_idx){
- return (hh_get_palette(tile_idx) != 0);
-}
diff --git a/src/engine/sprite_controller.h b/src/engine/sprite_controller.h
deleted file mode 100644
index 001a459..0000000
--- a/src/engine/sprite_controller.h
+++ /dev/null
@@ -1,106 +0,0 @@
-#pragma once
-#include <stdint.h>
-
-#include "ppu/types.h"
-
-// handles sprites
-
-// Bg sprites
-
-// Fg or entity sprites
-
-//TODO: pack data inside of sprite_palette LUT
-//HH_PPU_PALETTE_COUNT
-#define HH_SPRITE_COUNT 40
-#define HH_PAL_IDX_SKY 0
-#define HH_PAL_IDX_BRICK 1
-const static uint8_t hh_g_sprite_palette[HH_SPRITE_COUNT] = {
- 0,1,1,1,1,1,1,1,1,1, //1+9
- 1,1,1,1,1,1,1,1,1,1, //6+4
- 1,1,1,1,1,1,1,1,1, //9
- 7,7,7,2,7,7,1,2,7
- //other palettes here:
-};
-
-
-const static hh_ppu_loc_palette_table_t hh_g_palette = {
- {//palette info here
- {0x1,0x2,0x3},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0}},
- {//Bricks
- {0x1,0x2,0x3},//01
- {0xd,0x8,0xa},//24
- {0x0,0x0,0x1},//25
- {0x1,0x1,0x1},//26
- {0x1,0x1,0x2},//27
- {0x2,0x2,0x3},//28
- {0x3,0x4,0x5},//29
- {0x5,0x1,0x7}},
- {//slime
- {0x1,0x2,0x3},
- {0x1,0x3,0x2},
- {0x4,0x8,0x3},
- {0x7,0xa,0x4},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0}},
- {
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0}},
- {
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0}},
- {
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0}},
- {
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0}},
- {
- {0x0,0xf,0xf},
- {0xf,0xf,0xf},
- {0xf,0x0,0xf},
- {0xf,0xf,0x0},
- {0xf,0x0,0x0},
- {0x0,0xf,0x0},
- {0x0,0x0,0xf},
- {0x0,0x0,0x0}}
-};
-
-void hh_setup_palettes();
-
-/** @brief return palette index that belongs to tilemap index */
-uint8_t hh_get_palette(uint8_t tile_idx);
-
-bool hh_colidable(uint8_t tile_idx);
diff --git a/src/makefile b/src/makefile
index d7d9087..96751fb 100644
--- a/src/makefile
+++ b/src/makefile
@@ -31,13 +31,7 @@ LOCAL_SRCS += main.c \
ppu/internals.c \
ppu/ppu.c \
demo.c \
- engine/engine.c \
- engine/sprite_controller.c \
- engine/player_controller.c \
- engine/draw_screen.c \
- engine/camera.c \
- engine/maths.c \
- engine/entity.c
+ engine/engine.c
CFLAGS += $(SHARED_FLAGS)
LFLAGS += $(SHARED_FLAGS)
diff --git a/src/ppusim/sim.c b/src/ppusim/sim.c
index a5fec45..1fceb82 100644
--- a/src/ppusim/sim.c
+++ b/src/ppusim/sim.c
@@ -29,21 +29,20 @@ void hh_ppu_init() {
}
void hh_ppu_load_tilemap() {
- char* filename = "../test/bin/tiles.bin";
+ char* filename = "tiles.bin";
FILE* fp = fopen(filename,"rb");
if (!fp){
- fprintf(stderr,"Error: Failed to load tiles.");
return;//error
}
- int sprite_size = (HH_PPU_SPRITE_WIDTH * HH_PPU_SPRITE_HEIGHT);
+
fseek(fp, 0, SEEK_END);//goto EOF
- int _size = ftell(fp)/sprite_size;
+ 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[sprite_size];
+ uint8_t data[HH_PPU_VRAM_TMM_SPRITE_SIZE];
- fread(data,sizeof(uint8_t),sprite_size,fp);
+ 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;