Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
Add initial GUI hack
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeckmann committed Dec 27, 2020
1 parent 4678e7e commit d4854c7
Show file tree
Hide file tree
Showing 37 changed files with 17,170 additions and 24 deletions.
20 changes: 13 additions & 7 deletions Core/Inc/gw_lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@
#include "stm32h7xx_hal.h"
#include <stdint.h>

#define GW_LCD_WIDTH 320
#define GW_LCD_HEIGHT 240

#ifdef GW_LCD_MODE_LUT8
extern uint8_t framebuffer1[320 * 240] __attribute__((section (".lcd")));
extern uint8_t framebuffer2[320 * 240] __attribute__((section (".lcd")));
extern uint8_t framebuffer1[GW_LCD_WIDTH * GW_LCD_HEIGHT] __attribute__((section (".lcd")));
extern uint8_t framebuffer2[GW_LCD_WIDTH * GW_LCD_HEIGHT] __attribute__((section (".lcd")));
typedef uint8_t pixel_t;
#else
extern uint16_t framebuffer1[320 * 240] __attribute__((section (".lcd")));
extern uint16_t framebuffer2[320 * 240] __attribute__((section (".lcd")));
extern uint16_t framebuffer1[GW_LCD_WIDTH * GW_LCD_HEIGHT] __attribute__((section (".lcd")));
extern uint16_t framebuffer2[GW_LCD_WIDTH * GW_LCD_HEIGHT] __attribute__((section (".lcd")));
typedef uint16_t pixel_t;
#endif // GW_LCD_MODE_LUT8

#define GFX_MAX_WIDTH 320
// 0 => framebuffer1
// 1 => framebuffer2
extern uint32_t active_framebuffer;


#define GW_LCD_WIDTH 320
#define GW_LCD_HEIGHT 240

void lcd_init(SPI_HandleTypeDef *spi, LTDC_HandleTypeDef *ltdc);
void lcd_backlight_on();
Expand Down
10 changes: 6 additions & 4 deletions Core/Src/gw_lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
#include "main.h"

#if GW_LCD_MODE_LUT8
uint8_t framebuffer1[320 * 240];
uint8_t framebuffer2[320 * 240];
uint8_t framebuffer1[GW_LCD_WIDTH * GW_LCD_HEIGHT];
uint8_t framebuffer2[GW_LCD_WIDTH * GW_LCD_HEIGHT];
#else
uint16_t framebuffer1[320 * 240] __attribute__((section (".lcd")));
uint16_t framebuffer2[320 * 240] __attribute__((section (".lcd")));
uint16_t framebuffer1[GW_LCD_WIDTH * GW_LCD_HEIGHT] __attribute__((section (".lcd")));
uint16_t framebuffer2[GW_LCD_WIDTH * GW_LCD_HEIGHT] __attribute__((section (".lcd")));
#endif // GW_LCD_MODE_LUT8

uint32_t active_framebuffer = 0;

void lcd_backlight_off() {
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
Expand Down
2 changes: 1 addition & 1 deletion Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ uint8_t nullpointer_guard[1024] __attribute__((section (".itcram_start"))) __at

// uint16_t audiobuffer[48000] __attribute__((section (".audio")));
uint8_t extflash_variable[1] __attribute__((section (".extflash_data")));
uint8_t logbuf[1024 * 4];
uint8_t logbuf[1024 * 16];
uint32_t log_idx;

uint32_t boot_buttons;
Expand Down
7 changes: 5 additions & 2 deletions Core/Src/porting/gb/main_gb.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static bool netplay = false;
static bool saveSRAM = false;
static int saveSRAM_Timer = 0;

static uint32_t active_framebuffer = 0;

// --- MAIN

Expand Down Expand Up @@ -480,7 +479,7 @@ void pcm_submit() {
}
}

void app_main(void)
void app_main_gb(void)
{
odroid_gamepad_state_t joystick;

Expand Down Expand Up @@ -547,6 +546,10 @@ void app_main(void)

while (true)
{
gui_redraw();
continue;


odroid_input_read_gamepad(&joystick);

/*if (joystick.values[ODROID_INPUT_MENU]) {
Expand Down
6 changes: 0 additions & 6 deletions Core/Src/porting/nes/main_nes.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ static uint frameTime = 0;
static uint32_t vsync_wait_ms = 0;

static bool autoload = false;
static uint32_t active_framebuffer = 0;
// TODO
extern void store_save(uint8_t *data, size_t size);

Expand All @@ -88,11 +87,6 @@ char nes_save_buffer[24000];



void odroid_display_force_refresh(void)
{
// forceVideoRefresh = true;
}

int osd_init()
{
return 0;
Expand Down
23 changes: 23 additions & 0 deletions Core/Src/porting/odroid_display.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
#include "odroid_system.h"
#include "odroid_display.h"
#include "gw_lcd.h"

short odroid_display_queue_update(odroid_video_frame_t *frame, odroid_video_frame_t *previousFrame)
{
return SCREEN_UPDATE_FULL;
}

void odroid_display_write_rect(short left, short top, short width, short height, short stride, const uint16_t* buffer)
{
pixel_t *dest = active_framebuffer ? framebuffer2 : framebuffer1;

for (short y = 0; y < height; y++) {
pixel_t *dest_row = &dest[(y + top) * GW_LCD_WIDTH + left];
memcpy(dest_row, &buffer[y * stride], width * sizeof(pixel_t));
}
}

// Same as odroid_display_write_rect but stride is assumed to be width (for backwards compat)
void odroid_display_write(short left, short top, short width, short height, const uint16_t* buffer)
{
odroid_display_write_rect(left, top, width, height, width, buffer);
}

void odroid_display_force_refresh(void)
{
// forceVideoRefresh = true;
}

21 changes: 21 additions & 0 deletions Core/Src/porting/odroid_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,24 @@ void odroid_input_wait_for_key(odroid_gamepad_key_t key, bool pressed)
{
}

bool odroid_input_key_is_pressed(odroid_gamepad_key_t key)
{
odroid_gamepad_state_t joystick;
odroid_input_read_gamepad(&joystick);

if (key == ODROID_INPUT_ANY) {
return joystick.bitmask > 0 ? 1 : 0;
}

return joystick.values[key];
}

odroid_battery_state_t odroid_input_read_battery()
{
odroid_battery_state_t ret = {
.millivolts = 1337,
.percentage = 42,
};

return ret;
}
Loading

0 comments on commit d4854c7

Please sign in to comment.