diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-02-24 19:11:59 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-02-24 19:11:59 +0100 |
commit | f5c8ae2f2d2074d483490e857db5aef8388f06c9 (patch) | |
tree | a76e1985433216a31e112d3f4daccdf19097c06d /src/main.c | |
parent | 5f5c6a410cafaa917ca3ff0a2a95bb1f2db4b980 (diff) |
c interface semi-done
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 66 |
1 files changed, 45 insertions, 21 deletions
@@ -1,39 +1,63 @@ #include <stdlib.h> #include <math.h> +#ifdef HH_TARGET_DESKTOP +#include <stdio.h> +#endif +#include "main.h" #include "ppu/ppu.h" #include "ppu/consts.h" -hh_s_ppu_loc_sprite* hh_debug_circle_sprite() { - hh_s_ppu_loc_sprite* s = malloc(sizeof(hh_s_ppu_loc_sprite)); +bool g_hh_run = true; - for (int x = 0; x < HH_PPU_SPRITE_WIDTH; x++) - for (int y = 0; y < HH_PPU_SPRITE_HEIGHT; y++) - *s[y * HH_PPU_SPRITE_WIDTH + x] = (pow(x - 8, 2) + pow(y - 8, 2) < 67) ? 1 : 0; +int main() { + hh_setup(); + hh_loop(); + hh_exit(); + return 0; +} + +void hh_ppu_vblank_interrupt() { + static unsigned long frame = 0; + frame++; - return s; +#ifdef HH_TARGET_DESKTOP + printf("frame %lu\n", frame); +#endif } -int main() { +void hh_setup() { hh_ppu_init(); - // hh_ppu_update_aux((hh_s_ppu_loc_aux) { - // .bg_shift_x = 0, - // .bg_shift_y = 0, - // .fg_fetch = 0, - // .sysreset = 0, - // }); + hh_ppu_update_aux((hh_s_ppu_loc_aux) { + .bg_shift_x = 24, + .bg_shift_y = 0, + .fg_fetch = 1, + .sysreset = 1, + }); - hh_s_ppu_loc_sprite* sprite = hh_debug_circle_sprite(); - // hh_ppu_update_sprite(0, *sprite); - free(sprite); + hh_s_ppu_loc_sprite sprite = {0}; - while (1); + for (int x = 0; x < HH_PPU_SPRITE_WIDTH; x++) + for (int y = 0; y < HH_PPU_SPRITE_HEIGHT; y++) + sprite[y * HH_PPU_SPRITE_WIDTH + x] = (pow(x - 8, 2) + pow(y - 8, 2) < 67) ? 1 : 0; - hh_ppu_deinit(); + hh_ppu_update_sprite(0, sprite); + + hh_ppu_update_foreground(0, (hh_s_ppu_loc_fam_entry) { + .horizontal_flip = false, + .vertical_flip = false, + .palette_index = 1, + .tilemap_index = 0, + .position_x = 30, + .position_y = 40 + }); + + hh_ppu_update_color(1, 1, (hh_ppu_rgb_color_t) {15, 0, 15}); } -void hh_ppu_vblank_interrupt() { - static unsigned long frame = 0; - frame++; +void hh_exit() { + g_hh_run = false; + + hh_ppu_deinit(); } |