diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-02-24 14:06:59 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-02-24 14:06:59 +0100 |
commit | b69ddf1cd7123cc26b3936eda3c7c96a2750e612 (patch) | |
tree | 9ca68b0fb0aebe4cbd68f22f35e3da298baf8d5c /src/ppu | |
parent | f3a47bde9bfaaa716de835c0c1499a685b4ac4f7 (diff) |
rename and move files
Diffstat (limited to 'src/ppu')
-rw-r--r-- | src/ppu/consts.h | 26 | ||||
-rw-r--r-- | src/ppu/internals.h | 22 | ||||
-rw-r--r-- | src/ppu/ppu.h | 11 | ||||
-rw-r--r-- | src/ppu/types.h | 40 |
4 files changed, 99 insertions, 0 deletions
diff --git a/src/ppu/consts.h b/src/ppu/consts.h new file mode 100644 index 0000000..ee94a69 --- /dev/null +++ b/src/ppu/consts.h @@ -0,0 +1,26 @@ +#pragma once + +#define HH_PPU_PALETTE_COUNT 8 +#define HH_PPU_PALETTE_COLOR_COUNT 8 +#define HH_PPU_RAM_BUS_ADDR_WIDTH 16 +#define HH_PPU_RAM_BUS_DATA_WIDTH 16 +#define HH_PPU_FG_SPRITE_COUNT 128 +#define HH_PPU_SPRITE_WIDTH 16 +#define HH_PPU_SPRITE_HEIGHT 16 +#define HH_PPU_SCREEN_WIDTH 320 +#define HH_PPU_SCREEN_HEIGHT 240 +#define HH_PPU_BG_CANVAS_TILES_H 40 +#define HH_PPU_BG_CANVAS_TILES_V 30 + +#include "types.h" + +#define HH_PPU_VRAM_TMM_OFFSET ((hh_ppu_addr_t) 0x0000) +#define HH_PPU_VRAM_TMM_SIZE ((hh_ppu_addr_t) 0xd000) +#define HH_PPU_VRAM_BAM_OFFSET ((hh_ppu_addr_t) 0xd000) +#define HH_PPU_VRAM_BAM_SIZE ((hh_ppu_addr_t) 0x04b0) +#define HH_PPU_VRAM_FAM_OFFSET ((hh_ppu_addr_t) 0xd800) +#define HH_PPU_VRAM_FAM_SIZE ((hh_ppu_addr_t) 0x0100) +#define HH_PPU_VRAM_PAL_OFFSET ((hh_ppu_addr_t) 0xdc00) +#define HH_PPU_VRAM_PAL_SIZE ((hh_ppu_addr_t) 0x0040) +#define HH_PPU_VRAM_AUX_OFFSET ((hh_ppu_addr_t) 0xde00) +#define HH_PPU_VRAM_AUX_SIZE ((hh_ppu_addr_t) 0x0002) diff --git a/src/ppu/internals.h b/src/ppu/internals.h new file mode 100644 index 0000000..ddb2196 --- /dev/null +++ b/src/ppu/internals.h @@ -0,0 +1,22 @@ +#pragma once + +#include <stdbool.h> + +#include "types.h" + +typedef struct { + hh_ppu_addr_t offset; + hh_ppu_addr_t size; + hh_ppu_data_t* data; +} hh_s_ppu_vram_data; + +bool hh_ppu_vram_valid_address(hh_ppu_addr_t addr); +void hh_ppu_vram_write(hh_ppu_addr_t addr, hh_ppu_data_t data); +void hh_ppu_vram_memcpy(void* a, hh_s_ppu_vram_data b); + +hh_s_ppu_vram_data* hh_ppu_2nat_bam(hh_s_ppu_loc_bam_entry); +hh_s_ppu_vram_data* hh_ppu_2nat_fam(hh_s_ppu_loc_fam_entry); +hh_s_ppu_vram_data* hh_ppu_2nat_aux(hh_s_ppu_loc_aux); +hh_s_ppu_vram_data* hh_ppu_2nat_sprite(hh_ppu_loc_sprite_data_t); +hh_s_ppu_vram_data* hh_ppu_2nat_pal(hh_ppu_loc_palette_data_t); + diff --git a/src/ppu/ppu.h b/src/ppu/ppu.h new file mode 100644 index 0000000..ac01ef7 --- /dev/null +++ b/src/ppu/ppu.h @@ -0,0 +1,11 @@ +#pragma once + +#include "types.h" + +void hh_ppu_vblank_interrupt(); +void hh_ppu_init(); + +void hh_ppu_update_foreground(unsigned index, hh_s_ppu_loc_fam_entry e); +void hh_ppu_update_background(unsigned index, hh_s_ppu_loc_bam_entry e); +void hh_ppu_update_sprite(unsigned tilemap_index, hh_s_ppu_loc_sprite sprite); +void hh_ppu_update_aux(hh_s_ppu_loc_aux aux); diff --git a/src/ppu/types.h b/src/ppu/types.h new file mode 100644 index 0000000..d7605a5 --- /dev/null +++ b/src/ppu/types.h @@ -0,0 +1,40 @@ +#pragma once + +#include <stdint.h> +#include <stdbool.h> + +#include "consts.h" + +typedef uint16_t hh_ppu_addr_t; +typedef uint16_t hh_ppu_data_t; + +typedef uint8_t hh_ppu_loc_sprite_data_t[HH_PPU_SPRITE_WIDTH * HH_PPU_SPRITE_HEIGHT]; +typedef uint8_t hh_ppu_loc_palette_data_t[HH_PPU_PALETTE_COLOR_COUNT]; + +typedef hh_ppu_loc_sprite_data_t hh_s_ppu_loc_sprite; +typedef hh_ppu_loc_palette_data_t hh_s_ppu_loc_palette; + +typedef struct { + bool horizontal_flip; + bool vertical_flip; + uint8_t palette_index; + uint8_t tilemap_index; +} hh_s_ppu_loc_bam_entry; + +typedef struct { + bool horizontal_flip; + bool vertical_flip; + uint16_t position_x; + uint16_t position_y; + uint8_t palette_index; + uint8_t tilemap_index; +} hh_s_ppu_loc_fam_entry; + +typedef struct { + bool sysreset; + bool fg_fetch; + uint16_t bg_shift_x; + uint16_t bg_shift_y; +} hh_s_ppu_loc_aux; + +typedef uint16_t hh_ppu_native_color_t; |