aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ds.c3
-rw-r--r--src/main.c34
-rw-r--r--src/makefile4
-rw-r--r--src/ppu/stm.c19
-rw-r--r--src/ppusim/sim.c1
-rw-r--r--src/stm32/main.c5
6 files changed, 36 insertions, 30 deletions
diff --git a/src/ds.c b/src/ds.c
index 24ef58f..80e947e 100644
--- a/src/ds.c
+++ b/src/ds.c
@@ -1,11 +1,8 @@
-#include "demo.h"
#include "main.h"
#include "ppu/ppu.h"
void hh_setup() {
hh_ppu_init();
-
- hh_demo_setup();
}
void hh_exit() {
diff --git a/src/main.c b/src/main.c
index 8d36bf5..bbb6001 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,36 +1,22 @@
#include <stdlib.h>
-#include <stm32f0xx_hal.h>
#include "main.h"
-#include "stm32/setup.h"
#include "../test/ppu-stm-integration-demo/data.h"
+#include "ppu/internals.h"
bool g_hh_run = true;
-int main() {
- hh_setup();
-
- while (1) {
- for (unsigned long i = 0; i < HH_PPUINTDEMO_LENGTH; i++) {
- uint16_t addr = HH_PPUINTDEMO_ADDR[i];
- uint16_t data = HH_PPUINTDEMO_DATA[i];
-
- uint8_t spi_data[4] = {
- (addr & 0xff00) >> 8,
- (addr & 0x00ff) >> 0,
- (data & 0xff00) >> 8,
- (data & 0x00ff) >> 0,
- };
-
- HAL_SPI_Transmit(&hspi1, spi_data, 4, HAL_MAX_DELAY);
- HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, true);
- // HAL_Delay(1);
- HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, false);
- // HAL_Delay(1);
- }
- HAL_Delay(1e3);
+void hh_ppu_vblank_interrupt() {
+ for (unsigned long i = 0; i < HH_PPUINTDEMO_LENGTH; i++) {
+ uint16_t addr = HH_PPUINTDEMO_ADDR[i];
+ uint16_t data = HH_PPUINTDEMO_DATA[i];
+ hh_ppu_vram_dwrite(addr, data);
}
+}
+int main() {
+ hh_setup();
+ hh_loop();
hh_exit();
return 0;
}
diff --git a/src/makefile b/src/makefile
index e2fc1d3..bbd859e 100644
--- a/src/makefile
+++ b/src/makefile
@@ -27,7 +27,9 @@ LFLAGS += -lm
CFLAGS += $(if $(STM), -DHH_TARGET_STM32, )
CFLAGS += $(if $(DESKTOP), -DHH_TARGET_DESKTOP, )
-LOCAL_SRCS += main.c
+LOCAL_SRCS += ppu/internals.c \
+ ppu/ppu.c \
+ main.c
CFLAGS += $(SHARED_FLAGS)
LFLAGS += $(SHARED_FLAGS)
diff --git a/src/ppu/stm.c b/src/ppu/stm.c
index fd4a18c..371e557 100644
--- a/src/ppu/stm.c
+++ b/src/ppu/stm.c
@@ -1,4 +1,23 @@
+#include <stm32f0xx_hal.h>
+
#include "ppu/ppu.h"
+#include "ppu/internals.h"
+#include "stm32/setup.h"
void hh_ppu_init() {}
void hh_ppu_deinit() {}
+
+void hh_ppu_vram_dwrite(hh_ppu_addr_t addr, hh_ppu_data_t data) {
+ // if (!hh_ppu_vram_valid_address(addr)) return;
+
+ uint8_t spi_data[4] = {
+ (addr & 0xff00) >> 8,
+ (addr & 0x00ff) >> 0,
+ (data & 0xff00) >> 8,
+ (data & 0x00ff) >> 0,
+ };
+
+ HAL_SPI_Transmit(&hspi1, spi_data, 4, HAL_MAX_DELAY);
+ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, true);
+ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, false);
+}
diff --git a/src/ppusim/sim.c b/src/ppusim/sim.c
index a5fec45..be5fbeb 100644
--- a/src/ppusim/sim.c
+++ b/src/ppusim/sim.c
@@ -25,7 +25,6 @@ void hh_ppu_init() {
g_hh_ppusim_vram = malloc(sizeof(hh_ppu_data_t) * 0xffff);
memset(g_hh_ppusim_vram, 0x0000, 0xffff);
- hh_ppu_load_tilemap();
}
void hh_ppu_load_tilemap() {
diff --git a/src/stm32/main.c b/src/stm32/main.c
index d381d35..84288c3 100644
--- a/src/stm32/main.c
+++ b/src/stm32/main.c
@@ -1,8 +1,11 @@
+#include <stm32f0xx_hal.h>
+
#include "main.h"
#include "ppu/ppu.h"
void hh_ppu_load_tilemap() {}
void hh_loop() {
- while(g_hh_run);
+ HAL_Delay(1e3);
+ hh_ppu_vblank_interrupt();
}