aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-04-07 19:29:17 +0200
committerlonkaars <loek@pipeframe.xyz>2023-04-07 19:29:17 +0200
commitcc5fda1626ac77a74459bcfe3c422be3c2a5267b (patch)
tree07b46ae1a507359ac241869c7c3e5887d80880d0 /src
parent892424ba4d0c979e4351f7a866b6fe777783e4d2 (diff)
WIP more debugging
Diffstat (limited to 'src')
-rw-r--r--src/demo.c12
-rw-r--r--src/main.c4
-rw-r--r--src/ppu/stm.c2
-rw-r--r--src/ppusim/mem.c11
-rw-r--r--src/ppusim/sim.h2
-rw-r--r--src/ppusim/work.c4
-rw-r--r--src/stm32/setup.c1
7 files changed, 21 insertions, 15 deletions
diff --git a/src/demo.c b/src/demo.c
index fe58758..a5a3a1e 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -10,8 +10,8 @@ hh_s_ppu_loc_fam_entry g_hh_demo_balls[HH_DEMO_BALL_COUNT];
void hh_demo_setup() {
// load sprites
- hh_ppu_update_sprite(0, HH_DBG_SPRITE_BALL);
- hh_ppu_update_sprite(1, HH_DBG_SPRITE_CHECKERBOARD);
+ hh_ppu_update_sprite(1, HH_DBG_SPRITE_BALL);
+ hh_ppu_update_sprite(2, HH_DBG_SPRITE_CHECKERBOARD);
// background pattern
hh_ppu_update_color(0, 0, (hh_ppu_rgb_color_t) {0x1, 0x1, 0x3});
@@ -21,7 +21,7 @@ void hh_demo_setup() {
.horizontal_flip = false,
.vertical_flip = false,
.palette_index = 0,
- .tilemap_index = 1,
+ .tilemap_index = 2,
});
}
@@ -37,11 +37,14 @@ void hh_demo_setup() {
g_hh_demo_balls[i].horizontal_flip = false;
g_hh_demo_balls[i].vertical_flip = false;
g_hh_demo_balls[i].palette_index = i+1;
- g_hh_demo_balls[i].tilemap_index = 0;
+ g_hh_demo_balls[i].tilemap_index = 1;
}
+ hh_ppu_flush();
}
void hh_demo_loop(unsigned long frame) {
+ // if (frame % 300 == 0) hh_demo_setup();
+
// set background pattern position
hh_ppu_update_background_pos((frame / 5) % HH_PPU_SPRITE_WIDTH, (frame / 20) % HH_PPU_SPRITE_HEIGHT);
@@ -50,7 +53,6 @@ void hh_demo_loop(unsigned long frame) {
g_hh_demo_balls[i].position_y = HH_PPU_SCREEN_HEIGHT/2 - HH_PPU_SPRITE_HEIGHT/2 + (int)(30 * (double)sin((2*(double)frame / 10) + (double)i * 12));
hh_ppu_update_foreground(i+16, g_hh_demo_balls[i]);
}
-
return;
/*
hh_ppu_update_foreground(32, (hh_s_ppu_loc_fam_entry) {
diff --git a/src/main.c b/src/main.c
index fb96d84..0676dd6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -17,16 +17,16 @@ volatile unsigned short g_hh_hcount;
void hh_ppu_vblank_interrupt() {
static unsigned long frame = 0;
- static bool done = false;
#ifdef HH_TARGET_STM32
hh_ppu_flush();
hh_input_read();
hh_demo_loop(frame);
#endif
#ifdef HH_TARGET_DESKTOP
+ static bool done = false;
//hh_ppu_vram_dwrite((uint8_t*) HH_PPUINTDEMO_ARR, HH_PPUINTDEMO_LENGTH);
for (unsigned int limit = 0; limit < 1000; limit++) {
- if (frame * 4 > HH_PPUINTDEMO_LENGTH) {
+ if (frame * 4 >= HH_PPUINTDEMO_LENGTH) {
if (!done) printf("done\n");
done = true;
return;
diff --git a/src/ppu/stm.c b/src/ppu/stm.c
index ddd62b9..ccf3566 100644
--- a/src/ppu/stm.c
+++ b/src/ppu/stm.c
@@ -6,6 +6,8 @@
void hh_ppu_init() {
hh_ppu_update_aux((hh_s_ppu_loc_aux) { .sysreset = 1 });
+ hh_ppu_vram_buffer((uint8_t[4]) { 0xff, 0xff, 0xff, 0xff });
+ hh_ppu_flush();
}
void hh_ppu_deinit() {}
diff --git a/src/ppusim/mem.c b/src/ppusim/mem.c
index 20464cb..def14c0 100644
--- a/src/ppusim/mem.c
+++ b/src/ppusim/mem.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "ppu/internals.h"
#include "ppusim/mem.h"
@@ -39,9 +40,10 @@ static void hh_ppu_dbg_memprint(hh_ppu_addr_t addr, hh_ppu_data_t data) {
}
case 3: {
unsigned short i = addr - HH_PPU_VRAM_PAL_OFFSET;
- printf(" (pal[%02i] = #%x%x%x%x%x%x)", i, (data >> 0) & 0xf, (data >> 0) & 0xf,
+ printf(" (pal[%02i] = #%x%x%x%x%x%x)", i,
+ (data >> 8) & 0xf, (data >> 8) & 0xf,
(data >> 4) & 0xf, (data >> 4) & 0xf,
- (data >> 8) & 0xf, (data >> 8) & 0xf);
+ (data >> 0) & 0xf, (data >> 0) & 0xf);
break;
}
case 4: {
@@ -68,6 +70,11 @@ void hh_ppu_vram_dwrite(uint8_t* data, size_t size) {
#endif
if (!hh_ppu_vram_valid_address(ppu_addr)) continue;
g_hh_ppusim_vram[ppu_addr] = ppu_data;
+
+ if (ppu_addr == HH_PPU_VRAM_AUX_OFFSET + 1) {
+ bool reset = HH_RESIZE(ppu_data, 2, 2);
+ if (reset) memset(g_hh_ppusim_vram, 0x0000, 0xffff * sizeof(hh_ppu_data_t));
+ }
}
}
diff --git a/src/ppusim/sim.h b/src/ppusim/sim.h
index 4d1d718..4911a06 100644
--- a/src/ppusim/sim.h
+++ b/src/ppusim/sim.h
@@ -1,7 +1,7 @@
#pragma once
/** @brief pixel-perfect upscale factor for PPUSIM */
-#define HH_PPUSIM_UPSCALE_FACTOR 3
+#define HH_PPUSIM_UPSCALE_FACTOR 1
/** @brief max framerate for PPUSIM */
#define HH_PPUSIM_FRAMERATE 60
diff --git a/src/ppusim/work.c b/src/ppusim/work.c
index 977b2c4..c8964cd 100644
--- a/src/ppusim/work.c
+++ b/src/ppusim/work.c
@@ -25,10 +25,6 @@ void *hh_ppusim_draw_thread(void *arg) {
}
void hh_ppusim_draw_frame(SDL_Renderer *renderer) {
- hh_ppu_data_t *aux = &g_hh_ppusim_vram[HH_PPU_VRAM_AUX_OFFSET];
- bool reset = HH_RESIZE(aux[1], 2, 2);
- if (reset) memset(g_hh_ppusim_vram, 0x0000, 0xffff * sizeof(hh_ppu_data_t));
-
for (unsigned core = 0; core < g_hh_ppusim_core_count; core++) pthread_create(&g_hh_ppusim_threads[core], NULL, hh_ppusim_draw_thread, (void *)(unsigned long)core);
for (unsigned core = 0; core < g_hh_ppusim_core_count; core++) pthread_join(g_hh_ppusim_threads[core], NULL);
diff --git a/src/stm32/setup.c b/src/stm32/setup.c
index d15c643..6975592 100644
--- a/src/stm32/setup.c
+++ b/src/stm32/setup.c
@@ -69,7 +69,6 @@ static void hh_io_usart2_setup();
static void hh_io_gpio_setup();
static void hh_io_clock_setup();
static void hh_io_setup_error_handler();
-static void hh_interrupt_setup();
static void hh_io_dma_setup();
void hh_setup() {