Support 512x342 with hstx when mirroring from psram
This commit is contained in:
parent
9fb0ec8f60
commit
ada575fe01
4 changed files with 31 additions and 26 deletions
|
|
@ -46,10 +46,10 @@ option(USE_HSTX "Use HSTX digital video (only for rp2350 / pico2)" OFF)
|
|||
|
||||
# Options for HSTX output (defaults are for Adafruit FruitJam)
|
||||
# HSTX always uses 640x480 for now
|
||||
set(HSTX_CKP 12 CACHE STRING "HSTX CK+ PIN")
|
||||
set(HSTX_D0P 14 CACHE STRING "HSTX D0+ PIN")
|
||||
set(HSTX_D1P 16 CACHE STRING "HSTX D1+ PIN")
|
||||
set(HSTX_D2P 18 CACHE STRING "HSTX D2+ PIN")
|
||||
set(HSTX_CKP 13 CACHE STRING "HSTX CK+ PIN")
|
||||
set(HSTX_D0P 15 CACHE STRING "HSTX D0+ PIN")
|
||||
set(HSTX_D1P 17 CACHE STRING "HSTX D1+ PIN")
|
||||
set(HSTX_D2P 19 CACHE STRING "HSTX D2+ PIN")
|
||||
|
||||
# Options for analog VGA output
|
||||
option(USE_VGA_RES "Video uses VGA (640x480) resolution" OFF)
|
||||
|
|
@ -110,23 +110,20 @@ endif()
|
|||
|
||||
if (USE_HSTX)
|
||||
add_compile_definitions(USE_VGA_RES=1)
|
||||
add_compile_definitions(DISP_WIDTH=640)
|
||||
add_compile_definitions(DISP_HEIGHT=480)
|
||||
add_compile_definitions(HSTX_CKP=${HSTX_CKP} HSTX_D0P=${HSTX_D0P} HSTX_D1P=${HSTX_D1P} HSTX_D2P=${HSTX_D2P})
|
||||
set(VIDEO_SRC src/video_hstx.c)
|
||||
else()
|
||||
if (USE_VGA_RES)
|
||||
add_compile_definitions(USE_VGA_RES=1)
|
||||
add_compile_definitions(DISP_WIDTH=640)
|
||||
add_compile_definitions(DISP_HEIGHT=480)
|
||||
else()
|
||||
add_compile_definitions(DISP_WIDTH=512)
|
||||
add_compile_definitions(DISP_HEIGHT=342)
|
||||
endif()
|
||||
|
||||
add_compile_definitions(GPIO_VID_BASE=${VIDEO_PIN})
|
||||
set(VIDEO_SRC src/video_vga.c)
|
||||
endif()
|
||||
if (USE_VGA_RES)
|
||||
add_compile_definitions(USE_VGA_RES=1)
|
||||
add_compile_definitions(DISP_WIDTH=640)
|
||||
add_compile_definitions(DISP_HEIGHT=480)
|
||||
else()
|
||||
add_compile_definitions(DISP_WIDTH=512)
|
||||
add_compile_definitions(DISP_HEIGHT=342)
|
||||
endif()
|
||||
|
||||
add_compile_definitions(PIN_USB_HOST_DP=${PIN_USB_HOST_DP})
|
||||
add_compile_definitions(PIN_USB_HOST_DM=${PIN_USB_HOST_DM})
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ if ! [ -f rom.bin ]; then
|
|||
if ! [ -f '4D1F8172 - MacPlus v3.ROM' ]; then
|
||||
curl -L 'https://ia902205.us.archive.org/view_archive.php?archive=/18/items/mac_rom_archive_-_as_of_8-19-2011/mac_rom_archive_-_as_of_8-19-2011.zip&file=4D1F8172%20-%20MacPlus%20v3.ROM' > '4D1F8172 - MacPlus v3.ROM'
|
||||
fi
|
||||
make -C external/umac clean
|
||||
make -C external/umac DISP_WIDTH=512 DISP_HEIGHT=342
|
||||
./external/umac/main -r '4D1F8172 - MacPlus v3.ROM' -W rom.bin
|
||||
fi
|
||||
|
||||
|
|
|
|||
18
src/main.c
18
src/main.c
|
|
@ -108,21 +108,25 @@ static int umac_cursor_button = 0;
|
|||
|
||||
#if USE_PSRAM
|
||||
static void copy_framebuffer() {
|
||||
uint32_t *src = (uint32_t*)(umac_ram + umac_get_fb_offset());
|
||||
#if DISP_WIDTH==640 && DISP_HEIGHT==480
|
||||
uint32_t *src = (uint32_t*)(umac_ram + umac_get_fb_offset()), *dest = umac_framebuffer_mirror;
|
||||
uint32_t *dest = umac_framebuffer_mirror;
|
||||
for(int i=0; i<640*480/32; i++) {
|
||||
*dest++ = *src++ ^ 0xfffffffful;
|
||||
}
|
||||
#elif DISP_WIDTH==512 && DISP_HEIGHT==384
|
||||
uint32_t *src = umac_ram + umac_get_fb_offset();
|
||||
for(i=0; i<384; i++) {
|
||||
uint32_t *dest = umac_framebuffer_mirror + 962 + 20 * i;
|
||||
for(j=0; j<16; i++) {
|
||||
#elif DISP_WIDTH==512 && DISP_HEIGHT==342
|
||||
#define DISP_XOFFSET ((640 - DISP_WIDTH) / 32 / 2)
|
||||
#define DISP_YOFFSET ((480 - DISP_HEIGHT) / 2)
|
||||
#define LONGS_PER_INPUT_ROW (DISP_WIDTH / 32)
|
||||
#define LONGS_PER_OUTPUT_ROW (640 / 32)
|
||||
for(int i=0; i<DISP_HEIGHT; i++) {
|
||||
uint32_t *dest = umac_framebuffer_mirror + (DISP_YOFFSET * LONGS_PER_OUTPUT_ROW + DISP_XOFFSET) + LONGS_PER_OUTPUT_ROW * i;
|
||||
for(int j=0; j<LONGS_PER_INPUT_ROW; j++) {
|
||||
*dest++ = *src++ ^ 0xfffffffful;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#error Unsupported display geometry
|
||||
#error Unsupported display geometry for framebuffer mirroring
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -141,10 +141,12 @@ static void __not_in_flash_func(dma_irq_handler)(void) {
|
|||
ch->al3_read_addr_trig = (uintptr_t)active_picodvi->dma_commands;
|
||||
}
|
||||
|
||||
#if DISP_WIDTH != 640 || DISP_HEIGHT != 480
|
||||
#error Only VGA resolution is supported
|
||||
#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
|
||||
|
||||
void video_init(uint32_t *framebuffer) {
|
||||
picodvi_framebuffer_obj_t *self = &picodvi;
|
||||
|
|
@ -164,7 +166,7 @@ void video_init(uint32_t *framebuffer) {
|
|||
self->dma_command_channel = dma_claim_unused_channel(true);
|
||||
|
||||
size_t pixels_per_word = 32;
|
||||
size_t words_per_line = DISP_WIDTH / pixels_per_word;
|
||||
size_t words_per_line = REAL_DISP_WIDTH / pixels_per_word;
|
||||
uint8_t rot = 24; // 24 + color_depth;
|
||||
size_t shift_amount = 31; // color_depth % 32;
|
||||
|
||||
|
|
@ -211,7 +213,7 @@ void video_init(uint32_t *framebuffer) {
|
|||
size_t row = v_scanline - active_start;
|
||||
size_t transfer_count = words_per_line;
|
||||
self->dma_commands[command_word++] = transfer_count;
|
||||
uintptr_t row_start = row * (DISP_WIDTH / 8) + (uintptr_t)framebuffer;
|
||||
uintptr_t row_start = row * (REAL_DISP_WIDTH / 8) + (uintptr_t)framebuffer;
|
||||
self->dma_commands[command_word++] = row_start;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue