aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-05-29 16:08:20 +0200
committerlonkaars <loek@pipeframe.xyz>2023-05-29 16:08:20 +0200
commit5cf7922107da55380e0cbc9c26d518db76eaf3ed (patch)
tree0f2ade7fe180cbadba596637f08d4efa6e683a6a
parent151ef82382104cfef375d8c1d256d72cb61b16fd (diff)
???
-rw-r--r--src/demo.c2
-rw-r--r--src/ds.c2
-rw-r--r--src/main.c12
-rw-r--r--src/ppu/stm.c23
-rw-r--r--src/stm32/main.c6
-rw-r--r--src/stm32/setup.c12
6 files changed, 33 insertions, 24 deletions
diff --git a/src/demo.c b/src/demo.c
index cf6f4a0..dbaf2ca 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -9,7 +9,6 @@
hh_s_ppu_loc_fam_entry g_hh_demo_balls[HH_DEMO_BALL_COUNT];
void hh_demo_setup() {
- return;
// load sprites
hh_ppu_update_sprite(1, HH_DBG_SPRITE_BALL);
hh_ppu_update_sprite(2, HH_DBG_SPRITE_CHECKERBOARD);
@@ -44,7 +43,6 @@ void hh_demo_setup() {
}
void hh_demo_loop(unsigned long frame) {
- return;
// if (frame % 300 == 0) hh_demo_setup();
//
// if (frame > 1) return;
diff --git a/src/ds.c b/src/ds.c
index 71c595a..570fb61 100644
--- a/src/ds.c
+++ b/src/ds.c
@@ -4,7 +4,7 @@
void hh_setup() {
hh_ppu_init();
- // hh_demo_setup();
+ hh_demo_setup();
}
void hh_exit() {
diff --git a/src/main.c b/src/main.c
index d061bb3..810a69a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -18,15 +18,9 @@ volatile unsigned short g_hh_hcount;
void hh_ppu_vblank_interrupt() {
static unsigned long frame = 0;
- // hh_ppu_flush();
- // hh_input_read();
- // hh_demo_loop(frame);
-
- size_t offset = frame * 4;
- if (offset >= HH_PPUINTDEMO_LENGTH) return;
- uint8_t* d = HH_PPUINTDEMO_ARR + offset;
- hh_ppu_vram_buffer(d);
- hh_ppu_vram_flush();
+ hh_input_read();
+ hh_demo_loop(frame);
+ hh_ppu_flush();
frame++;
}
diff --git a/src/ppu/stm.c b/src/ppu/stm.c
index 7f60aed..146d275 100644
--- a/src/ppu/stm.c
+++ b/src/ppu/stm.c
@@ -5,17 +5,30 @@
#include "stm32/setup.h"
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();
+ // 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();
HAL_Delay(10);
}
void hh_ppu_deinit() {}
+// void hh_ppu_vram_dwrite(uint8_t* data, size_t size) {
+// HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_SET);
+// HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_RESET);
+// HAL_SPI_Transmit_DMA(&hspi1, data, size);
+// }
+
void hh_ppu_vram_dwrite(uint8_t* data, size_t size) {
+ // HAL_SPI_Transmit(&hspi1, data, size, HAL_MAX_DELAY);
+ for (size_t i = 0; i < size; i += 4) {
+ if (i+4 > size) break;
+ uint8_t test[4] = { data[i+0], data[i+1], data[i+2], data[i+3], };
+ HAL_SPI_Transmit(&hspi1, test, 4, HAL_MAX_DELAY);
+ // HAL_Delay(100);
+ }
+ HAL_SPI_Transmit(&hspi1, (uint8_t[4]){ 0xff, 0xff, 0xff, 0xff }, 4, HAL_MAX_DELAY);
+ // reset SPI
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_RESET);
- HAL_SPI_Transmit_DMA(&hspi1, data, size);
}
-
diff --git a/src/stm32/main.c b/src/stm32/main.c
index 181657c..78b166e 100644
--- a/src/stm32/main.c
+++ b/src/stm32/main.c
@@ -1,9 +1,13 @@
#include <stm32f0xx_hal.h>
#include "main.h"
+#include "demo.h"
+#include "ppu/ppu.h"
void hh_ppu_load_tilemap() {}
void hh_loop() {
- while(g_hh_run);
+ while (1) {
+ hh_ppu_vblank_interrupt();
+ }
}
diff --git a/src/stm32/setup.c b/src/stm32/setup.c
index 7b9f35a..644d15e 100644
--- a/src/stm32/setup.c
+++ b/src/stm32/setup.c
@@ -165,10 +165,10 @@ void hh_io_gpio_setup() {
gpio_init(HH_IO_SPI_SR_PORT, HH_IO_SPI_SR_PIN, GPIO_MODE_OUTPUT_PP, GPIO_NOPULL);
// PPU HBLANK/VBLANK
- gpio_init(HH_IO_PPU_HBLANK_PORT, HH_IO_PPU_HBLANK_PIN, GPIO_MODE_INPUT, GPIO_NOPULL);
- gpio_init(HH_IO_PPU_VBLANK_PORT, HH_IO_PPU_VBLANK_PIN, GPIO_MODE_IT_RISING, GPIO_NOPULL);
- HAL_NVIC_SetPriority(EXTI4_15_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);
+ // gpio_init(HH_IO_PPU_HBLANK_PORT, HH_IO_PPU_HBLANK_PIN, GPIO_MODE_INPUT, GPIO_NOPULL);
+ // gpio_init(HH_IO_PPU_VBLANK_PORT, HH_IO_PPU_VBLANK_PIN, GPIO_MODE_IT_RISING, GPIO_NOPULL);
+ // HAL_NVIC_SetPriority(EXTI4_15_IRQn, 0, 0);
+ // HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);
// gamepad 1
gpio_init(HH_IO_GP1_UP_PORT, HH_IO_GP1_UP_PIN, GPIO_MODE_INPUT, GPIO_PULLDOWN);
@@ -251,8 +251,8 @@ void hh_io_setup_error_handler() {
}
void EXTI4_15_IRQHandler() {
- HAL_GPIO_EXTI_IRQHandler(HH_IO_PPU_HBLANK_PIN);
- HAL_GPIO_EXTI_IRQHandler(HH_IO_PPU_VBLANK_PIN);
+ // HAL_GPIO_EXTI_IRQHandler(HH_IO_PPU_HBLANK_PIN);
+ // HAL_GPIO_EXTI_IRQHandler(HH_IO_PPU_VBLANK_PIN);
}
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {