From cd3bb3448280d492ff225dfcb8604dc21a7c14e0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 24 Mar 2025 09:50:47 -0500 Subject: [PATCH] Fix inverse video & support 512x342 w/o psram --- fruitjam-build.sh | 12 +++++++++--- src/main.c | 21 ++++++++++++--------- src/video_hstx.c | 4 ---- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/fruitjam-build.sh b/fruitjam-build.sh index 9e20a80..eaee774 100755 --- a/fruitjam-build.sh +++ b/fruitjam-build.sh @@ -11,14 +11,14 @@ DISP_WIDTH=512 DISP_HEIGHT=342 MEMSIZE=400 DISK_IMAGE="" -CMAKE_ARGS= +CMAKE_ARGS="" while getopts "hvd:m:" o; do case "$o" in (v) DISP_WIDTH=640 DISP_HEIGHT=480 - CMAKE_ARGS="$CMAKE_ARGS -DUSE_VGA_RES=1 -DHSTX_CKP=12 -DHSTX_D0P=14 -DHSTX_D1P=16 -DHSTX_D2P=18" + CMAKE_ARGS="-DUSE_VGA_RES=1" ;; (m) MEMSIZE=$OPTARG @@ -42,12 +42,17 @@ done shift $((OPTIND-1)) TAG=fruitjam_${DISP_WIDTH}x${DISP_HEIGHT}_${MEMSIZE}k -PSRAM=$((MEMSIZE > 448 || DISP_WIDTH < 640)) +PSRAM=$((MEMSIZE > 400)) if [ $PSRAM -ne 0 ] ; then TAG=${TAG}_psram CMAKE_ARGS="$CMAKE_ARGS -DUSE_PSRAM=1" fi +MIRROR_FRAMEBUFFER=$((USE_PSRAM || DISP_WIDTH != 640)) +if [ "$MIRROR_FRAMEBUFFER" -eq 0 ]; then + CMAKE_ARGS="$CMAKE_ARGS -DHSTX_CKP=12 -DHSTX_D0P=14 -DHSTX_D1P=16 -DHSTX_D2P=18 " +fi + # Append disk name to build directory if disk image is specified if [ -n "$DISK_IMAGE" ] && [ -f "$DISK_IMAGE" ]; then # Extract filename without extension @@ -74,5 +79,6 @@ cmake -S . -B build_${TAG} \ -DUSE_HSTX=1 \ -DSD_TX=35 -DSD_RX=36 -DSD_SCK=34 -DSD_CS=39 -DUSE_SD=1 \ -DUART_TX=44 -DUART_RX=45 -DUART=0 \ + -DBOARD_FILE=boards/adafruit_fruit_jam.c \ ${CMAKE_ARGS} "$@" make -C build_${TAG} -j$(nproc) diff --git a/src/main.c b/src/main.c index 7902641..9f56db1 100644 --- a/src/main.c +++ b/src/main.c @@ -82,12 +82,16 @@ static const uint8_t umac_rom[] = { }; #if USE_PSRAM -static uint32_t umac_framebuffer_mirror[640*480/32]; #define umac_ram ((uint8_t*)0x11000000) #else static uint8_t umac_ram[RAM_SIZE]; #endif +#define MIRROR_FRAMEBUFFER (USE_PSRAM || DISP_WIDTH != 640) +#if MIRROR_FRAMEBUFFER +static uint32_t umac_framebuffer_mirror[640*480/32]; +#endif + //////////////////////////////////////////////////////////////////////////////// static void io_init() @@ -115,13 +119,13 @@ static int umac_cursor_y = 0; static int umac_cursor_button = 0; #define umac_get_audio_offset() (RAM_SIZE - 768) -#if USE_PSRAM +#if MIRROR_FRAMEBUFFER static void copy_framebuffer() { uint32_t *src = (uint32_t*)(umac_ram + umac_get_fb_offset()); #if DISP_WIDTH==640 && DISP_HEIGHT==480 uint32_t *dest = umac_framebuffer_mirror; for(int i=0; i<640*480/32; i++) { - *dest++ = *src++ ^ 0xfffffffful; + *dest++ = *src++; } #elif DISP_WIDTH==512 && DISP_HEIGHT==342 #define DISP_XOFFSET ((640 - DISP_WIDTH) / 32 / 2) @@ -131,7 +135,7 @@ static void copy_framebuffer() { for(int i=0; ial3_read_addr_trig = (uintptr_t)active_picodvi->dma_commands; } -#if (DISP_WIDTH != 640 || DISP_HEIGHT != 480) && !USE_PSRAM -#error Only VGA resolution is supported without PSRAM -#endif - #define REAL_DISP_WIDTH 640 #define REAL_DISP_HEIGHT 480