diff options
author | UnavailableDev <ggwildplay@gmail.com> | 2023-04-04 14:34:03 +0200 |
---|---|---|
committer | UnavailableDev <ggwildplay@gmail.com> | 2023-04-04 14:34:03 +0200 |
commit | abfb6d3667e0c1955f09636ed72e48ed17129c84 (patch) | |
tree | 2245e26fe38e00c194fb9db5d53947c6572b7851 /src/ppu/ppu.c | |
parent | b125ec41bfc18c9beb652cff1a58e567304c9c32 (diff) | |
parent | 9df9b163852cd5fd2462e1dec25ad4b00ca12a8c (diff) |
Merge branch 'tilemap-build-system' into dev
Diffstat (limited to 'src/ppu/ppu.c')
-rw-r--r-- | src/ppu/ppu.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/ppu/ppu.c b/src/ppu/ppu.c index df14b9f..1f46b16 100644 --- a/src/ppu/ppu.c +++ b/src/ppu/ppu.c @@ -3,6 +3,7 @@ #include "ppu/consts.h" #include "ppu/internals.h" #include "ppu/ppu.h" +#include "tilemap.h" void hh_ppu_update_foreground(unsigned index, hh_s_ppu_loc_fam_entry e) { hh_s_ppu_vram_data s = hh_ppu_2nat_fam(e); @@ -46,3 +47,26 @@ void hh_ppu_update_color(unsigned palette_index, unsigned color_index, hh_ppu_rg hh_ppu_vram_write(c); free(c.data); } + +void hh_ppu_load_tilemap() { + for (size_t sprite_idx = 0; sprite_idx < HH_TM_SIZE; sprite_idx++) { + for (size_t word_idx = 0; word_idx < HH_PPU_NATIVE_SPRITE_SIZE; word_idx++) { + uint32_t native_word = g_hh_tilemap_rom[word_idx + sprite_idx * HH_PPU_NATIVE_SPRITE_SIZE]; + uint32_t native_word_bytes[4] = { // TODO: check endianness of stm32 + (native_word >> 24) & 0xff, + (native_word >> 16) & 0xff, + (native_word >> 8) & 0xff, + (native_word >> 0) & 0xff, + }; + uint16_t ppu_words[2] = { + (native_word_bytes[2] << 8) | (native_word_bytes[3] << 0), + (native_word_bytes[0] << 8) | (native_word_bytes[1] << 0), + }; + hh_ppu_vram_write((hh_s_ppu_vram_data) { + .data = ppu_words, + .offset = HH_PPU_VRAM_TMM_OFFSET + sprite_idx * HH_PPU_VRAM_TMM_SPRITE_SIZE + word_idx * 2, + .size = 2, + }); + } + } +} |