aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-02-24 22:24:50 +0100
committerlonkaars <loek@pipeframe.xyz>2023-02-24 22:24:50 +0100
commit1a2bd8b70c12d497acb2eba548d161b2bfc4f9b6 (patch)
tree593cddcc473aad7a5e55f870893d813f17651a85 /src/main.c
parent97dd5f6bd354c8e931778c79c7a421d5bdaafee5 (diff)
background sprites working in ppusim
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c88
1 files changed, 73 insertions, 15 deletions
diff --git a/src/main.c b/src/main.c
index 8cb0450..b61f124 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,36 +24,94 @@ void hh_ppu_vblank_interrupt() {
#ifdef HH_TARGET_DESKTOP
// printf("frame %lu\n", frame);
#endif
-}
-
-void hh_setup() {
- hh_ppu_init();
+ unsigned shift = (double) sin((double) frame / 20) * 10 + 10;
hh_ppu_update_aux((hh_s_ppu_loc_aux) {
- .bg_shift_x = 24,
+ .bg_shift_x = shift,
.bg_shift_y = 0,
- .fg_fetch = 1,
- .sysreset = 1,
+ .fg_fetch = 0,
+ .sysreset = 0,
});
+}
- hh_s_ppu_loc_sprite sprite = {0};
+void hh_setup() {
+ hh_ppu_init();
+
+ hh_s_ppu_loc_sprite sprite = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
+ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
+ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,
+ 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0,
+ 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0
+ };
- 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;
+ 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) < 64) ? 1 : 0;
+ uint8_t p = sprite[y * HH_PPU_SPRITE_WIDTH + x];
+ printf("%c%c%c", p ? 'X' : ' ', p ? 'X' : ' ', p ? 'X' : ' ');
+ }
+ printf("\n");
+ }
hh_ppu_update_sprite(0, sprite);
- hh_ppu_update_foreground(0, (hh_s_ppu_loc_fam_entry) {
+ // 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_background(3, (hh_s_ppu_loc_bam_entry) {
.horizontal_flip = false,
.vertical_flip = false,
.palette_index = 1,
.tilemap_index = 0,
- .position_x = 30,
- .position_y = 40
+ });
+ hh_ppu_update_background(4, (hh_s_ppu_loc_bam_entry) {
+ .horizontal_flip = true,
+ .vertical_flip = false,
+ .palette_index = 2,
+ .tilemap_index = 0,
+ });
+ hh_ppu_update_background(5, (hh_s_ppu_loc_bam_entry) {
+ .horizontal_flip = false,
+ .vertical_flip = false,
+ .palette_index = 3,
+ .tilemap_index = 0,
+ });
+ hh_ppu_update_background(6, (hh_s_ppu_loc_bam_entry) {
+ .horizontal_flip = false,
+ .vertical_flip = true,
+ .palette_index = 4,
+ .tilemap_index = 0,
+ });
+ hh_ppu_update_background(7, (hh_s_ppu_loc_bam_entry) {
+ .horizontal_flip = true,
+ .vertical_flip = true,
+ .palette_index = 5,
+ .tilemap_index = 0,
});
- hh_ppu_update_color(1, 1, (hh_ppu_rgb_color_t) {15, 0, 15});
+ hh_ppu_update_color(1, 1, (hh_ppu_rgb_color_t) {0xf, 0x0, 0xf});
+ hh_ppu_update_color(2, 1, (hh_ppu_rgb_color_t) {0xf, 0xf, 0xf});
+ hh_ppu_update_color(3, 1, (hh_ppu_rgb_color_t) {0xf, 0x0, 0x0});
+ hh_ppu_update_color(4, 1, (hh_ppu_rgb_color_t) {0x0, 0xf, 0xf});
+ hh_ppu_update_color(5, 1, (hh_ppu_rgb_color_t) {0x0, 0x0, 0xf});
}
void hh_exit() {