From 28bea2e1ce61099cfe8a05a40eb0f8af11649de6 Mon Sep 17 00:00:00 2001 From: Lephe Date: Sat, 23 Mar 2024 10:02:51 +0100 Subject: [PATCH] gint: switch from file filters to config macros + basic fxg3a target Nothing interesting in this commit, just moving files around, making sure every target compiles every file, and controlling with macros instead. Basic support for fxg3a target in CMakeLists.txt, cmake/FindGint.cmake, giteapc.make and include/gint/config.h.in. The rest is forgettable. --- CMakeLists.txt | 202 +++++++++--------- cmake/FindGint.cmake | 4 + giteapc.make | 6 + include/gint/config.h.in | 16 +- include/gint/display-cg.h | 4 +- include/gint/display-fx.h | 4 +- include/gint/display.h | 5 +- include/gint/image.h | 7 +- src/gray/engine.c | 6 + src/gray/gclear.c | 5 + src/gray/ggetpixel.c | 5 + src/gray/gint_gline.c | 5 + src/gray/gpixel.c | 5 + src/gray/grect.c | 5 + src/gray/gsubimage.c | 6 +- src/gray/gtext.c | 7 +- src/image/fixed.h | 2 + src/image/image_alloc.c | 4 + src/image/image_alloc_palette.c | 5 + src/image/image_alpha.c | 4 + src/image/image_clear.c | 4 + src/image/image_copy.c | 4 + src/image/image_copy_alloc.c | 5 + src/image/image_copy_palette.c | 5 + src/image/image_create.c | 5 + src/image/image_create_vram.c | 4 + src/image/image_data_size.c | 4 + src/image/image_decode_pixel.c | 4 + src/image/image_fill.c | 4 + src/image/image_free.c | 5 + src/image/image_get_pixel.c | 4 + src/image/image_hflip.c | 4 + src/image/image_hflip_alloc.c | 4 + src/image/image_linear.S | 5 + src/image/image_linear.c | 5 + src/image/image_linear_alloc.c | 4 + src/image/image_rotate.c | 4 + src/image/image_rotate_around.c | 5 + src/image/image_rotate_around_scale.c | 5 + src/image/image_scale.c | 5 + src/image/image_set_palette.c | 5 + src/image/image_set_pixel.c | 4 + src/image/image_sub.c | 5 + src/image/image_target.c | 5 + src/image/image_valid.c | 4 + src/image/image_vflip.c | 4 + src/image/image_vflip_alloc.c | 4 + src/kmalloc/arena_gint.c | 1 + src/r61524/r61524.c | 5 + src/render-cg/dclear.c | 4 + src/render-cg/dgetpixel.c | 4 + src/render-cg/dpixel.c | 4 + src/render-cg/drect.c | 4 + src/render-cg/dsubimage.c | 4 + src/render-cg/dupdate.c | 4 + src/render-cg/dvram.c | 3 + src/render-cg/gint_dline.c | 3 + src/render-cg/image/image.c | 4 + src/render-cg/image/image_p4.S | 5 + src/render-cg/image/image_p4.c | 4 + src/render-cg/image/image_p4_clearbg.S | 5 + src/render-cg/image/image_p4_clearbg_alt.S | 5 + src/render-cg/image/image_p4_clearbg_alt.c | 4 + src/render-cg/image/image_p4_dye.S | 5 + src/render-cg/image/image_p4_dye.c | 4 + src/render-cg/image/image_p4_effect.c | 4 + src/render-cg/image/image_p4_normal.S | 5 + src/render-cg/image/image_p4_swapcolor.S | 5 + src/render-cg/image/image_p4_swapcolor.c | 4 + src/render-cg/image/image_p8.S | 5 + src/render-cg/image/image_p8.c | 4 + src/render-cg/image/image_p8_clearbg.S | 5 + src/render-cg/image/image_p8_dye.S | 5 + src/render-cg/image/image_p8_dye.c | 4 + src/render-cg/image/image_p8_effect.c | 4 + src/render-cg/image/image_p8_normal.S | 5 + src/render-cg/image/image_p8_swapcolor.S | 5 + src/render-cg/image/image_p8_swapcolor.c | 4 + src/render-cg/image/image_rgb16.S | 5 + src/render-cg/image/image_rgb16.c | 4 + src/render-cg/image/image_rgb16_clearbg_dye.S | 5 + src/render-cg/image/image_rgb16_dye.c | 4 + src/render-cg/image/image_rgb16_effect.c | 4 + src/render-cg/image/image_rgb16_normal.S | 5 + src/render-cg/image/image_rgb16_swapcolor.S | 5 + src/render-cg/image/image_rgb16_swapcolor.c | 4 + src/render-cg/{topti-asm.s => topti-asm.S} | 5 + src/render-cg/topti-asm.h | 5 + src/render-cg/topti.c | 5 + src/render-fx/bopti-asm-gray-scsp.S | 156 ++++++++++++++ src/render-fx/bopti-asm-gray-scsp.s | 152 ------------- .../{bopti-asm-gray.s => bopti-asm-gray.S} | 184 ++++++++-------- src/render-fx/bopti-asm-mono-scsp.S | 64 ++++++ src/render-fx/bopti-asm-mono-scsp.s | 60 ------ src/render-fx/bopti-asm.S | 97 +++++++++ src/render-fx/bopti-asm.h | 118 ---------- src/render-fx/bopti-asm.s | 93 -------- src/render-fx/bopti.c | 6 +- src/render-fx/dclear.c | 5 + src/render-fx/dgetpixel.c | 5 + src/render-fx/dpixel.c | 6 +- src/render-fx/drect.c | 5 + src/render-fx/dsubimage.c | 6 +- src/render-fx/dupdate.c | 5 + src/render-fx/gint_dline.c | 5 + src/render-fx/masks.c | 5 + src/render-fx/render-fx.h | 145 ++++++++++++- src/render-fx/{topti-asm.s => topti-asm.S} | 40 ++-- src/render-fx/topti-asm.h | 31 --- src/render-fx/topti.c | 6 +- src/t6k11/t6k11.c | 5 + src/usb/classes/ff-bulk-gray.c | 7 +- 112 files changed, 1128 insertions(+), 687 deletions(-) rename src/render-cg/{topti-asm.s => topti-asm.S} (98%) create mode 100644 src/render-fx/bopti-asm-gray-scsp.S delete mode 100644 src/render-fx/bopti-asm-gray-scsp.s rename src/render-fx/{bopti-asm-gray.s => bopti-asm-gray.S} (52%) create mode 100644 src/render-fx/bopti-asm-mono-scsp.S delete mode 100644 src/render-fx/bopti-asm-mono-scsp.s create mode 100644 src/render-fx/bopti-asm.S delete mode 100644 src/render-fx/bopti-asm.h delete mode 100644 src/render-fx/bopti-asm.s rename src/render-fx/{topti-asm.s => topti-asm.S} (65%) delete mode 100644 src/render-fx/topti-asm.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a8307e3..3ea635b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ else() endif() configure_file(include/gint/config.h.in include/gint/config.h) -set(SOURCES_COMMON +set(SOURCES # Clock Pulse Generator driver src/cpg/cpg.c src/cpg/overclock.c @@ -70,73 +70,6 @@ set(SOURCES_COMMON src/fs/fugue/fugue_rmdir.c src/fs/fugue/fugue_unlink.c src/fs/fugue/util.c - # Interrupt Controller driver - src/intc/intc.c - src/intc/inth.s - # Kernel - src/kernel/exch.c - src/kernel/exch.s - src/kernel/hardware.c - src/kernel/inth.S - src/kernel/kernel.c - src/kernel/osmenu.c - src/kernel/start.c - src/kernel/syscalls.S - src/kernel/tlbh.S - src/kernel/world.c - # Key Scan Interface driver - src/keysc/getkey.c - src/keysc/iokbd.c - src/keysc/keycodes.c - src/keysc/keydev.c - src/keysc/keydev_idle.c - src/keysc/keydev_process_key.c - src/keysc/keydown_all.c - src/keysc/keydown_any.c - src/keysc/keysc.c - src/keysc/scan_frequency.c - # Memory allocator - src/kmalloc/arena_gint.c - src/kmalloc/arena_osheap.c - src/kmalloc/kmalloc.c - # MMU driver - src/mmu/mmu.c - # Rendering - src/render/dcircle.c - src/render/dellipse.c - src/render/dhline.c - src/render/dimage.c - src/render/dline.c - src/render/dpoly.c - src/render/dprint.c - src/render/drect_border.c - src/render/dtext.c - src/render/dupdate_hook.c - src/render/dvline.c - src/render/dwindow.c - src/render/topti.c - # RTC driver - src/rtc/rtc.c - src/rtc/rtc_ticks.c - # Sound Processing Unit driver - src/spu/spu.c - # Timer Unit driver - src/tmu/inth-etmu.s - src/tmu/inth-tmu.s - src/tmu/sleep.c - src/tmu/tmu.c - # USB driver - src/usb/asyncio.c - src/usb/classes/ff-bulk.c - src/usb/configure.c - src/usb/pipes.c - src/usb/read4.S - src/usb/setup.c - src/usb/string.c - src/usb/usb.c - src/usb/write4.S -) -set(SOURCES_FX # Gray engine src/gray/engine.c src/gray/gclear.c @@ -146,30 +79,6 @@ set(SOURCES_FX src/gray/grect.c src/gray/gsubimage.c src/gray/gtext.c - # Rendering - src/render-fx/bopti-asm-gray-scsp.s - src/render-fx/bopti-asm-gray.s - src/render-fx/bopti-asm-mono-scsp.s - src/render-fx/bopti-asm.s - src/render-fx/bopti.c - src/render-fx/dclear.c - src/render-fx/dgetpixel.c - src/render-fx/dpixel.c - src/render-fx/drect.c - src/render-fx/dsubimage.c - src/render-fx/dupdate.c - src/render-fx/gint_dline.c - src/render-fx/masks.c - src/render-fx/topti-asm.s - src/render-fx/topti.c - # T6K11 driver - src/t6k11/t6k11.c - - src/usb/classes/ff-bulk-gray.c -) -set(SOURCES_CG - # R61524 driver - src/r61524/r61524.c # Image library src/image/image_alloc.c src/image/image_alloc_palette.c @@ -201,7 +110,54 @@ set(SOURCES_CG src/image/image_valid.c src/image/image_vflip.c src/image/image_vflip_alloc.c - # Rendering + # Interrupt Controller driver + src/intc/intc.c + src/intc/inth.s + # Kernel + src/kernel/exch.c + src/kernel/exch.s + src/kernel/hardware.c + src/kernel/inth.S + src/kernel/kernel.c + src/kernel/osmenu.c + src/kernel/start.c + src/kernel/syscalls.S + src/kernel/tlbh.S + src/kernel/world.c + # Key Scan Interface driver + src/keysc/getkey.c + src/keysc/iokbd.c + src/keysc/keycodes.c + src/keysc/keydev.c + src/keysc/keydev_idle.c + src/keysc/keydev_process_key.c + src/keysc/keydown_all.c + src/keysc/keydown_any.c + src/keysc/keysc.c + src/keysc/scan_frequency.c + # Memory allocator + src/kmalloc/arena_gint.c + src/kmalloc/arena_osheap.c + src/kmalloc/kmalloc.c + # MMU driver + src/mmu/mmu.c + # R61524 display driver + src/r61524/r61524.c + # Format-agnostic rendering + src/render/dcircle.c + src/render/dellipse.c + src/render/dhline.c + src/render/dimage.c + src/render/dline.c + src/render/dpoly.c + src/render/dprint.c + src/render/drect_border.c + src/render/dtext.c + src/render/dupdate_hook.c + src/render/dvline.c + src/render/dwindow.c + src/render/topti.c + # RGB Rendering src/render-cg/dclear.c src/render-cg/dgetpixel.c src/render-cg/dpixel.c @@ -210,9 +166,9 @@ set(SOURCES_CG src/render-cg/dupdate.c src/render-cg/dvram.c src/render-cg/gint_dline.c - src/render-cg/topti-asm.s + src/render-cg/topti-asm.S src/render-cg/topti.c - # Fast image renderer + # Fast RGB image renderer src/render-cg/image/image.c src/render-cg/image/image_rgb16.S src/render-cg/image/image_rgb16_normal.S @@ -229,7 +185,7 @@ set(SOURCES_CG src/render-cg/image/image_p4_clearbg_alt.S src/render-cg/image/image_p4_swapcolor.S src/render-cg/image/image_p4_dye.S - # Interface to the fast image renderer + # Interface to the fast RGB image renderer src/render-cg/image/image_rgb16.c src/render-cg/image/image_rgb16_effect.c src/render-cg/image/image_rgb16_swapcolor.c @@ -243,6 +199,45 @@ set(SOURCES_CG src/render-cg/image/image_p4_effect.c src/render-cg/image/image_p4_swapcolor.c src/render-cg/image/image_p4_dye.c + # Mono rendering + src/render-fx/bopti-asm-gray-scsp.S + src/render-fx/bopti-asm-gray.S + src/render-fx/bopti-asm-mono-scsp.S + src/render-fx/bopti-asm.S + src/render-fx/bopti.c + src/render-fx/dclear.c + src/render-fx/dgetpixel.c + src/render-fx/dpixel.c + src/render-fx/drect.c + src/render-fx/dsubimage.c + src/render-fx/dupdate.c + src/render-fx/gint_dline.c + src/render-fx/masks.c + src/render-fx/topti-asm.S + src/render-fx/topti.c + # RTC driver + src/rtc/rtc.c + src/rtc/rtc_ticks.c + # Sound Processing Unit driver + src/spu/spu.c + # T6K11 display driver + src/t6k11/t6k11.c + # Timer Unit driver + src/tmu/inth-etmu.s + src/tmu/inth-tmu.s + src/tmu/sleep.c + src/tmu/tmu.c + # USB driver + src/usb/asyncio.c + src/usb/classes/ff-bulk.c + src/usb/classes/ff-bulk-gray.c + src/usb/configure.c + src/usb/pipes.c + src/usb/read4.S + src/usb/setup.c + src/usb/string.c + src/usb/usb.c + src/usb/write4.S ) set(ASSETS_FX src/font5x7.png) @@ -259,8 +254,7 @@ if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G) set(NAME "gint-fx") set(LINKER_SCRIPTS "${CMAKE_CURRENT_BINARY_DIR}/fx9860g.ld") - add_library(gint-fx STATIC ${SOURCES_COMMON} ${SOURCES_FX} ${ASSETS_FX} - ${LINKER_SCRIPTS}) + add_library(${NAME} STATIC ${SOURCES} ${ASSETS_FX} ${LINKER_SCRIPTS}) endif() if("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50) @@ -269,8 +263,16 @@ if("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50) set(LINKER_SCRIPTS "${CMAKE_CURRENT_BINARY_DIR}/fxcg50.ld" "${CMAKE_CURRENT_BINARY_DIR}/fxcg50_fastload.ld") - add_library(gint-cg STATIC ${SOURCES_COMMON} ${SOURCES_CG} ${ASSETS_CG} - ${LINKER_SCRIPTS}) + add_library(${NAME} STATIC ${SOURCES} ${ASSETS_CG} ${LINKER_SCRIPTS}) +endif() + +if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G_G3A) + add_compile_definitions(FX9860G_G3A) + set(NAME "gint-fxg3a") + set(LINKER_SCRIPTS + "${CMAKE_CURRENT_BINARY_DIR}/fxcg50.ld" + "${CMAKE_CURRENT_BINARY_DIR}/fxcg50_fastload.ld") + add_library(${NAME} STATIC ${SOURCES} ${ASSETS_FX} ${LINKER_SCRIPTS}) endif() set_target_properties("${NAME}" PROPERTIES OUTPUT_NAME "${NAME}") diff --git a/cmake/FindGint.cmake b/cmake/FindGint.cmake index 89ddd4f..207f632 100644 --- a/cmake/FindGint.cmake +++ b/cmake/FindGint.cmake @@ -7,6 +7,10 @@ elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G) set(PC fx) set(INTF_DEFN FX9860G) set(INTF_LINK "-T;fx9860g.ld") +elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G_G3A) + set(PC fxg3a) + set(INTF_DEFN FX9860G_G3A) + set(INTF_LINK "-T;fxcg50.ld") else() message(FATAL_ERROR "gint: unknown fxSDK platform '${FXSDK_PLATFORM}'") endif() diff --git a/giteapc.make b/giteapc.make index 0e04359..f7c7126 100644 --- a/giteapc.make +++ b/giteapc.make @@ -5,14 +5,17 @@ configure: @ fxsdk build-fx -c $(GINT_CMAKE_OPTIONS) @ fxsdk build-cg -c $(GINT_CMAKE_OPTIONS) + @ fxsdk build-fxg3a -c $(GINT_CMAKE_OPTIONS) build: @ fxsdk build-fx @ fxsdk build-cg + @ fxsdk build-fxg3a install: @ fxsdk build-fx install @ fxsdk build-cg install + @ fxsdk build-fxg3a install uninstall: @ if [ -e build-fx/install_manifest.txt ]; then \ @@ -21,5 +24,8 @@ uninstall: @ if [ -e build-cg/install_manifest.txt ]; then \ xargs rm -f < build-cg/install_manifest.txt; \ fi + @ if [ -e build-fxg3a/install_manifest.txt ]; then \ + xargs rm -f < build-fxg3a/install_manifest.txt; \ + fi .PHONY: configure build install uninstall diff --git a/include/gint/config.h.in b/include/gint/config.h.in index 6e3d500..d43c7f3 100644 --- a/include/gint/config.h.in +++ b/include/gint/config.h.in @@ -5,8 +5,6 @@ #ifndef GINT_CONFIG #define GINT_CONFIG -#include - /* GINT_VERSION: Latest tag and number of additional commits "2.1.0" = Release 2.1.0 "2.1.1-5" = 5 commits after release 2.1.1 */ @@ -25,6 +23,13 @@ # define GINT_HW_CG 1 #endif +/* Shorthand to simplify definitions below. Won't be needed for long. */ +#if defined(FX9860G_G3A) +# define GINT_FX9860G_G3A 1 +#else +# define GINT_FX9860G_G3A 0 +#endif + /* GINT_OS_{FX,CG}: Identifies the type of OS API we're assuming. Currently I see no reason this would be different from hardware, but who knows. */ #define GINT_OS_FX GINT_HW_FX @@ -57,6 +62,11 @@ /* GINT_RENDER_DMODE: Selects whether the dmode override is available on rendering functions. */ -#define GINT_RENDER_DMODE GINT_HW_FX +#define GINT_RENDER_DMODE (GINT_HW_FX || GINT_FX9860G_G3A) + +/* GINT_RENDER_{MONO,RGB}: Enable the mono/rgb rendering API. + Currently these are exclusive. */ +#define GINT_RENDER_MONO (GINT_HW_FX || GINT_FX9860G_G3A) +#define GINT_RENDER_RGB (GINT_HW_CG && !GINT_FX9860G_G3A) #endif /* GINT_CONFIG */ diff --git a/include/gint/display-cg.h b/include/gint/display-cg.h index e297205..9ca0b25 100644 --- a/include/gint/display-cg.h +++ b/include/gint/display-cg.h @@ -15,7 +15,7 @@ #ifndef GINT_DISPLAY_CG #define GINT_DISPLAY_CG -#ifdef FXCG50 +#if GINT_RENDER_RGB #ifdef __cplusplus extern "C" { @@ -104,6 +104,6 @@ void dgetvram(uint16_t **main, uint16_t **secondary); } #endif -#endif /* FXCG50 */ +#endif /* GINT_RENDER_RGB */ #endif /* GINT_DISPLAY_CG */ diff --git a/include/gint/display-fx.h b/include/gint/display-fx.h index af85e43..0515b6d 100644 --- a/include/gint/display-fx.h +++ b/include/gint/display-fx.h @@ -9,7 +9,7 @@ #ifndef GINT_DISPLAY_FX #define GINT_DISPLAY_FX -#ifdef FX9860G +#if GINT_RENDER_MONO #ifdef __cplusplus extern "C" { @@ -110,6 +110,6 @@ GINLINE static int image_layer_count(int profile) } #endif -#endif /* FX9860G */ +#endif /* GINT_RENDER_MONO */ #endif /* GINT_DISPLAY_FX */ diff --git a/include/gint/display.h b/include/gint/display.h index 599fd15..1e3fa74 100644 --- a/include/gint/display.h +++ b/include/gint/display.h @@ -15,15 +15,16 @@ extern "C" { #include #include +#include /* Platform-specific functions include VRAM management and the definition of the color_t type. */ -#ifdef FX9860G +#if GINT_RENDER_MONO #include #endif -#ifdef FXCG50 +#if GINT_RENDER_RGB #include #endif diff --git a/include/gint/image.h b/include/gint/image.h index 025649c..7d0c711 100644 --- a/include/gint/image.h +++ b/include/gint/image.h @@ -34,9 +34,8 @@ extern "C" { #endif -#ifndef FXCG50 -#error is only supported on FXCG50 -#else +#include +#if GINT_RENDER_RGB #include #include @@ -838,7 +837,7 @@ bool image_target(image_t const *src, image_t *dst, ...); #define image_alpha_2(fmt, copy_alpha) \ ((copy_alpha) ? 0x10000 : image_alpha(fmt)) -#endif /* FXCG50 */ +#endif /* GINT_RENDER_RGB */ #ifdef __cplusplus } diff --git a/src/gray/engine.c b/src/gray/engine.c index 5e51e72..ccb6f53 100644 --- a/src/gray/engine.c +++ b/src/gray/engine.c @@ -12,6 +12,10 @@ #include "../render-fx/render-fx.h" #include "../render/render.h" +#include + +// TODO: Move the gray "engine" into the T6K11 driver. +#if GINT_RENDER_MONO && GINT_HW_FX /* Three additional video RAMS, allocated statically if --static-gray was set at configure time, or with malloc() otherwise. */ @@ -270,3 +274,5 @@ void dgray_getscreen(uint32_t **light, uint32_t **dark) if(light) *light = vrams[base & 2]; if(dark) *dark = vrams[base | 1]; } + +#endif /* GINT_RENDER_MONO && GINT_HW_FX */ diff --git a/src/gray/gclear.c b/src/gray/gclear.c index ba7420e..ab8a2b2 100644 --- a/src/gray/gclear.c +++ b/src/gray/gclear.c @@ -1,4 +1,7 @@ #include +#include + +#if GINT_RENDER_MONO /* gclear(): Fill the screen with a single color */ void gclear(color_t color) @@ -35,3 +38,5 @@ void gclear(color_t color) dark += 8; } } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/gray/ggetpixel.c b/src/gray/ggetpixel.c index c508d5c..53956e0 100644 --- a/src/gray/ggetpixel.c +++ b/src/gray/ggetpixel.c @@ -1,5 +1,8 @@ #include #include +#include + +#if GINT_RENDER_MONO int ggetpixel(int x, int y) { @@ -13,3 +16,5 @@ int ggetpixel(int x, int y) bool d = (dark [offset] & mask) != 0; return (d << 1) | l; } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/gray/gint_gline.c b/src/gray/gint_gline.c index 75473d7..62a1bcd 100644 --- a/src/gray/gint_gline.c +++ b/src/gray/gint_gline.c @@ -1,5 +1,8 @@ #include #include +#include + +#if GINT_RENDER_MONO /* gint_ghline(): Optimized horizontal line, but not actually optimized */ void gint_ghline(int x1, int x2, int y, int color) @@ -14,3 +17,5 @@ void gint_gvline(int y1, int y2, int x, int color) if(y1 > y2) swap(y1, y2); for(int y = y1; y <= y2; y++) dpixel(x, y, color); } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/gray/gpixel.c b/src/gray/gpixel.c index a3e0750..b755cb8 100644 --- a/src/gray/gpixel.c +++ b/src/gray/gpixel.c @@ -1,5 +1,8 @@ #include #include +#include + +#if GINT_RENDER_MONO /* gpixel(): Change a pixel's color */ void gpixel(int x, int y, color_t color) @@ -55,3 +58,5 @@ void gpixel(int x, int y, color_t color) break; } } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/gray/grect.c b/src/gray/grect.c index 511253c..7539119 100644 --- a/src/gray/grect.c +++ b/src/gray/grect.c @@ -1,6 +1,9 @@ #include #include #include "../render-fx/render-fx.h" +#include + +#if GINT_RENDER_MONO /* grect(): Fill a rectangle on the screen */ void grect(int x1, int y1, int x2, int y2, color_t color) @@ -112,3 +115,5 @@ void grect(int x1, int y1, int x2, int y2, color_t color) light++, dark++; } } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/gray/gsubimage.c b/src/gray/gsubimage.c index 315bd37..f835ee7 100644 --- a/src/gray/gsubimage.c +++ b/src/gray/gsubimage.c @@ -1,6 +1,8 @@ #include #include "../render-fx/render-fx.h" -#include "../render-fx/bopti-asm.h" +#include + +#if GINT_RENDER_MONO #pragma GCC optimize("O3") @@ -37,3 +39,5 @@ void gsubimage(bopti_image_t const *img, struct rbox *r, GUNUSED int flags) bopti_render(img, r, light, dark); } } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/gray/gtext.c b/src/gray/gtext.c index b0dcc09..dc2402c 100644 --- a/src/gray/gtext.c +++ b/src/gray/gtext.c @@ -1,6 +1,9 @@ #include #include "../render/render.h" -#include "../render-fx/topti-asm.h" +#include "../render-fx/render-fx.h" +#include + +#if GINT_RENDER_MONO /* gtext_opt(): Display a string of text */ void gtext_opt(int x, int y, int fg, int bg, int halign, int valign, @@ -23,3 +26,5 @@ void gtext_opt(int x, int y, int fg, int bg, int halign, int valign, topti_render(x, y, str, topti_font, topti_asm_text[fg], topti_asm_text[bg], light, dark, size); } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/image/fixed.h b/src/image/fixed.h index 2384cd3..dc3c193 100644 --- a/src/image/fixed.h +++ b/src/image/fixed.h @@ -5,6 +5,8 @@ #ifndef GINT_IMAGE_FIXED #define GINT_IMAGE_FIXED +#include + /* Constants */ #define fconst(x) ((x) * 65536) diff --git a/src/image/image_alloc.c b/src/image/image_alloc.c index 010aa44..12ab27d 100644 --- a/src/image/image_alloc.c +++ b/src/image/image_alloc.c @@ -1,6 +1,8 @@ #include #include #include +#include +#if GINT_RENDER_RGB image_t *image_alloc(int width, int height, int format) { @@ -25,3 +27,5 @@ image_t *image_alloc(int width, int height, int format) img->flags |= IMAGE_FLAGS_DATA_ALLOC; return img; } + +#endif diff --git a/src/image/image_alloc_palette.c b/src/image/image_alloc_palette.c index 040ba2e..eb86646 100644 --- a/src/image/image_alloc_palette.c +++ b/src/image/image_alloc_palette.c @@ -3,6 +3,9 @@ #include #include +#include +#if GINT_RENDER_RGB + bool image_alloc_palette(image_t *img, int size) { if(!img || !IMAGE_IS_INDEXED(img->format)) @@ -29,3 +32,5 @@ bool image_alloc_palette(image_t *img, int size) img->flags |= IMAGE_FLAGS_PALETTE_ALLOC; return true; } + +#endif diff --git a/src/image/image_alpha.c b/src/image/image_alpha.c index d96c25b..07acc28 100644 --- a/src/image/image_alpha.c +++ b/src/image/image_alpha.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB int image_alpha(int format) { @@ -14,3 +16,5 @@ int image_alpha(int format) return 0x10000; } } + +#endif diff --git a/src/image/image_clear.c b/src/image/image_clear.c index 1144e02..9eca5d4 100644 --- a/src/image/image_clear.c +++ b/src/image/image_clear.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB void image_clear(image_t *img) { @@ -7,3 +9,5 @@ void image_clear(image_t *img) image_fill(img, image_alpha(img->format)); } + +#endif diff --git a/src/image/image_copy.c b/src/image/image_copy.c index ca7b700..6915af5 100644 --- a/src/image/image_copy.c +++ b/src/image/image_copy.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void image_copy(image_t const *src, image_t *dst, bool copy_alpha) { @@ -120,3 +122,5 @@ void image_copy(image_t const *src, image_t *dst, bool copy_alpha) } while(--h > 0); } } + +#endif diff --git a/src/image/image_copy_alloc.c b/src/image/image_copy_alloc.c index 40a0920..5fcd1f7 100644 --- a/src/image/image_copy_alloc.c +++ b/src/image/image_copy_alloc.c @@ -2,6 +2,9 @@ #include #include +#include +#if GINT_RENDER_RGB + image_t *image_copy_alloc(image_t const *src, int new_format) { if(!image_valid(src)) @@ -18,3 +21,5 @@ image_t *image_copy_alloc(image_t const *src, int new_format) image_copy(src, dst, true); return dst; } + +#endif diff --git a/src/image/image_copy_palette.c b/src/image/image_copy_palette.c index 7169c15..8a8316f 100644 --- a/src/image/image_copy_palette.c +++ b/src/image/image_copy_palette.c @@ -2,6 +2,9 @@ #include #include +#include +#if GINT_RENDER_RGB + bool image_copy_palette(image_t const *src, image_t *dst, int size) { if(!image_valid(src) || !dst) @@ -18,3 +21,5 @@ bool image_copy_palette(image_t const *src, image_t *dst, int size) memcpy(dst->palette, src->palette, 2*N); return true; } + +#endif diff --git a/src/image/image_create.c b/src/image/image_create.c index d7a1a58..b8a1876 100644 --- a/src/image/image_create.c +++ b/src/image/image_create.c @@ -1,6 +1,9 @@ #include #include +#include +#if GINT_RENDER_RGB + image_t *image_create(int width, int height, int format) { if(!IMAGE_IS_RGB16(format) && !IMAGE_IS_P8(format) && !IMAGE_IS_P4(format)) @@ -23,3 +26,5 @@ image_t *image_create(int width, int height, int format) return img; } + +#endif diff --git a/src/image/image_create_vram.c b/src/image/image_create_vram.c index 03e7fdc..191132d 100644 --- a/src/image/image_create_vram.c +++ b/src/image/image_create_vram.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB image_t *image_create_vram(void) { @@ -11,3 +13,5 @@ image_t *image_create_vram(void) img->data = gint_vram; return img; } + +#endif diff --git a/src/image/image_data_size.c b/src/image/image_data_size.c index 12e9953..40a713a 100644 --- a/src/image/image_data_size.c +++ b/src/image/image_data_size.c @@ -1,6 +1,10 @@ #include +#include +#if GINT_RENDER_RGB int image_data_size(image_t const *img) { return img->stride * img->height; } + +#endif diff --git a/src/image/image_decode_pixel.c b/src/image/image_decode_pixel.c index c152b0a..bd6c41a 100644 --- a/src/image/image_decode_pixel.c +++ b/src/image/image_decode_pixel.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB int image_decode_pixel(image_t const *img, int pixel) { @@ -10,3 +12,5 @@ int image_decode_pixel(image_t const *img, int pixel) return img->palette[pixel]; return -1; } + +#endif diff --git a/src/image/image_fill.c b/src/image/image_fill.c index ecd0534..02edfb8 100644 --- a/src/image/image_fill.c +++ b/src/image/image_fill.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB void image_fill(image_t *img, int value) { @@ -24,3 +26,5 @@ void image_fill(image_t *img, int value) } } } + +#endif diff --git a/src/image/image_free.c b/src/image/image_free.c index 64c470f..2cf09ed 100644 --- a/src/image/image_free.c +++ b/src/image/image_free.c @@ -2,6 +2,9 @@ #include #include +#include +#if GINT_RENDER_RGB + void image_free(image_t *img) { if(!img || mmu_is_rom(img)) @@ -14,3 +17,5 @@ void image_free(image_t *img) free(img); } + +#endif diff --git a/src/image/image_get_pixel.c b/src/image/image_get_pixel.c index 9e36b74..a471cb1 100644 --- a/src/image/image_get_pixel.c +++ b/src/image/image_get_pixel.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB int image_get_pixel(image_t const *img, int x, int y) { @@ -23,3 +25,5 @@ int image_get_pixel(image_t const *img, int x, int y) } return 0; } + +#endif diff --git a/src/image/image_hflip.c b/src/image/image_hflip.c index b4f97dc..c1f2b66 100644 --- a/src/image/image_hflip.c +++ b/src/image/image_hflip.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB void image_hflip(image_t const *src, image_t *dst, bool copy_alpha) { @@ -45,3 +47,5 @@ void image_hflip(image_t const *src, image_t *dst, bool copy_alpha) } } } + +#endif diff --git a/src/image/image_hflip_alloc.c b/src/image/image_hflip_alloc.c index cfe1e9f..40b58b0 100644 --- a/src/image/image_hflip_alloc.c +++ b/src/image/image_hflip_alloc.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB image_t *image_hflip_alloc(image_t const *src) { @@ -14,3 +16,5 @@ image_t *image_hflip_alloc(image_t const *src) image_hflip(src, dst, true); return dst; } + +#endif diff --git a/src/image/image_linear.S b/src/image/image_linear.S index ee6b43d..50c5a6a 100644 --- a/src/image/image_linear.S +++ b/src/image/image_linear.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _image_linear_rgb16 .global _image_linear_p8 @@ -124,3 +127,5 @@ _image_linear_rgb16: _image_linear_p8: GEN_LINEAR_LOOP mov.b, 1 + +#endif diff --git a/src/image/image_linear.c b/src/image/image_linear.c index f3df33a..7782f64 100644 --- a/src/image/image_linear.c +++ b/src/image/image_linear.c @@ -2,6 +2,9 @@ #include #include "fixed.h" +#include +#if GINT_RENDER_RGB + void image_linear_rgb16(void *src, void *dst, struct image_linear_map *map); void image_linear_p8(void *src, void *dst, struct image_linear_map *map); @@ -32,3 +35,5 @@ void image_linear(image_t const *src, image_t *dst, else if(IMAGE_IS_P8(src->format)) image_linear_p8(src->data, dst->data, map); } + +#endif diff --git a/src/image/image_linear_alloc.c b/src/image/image_linear_alloc.c index c51760c..ca9caa8 100644 --- a/src/image/image_linear_alloc.c +++ b/src/image/image_linear_alloc.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB image_t *image_linear_alloc(image_t const *src, struct image_linear_map *map) { @@ -18,3 +20,5 @@ image_t *image_linear_alloc(image_t const *src, struct image_linear_map *map) image_linear(src, dst, map); return dst; } + +#endif diff --git a/src/image/image_rotate.c b/src/image/image_rotate.c index 3d72478..d0d1628 100644 --- a/src/image/image_rotate.c +++ b/src/image/image_rotate.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB void image_rotate(image_t const *src, float angle, bool resize, struct image_linear_map *map) @@ -11,3 +13,5 @@ void image_rotate(image_t const *src, float angle, bool resize, image_rotate_around(src, angle, resize, ¢er_x, ¢er_y, map); } + +#endif diff --git a/src/image/image_rotate_around.c b/src/image/image_rotate_around.c index bf554e5..6788e4a 100644 --- a/src/image/image_rotate_around.c +++ b/src/image/image_rotate_around.c @@ -1,9 +1,14 @@ #include #include "fixed.h" +#include +#if GINT_RENDER_RGB + void image_rotate_around(image_t const *src, float angle, bool resize, int *center_x, int *center_y, struct image_linear_map *map) { image_rotate_around_scale(src, angle, fconst(1.0), resize, center_x, center_y, map); } + +#endif diff --git a/src/image/image_rotate_around_scale.c b/src/image/image_rotate_around_scale.c index a8b725b..a959bcb 100644 --- a/src/image/image_rotate_around_scale.c +++ b/src/image/image_rotate_around_scale.c @@ -2,6 +2,9 @@ #include #include "fixed.h" +#include +#if GINT_RENDER_RGB + void image_rotate_around_scale(image_t const *src, float alpha, int gamma, bool resize, int *center_x, int *center_y, struct image_linear_map *map) { @@ -58,3 +61,5 @@ void image_rotate_around_scale(image_t const *src, float alpha, int gamma, *center_x = new_center_x; *center_y = new_center_y; } + +#endif diff --git a/src/image/image_scale.c b/src/image/image_scale.c index 7910bfd..14488fd 100644 --- a/src/image/image_scale.c +++ b/src/image/image_scale.c @@ -1,6 +1,9 @@ #include #include "fixed.h" +#include +#if GINT_RENDER_RGB + void image_scale(image_t const *src, int gamma_x, int gamma_y, struct image_linear_map *map) { @@ -22,3 +25,5 @@ void image_scale(image_t const *src, int gamma_x, int gamma_y, map->dst_w = fround(src->width * gamma_x); map->dst_h = fround(src->height * gamma_y); } + +#endif diff --git a/src/image/image_set_palette.c b/src/image/image_set_palette.c index 4da4f2c..ee39c82 100644 --- a/src/image/image_set_palette.c +++ b/src/image/image_set_palette.c @@ -1,6 +1,9 @@ #include #include +#include +#if GINT_RENDER_RGB + void image_set_palette(image_t *img, uint16_t *palette, int size, bool owns) { if(!img || !IMAGE_IS_INDEXED(img->format)) @@ -16,3 +19,5 @@ void image_set_palette(image_t *img, uint16_t *palette, int size, bool owns) else img->flags &= ~IMAGE_FLAGS_PALETTE_ALLOC; } + +#endif diff --git a/src/image/image_set_pixel.c b/src/image/image_set_pixel.c index a8dfb15..ce1326d 100644 --- a/src/image/image_set_pixel.c +++ b/src/image/image_set_pixel.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB void image_set_pixel(image_t const *img, int x, int y, int value) { @@ -24,3 +26,5 @@ void image_set_pixel(image_t const *img, int x, int y, int value) data_u8[x >> 1] = (data_u8[x >> 1] & 0x0f) | (value << 4); } } + +#endif diff --git a/src/image/image_sub.c b/src/image/image_sub.c index ccc4c33..d2cd2cc 100644 --- a/src/image/image_sub.c +++ b/src/image/image_sub.c @@ -3,6 +3,9 @@ #include #undef image_sub +#include +#if GINT_RENDER_RGB + static image_t image_sub_default; image_t *image_sub(image_t const *src, int left, int top, int w, int h, @@ -39,3 +42,5 @@ image_t *image_sub(image_t const *src, int left, int top, int w, int h, dst->palette = src->palette; return dst; } + +#endif diff --git a/src/image/image_target.c b/src/image/image_target.c index ccd6e15..cc2991f 100644 --- a/src/image/image_target.c +++ b/src/image/image_target.c @@ -1,6 +1,9 @@ #include #undef image_target +#include +#if GINT_RENDER_RGB + bool image_target(image_t const *src, image_t *dst, ...) { if(!image_valid(src) || !image_valid(dst)) @@ -37,3 +40,5 @@ bool image_target(image_t const *src, image_t *dst, ...) va_end(args); return true; } + +#endif diff --git a/src/image/image_valid.c b/src/image/image_valid.c index 4533161..11697c5 100644 --- a/src/image/image_valid.c +++ b/src/image/image_valid.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB bool image_valid(image_t const *img) { @@ -16,3 +18,5 @@ bool image_valid(image_t const *img) /* Invalid format */ return false; } + +#endif diff --git a/src/image/image_vflip.c b/src/image/image_vflip.c index e56de77..6263759 100644 --- a/src/image/image_vflip.c +++ b/src/image/image_vflip.c @@ -1,6 +1,8 @@ #include #include #include +#include +#if GINT_RENDER_RGB static void copy_row_rgb16(uint16_t *src, uint16_t *dst, int src_alpha, int dst_alpha, int width) @@ -60,3 +62,5 @@ void image_vflip(image_t const *src, image_t *dst, bool copy_alpha) free(row); } + +#endif diff --git a/src/image/image_vflip_alloc.c b/src/image/image_vflip_alloc.c index 21442e5..fffbe96 100644 --- a/src/image/image_vflip_alloc.c +++ b/src/image/image_vflip_alloc.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB image_t *image_vflip_alloc(image_t const *src) { @@ -14,3 +16,5 @@ image_t *image_vflip_alloc(image_t const *src) image_vflip(src, dst, true); return dst; } + +#endif diff --git a/src/kmalloc/arena_gint.c b/src/kmalloc/arena_gint.c index 73cf110..b042fd6 100644 --- a/src/kmalloc/arena_gint.c +++ b/src/kmalloc/arena_gint.c @@ -5,6 +5,7 @@ #include #include #include +#include #include diff --git a/src/r61524/r61524.c b/src/r61524/r61524.c index 0b5be8e..b671ffe 100644 --- a/src/r61524/r61524.c +++ b/src/r61524/r61524.c @@ -9,6 +9,9 @@ #include #include #include +#include + +#if GINT_RENDER_RGB #define DMA SH7305_DMA #define POWER SH7305_POWER @@ -217,3 +220,5 @@ gint_driver_t drv_r61524 = { .state_size = sizeof(r61524_state_t), }; GINT_DECLARE_DRIVER(26, drv_r61524); + +#endif /* GINT_RENDER_RGB */ diff --git a/src/render-cg/dclear.c b/src/render-cg/dclear.c index 4373bb7..e5c15a4 100644 --- a/src/render-cg/dclear.c +++ b/src/render-cg/dclear.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void dclear(uint16_t color) { @@ -16,3 +18,5 @@ void dclear(uint16_t color) dwindow.bottom - 1, color); } } + +#endif diff --git a/src/render-cg/dgetpixel.c b/src/render-cg/dgetpixel.c index 1068449..46eaf09 100644 --- a/src/render-cg/dgetpixel.c +++ b/src/render-cg/dgetpixel.c @@ -1,7 +1,11 @@ #include +#include +#if GINT_RENDER_RGB int dgetpixel(int x, int y) { if((uint)x >= DWIDTH || (uint)y >= DHEIGHT) return -1; return gint_vram[DWIDTH * y + x]; } + +#endif diff --git a/src/render-cg/dpixel.c b/src/render-cg/dpixel.c index 44e8d56..7b856d8 100644 --- a/src/render-cg/dpixel.c +++ b/src/render-cg/dpixel.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB void dpixel(int x, int y, int color) { @@ -11,3 +13,5 @@ void dpixel(int x, int y, int color) if(color == C_INVERT) gint_vram[index] ^= 0xffff; else gint_vram[index] = color; } + +#endif diff --git a/src/render-cg/drect.c b/src/render-cg/drect.c index 24bdba7..7ea250c 100644 --- a/src/render-cg/drect.c +++ b/src/render-cg/drect.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void drect(int x1, int y1, int x2, int y2, int color) { @@ -50,3 +52,5 @@ void drect(int x1, int y1, int x2, int y2, int color) base += DWIDTH; } } + +#endif diff --git a/src/render-cg/dsubimage.c b/src/render-cg/dsubimage.c index f3d1379..dc31b37 100644 --- a/src/render-cg/dsubimage.c +++ b/src/render-cg/dsubimage.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB /* dsubimage(): Render a section of an image */ void dsubimage(int x, int y, image_t const *img, int left, int top, @@ -11,3 +13,5 @@ void dsubimage(int x, int y, image_t const *img, int left, int top, else if(IMAGE_IS_P4(img->format)) return dsubimage_p4(x, y, img, left, top, w, h, flags); } + +#endif diff --git a/src/render-cg/dupdate.c b/src/render-cg/dupdate.c index 8dfd18c..d6480c9 100644 --- a/src/render-cg/dupdate.c +++ b/src/render-cg/dupdate.c @@ -1,6 +1,8 @@ #include #include #include "render-cg.h" +#include +#if GINT_RENDER_RGB /* dupdate(): Push the video RAM to the display driver */ void dupdate(void) @@ -19,3 +21,5 @@ void dupdate(void) } __attribute__((alias("dupdate"))) void _WEAK_dupdate(void); + +#endif diff --git a/src/render-cg/dvram.c b/src/render-cg/dvram.c index 0bbde2b..88b1d57 100644 --- a/src/render-cg/dvram.c +++ b/src/render-cg/dvram.c @@ -1,6 +1,7 @@ #include #include #include +#if GINT_RENDER_RGB /* Up to two VRAM pointers can be set, for triple buffering. */ static uint16_t *vram_1 = NULL, *vram_2 = NULL; @@ -67,3 +68,5 @@ void dvram_switch(void) { gint_vram = (gint_vram == vram_1) ? vram_2 : vram_1; } + +#endif diff --git a/src/render-cg/gint_dline.c b/src/render-cg/gint_dline.c index 5b27559..18941ea 100644 --- a/src/render-cg/gint_dline.c +++ b/src/render-cg/gint_dline.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB /* gint_dhline(): Optimized horizontal line */ void gint_dhline(int x1, int x2, int y, uint16_t color) @@ -43,3 +45,4 @@ void gint_dvline(int y1, int y2, int x, uint16_t color) while(height-- > 0) *v = color, v += DWIDTH; } +#endif diff --git a/src/render-cg/image/image.c b/src/render-cg/image/image.c index a70e923..3f45315 100644 --- a/src/render-cg/image/image.c +++ b/src/render-cg/image/image.c @@ -1,6 +1,8 @@ #include #include #include +#include +#if GINT_RENDER_RGB bool gint_image_clip_input(image_t const *img, struct gint_image_box *b, struct dwindow const *window) @@ -119,3 +121,5 @@ bool gint_image_mkcmd(struct gint_image_box *box, image_t const *img, cmd->output = (void *)gint_vram + (DWIDTH * box->y + cmd->x) * 2; return true; } + +#endif diff --git a/src/render-cg/image/image_p4.S b/src/render-cg/image/image_p4.S index 9ff67f4..57a629c 100644 --- a/src/render-cg/image/image_p4.S +++ b/src/render-cg/image/image_p4.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_p4_loop /* gint's image renderer: 4-bit indexed entry point @@ -81,3 +84,5 @@ _NO_VFLIP: jmp @r9 subc r7, r4 + +#endif diff --git a/src/render-cg/image/image_p4.c b/src/render-cg/image/image_p4.c index cf87f0a..ac8bc8e 100644 --- a/src/render-cg/image/image_p4.c +++ b/src/render-cg/image/image_p4.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void dimage_p4(int x, int y, image_t const *img, int eff) { @@ -39,3 +41,5 @@ void dsubimage_p4_clearbg(int x, int y, image_t const *img, cmd.loop = gint_image_p4_clearbg; gint_image_p4_loop(DWIDTH, &cmd); } + +#endif diff --git a/src/render-cg/image/image_p4_clearbg.S b/src/render-cg/image/image_p4_clearbg.S index 873222b..5235f25 100644 --- a/src/render-cg/image/image_p4_clearbg.S +++ b/src/render-cg/image/image_p4_clearbg.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_p4_clearbg #include "image_macros.S" @@ -95,3 +98,5 @@ _gint_image_p4_clearbg: GEN_CLEARBG_LOOP 0, 2 9: GEN_CLEARBG_LOOP 1, -2 + +#endif diff --git a/src/render-cg/image/image_p4_clearbg_alt.S b/src/render-cg/image/image_p4_clearbg_alt.S index 660c49c..b0bbf0d 100644 --- a/src/render-cg/image/image_p4_clearbg_alt.S +++ b/src/render-cg/image/image_p4_clearbg_alt.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_p4_clearbg_alt #include "image_macros.S" @@ -151,3 +154,5 @@ _gint_image_p4_clearbg_alt: GEN_CLEARBG_LOOP 0, 4, r13, r14, 6, 4 9: GEN_CLEARBG_LOOP 1, -4, r13, r14, 0, 2 + +#endif diff --git a/src/render-cg/image/image_p4_clearbg_alt.c b/src/render-cg/image/image_p4_clearbg_alt.c index 3d05f99..bf18b17 100644 --- a/src/render-cg/image/image_p4_clearbg_alt.c +++ b/src/render-cg/image/image_p4_clearbg_alt.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void dimage_p4_clearbg_alt(int x, int y, image_t const *img, int eff, int bg) { @@ -19,3 +21,5 @@ void dsubimage_p4_clearbg_alt(int x, int y, image_t const *img, cmd.loop = gint_image_p4_clearbg_alt; gint_image_p4_loop(DWIDTH, &cmd); } + +#endif diff --git a/src/render-cg/image/image_p4_dye.S b/src/render-cg/image/image_p4_dye.S index d1cc9d6..19be979 100644 --- a/src/render-cg/image/image_p4_dye.S +++ b/src/render-cg/image/image_p4_dye.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_p4_dye #include "image_macros.S" @@ -145,3 +148,5 @@ _gint_image_p4_dye: GEN_DYE_LOOP 0, 4, r13, r14, 6, 4 9: GEN_DYE_LOOP 1, -4, r13, r14, 0, 2 + +#endif diff --git a/src/render-cg/image/image_p4_dye.c b/src/render-cg/image/image_p4_dye.c index 7a9e46b..f1c24cc 100644 --- a/src/render-cg/image/image_p4_dye.c +++ b/src/render-cg/image/image_p4_dye.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void dimage_p4_dye(int x, int y, image_t const *img, int eff, int dye_color) { @@ -20,3 +22,5 @@ void dsubimage_p4_dye(int x, int y, image_t const *img, cmd.loop = gint_image_p4_dye; gint_image_p4_loop(DWIDTH, &cmd); } + +#endif diff --git a/src/render-cg/image/image_p4_effect.c b/src/render-cg/image/image_p4_effect.c index 1af0497..92ac23f 100644 --- a/src/render-cg/image/image_p4_effect.c +++ b/src/render-cg/image/image_p4_effect.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB void dsubimage_p4_effect(int x, int y, image_t const *img, int left, int top, int w, int h, int eff, ...) @@ -30,3 +32,5 @@ void dsubimage_p4_effect(int x, int y, image_t const *img, va_end(args); } + +#endif diff --git a/src/render-cg/image/image_p4_normal.S b/src/render-cg/image/image_p4_normal.S index 15652ab..33f21e6 100644 --- a/src/render-cg/image/image_p4_normal.S +++ b/src/render-cg/image/image_p4_normal.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_p4_normal #include "image_macros.S" @@ -123,3 +126,5 @@ _gint_image_p4_normal: GEN_NORMAL_LOOP 0, 2, r7, r11, 4, 2 9: GEN_NORMAL_LOOP 1, -2, r7, r11, 2, 4 + +#endif diff --git a/src/render-cg/image/image_p4_swapcolor.S b/src/render-cg/image/image_p4_swapcolor.S index 3d35d34..66450ab 100644 --- a/src/render-cg/image/image_p4_swapcolor.S +++ b/src/render-cg/image/image_p4_swapcolor.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_p4_swapcolor #include "image_macros.S" @@ -173,3 +176,5 @@ _gint_image_p4_swapcolor: GEN_SWAPCOLOR_LOOP 0, 4, r13, r14, 6, 0 9: GEN_SWAPCOLOR_LOOP 1, -4, r13, r14, 0, 6 + +#endif diff --git a/src/render-cg/image/image_p4_swapcolor.c b/src/render-cg/image/image_p4_swapcolor.c index b1a3753..838bbe7 100644 --- a/src/render-cg/image/image_p4_swapcolor.c +++ b/src/render-cg/image/image_p4_swapcolor.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void dimage_p4_swapcolor(int x, int y, image_t const *img, int eff, int old_color, int new_color) @@ -42,3 +44,5 @@ void dsubimage_p4_addbg(int x, int y, image_t const *img, cmd.loop = gint_image_p4_swapcolor; gint_image_p4_loop(DWIDTH, &cmd); } + +#endif diff --git a/src/render-cg/image/image_p8.S b/src/render-cg/image/image_p8.S index 7ea1af3..e90ede6 100644 --- a/src/render-cg/image/image_p8.S +++ b/src/render-cg/image/image_p8.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_p8_loop /* gint's image renderer: 8-bit indexed entry point @@ -101,3 +104,5 @@ _VFLIP: _NO_VFLIP: jmp @r9 sub r2, r4 + +#endif diff --git a/src/render-cg/image/image_p8.c b/src/render-cg/image/image_p8.c index f0005e4..4c0040f 100644 --- a/src/render-cg/image/image_p8.c +++ b/src/render-cg/image/image_p8.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void dimage_p8(int x, int y, image_t const *img, int eff) { @@ -39,3 +41,5 @@ void dsubimage_p8_clearbg(int x, int y, image_t const *img, cmd.loop = gint_image_p8_clearbg; gint_image_p8_loop(DWIDTH, &cmd); } + +#endif diff --git a/src/render-cg/image/image_p8_clearbg.S b/src/render-cg/image/image_p8_clearbg.S index 3193d7d..4f6396c 100644 --- a/src/render-cg/image/image_p8_clearbg.S +++ b/src/render-cg/image/image_p8_clearbg.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_p8_clearbg #include "image_macros.S" @@ -148,3 +151,5 @@ _gint_image_p8_clearbg: GEN_CLEARBG_LOOP 0, 4, r13, r14, 4, 2 9: GEN_CLEARBG_LOOP 1, -4, r13, r14, 2, 4 + +#endif diff --git a/src/render-cg/image/image_p8_dye.S b/src/render-cg/image/image_p8_dye.S index 659fd87..d66a1f7 100644 --- a/src/render-cg/image/image_p8_dye.S +++ b/src/render-cg/image/image_p8_dye.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_p8_dye #include "image_macros.S" @@ -116,3 +119,5 @@ _gint_image_p8_dye: GEN_DYE_LOOP 0, 4, r13, r14, 4, 2 9: GEN_DYE_LOOP 1, -4, r13, r14, 2, 4 + +#endif diff --git a/src/render-cg/image/image_p8_dye.c b/src/render-cg/image/image_p8_dye.c index 5047613..3b73eba 100644 --- a/src/render-cg/image/image_p8_dye.c +++ b/src/render-cg/image/image_p8_dye.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void dimage_p8_dye(int x, int y, image_t const *img, int eff, int dye_color) { @@ -20,3 +22,5 @@ void dsubimage_p8_dye(int x, int y, image_t const *img, cmd.loop = gint_image_p8_dye; gint_image_p8_loop(DWIDTH, &cmd); } + +#endif diff --git a/src/render-cg/image/image_p8_effect.c b/src/render-cg/image/image_p8_effect.c index 00b301a..92bd17f 100644 --- a/src/render-cg/image/image_p8_effect.c +++ b/src/render-cg/image/image_p8_effect.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB void dsubimage_p8_effect(int x, int y, image_t const *img, int left, int top, int w, int h, int eff, ...) @@ -30,3 +32,5 @@ void dsubimage_p8_effect(int x, int y, image_t const *img, va_end(args); } + +#endif diff --git a/src/render-cg/image/image_p8_normal.S b/src/render-cg/image/image_p8_normal.S index 7cc5c53..38d9a5b 100644 --- a/src/render-cg/image/image_p8_normal.S +++ b/src/render-cg/image/image_p8_normal.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_p8_normal #include "image_macros.S" @@ -40,3 +43,5 @@ _gint_image_p8_normal: GEN_NORMAL_LOOP 0, 2 9: GEN_NORMAL_LOOP 1, -2 + +#endif diff --git a/src/render-cg/image/image_p8_swapcolor.S b/src/render-cg/image/image_p8_swapcolor.S index 2166d5b..b72532c 100644 --- a/src/render-cg/image/image_p8_swapcolor.S +++ b/src/render-cg/image/image_p8_swapcolor.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_p8_swapcolor #include "image_macros.S" @@ -75,3 +78,5 @@ _gint_image_p8_swapcolor: GEN_SWAPCOLOR_LOOP 0, 2 9: GEN_SWAPCOLOR_LOOP 1, -2 + +#endif diff --git a/src/render-cg/image/image_p8_swapcolor.c b/src/render-cg/image/image_p8_swapcolor.c index 6cc45ad..df73a5b 100644 --- a/src/render-cg/image/image_p8_swapcolor.c +++ b/src/render-cg/image/image_p8_swapcolor.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void dimage_p8_swapcolor(int x, int y, image_t const *img, int eff, int old_color, int new_color) @@ -42,3 +44,5 @@ void dsubimage_p8_addbg(int x, int y, image_t const *img, cmd.loop = gint_image_p8_swapcolor; gint_image_p8_loop(DWIDTH, &cmd); } + +#endif diff --git a/src/render-cg/image/image_rgb16.S b/src/render-cg/image/image_rgb16.S index c6f5c7d..f5e0afc 100644 --- a/src/render-cg/image/image_rgb16.S +++ b/src/render-cg/image/image_rgb16.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_rgb16_loop /* gint's image renderer: 16-bit RGB entry point @@ -67,3 +70,5 @@ _NO_VFLIP: jmp @r9 add r4, r4 + +#endif diff --git a/src/render-cg/image/image_rgb16.c b/src/render-cg/image/image_rgb16.c index 32f3784..cd4ae28 100644 --- a/src/render-cg/image/image_rgb16.c +++ b/src/render-cg/image/image_rgb16.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void dimage_rgb16(int x, int y, image_t const *img, int eff) { @@ -40,3 +42,5 @@ void dsubimage_rgb16_clearbg(int x, int y, image_t const *img, cmd.loop = gint_image_rgb16_clearbg; gint_image_rgb16_loop(DWIDTH, &cmd); } + +#endif diff --git a/src/render-cg/image/image_rgb16_clearbg_dye.S b/src/render-cg/image/image_rgb16_clearbg_dye.S index 904aa3d..fa51824 100644 --- a/src/render-cg/image/image_rgb16_clearbg_dye.S +++ b/src/render-cg/image/image_rgb16_clearbg_dye.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_rgb16_clearbg .global _gint_image_rgb16_dye #include "image_macros.S" @@ -51,3 +54,5 @@ _gint_image_rgb16_dye: GEN_CLEARBG_DYE_LOOP 0, 4, r7, r0 9: GEN_CLEARBG_DYE_LOOP 1, -4, r7, r0 + +#endif diff --git a/src/render-cg/image/image_rgb16_dye.c b/src/render-cg/image/image_rgb16_dye.c index ed70b8a..012b8bb 100644 --- a/src/render-cg/image/image_rgb16_dye.c +++ b/src/render-cg/image/image_rgb16_dye.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void dimage_rgb16_dye(int x, int y, image_t const *img, int eff, int dye_color) { @@ -20,3 +22,5 @@ void dsubimage_rgb16_dye(int x, int y, image_t const *img, cmd.loop = gint_image_rgb16_dye; gint_image_rgb16_loop(DWIDTH, &cmd); } + +#endif diff --git a/src/render-cg/image/image_rgb16_effect.c b/src/render-cg/image/image_rgb16_effect.c index 64c9b5c..3e8abc0 100644 --- a/src/render-cg/image/image_rgb16_effect.c +++ b/src/render-cg/image/image_rgb16_effect.c @@ -1,4 +1,6 @@ #include +#include +#if GINT_RENDER_RGB void dsubimage_rgb16_effect(int x, int y, image_t const *img, int left, int top, int w, int h, int eff, ...) @@ -30,3 +32,5 @@ void dsubimage_rgb16_effect(int x, int y, image_t const *img, va_end(args); } + +#endif diff --git a/src/render-cg/image/image_rgb16_normal.S b/src/render-cg/image/image_rgb16_normal.S index bc9d087..ecec018 100644 --- a/src/render-cg/image/image_rgb16_normal.S +++ b/src/render-cg/image/image_rgb16_normal.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_rgb16_normal #include "image_macros.S" @@ -199,3 +202,5 @@ _BACKWARD_LONG_COPY: 3: mov.l r0, @-r5 END EPILOGUE + +#endif diff --git a/src/render-cg/image/image_rgb16_swapcolor.S b/src/render-cg/image/image_rgb16_swapcolor.S index 924b9fb..cacebc4 100644 --- a/src/render-cg/image/image_rgb16_swapcolor.S +++ b/src/render-cg/image/image_rgb16_swapcolor.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _gint_image_rgb16_swapcolor #include "image_macros.S" @@ -43,3 +46,5 @@ _gint_image_rgb16_swapcolor: GEN_SWAPCOLOR_LOOP 0, 2 9: GEN_SWAPCOLOR_LOOP 1, -2 + +#endif diff --git a/src/render-cg/image/image_rgb16_swapcolor.c b/src/render-cg/image/image_rgb16_swapcolor.c index 6843827..e568fa0 100644 --- a/src/render-cg/image/image_rgb16_swapcolor.c +++ b/src/render-cg/image/image_rgb16_swapcolor.c @@ -1,5 +1,7 @@ #include #include +#include +#if GINT_RENDER_RGB void dimage_rgb16_swapcolor(int x, int y, image_t const *img, int eff, int old_color, int new_color) @@ -42,3 +44,5 @@ void dsubimage_rgb16_addbg(int x, int y, image_t const *img, cmd.loop = gint_image_rgb16_swapcolor; gint_image_rgb16_loop(DWIDTH, &cmd); } + +#endif diff --git a/src/render-cg/topti-asm.s b/src/render-cg/topti-asm.S similarity index 98% rename from src/render-cg/topti-asm.s rename to src/render-cg/topti-asm.S index 94d3091..b1aaf30 100644 --- a/src/render-cg/topti-asm.s +++ b/src/render-cg/topti-asm.S @@ -1,3 +1,6 @@ +#include +#if GINT_RENDER_RGB + .global _topti_glyph_fg_bg .global _topti_glyph_fg .global _topti_glyph_bg @@ -200,3 +203,5 @@ _topti_glyph_bg: .align 4 1: .long 396*2 + +#endif diff --git a/src/render-cg/topti-asm.h b/src/render-cg/topti-asm.h index d5d4e1a..8021457 100644 --- a/src/render-cg/topti-asm.h +++ b/src/render-cg/topti-asm.h @@ -5,6 +5,9 @@ #ifndef GINT_RENDERCG_TOPTIASM #define GINT_RENDERCG_TOPTIASM +#include +#if GINT_RENDER_RGB + /* Text rendering functions @vram Pointer to VRAM, offset for subglyph position @@ -26,4 +29,6 @@ extern asm_text_t topti_glyph_bg; /* Opaque foreground, opaque background */ extern asm_text_t topti_glyph_fg_bg; +#endif + #endif /* GINT_RENDERFX_TOPTIASM */ diff --git a/src/render-cg/topti.c b/src/render-cg/topti.c index 31fdb39..60da5dc 100644 --- a/src/render-cg/topti.c +++ b/src/render-cg/topti.c @@ -8,6 +8,9 @@ #include "../render/render.h" #include "topti-asm.h" +#include +#if GINT_RENDER_RGB + /* Default font */ extern font_t gint_font8x9; font_t const * gint_default_font = &gint_font8x9; @@ -136,3 +139,5 @@ void dtext_opt(int x, int y, int fg, int bg, int halign, int valign, topti_render(x, y, str, topti_font, fg, bg, size); } + +#endif diff --git a/src/render-fx/bopti-asm-gray-scsp.S b/src/render-fx/bopti-asm-gray-scsp.S new file mode 100644 index 0000000..9684dfa --- /dev/null +++ b/src/render-fx/bopti-asm-gray-scsp.S @@ -0,0 +1,156 @@ +#include +#if GINT_RENDER_MONO + +.global _bopti_gasm_mono_scsp +.global _bopti_gasm_mono_alpha_scsp +.global _bopti_gasm_gray_scsp +.global _bopti_gasm_gray_alpha_scsp + +/* REGISTER ALLOCATION: + r0: OR layer + r1: (temp) + r2: light vram longword + r3: dark vram longword + -- + r4: light pointer + r5: layer pointer + r6: mask + r7: dark pointer + -- + @r15: -(x&31) */ + +_bopti_gasm_mono_scsp: + /* Read layer longword and shift it */ + mov.l @r5, r0 + mov.l @r15, r1 + shld r1, r0 + + /* Clear target VRAM and unwanted image data */ + and r6, r0 + mov.l @r4, r2 + not r6, r6 + mov.l @r7, r3 + and r6, r2 + and r6, r3 + + /* Blit and return */ + or r0, r2 + or r0, r3 + mov.l r2, @r4 + rts + mov.l r3, @r7 + +/* REGISTER ALLOCATION: + r0: AND layer + r1: (temp) + r2: light vram longword + r3: dark vram longword + -- + r4: light pointer + r5: layer pointer, then OR layer + r6: mask + r7: dark pointer + -- + @r15: -(x&31) */ +_bopti_gasm_mono_alpha_scsp: + /* Read layer longwords and shift them */ + mov.l @r5, r0 + mov.l @r15, r1 + mov.l @(4,r5), r5 + shld r1, r0 + shld r1, r5 + + /* Clear any unwanted image data */ + and r6, r0 + mov.l @r4, r2 + and r6, r5 + mov.l @r7, r3 + + /* Blit and return */ + not r0, r0 + and r0, r2 + and r0, r3 + or r5, r2 + or r5, r3 + mov.l r2, @r4 + rts + mov.l r3, @r7 + +/* REGISTER ALLOCATION: + r0: LIGHT layer + r1: (temp) + r2: light vram longword + r3: dark vram longword + -- + r4: light pointer + r5: layer pointer, then DARK layer + r6: mask + r7: dark pointer + -- + @r15: -(x&31) */ +_bopti_gasm_gray_scsp: + /* Read layer longwords and shift them */ + mov.l @r5, r0 + mov.l @r15, r1 + mov.l @(4,r5), r5 + shld r1, r0 + shld r1, r5 + + /* Clear target VRAM and unapplied image data */ + and r6, r0 + mov.l @r4, r2 + and r6, r5 + mov.l @r7, r3 + not r6, r6 + and r6, r2 + and r6, r3 + + /* Blit and return */ + or r0, r2 + or r5, r3 + mov.l r2, @r4 + rts + mov.l r3, @r7 + +/* REGISTER ALLOCATION: + r0: AND layer + r1: LIGHT layer + r2: (temp), then light vram longword + r3: dark vram longword + -- + r4: light pointer + r5: layer pointer, then DARK layer + r6: mask + r7: dark pointer + -- + @r15: -(x&31) */ +_bopti_gasm_gray_alpha_scsp: + /* Read layer longwords and shift them */ + mov.l @r5, r0 + mov.l @(4,r5), r1 + mov.l @(8,r5), r5 + mov.l @r15, r2 + shld r2, r0 + shld r2, r1 + shld r2, r5 + + /* Clear unappliqed image data */ + and r6, r0 + and r6, r1 + and r6, r5 + + /* Blit the AND layer */ + mov.l @r4, r2 + not r0, r0 + mov.l @r7, r3 + and r0, r2 + and r0, r3 + + /* Blit the LIGHT and DARY layers, and return */ + or r1, r2 + or r5, r3 + mov.l r2, @r4 + rts + mov.l r3, @r7 + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/bopti-asm-gray-scsp.s b/src/render-fx/bopti-asm-gray-scsp.s deleted file mode 100644 index 1e567b6..0000000 --- a/src/render-fx/bopti-asm-gray-scsp.s +++ /dev/null @@ -1,152 +0,0 @@ - -.global _bopti_gasm_mono_scsp -.global _bopti_gasm_mono_alpha_scsp -.global _bopti_gasm_gray_scsp -.global _bopti_gasm_gray_alpha_scsp - -# REGISTER ALLOCATION: -# r0: OR layer -# r1: (temp) -# r2: light vram longword -# r3: dark vram longword -# -- -# r4: light pointer -# r5: layer pointer -# r6: mask -# r7: dark pointer -# -- -# @r15: -(x&31) - -_bopti_gasm_mono_scsp: - # Read layer longword and shift it - mov.l @r5, r0 - mov.l @r15, r1 - shld r1, r0 - - # Clear target VRAM and unwanted image data - and r6, r0 - mov.l @r4, r2 - not r6, r6 - mov.l @r7, r3 - and r6, r2 - and r6, r3 - - # Blit and return - or r0, r2 - or r0, r3 - mov.l r2, @r4 - rts - mov.l r3, @r7 - -# REGISTER ALLOCATION: -# r0: AND layer -# r1: (temp) -# r2: light vram longword -# r3: dark vram longword -# -- -# r4: light pointer -# r5: layer pointer, then OR layer -# r6: mask -# r7: dark pointer -# -- -# @r15: -(x&31) -_bopti_gasm_mono_alpha_scsp: - # Read layer longwords and shift them - mov.l @r5, r0 - mov.l @r15, r1 - mov.l @(4,r5), r5 - shld r1, r0 - shld r1, r5 - - # Clear any unwanted image data - and r6, r0 - mov.l @r4, r2 - and r6, r5 - mov.l @r7, r3 - - # Blit and return - not r0, r0 - and r0, r2 - and r0, r3 - or r5, r2 - or r5, r3 - mov.l r2, @r4 - rts - mov.l r3, @r7 - -# REGISTER ALLOCATION: -# r0: LIGHT layer -# r1: (temp) -# r2: light vram longword -# r3: dark vram longword -# -- -# r4: light pointer -# r5: layer pointer, then DARK layer -# r6: mask -# r7: dark pointer -# -- -# @r15: -(x&31) -_bopti_gasm_gray_scsp: - # Read layer longwords and shift them - mov.l @r5, r0 - mov.l @r15, r1 - mov.l @(4,r5), r5 - shld r1, r0 - shld r1, r5 - - # Clear target VRAM and unapplied image data - and r6, r0 - mov.l @r4, r2 - and r6, r5 - mov.l @r7, r3 - not r6, r6 - and r6, r2 - and r6, r3 - - # Blit and return - or r0, r2 - or r5, r3 - mov.l r2, @r4 - rts - mov.l r3, @r7 - -# REGISTER ALLOCATION: -# r0: AND layer -# r1: LIGHT layer -# r2: (temp), then light vram longword -# r3: dark vram longword -# -- -# r4: light pointer -# r5: layer pointer, then DARK layer -# r6: mask -# r7: dark pointer -# -- -# @r15: -(x&31) -_bopti_gasm_gray_alpha_scsp: - # Read layer longwords and shift them - mov.l @r5, r0 - mov.l @(4,r5), r1 - mov.l @(8,r5), r5 - mov.l @r15, r2 - shld r2, r0 - shld r2, r1 - shld r2, r5 - - # Clear unappliqed image data - and r6, r0 - and r6, r1 - and r6, r5 - - # Blit the AND layer - mov.l @r4, r2 - not r0, r0 - mov.l @r7, r3 - and r0, r2 - and r0, r3 - - # Blit the LIGHT and DARY layers, and return - or r1, r2 - or r5, r3 - mov.l r2, @r4 - rts - mov.l r3, @r7 diff --git a/src/render-fx/bopti-asm-gray.s b/src/render-fx/bopti-asm-gray.S similarity index 52% rename from src/render-fx/bopti-asm-gray.s rename to src/render-fx/bopti-asm-gray.S index 42fd204..248680e 100644 --- a/src/render-fx/bopti-asm-gray.s +++ b/src/render-fx/bopti-asm-gray.S @@ -1,40 +1,42 @@ +#include +#if GINT_RENDER_MONO .global _bopti_gasm_mono .global _bopti_gasm_mono_alpha .global _bopti_gasm_gray .global _bopti_gasm_gray_alpha -# REGISTER ALLOCATION -# r0: layer_1 (left) -# r1: layer_1 (right) -# r2: layer pointer and temp -# r3: mask pointer and temp -# -- -# r4: vram light (left) -# r5: vram light (right) -# r6: vram dark (left) -# r7: vram dark (right) -# -- -# @r15: layer pointer -# @(4,r15): mask pointer -# @(8,r15): -(x&31) -# @(12,r15): destination +/* REGISTER ALLOCATION + r0: layer_1 (left) + r1: layer_1 (right) + r2: layer pointer and temp + r3: mask pointer and temp + -- + r4: vram light (left) + r5: vram light (right) + r6: vram dark (left) + r7: vram dark (right) + -- + @r15: layer pointer + @(4,r15): mask pointer + @(8,r15): -(x&31) + @(12,r15): destination */ _bopti_gasm_mono: - # Read the data longword and update the layer address + /* Read the data longword and update the layer address */ mov.l @r15, r2 mov.l @r2, r3 mov.l @r3+, r0 mov.l r3, @r2 mov r0, r1 - # Shift it + /* Shift it */ mov.l @(8, r15), r2 shld r2, r0 add #32, r2 shld r2, r1 - # Clear target VRAM and unwanted image data + /* Clear target VRAM and unwanted image data */ mov.l @(4, r15), r3 mov.l @r3, r2 and r2, r0 @@ -47,7 +49,7 @@ _bopti_gasm_mono: and r2, r5 and r2, r7 - # Join everything and return + /* Join everything and return */ or r0, r4 or r1, r5 or r0, r6 @@ -59,30 +61,30 @@ _bopti_gasm_mono: rts mov.l r7, @(12, r2) -# REGISTER ALLOCATION -# r0: layer_1 (left) -# r1: layer_1 (right) -# r2: layer_2 (left) -# r3: layer_2 (right) -# -- -# r4: vram light (left) -# r5: vram light (right) -# r6: vram dark (left) -# r7: vram dark (right) -# -- -# r8: layer pointer and temp -# r9: mask pointer and temp -# -- -# @(8,r15): layer pointer -# @(12,r15): mask pointer -# @(16,r15): -(x&31) -# @(20,r15): destination +/* REGISTER ALLOCATION + r0: layer_1 (left) + r1: layer_1 (right) + r2: layer_2 (left) + r3: layer_2 (right) + -- + r4: vram light (left) + r5: vram light (right) + r6: vram dark (left) + r7: vram dark (right) + -- + r8: layer pointer and temp + r9: mask pointer and temp + -- + @(8,r15): layer pointer + @(12,r15): mask pointer + @(16,r15): -(x&31) + @(20,r15): destination */ _bopti_gasm_mono_alpha: mov.l r8, @-r15 mov.l r9, @-r15 - # Read data longwords + /* Read data longwords */ mov.l @(8, r15), r8 mov.l @r8, r9 mov.l @r9+, r0 @@ -91,7 +93,7 @@ _bopti_gasm_mono_alpha: mov r0, r1 mov r2, r3 - # Shift all layer data + /* Shift all layer data */ mov.l @(16, r15), r8 shld r8, r0 shld r8, r2 @@ -99,7 +101,7 @@ _bopti_gasm_mono_alpha: shld r8, r1 shld r8, r3 - # Apply masks on image data + /* Apply masks on image data */ mov.l @(12, r15), r9 mov.l @r9, r8 and r8, r0 @@ -108,7 +110,7 @@ _bopti_gasm_mono_alpha: and r8, r1 and r8, r3 - # Render and leave + /* Render and leave */ not r0, r0 not r1, r1 and r0, r4 @@ -129,30 +131,30 @@ _bopti_gasm_mono_alpha: rts mov.l @r15+, r8 -# REGISTER ALLOCATION -# r0: layer_1 (left) -# r1: layer_1 (right) -# r2: layer_2 (left) -# r3: layer_2 (right) -# -- -# r4: vram light (left) -# r5: vram light (right) -# r6: vram dark (left) -# r7: vram dark (right) -# -- -# r8: layer pointer (also +- x&31) -# r9: mask pointer (also layer) -# -- -# @(8,r15): layer pointer -# @(12,r15): mask pointer -# @(16,r15): -(x&31) -# @(20,r15): destination +/* REGISTER ALLOCATION + r0: layer_1 (left) + r1: layer_1 (right) + r2: layer_2 (left) + r3: layer_2 (right) + -- + r4: vram light (left) + r5: vram light (right) + r6: vram dark (left) + r7: vram dark (right) + -- + r8: layer pointer (also +- x&31) + r9: mask pointer (also layer) + -- + @(8,r15): layer pointer + @(12,r15): mask pointer + @(16,r15): -(x&31) + @(20,r15): destination */ _bopti_gasm_gray: mov.l r8, @-r15 mov.l r9, @-r15 - # Read data longwords and update the layer address pointer + /* Read data longwords and update the layer address pointer */ mov.l @(8, r15), r8 mov.l @r8, r9 mov.l @r9+, r0 @@ -161,7 +163,7 @@ _bopti_gasm_gray: mov r0, r1 mov r2, r3 - # Shift all layer data + /* Shift all layer data */ mov.l @(16, r15), r8 shld r8, r0 shld r8, r2 @@ -169,8 +171,8 @@ _bopti_gasm_gray: shld r8, r1 shld r8, r3 - # On the left side, clear the VRAM which is about to be rewritten using - # the left mask, and also clear unwanted image data + /* On the left side, clear the VRAM which is about to be rewritten using + the left mask, and also clear unwanted image data */ mov.l @(12, r15), r9 mov.l @r9, r8 and r8, r0 @@ -179,7 +181,7 @@ _bopti_gasm_gray: and r8, r4 and r8, r6 - # Same on the right side + /* Same on the right side */ mov.l @(4, r9), r8 and r8, r1 and r8, r3 @@ -187,7 +189,7 @@ _bopti_gasm_gray: and r8, r5 and r8, r7 - # Render these together and store the result + /* Render these together and store the result */ or r0, r4 or r1, r5 or r2, r6 @@ -203,26 +205,26 @@ _bopti_gasm_gray: mov.l @r15+, r8 -# REGISTER ALLOCATION -# r0: layer_1 (left) -# r1: layer_1 (right) -# r2: layer_2 (left) -# r3: layer_2 (right) -# -- -# r4: vram light (left) -# r5: vram light (right) -# r6: vram dark (left) -# r7: vram dark (right) -# -- -# r8: layer pointer (also +- x&31) -# r9: mask pointer (also layer) -# r10: layer_3 (left) -# r11: layer_3 (right) -# -- -# @(16,r15): layer pointer -# @(20,r15): mask pointer -# @(24,r15): -(x&31) -# @(28,r15): destination +/* REGISTER ALLOCATION + r0: layer_1 (left) + r1: layer_1 (right) + r2: layer_2 (left) + r3: layer_2 (right) + -- + r4: vram light (left) + r5: vram light (right) + r6: vram dark (left) + r7: vram dark (right) + -- + r8: layer pointer (also +- x&31) + r9: mask pointer (also layer) + r10: layer_3 (left) + r11: layer_3 (right) + -- + @(16,r15): layer pointer + @(20,r15): mask pointer + @(24,r15): -(x&31) + @(28,r15): destination */ .align 4 _bopti_gasm_gray_alpha: @@ -231,7 +233,7 @@ _bopti_gasm_gray_alpha: mov.l r10, @-r15 mov.l r11, @-r15 - # Load layer data + /* Load layer data */ mov.l @(16, r15), r8 mov.l @r8, r9 mov.l @r9+, r0 @@ -242,7 +244,7 @@ _bopti_gasm_gray_alpha: mov.l r9, @r8 mov r10, r11 - # Shift layer data + /* Shift layer data */ mov.l @(24, r15), r8 shld r8, r0 shld r8, r2 @@ -252,7 +254,7 @@ _bopti_gasm_gray_alpha: shld r8, r3 shld r8, r11 - # Clear unwanted layer bits + /* Clear unwanted layer bits */ mov.l @(20, r15), r9 mov.l @r9, r8 and r8, r0 @@ -263,7 +265,7 @@ _bopti_gasm_gray_alpha: and r8, r3 and r8, r11 - # Blit everything + /* Blit everything */ not r0, r0 and r0, r4 and r0, r6 @@ -275,7 +277,7 @@ _bopti_gasm_gray_alpha: or r10, r6 or r11, r7 - # Store results and leave + /* Store results and leave */ mov.l @(28, r15), r8 mov.l r4, @r8 mov.l r5, @(4, r8) @@ -286,3 +288,5 @@ _bopti_gasm_gray_alpha: mov.l @r15+, r9 rts mov.l @r15+, r8 + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/bopti-asm-mono-scsp.S b/src/render-fx/bopti-asm-mono-scsp.S new file mode 100644 index 0000000..5604ef3 --- /dev/null +++ b/src/render-fx/bopti-asm-mono-scsp.S @@ -0,0 +1,64 @@ +#include +#if GINT_RENDER_MONO + +.global _bopti_asm_mono_scsp +.global _bopti_asm_mono_alpha_scsp + +/* REGISTER ALLOCATION: + r0: layer + r1: - + r2: (temp) + r3: vram longword + -- + r4: vram pointer + r5: layer pointer + r6: mask + r7: -(x&31) */ + +_bopti_asm_mono_scsp: + /* Read layer longword and shift it */ + mov.l @r5, r0 + shld r7, r0 + + /* Clear the target VRAM and unwanted image data */ + mov.l @r4, r3 + and r6, r0 + not r6, r6 + and r6, r3 + + /* Blit and return */ + or r0, r3 + rts + mov.l r3, @r4 + +/* REGISTER ALLOCATION: + r0: AND layer + r1: OR layer + r2: (temp) + r3: vram longword + -- + r4: vram pointer + r5: layer pointer + r6: mask + r7: -(x&31) */ + +_bopti_asm_mono_alpha_scsp: + /* Read layer longwords and shift them */ + mov.l @r5, r0 + mov.l @(4,r5), r1 + shld r7, r0 + shld r7, r1 + + /* Apply masks to clear layer data */ + and r6, r0 + and r6, r1 + + /* Blit to VRAM */ + mov.l @r4, r3 + not r0, r0 + and r0, r3 + or r1, r3 + rts + mov.l r3, @r4 + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/bopti-asm-mono-scsp.s b/src/render-fx/bopti-asm-mono-scsp.s deleted file mode 100644 index 0d123c1..0000000 --- a/src/render-fx/bopti-asm-mono-scsp.s +++ /dev/null @@ -1,60 +0,0 @@ - -.global _bopti_asm_mono_scsp -.global _bopti_asm_mono_alpha_scsp - -# REGISTER ALLOCATION: -# r0: layer -# r1: - -# r2: (temp) -# r3: vram longword -# -- -# r4: vram pointer -# r5: layer pointer -# r6: mask -# r7: -(x&31) - -_bopti_asm_mono_scsp: - # Read layer longword and shift it - mov.l @r5, r0 - shld r7, r0 - - # Clear the target VRAM and unwanted image data - mov.l @r4, r3 - and r6, r0 - not r6, r6 - and r6, r3 - - # Blit and return - or r0, r3 - rts - mov.l r3, @r4 - -# REGISTER ALLOCATION: -# r0: AND layer -# r1: OR layer -# r2: (temp) -# r3: vram longword -# -- -# r4: vram pointer -# r5: layer pointer -# r6: mask -# r7: -(x&31) - -_bopti_asm_mono_alpha_scsp: - # Read layer longwords and shift them - mov.l @r5, r0 - mov.l @(4,r5), r1 - shld r7, r0 - shld r7, r1 - - # Apply masks to clear layer data - and r6, r0 - and r6, r1 - - # Blit to VRAM - mov.l @r4, r3 - not r0, r0 - and r0, r3 - or r1, r3 - rts - mov.l r3, @r4 diff --git a/src/render-fx/bopti-asm.S b/src/render-fx/bopti-asm.S new file mode 100644 index 0000000..a451b0f --- /dev/null +++ b/src/render-fx/bopti-asm.S @@ -0,0 +1,97 @@ +#include +#if GINT_RENDER_MONO + +.global _bopti_asm_mono +.global _bopti_asm_mono_alpha + +/* REGISTER ALLOCATION: + r0: layer (left) + r1: layer (right) + r2: (temp) + r3: - + -- + r4: vram (left) + r5: vram (right) + r6: layer pointer; f(x&31) + r7: mask pointer + -- + @r15: -(x&31) */ + +_bopti_asm_mono: + /* Read data longword and update the layer address pointer */ + mov.l @r6, r2 + mov.l @r2+, r0 + mov.l r2, @r6 + mov r0, r1 + + /* Shift the layer data */ + mov.l @r15, r6 + shld r6, r0 + add #32, r6 + shld r6, r1 + + /* Get the masks and clear the target VRAM area and unwanted image data */ + mov.l @r7, r2 + and r2, r0 + not r2, r2 + and r2, r4 + mov.l @(4, r7), r2 + and r2, r1 + not r2, r2 + and r2, r5 + + /* Do the drawing by joining the two */ + or r4, r0 + rts + or r5, r1 + +/* REGISTER ALLOCATION + r0: layer_1 (left) + r1: layer_1 (right) + r2: layer_2 (left) + r3: layer_2 (right) + -- + r4: vram (left) + r5: vram (right) + r6: layer pointer; f(x&31); mask (left); mask (right) + r7: mask pointer + -- + @r15: -(x&31) */ + +_bopti_asm_mono_alpha: + /* Read data longwords and update the layer address pointer */ + mov.l @r6, r2 + mov.l @r2+, r0 + mov.l @r2+, r3 + mov.l r2, @r6 + mov r0, r1 + mov r3, r2 + + /* Shift all layer data */ + mov.l @r15, r6 + shld r6, r0 + shld r6, r2 + add #32, r6 + shld r6, r1 + shld r6, r3 + + /* Apply the masks on the layer data */ + mov.l @r7, r6 + and r6, r0 + and r6, r2 + mov.l @(4, r7), r6 + and r6, r1 + and r6, r3 + + /* Blit the clear on the VRAM */ + not r0, r0 + and r4, r0 + not r1, r1 + and r5, r1 + + /* Blit the write on the VRAM */ + or r2, r0 + rts + or r3, r1 + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/bopti-asm.h b/src/render-fx/bopti-asm.h deleted file mode 100644 index a5f9dbb..0000000 --- a/src/render-fx/bopti-asm.h +++ /dev/null @@ -1,118 +0,0 @@ -//--- -// gint:render-fx:bopti-asm - Assembler drawing routines for bopti -//--- - -#ifndef GINT_RENDERFX_BOPTIASM -#define GINT_RENDERFX_BOPTIASM - -#include -#include - -/* pair_t: A pair of consecutive VRAM longwords */ -typedef struct { - uint32_t l; - uint32_t r; -} pair_t; - -/* quadr_t: Two pairs for light and gray VRAMs */ -typedef struct { - uint32_t l1; - uint32_t r1; - uint32_t l2; - uint32_t r2; -} quadr_t; - -/* Signature of mono rendering functions */ -typedef pair_t asm_mono_t(pair_t p, void **layer, uint32_t *masks, int x); -/* Signature of gray rendering functions */ -typedef void asm_gray_t(quadr_t q, void **layer, uint32_t *masks, int x, - quadr_t *ret); -/* Signature of mono single-column single-position rendering functions */ -typedef void asm_mono_scsp_t(uint32_t *vram, uint32_t const *layer, - uint32_t mask, int x); -/* Signature of gray single-column single-position rendering functions */ -typedef void asm_gray_scsp_t(uint32_t *v1, uint32_t const *layer, - uint32_t mask, uint32_t *v2, int x); - -/* Type of any rendering function */ -typedef union { - void *gen; - asm_mono_t *asm_mono; - asm_gray_t *asm_gray; - asm_mono_scsp_t *asm_mono_scsp; - asm_gray_scsp_t *asm_gray_scsp; -} bopti_asm_t; - -/* Each of the following rendering functions: - 1. Takes VRAM data for two longword positions of the screen. - 2. Reads data for one longword position of the image from *layer. This - consists in n longwords where n is the number of layers in the image. - 3. Increments *layer by 4*n. - 4. Shifts the image data and apply it to the VRAM positions in accordance - with the two masks given in the masks argument. */ - -/* bopti_asm_mono(): Rendering function for the "mono" profile */ -extern asm_mono_t bopti_asm_mono; -/* bopti_asm_mono_alpha(): Rendering function for the "mono alpha" profile */ -extern asm_mono_t bopti_asm_mono_alpha; - -/* bopti_gasm_mono(): "mono" profile on gray VRAMs */ -extern asm_gray_t bopti_gasm_mono; -/* bopti_gasm_mono_alpha(): "mono_alpha" profile on gray VRAMs */ -extern asm_gray_t bopti_gasm_mono_alpha; -/* bopti_asm_gray(): Rendering function for the "gray" profile */ -extern asm_gray_t bopti_gasm_gray; -/* bpoti_asm_gray_alpha(): Rendering function for the "gray_alpha" profile */ -extern asm_gray_t bopti_gasm_gray_alpha; - -/* Each of the following rendering functions: - 1. Takes VRAM data from one longword position of the screen. - 2. Reads data from one longword position of the image from layer. - 3. Shifts the image data and applies it to the VRAM position. - None update the layer pointer. */ - -/* bopti_asm_mono_scsp(): SCSP "mono" profile */ -extern asm_mono_scsp_t bopti_asm_mono_scsp; -/* bopti_asm_mono_alpha_scsp(): SCSP "mono_alpha" profile */ -extern asm_mono_scsp_t bopti_asm_mono_alpha_scsp; - -/* bopti_gasm_mono_scsp(): SCSP "mono" profile on gray VRAMs */ -extern asm_gray_scsp_t bopti_gasm_mono_scsp; -/* bopti_gasm_mono_scsp_alpha(): SCSP "mono_alpha" profile on gray VRAMs */ -extern asm_gray_scsp_t bopti_gasm_mono_alpha_scsp; -/* bopti_asm_gray_scsp(): SCSP "gray" profile */ -extern asm_gray_scsp_t bopti_gasm_gray_scsp; -/* bpoti_asm_gray_alpha_scsp(): SCSP "gray_alpha" profile */ -extern asm_gray_scsp_t bopti_gasm_gray_alpha_scsp; - -//--- -// Renderer's data structures -//--- - -/* struct rbox: A rendering box (target coordinates and source rectangle) - Meaning of fields vary during the rendering process! */ -struct rbox -{ - /* General renderer: - On-screen location of the leftmost pixel of the leftmost rendered - column (this particular pixel might not be drawn but is of - importance in the positioning process) - SCSP renderer: - Shift value used to align columns with positions */ - int x; - /* On-screen location of top-left corner; the (x,y) of dsubimage() */ - int visual_x, y; - /* Width of rendered sub-image */ - int width; - /* Before bopti_render{_scsp}(): - Left-coordinate of the source box (included, in pixels) - In bopti_render{_scsp}(): - Left-coordinate of the source box (included, in columns) */ - int left; - /* Number of columns used in the source box */ - int columns; - /* Vertical bounds of the box in the image (inc-excluded, in pixels) */ - int top, height; -}; - -#endif /* GINT_RENDERFX_BOPTIASM */ diff --git a/src/render-fx/bopti-asm.s b/src/render-fx/bopti-asm.s deleted file mode 100644 index 3c1de79..0000000 --- a/src/render-fx/bopti-asm.s +++ /dev/null @@ -1,93 +0,0 @@ - -.global _bopti_asm_mono -.global _bopti_asm_mono_alpha - -# REGISTER ALLOCATION: -# r0: layer (left) -# r1: layer (right) -# r2: (temp) -# r3: - -# -- -# r4: vram (left) -# r5: vram (right) -# r6: layer pointer; f(x&31) -# r7: mask pointer -# -- -# @r15: -(x&31) - -_bopti_asm_mono: - # Read data longword and update the layer address pointer - mov.l @r6, r2 - mov.l @r2+, r0 - mov.l r2, @r6 - mov r0, r1 - - # Shift the layer data - mov.l @r15, r6 - shld r6, r0 - add #32, r6 - shld r6, r1 - - # Get the masks and clear the target VRAM area and unwanted image data - mov.l @r7, r2 - and r2, r0 - not r2, r2 - and r2, r4 - mov.l @(4, r7), r2 - and r2, r1 - not r2, r2 - and r2, r5 - - # Do the drawing by joining the two - or r4, r0 - rts - or r5, r1 - -# REGISTER ALLOCATION -# r0: layer_1 (left) -# r1: layer_1 (right) -# r2: layer_2 (left) -# r3: layer_2 (right) -# -- -# r4: vram (left) -# r5: vram (right) -# r6: layer pointer; f(x&31); mask (left); mask (right) -# r7: mask pointer -# -- -# @r15: -(x&31) - -_bopti_asm_mono_alpha: - # Read data longwords and update the layer address pointer - mov.l @r6, r2 - mov.l @r2+, r0 - mov.l @r2+, r3 - mov.l r2, @r6 - mov r0, r1 - mov r3, r2 - - # Shift all layer data - mov.l @r15, r6 - shld r6, r0 - shld r6, r2 - add #32, r6 - shld r6, r1 - shld r6, r3 - - # Apply the masks on the layer data - mov.l @r7, r6 - and r6, r0 - and r6, r2 - mov.l @(4, r7), r6 - and r6, r1 - and r6, r3 - - # Blit the clear on the VRAM - not r0, r0 - and r4, r0 - not r1, r1 - and r5, r1 - - # Blit the write on the VRAM - or r2, r0 - rts - or r3, r1 diff --git a/src/render-fx/bopti.c b/src/render-fx/bopti.c index 51a7f3d..230f225 100644 --- a/src/render-fx/bopti.c +++ b/src/render-fx/bopti.c @@ -2,7 +2,9 @@ #include #include #include "render-fx.h" -#include "bopti-asm.h" + +#include +#if GINT_RENDER_MONO #pragma GCC optimize("O3") @@ -305,3 +307,5 @@ int bopti_clip(bopti_image_t const *img, struct rbox *r) /* Return non-zero if the result is empty */ return (width <= 0 || height <= 0); } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/dclear.c b/src/render-fx/dclear.c index 3db7e80..ec73b70 100644 --- a/src/render-fx/dclear.c +++ b/src/render-fx/dclear.c @@ -1,6 +1,9 @@ #include #include "../render/render.h" +#include +#if GINT_RENDER_MONO + /* dclear() - fill the screen with a single color */ void dclear(color_t color) { @@ -46,3 +49,5 @@ void dclear(color_t color) *--index = fill; } } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/dgetpixel.c b/src/render-fx/dgetpixel.c index 0d27be6..224d51c 100644 --- a/src/render-fx/dgetpixel.c +++ b/src/render-fx/dgetpixel.c @@ -2,6 +2,9 @@ #include #include "../render/render.h" +#include +#if GINT_RENDER_MONO + int dgetpixel(int x, int y) { if(x < dwindow.left || x >= dwindow.right) return -1; @@ -14,3 +17,5 @@ int dgetpixel(int x, int y) return (gint_vram[offset] & mask) ? C_BLACK : C_WHITE; } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/dpixel.c b/src/render-fx/dpixel.c index 6b9cd0b..8f054d9 100644 --- a/src/render-fx/dpixel.c +++ b/src/render-fx/dpixel.c @@ -2,7 +2,9 @@ #include #include "../render/render.h" -/* dpixel() - change a pixel's color */ +#include +#if GINT_RENDER_MONO + void dpixel(int x, int y, int color) { if(x < dwindow.left || x >= dwindow.right) return; @@ -26,3 +28,5 @@ void dpixel(int x, int y, int color) *lword ^= mask; } } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/drect.c b/src/render-fx/drect.c index 7eb9f86..e413112 100644 --- a/src/render-fx/drect.c +++ b/src/render-fx/drect.c @@ -3,6 +3,9 @@ #include "../render/render.h" #include "render-fx.h" +#include +#if GINT_RENDER_MONO + void drect(int x1, int y1, int x2, int y2, int color) { if(x1 > x2) swap(x1, x2); @@ -48,3 +51,5 @@ void drect(int x1, int y1, int x2, int y2, int color) *--lword ^= m[0]; } } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/dsubimage.c b/src/render-fx/dsubimage.c index cbbd788..b7cb078 100644 --- a/src/render-fx/dsubimage.c +++ b/src/render-fx/dsubimage.c @@ -1,7 +1,9 @@ #include #include "../render/render.h" #include "render-fx.h" -#include "bopti-asm.h" + +#include +#if GINT_RENDER_MONO #pragma GCC optimize("O3") @@ -43,3 +45,5 @@ void dsubimage(int x, int y, bopti_image_t const *img, int left, int top, bopti_render(img, &r, gint_vram, NULL); } } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/dupdate.c b/src/render-fx/dupdate.c index 151a1a7..4eda33e 100644 --- a/src/render-fx/dupdate.c +++ b/src/render-fx/dupdate.c @@ -2,6 +2,9 @@ #include #include "../render/render.h" +#include +#if GINT_RENDER_MONO + /* Standard video RAM for fx9860g is 1 bit per pixel */ GSECTION(".bss") GALIGNED(32) static uint32_t fx_vram[256]; @@ -32,3 +35,5 @@ void dupdate(void) } __attribute__((alias("dupdate"))) void _WEAK_dupdate(void); + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/gint_dline.c b/src/render-fx/gint_dline.c index b087ebe..e8cef20 100644 --- a/src/render-fx/gint_dline.c +++ b/src/render-fx/gint_dline.c @@ -2,6 +2,9 @@ #include #include "render-fx.h" +#include +#if GINT_RENDER_MONO + /* gint_dhline(): Optimized horizontal line using a rectangle mask */ void gint_dhline(int x1, int x2, int y, int color) { @@ -64,3 +67,5 @@ void gint_dvline(int y1, int y2, int x, int color) while(lword > base) lword -= 4, *lword ^= mask; } } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/masks.c b/src/render-fx/masks.c index 864f8c4..8b4ed25 100644 --- a/src/render-fx/masks.c +++ b/src/render-fx/masks.c @@ -1,6 +1,9 @@ #include #include "render-fx.h" +#include +#if GINT_RENDER_MONO + void masks(int x1, int x2, uint32_t *masks) { x1 = max(x1, dwindow.left); @@ -22,3 +25,5 @@ void masks(int x1, int x2, uint32_t *masks) masks[l1] &= (0xffffffffu >> x1); masks[l2] &= (0xffffffffu << x2); } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/render-fx.h b/src/render-fx/render-fx.h index 2e272aa..fddd48a 100644 --- a/src/render-fx/render-fx.h +++ b/src/render-fx/render-fx.h @@ -6,8 +6,13 @@ #define RENDER_FX #include +#include #include -#include "bopti-asm.h" +#include + +#if GINT_RENDER_MONO + +struct rbox; /* masks(): Compute the vram masks for a given rectangle @@ -50,10 +55,142 @@ void bopti_render_scsp(bopti_image_t const *img, struct rbox *rbox, uint32_t *v1, uint32_t *v2); //--- -// Gray rendering functions for dmode +// Image rendering //--- -struct rbox; +/* pair_t: A pair of consecutive VRAM longwords */ +typedef struct { + uint32_t l; + uint32_t r; +} pair_t; + +/* quadr_t: Two pairs for light and gray VRAMs */ +typedef struct { + uint32_t l1; + uint32_t r1; + uint32_t l2; + uint32_t r2; +} quadr_t; + +/* Signature of mono rendering functions */ +typedef pair_t asm_mono_t(pair_t p, void **layer, uint32_t *masks, int x); +/* Signature of gray rendering functions */ +typedef void asm_gray_t(quadr_t q, void **layer, uint32_t *masks, int x, + quadr_t *ret); +/* Signature of mono single-column single-position rendering functions */ +typedef void asm_mono_scsp_t(uint32_t *vram, uint32_t const *layer, + uint32_t mask, int x); +/* Signature of gray single-column single-position rendering functions */ +typedef void asm_gray_scsp_t(uint32_t *v1, uint32_t const *layer, + uint32_t mask, uint32_t *v2, int x); + +/* Type of any rendering function */ +typedef union { + void *gen; + asm_mono_t *asm_mono; + asm_gray_t *asm_gray; + asm_mono_scsp_t *asm_mono_scsp; + asm_gray_scsp_t *asm_gray_scsp; +} bopti_asm_t; + +/* Each of the following rendering functions: + 1. Takes VRAM data for two longword positions of the screen. + 2. Reads data for one longword position of the image from *layer. This + consists in n longwords where n is the number of layers in the image. + 3. Increments *layer by 4*n. + 4. Shifts the image data and apply it to the VRAM positions in accordance + with the two masks given in the masks argument. */ + +/* bopti_asm_mono(): Rendering function for the "mono" profile */ +extern asm_mono_t bopti_asm_mono; +/* bopti_asm_mono_alpha(): Rendering function for the "mono alpha" profile */ +extern asm_mono_t bopti_asm_mono_alpha; + +/* bopti_gasm_mono(): "mono" profile on gray VRAMs */ +extern asm_gray_t bopti_gasm_mono; +/* bopti_gasm_mono_alpha(): "mono_alpha" profile on gray VRAMs */ +extern asm_gray_t bopti_gasm_mono_alpha; +/* bopti_asm_gray(): Rendering function for the "gray" profile */ +extern asm_gray_t bopti_gasm_gray; +/* bpoti_asm_gray_alpha(): Rendering function for the "gray_alpha" profile */ +extern asm_gray_t bopti_gasm_gray_alpha; + +/* Each of the following rendering functions: + 1. Takes VRAM data from one longword position of the screen. + 2. Reads data from one longword position of the image from layer. + 3. Shifts the image data and applies it to the VRAM position. + None update the layer pointer. */ + +/* bopti_asm_mono_scsp(): SCSP "mono" profile */ +extern asm_mono_scsp_t bopti_asm_mono_scsp; +/* bopti_asm_mono_alpha_scsp(): SCSP "mono_alpha" profile */ +extern asm_mono_scsp_t bopti_asm_mono_alpha_scsp; + +/* bopti_gasm_mono_scsp(): SCSP "mono" profile on gray VRAMs */ +extern asm_gray_scsp_t bopti_gasm_mono_scsp; +/* bopti_gasm_mono_scsp_alpha(): SCSP "mono_alpha" profile on gray VRAMs */ +extern asm_gray_scsp_t bopti_gasm_mono_alpha_scsp; +/* bopti_asm_gray_scsp(): SCSP "gray" profile */ +extern asm_gray_scsp_t bopti_gasm_gray_scsp; +/* bpoti_asm_gray_alpha_scsp(): SCSP "gray_alpha" profile */ +extern asm_gray_scsp_t bopti_gasm_gray_alpha_scsp; + +/* struct rbox: A rendering box (target coordinates and source rectangle) + Meaning of fields vary during the rendering process! */ +struct rbox +{ + /* General renderer: + On-screen location of the leftmost pixel of the leftmost rendered + column (this particular pixel might not be drawn but is of + importance in the positioning process) + SCSP renderer: + Shift value used to align columns with positions */ + int x; + /* On-screen location of top-left corner; the (x,y) of dsubimage() */ + int visual_x, y; + /* Width of rendered sub-image */ + int width; + /* Before bopti_render{_scsp}(): + Left-coordinate of the source box (included, in pixels) + In bopti_render{_scsp}(): + Left-coordinate of the source box (included, in columns) */ + int left; + /* Number of columns used in the source box */ + int columns; + /* Vertical bounds of the box in the image (inc-excluded, in pixels) */ + int top, height; +}; + +//--- +// Text rendering +//--- + +/* Signature of text rendering functions (which do not render text but really + just blend a column of operators onto the VRAM */ +typedef void asm_text_t(uint32_t *v1, uint32_t *v2, uint32_t *op, int height); + +/* One rendering function per color */ +extern asm_text_t *topti_asm_text[8]; + +/* topti_render(): Render a string on the VRAM + Combines glyph data onto VRAM operands and blits them efficiently onto the + VRAM. To write a single character, use a 2-byte string with a NUL. + + @x @y Target position on VRAM + @str Text source + @f Font + @asm_fg Assembler function for text rendering + @asm_bg Assembler function for background rendering + @v1 Monochrome VRAM or light gray VRAM + @v2 Monochrome or dark gray VRAM + @size Maximum number of characters to render */ +void topti_render(int x, int y, char const *str, font_t const *f, + asm_text_t *asm_fg, asm_text_t *asm_bg, uint32_t *v1, uint32_t *v2, + int size); + +//--- +// Gray rendering functions for dmode +//--- /* These are the corresponding gray rendering functions */ int gupdate(void); @@ -67,4 +204,6 @@ void gtext_opt(int x, int y, int fg, int bg, int halign, int valign, char const *str, int size); void gsubimage(bopti_image_t const *image, struct rbox *r, int flags); +#endif /* GINT_RENDER_MONO */ + #endif /* RENDER_FX */ diff --git a/src/render-fx/topti-asm.s b/src/render-fx/topti-asm.S similarity index 65% rename from src/render-fx/topti-asm.s rename to src/render-fx/topti-asm.S index fa89079..42a2385 100644 --- a/src/render-fx/topti-asm.s +++ b/src/render-fx/topti-asm.S @@ -1,24 +1,26 @@ +#include +#if GINT_RENDER_MONO .global _topti_asm_text -# REGISTER ALLOCATION: -# r0: x or ~x -# r1: light (except lighten/darken: swapped at some point with dark) -# r2: dark (except lighten/darken: swapped at some point with light) -# r3: (tmp) -# r4: vram (mono or light) -# r5: vram (mono or dark) -# r6: operators -# r7: number of rows (r7>0, otherwise the font is clearly ill-formed) +/* REGISTER ALLOCATION: + r0: x or ~x + r1: light (except lighten/darken: swapped at some point with dark) + r2: dark (except lighten/darken: swapped at some point with light) + r3: (tmp) + r4: vram (mono or light) + r5: vram (mono or dark) + r6: operators + r7: number of rows (r7>0, otherwise the font is clearly ill-formed) -# Mind that there are pipeline optimization efforts in this file: -# * Doing memory accesses on 4-aligned instructions to avoid contention between -# IF and MA (1 cycle); -# * Avoid using an operand just after it is fetched from memory because of the -# RAW dependency on the destination register (1 cycle); -# * Using delayed slot jumps bf.s rather than bf (1 cycle); -# * Executing the dt early to avoid waiting for its WB slot. Best if >=2 -# instructions are between dt and bt.s. (not sure if it's needed). + Mind that there are pipeline optimization efforts in this file: + * Doing memory accesses on 4-aligned instructions to avoid contention + between IF and MA (1 cycle); + * Avoid using an operand just after it is fetched from memory because of the + RAW dependency on the destination register (1 cycle); + * Using delayed slot jumps bf.s rather than bf (1 cycle); + * Executing the dt early to avoid waiting for its WB slot. Best if >=2 + instructions are between dt and bt.s. (not sure if it's needed). */ .align 4 _topti_asm_white: @@ -171,7 +173,7 @@ _topti_asm_darken: rts nop -# Export a table with these functions +/* Export a table with these functions */ .align 4 _topti_asm_text: @@ -183,3 +185,5 @@ _topti_asm_text: .long _topti_asm_invert .long _topti_asm_lighten .long _topti_asm_darken + +#endif /* GINT_RENDER_MONO */ diff --git a/src/render-fx/topti-asm.h b/src/render-fx/topti-asm.h deleted file mode 100644 index 1941faf..0000000 --- a/src/render-fx/topti-asm.h +++ /dev/null @@ -1,31 +0,0 @@ -//--- -// gint:render-fx:topti-asm - Assembler drawing routines for topti -//--- - -#ifndef GINT_RENDERFX_TOPTIASM -#define GINT_RENDERFX_TOPTIASM - -/* Signature of text rendering functions (which do not render text but really - just blend a column of operators onto the VRAM */ -typedef void asm_text_t(uint32_t *v1, uint32_t *v2, uint32_t *op, int height); - -/* One rendering function per color */ -extern asm_text_t *topti_asm_text[8]; - -/* topti_render(): Render a string on the VRAM - Combines glyph data onto VRAM operands and blits them efficiently onto the - VRAM. To write a single character, use a 2-byte string with a NUL. - - @x @y Target position on VRAM - @str Text source - @f Font - @asm_fg Assembler function for text rendering - @asm_bg Assembler function for background rendering - @v1 Monochrome VRAM or light gray VRAM - @v2 Monochrome or dark gray VRAM - @size Maximum number of characters to render */ -void topti_render(int x, int y, char const *str, font_t const *f, - asm_text_t *asm_fg, asm_text_t *asm_bg, uint32_t *v1, uint32_t *v2, - int size); - -#endif /* GINT_RENDERFX_TOPTIASM */ diff --git a/src/render-fx/topti.c b/src/render-fx/topti.c index af09bdc..f5ffd2c 100644 --- a/src/render-fx/topti.c +++ b/src/render-fx/topti.c @@ -5,7 +5,9 @@ #include "../render/render.h" #include "render-fx.h" -#include "topti-asm.h" + +#include +#if GINT_RENDER_MONO #undef dtext_opt @@ -219,3 +221,5 @@ void dtext_opt(int x, int y, int fg, int bg, int halign, int valign, topti_render(x, y, str, topti_font, topti_asm_text[fg], topti_asm_text[bg], gint_vram, gint_vram, size); } + +#endif /* GINT_RENDER_MONO */ diff --git a/src/t6k11/t6k11.c b/src/t6k11/t6k11.c index 516bbd1..bdf62c4 100644 --- a/src/t6k11/t6k11.c +++ b/src/t6k11/t6k11.c @@ -9,6 +9,9 @@ #include #include #include +#include + +#if GINT_HW_FX //--- // Device specification sheet @@ -226,3 +229,5 @@ gint_driver_t drv_t6k11 = { .state_size = sizeof(t6k11_state_t), }; GINT_DECLARE_DRIVER(26, drv_t6k11); + +#endif /* GINT_HW_FX */ diff --git a/src/usb/classes/ff-bulk-gray.c b/src/usb/classes/ff-bulk-gray.c index aab01e8..bf15962 100644 --- a/src/usb/classes/ff-bulk-gray.c +++ b/src/usb/classes/ff-bulk-gray.c @@ -1,9 +1,10 @@ -#ifdef FX9860G - #include #include #include #include +#include + +#if GINT_RENDER_MONO static void capture_vram_gray(GUNUSED bool onscreen, char const *type) { @@ -39,4 +40,4 @@ void usb_fxlink_videocapture_gray(bool onscreen) capture_vram_gray(onscreen, "video"); } -#endif /* FX9860G */ +#endif /* GINT_RENDER_MONO */