You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Update S2DEX Text Engine to latest version; fix build issues (#532)
Now its just part of HackerSM64 entirely, and HackerSM64 will be the source of all changes (as long as said changes can reasonably apply to homebrew games)
This commit is contained in:
15
Makefile
15
Makefile
@@ -124,6 +124,12 @@ endif
|
||||
TEXT_ENGINE := none
|
||||
$(eval $(call validate-option,TEXT_ENGINE,none s2dex_text_engine))
|
||||
|
||||
ifeq ($(TEXT_ENGINE), s2dex_text_engine)
|
||||
DEFINES += S2DEX_GBI_2=1 S2DEX_TEXT_ENGINE=1
|
||||
SRC_DIRS += src/s2d_engine
|
||||
endif
|
||||
# add more text engines here
|
||||
|
||||
#==============================================================================#
|
||||
# Optimization flags #
|
||||
#==============================================================================#
|
||||
@@ -415,14 +421,6 @@ endif
|
||||
|
||||
LIBRARIES := nustd hvqm2 z goddard
|
||||
|
||||
# Text engine
|
||||
ifeq ($(TEXT_ENGINE), s2dex_text_engine)
|
||||
DEFINES += S2DEX_GBI_2=1 S2DEX_TEXT_ENGINE=1
|
||||
LIBRARIES += s2d_engine
|
||||
DUMMY != $(MAKE) -C src/s2d_engine COPY_DIR=$(shell pwd)/lib/ CROSS=$(CROSS)
|
||||
endif
|
||||
# add more text engines here
|
||||
|
||||
LINK_LIBRARIES = $(foreach i,$(LIBRARIES),-l$(i))
|
||||
|
||||
export LD_LIBRARY_PATH=./tools
|
||||
@@ -560,7 +558,6 @@ all: $(ROM)
|
||||
|
||||
clean:
|
||||
$(RM) -r $(BUILD_DIR_BASE)
|
||||
make -C src/s2d_engine clean
|
||||
|
||||
distclean: clean
|
||||
$(PYTHON) extract_assets.py --clean
|
||||
|
||||
@@ -27,6 +27,6 @@
|
||||
#include "sparkle_animation/model.inc.c"
|
||||
|
||||
#ifdef S2DEX_TEXT_ENGINE
|
||||
#include "src/s2d_engine/config.h"
|
||||
#include "src/s2d_engine/s2d_config.h"
|
||||
#include FONT_C_FILE
|
||||
#endif
|
||||
|
||||
8
sm64.ld
8
sm64.ld
@@ -166,7 +166,7 @@ SECTIONS
|
||||
BUILD_DIR/src/usb*.o(.text*);
|
||||
BUILD_DIR/src/audio*.o(.text*);
|
||||
#ifdef S2DEX_TEXT_ENGINE
|
||||
lib/libs2d_engine.a:*(.text*);
|
||||
BUILD_DIR/src/s2d_engine*.o(.text*);
|
||||
#endif
|
||||
*/ULTRALIB.a:*.o(.text*);
|
||||
*/libnustd.a:*.o(.text*);
|
||||
@@ -188,7 +188,7 @@ SECTIONS
|
||||
BUILD_DIR/src/boot*.o(.*data*);
|
||||
BUILD_DIR/src/audio*.o(.*data*);
|
||||
#ifdef S2DEX_TEXT_ENGINE
|
||||
lib/libs2d_engine.a:*(.*data*);
|
||||
BUILD_DIR/src/s2d_engine*.o(.*data*);
|
||||
#endif
|
||||
*/ULTRALIB.a:*.o(.data*);
|
||||
*/libhvqm2.a:*.o(.data*);
|
||||
@@ -204,7 +204,7 @@ SECTIONS
|
||||
BUILD_DIR/src/usb*.o(.rodata*);
|
||||
BUILD_DIR/src/audio*.o(.rodata*);
|
||||
#ifdef S2DEX_TEXT_ENGINE
|
||||
lib/libs2d_engine.a:*(.rodata*);
|
||||
BUILD_DIR/src/s2d_engine*.o(.rodata*);
|
||||
#endif
|
||||
*/ULTRALIB.a:*.o(.rodata*);
|
||||
*/libgcc.a:*.o(.rodata*);
|
||||
@@ -221,7 +221,7 @@ SECTIONS
|
||||
BUILD_DIR/src/usb*.o(.*bss*);
|
||||
BUILD_DIR/src/audio*.o(.*bss*);
|
||||
#ifdef S2DEX_TEXT_ENGINE
|
||||
lib/libs2d_engine.a:*(.*bss*);
|
||||
BUILD_DIR/src/s2d_engine*.o(.*bss*);
|
||||
#endif
|
||||
*/ULTRALIB.a:*.o(COMMON);
|
||||
*/ULTRALIB.a:*.o(.scommon);
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
#include "debug_box.h"
|
||||
#include "engine/colors.h"
|
||||
#include "profiling.h"
|
||||
#ifdef S2DEX_TEXT_ENGINE
|
||||
#include "s2d_engine/init.h"
|
||||
#endif
|
||||
|
||||
struct SpawnInfo gPlayerSpawnInfos[1];
|
||||
struct GraphNode *gGraphNodePointers[MODEL_ID_COUNT];
|
||||
@@ -427,6 +430,14 @@ void render_game(void) {
|
||||
gWarpTransDelay--;
|
||||
}
|
||||
}
|
||||
#ifdef S2DEX_TEXT_ENGINE
|
||||
s2d_init();
|
||||
|
||||
// place any custom text engine code here if not using deferred prints
|
||||
|
||||
s2d_handle_deferred();
|
||||
s2d_stop();
|
||||
#endif
|
||||
} else {
|
||||
render_text_labels();
|
||||
#ifdef PUPPYPRINT
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
# Makefile for s2d_engine.a
|
||||
|
||||
TARGET = libs2d_engine.a
|
||||
|
||||
default: all
|
||||
|
||||
BUILD_DIR ?= build
|
||||
DUMMY != mkdir -p $(BUILD_DIR)
|
||||
|
||||
C_FILES = $(wildcard ./*.c)
|
||||
O_FILES = $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o))
|
||||
|
||||
CC = $(CROSS)gcc
|
||||
AR = $(CROSS)ar
|
||||
|
||||
INCLUDE_BASE := ../../
|
||||
I_DIRS = src include/n64/PR include/n64 include/libc include .
|
||||
FULL_I_DIRS = $(addprefix $(INCLUDE_BASE),$(I_DIRS))
|
||||
I_FLAGS = $(foreach i,$(FULL_I_DIRS),-I$(i))
|
||||
|
||||
TARGET_CFLAGS = -nostdinc -I include/libc -DTARGET_N64 -DF3DEX_GBI_2
|
||||
CFLAGS := -Wall $(TARGET_CFLAGS) $(I_FLAGS) -fno-stack-protector -march=vr4300 -mtune=vr4300 -mfix4300 -mabi=32 -mno-shared -G 0 -fno-PIC -mno-abicalls -fno-zero-initialized-in-bss -fno-toplevel-reorder -Wno-missing-braces
|
||||
|
||||
|
||||
all: $(BUILD_DIR)/$(TARGET)
|
||||
|
||||
clean:
|
||||
rm -r build/
|
||||
|
||||
COPY_DIR := none
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
ifeq ($(COPY_DIR),none)
|
||||
$(error S2DEX Text Engine: No COPY_DIR defined!)
|
||||
endif
|
||||
endif
|
||||
|
||||
$(BUILD_DIR)/$(TARGET): $(O_FILES)
|
||||
$(AR) rcs -o $@ $(O_FILES)
|
||||
cp $@ $(COPY_DIR)
|
||||
|
||||
$(BUILD_DIR)/%.o: %.c
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
|
||||
#include <ultra64.h>
|
||||
#include "mtx.h"
|
||||
@@ -62,7 +62,7 @@ void texrect(int x, int y, float scale) {
|
||||
qs510(1.0f / myScale), qs510(1.0f / myScale));
|
||||
}
|
||||
|
||||
void draw_f3d_dropshadow(char c, int x, int y, uObjMtx *ds) {
|
||||
void draw_f3d_dropshadow(char c, int x, int y, UNUSED uObjMtx *ds) {
|
||||
setup_f3d_texture(c);
|
||||
|
||||
if (s2d_red != 0
|
||||
@@ -81,7 +81,7 @@ void draw_f3d_dropshadow(char c, int x, int y, uObjMtx *ds) {
|
||||
}
|
||||
}
|
||||
|
||||
void draw_f3d_glyph(char c, int x, int y, uObjMtx *mt) {
|
||||
void draw_f3d_glyph(char c, int x, int y, UNUSED uObjMtx *mt) {
|
||||
setup_f3d_texture(c);
|
||||
|
||||
texrect(x, y, myScale);
|
||||
|
||||
1796
src/s2d_engine/fonts/ifunny.c
Normal file
1796
src/s2d_engine/fonts/ifunny.c
Normal file
File diff suppressed because one or more lines are too long
136
src/s2d_engine/fonts/ifunny.h
Normal file
136
src/s2d_engine/fonts/ifunny.h
Normal file
@@ -0,0 +1,136 @@
|
||||
#include <PR/ultratypes.h>
|
||||
#include <PR/gs2dex.h>
|
||||
extern uObjTxtr ifunny_tex[];
|
||||
extern uObjMtx ifunny_mtx;
|
||||
extern uObjSprite ifunny_obj;
|
||||
extern void call_ifunny_sprite_dl(int idx, int x, int y, uObjMtx *buffer, int buf_idx);
|
||||
extern u8 ifunny_tex_0[];
|
||||
extern u8 ifunny_tex_1[];
|
||||
extern u8 ifunny_tex_2[];
|
||||
extern u8 ifunny_tex_3[];
|
||||
extern u8 ifunny_tex_4[];
|
||||
extern u8 ifunny_tex_5[];
|
||||
extern u8 ifunny_tex_6[];
|
||||
extern u8 ifunny_tex_7[];
|
||||
extern u8 ifunny_tex_8[];
|
||||
extern u8 ifunny_tex_9[];
|
||||
extern u8 ifunny_tex_10[];
|
||||
extern u8 ifunny_tex_11[];
|
||||
extern u8 ifunny_tex_12[];
|
||||
extern u8 ifunny_tex_13[];
|
||||
extern u8 ifunny_tex_14[];
|
||||
extern u8 ifunny_tex_15[];
|
||||
extern u8 ifunny_tex_16[];
|
||||
extern u8 ifunny_tex_17[];
|
||||
extern u8 ifunny_tex_18[];
|
||||
extern u8 ifunny_tex_19[];
|
||||
extern u8 ifunny_tex_20[];
|
||||
extern u8 ifunny_tex_21[];
|
||||
extern u8 ifunny_tex_22[];
|
||||
extern u8 ifunny_tex_23[];
|
||||
extern u8 ifunny_tex_24[];
|
||||
extern u8 ifunny_tex_25[];
|
||||
extern u8 ifunny_tex_26[];
|
||||
extern u8 ifunny_tex_27[];
|
||||
extern u8 ifunny_tex_28[];
|
||||
extern u8 ifunny_tex_29[];
|
||||
extern u8 ifunny_tex_30[];
|
||||
extern u8 ifunny_tex_31[];
|
||||
extern u8 ifunny_tex_32[];
|
||||
extern u8 ifunny_tex_33[];
|
||||
extern u8 ifunny_tex_34[];
|
||||
extern u8 ifunny_tex_35[];
|
||||
extern u8 ifunny_tex_36[];
|
||||
extern u8 ifunny_tex_37[];
|
||||
extern u8 ifunny_tex_38[];
|
||||
extern u8 ifunny_tex_39[];
|
||||
extern u8 ifunny_tex_40[];
|
||||
extern u8 ifunny_tex_41[];
|
||||
extern u8 ifunny_tex_42[];
|
||||
extern u8 ifunny_tex_43[];
|
||||
extern u8 ifunny_tex_44[];
|
||||
extern u8 ifunny_tex_45[];
|
||||
extern u8 ifunny_tex_46[];
|
||||
extern u8 ifunny_tex_47[];
|
||||
extern u8 ifunny_tex_48[];
|
||||
extern u8 ifunny_tex_49[];
|
||||
extern u8 ifunny_tex_50[];
|
||||
extern u8 ifunny_tex_51[];
|
||||
extern u8 ifunny_tex_52[];
|
||||
extern u8 ifunny_tex_53[];
|
||||
extern u8 ifunny_tex_54[];
|
||||
extern u8 ifunny_tex_55[];
|
||||
extern u8 ifunny_tex_56[];
|
||||
extern u8 ifunny_tex_57[];
|
||||
extern u8 ifunny_tex_58[];
|
||||
extern u8 ifunny_tex_59[];
|
||||
extern u8 ifunny_tex_60[];
|
||||
extern u8 ifunny_tex_61[];
|
||||
extern u8 ifunny_tex_62[];
|
||||
extern u8 ifunny_tex_63[];
|
||||
extern u8 ifunny_tex_64[];
|
||||
extern u8 ifunny_tex_65[];
|
||||
extern u8 ifunny_tex_66[];
|
||||
extern u8 ifunny_tex_67[];
|
||||
extern u8 ifunny_tex_68[];
|
||||
extern u8 ifunny_tex_69[];
|
||||
extern u8 ifunny_tex_70[];
|
||||
extern u8 ifunny_tex_71[];
|
||||
extern u8 ifunny_tex_72[];
|
||||
extern u8 ifunny_tex_73[];
|
||||
extern u8 ifunny_tex_74[];
|
||||
extern u8 ifunny_tex_75[];
|
||||
extern u8 ifunny_tex_76[];
|
||||
extern u8 ifunny_tex_77[];
|
||||
extern u8 ifunny_tex_78[];
|
||||
extern u8 ifunny_tex_79[];
|
||||
extern u8 ifunny_tex_80[];
|
||||
extern u8 ifunny_tex_81[];
|
||||
extern u8 ifunny_tex_82[];
|
||||
extern u8 ifunny_tex_83[];
|
||||
extern u8 ifunny_tex_84[];
|
||||
extern u8 ifunny_tex_85[];
|
||||
extern u8 ifunny_tex_86[];
|
||||
extern u8 ifunny_tex_87[];
|
||||
extern u8 ifunny_tex_88[];
|
||||
extern u8 ifunny_tex_89[];
|
||||
extern u8 ifunny_tex_90[];
|
||||
extern u8 ifunny_tex_91[];
|
||||
extern u8 ifunny_tex_92[];
|
||||
extern u8 ifunny_tex_93[];
|
||||
extern u8 ifunny_tex_94[];
|
||||
extern u8 ifunny_tex_95[];
|
||||
extern u8 ifunny_tex_96[];
|
||||
extern u8 ifunny_tex_97[];
|
||||
extern u8 ifunny_tex_98[];
|
||||
extern u8 ifunny_tex_99[];
|
||||
extern u8 ifunny_tex_100[];
|
||||
extern u8 ifunny_tex_101[];
|
||||
extern u8 ifunny_tex_102[];
|
||||
extern u8 ifunny_tex_103[];
|
||||
extern u8 ifunny_tex_104[];
|
||||
extern u8 ifunny_tex_105[];
|
||||
extern u8 ifunny_tex_106[];
|
||||
extern u8 ifunny_tex_107[];
|
||||
extern u8 ifunny_tex_108[];
|
||||
extern u8 ifunny_tex_109[];
|
||||
extern u8 ifunny_tex_110[];
|
||||
extern u8 ifunny_tex_111[];
|
||||
extern u8 ifunny_tex_112[];
|
||||
extern u8 ifunny_tex_113[];
|
||||
extern u8 ifunny_tex_114[];
|
||||
extern u8 ifunny_tex_115[];
|
||||
extern u8 ifunny_tex_116[];
|
||||
extern u8 ifunny_tex_117[];
|
||||
extern u8 ifunny_tex_118[];
|
||||
extern u8 ifunny_tex_119[];
|
||||
extern u8 ifunny_tex_120[];
|
||||
extern u8 ifunny_tex_121[];
|
||||
extern u8 ifunny_tex_122[];
|
||||
extern u8 ifunny_tex_123[];
|
||||
extern u8 ifunny_tex_124[];
|
||||
extern u8 ifunny_tex_125[];
|
||||
extern u8 ifunny_tex_126[];
|
||||
extern u8 ifunny_tex_127[];
|
||||
|
||||
extern uObjSprite ifunny_obj_dropshadow;
|
||||
1796
src/s2d_engine/fonts/newsm64.c
Normal file
1796
src/s2d_engine/fonts/newsm64.c
Normal file
File diff suppressed because one or more lines are too long
136
src/s2d_engine/fonts/newsm64.h
Normal file
136
src/s2d_engine/fonts/newsm64.h
Normal file
@@ -0,0 +1,136 @@
|
||||
#include <PR/ultratypes.h>
|
||||
#include <PR/gs2dex.h>
|
||||
extern uObjTxtr newsm64_tex[];
|
||||
extern uObjMtx newsm64_mtx;
|
||||
extern uObjSprite newsm64_obj;
|
||||
extern void call_newsm64_sprite_dl(int idx, int x, int y, uObjMtx *buffer, int buf_idx);
|
||||
extern u8 newsm64_tex_0[];
|
||||
extern u8 newsm64_tex_1[];
|
||||
extern u8 newsm64_tex_2[];
|
||||
extern u8 newsm64_tex_3[];
|
||||
extern u8 newsm64_tex_4[];
|
||||
extern u8 newsm64_tex_5[];
|
||||
extern u8 newsm64_tex_6[];
|
||||
extern u8 newsm64_tex_7[];
|
||||
extern u8 newsm64_tex_8[];
|
||||
extern u8 newsm64_tex_9[];
|
||||
extern u8 newsm64_tex_10[];
|
||||
extern u8 newsm64_tex_11[];
|
||||
extern u8 newsm64_tex_12[];
|
||||
extern u8 newsm64_tex_13[];
|
||||
extern u8 newsm64_tex_14[];
|
||||
extern u8 newsm64_tex_15[];
|
||||
extern u8 newsm64_tex_16[];
|
||||
extern u8 newsm64_tex_17[];
|
||||
extern u8 newsm64_tex_18[];
|
||||
extern u8 newsm64_tex_19[];
|
||||
extern u8 newsm64_tex_20[];
|
||||
extern u8 newsm64_tex_21[];
|
||||
extern u8 newsm64_tex_22[];
|
||||
extern u8 newsm64_tex_23[];
|
||||
extern u8 newsm64_tex_24[];
|
||||
extern u8 newsm64_tex_25[];
|
||||
extern u8 newsm64_tex_26[];
|
||||
extern u8 newsm64_tex_27[];
|
||||
extern u8 newsm64_tex_28[];
|
||||
extern u8 newsm64_tex_29[];
|
||||
extern u8 newsm64_tex_30[];
|
||||
extern u8 newsm64_tex_31[];
|
||||
extern u8 newsm64_tex_32[];
|
||||
extern u8 newsm64_tex_33[];
|
||||
extern u8 newsm64_tex_34[];
|
||||
extern u8 newsm64_tex_35[];
|
||||
extern u8 newsm64_tex_36[];
|
||||
extern u8 newsm64_tex_37[];
|
||||
extern u8 newsm64_tex_38[];
|
||||
extern u8 newsm64_tex_39[];
|
||||
extern u8 newsm64_tex_40[];
|
||||
extern u8 newsm64_tex_41[];
|
||||
extern u8 newsm64_tex_42[];
|
||||
extern u8 newsm64_tex_43[];
|
||||
extern u8 newsm64_tex_44[];
|
||||
extern u8 newsm64_tex_45[];
|
||||
extern u8 newsm64_tex_46[];
|
||||
extern u8 newsm64_tex_47[];
|
||||
extern u8 newsm64_tex_48[];
|
||||
extern u8 newsm64_tex_49[];
|
||||
extern u8 newsm64_tex_50[];
|
||||
extern u8 newsm64_tex_51[];
|
||||
extern u8 newsm64_tex_52[];
|
||||
extern u8 newsm64_tex_53[];
|
||||
extern u8 newsm64_tex_54[];
|
||||
extern u8 newsm64_tex_55[];
|
||||
extern u8 newsm64_tex_56[];
|
||||
extern u8 newsm64_tex_57[];
|
||||
extern u8 newsm64_tex_58[];
|
||||
extern u8 newsm64_tex_59[];
|
||||
extern u8 newsm64_tex_60[];
|
||||
extern u8 newsm64_tex_61[];
|
||||
extern u8 newsm64_tex_62[];
|
||||
extern u8 newsm64_tex_63[];
|
||||
extern u8 newsm64_tex_64[];
|
||||
extern u8 newsm64_tex_65[];
|
||||
extern u8 newsm64_tex_66[];
|
||||
extern u8 newsm64_tex_67[];
|
||||
extern u8 newsm64_tex_68[];
|
||||
extern u8 newsm64_tex_69[];
|
||||
extern u8 newsm64_tex_70[];
|
||||
extern u8 newsm64_tex_71[];
|
||||
extern u8 newsm64_tex_72[];
|
||||
extern u8 newsm64_tex_73[];
|
||||
extern u8 newsm64_tex_74[];
|
||||
extern u8 newsm64_tex_75[];
|
||||
extern u8 newsm64_tex_76[];
|
||||
extern u8 newsm64_tex_77[];
|
||||
extern u8 newsm64_tex_78[];
|
||||
extern u8 newsm64_tex_79[];
|
||||
extern u8 newsm64_tex_80[];
|
||||
extern u8 newsm64_tex_81[];
|
||||
extern u8 newsm64_tex_82[];
|
||||
extern u8 newsm64_tex_83[];
|
||||
extern u8 newsm64_tex_84[];
|
||||
extern u8 newsm64_tex_85[];
|
||||
extern u8 newsm64_tex_86[];
|
||||
extern u8 newsm64_tex_87[];
|
||||
extern u8 newsm64_tex_88[];
|
||||
extern u8 newsm64_tex_89[];
|
||||
extern u8 newsm64_tex_90[];
|
||||
extern u8 newsm64_tex_91[];
|
||||
extern u8 newsm64_tex_92[];
|
||||
extern u8 newsm64_tex_93[];
|
||||
extern u8 newsm64_tex_94[];
|
||||
extern u8 newsm64_tex_95[];
|
||||
extern u8 newsm64_tex_96[];
|
||||
extern u8 newsm64_tex_97[];
|
||||
extern u8 newsm64_tex_98[];
|
||||
extern u8 newsm64_tex_99[];
|
||||
extern u8 newsm64_tex_100[];
|
||||
extern u8 newsm64_tex_101[];
|
||||
extern u8 newsm64_tex_102[];
|
||||
extern u8 newsm64_tex_103[];
|
||||
extern u8 newsm64_tex_104[];
|
||||
extern u8 newsm64_tex_105[];
|
||||
extern u8 newsm64_tex_106[];
|
||||
extern u8 newsm64_tex_107[];
|
||||
extern u8 newsm64_tex_108[];
|
||||
extern u8 newsm64_tex_109[];
|
||||
extern u8 newsm64_tex_110[];
|
||||
extern u8 newsm64_tex_111[];
|
||||
extern u8 newsm64_tex_112[];
|
||||
extern u8 newsm64_tex_113[];
|
||||
extern u8 newsm64_tex_114[];
|
||||
extern u8 newsm64_tex_115[];
|
||||
extern u8 newsm64_tex_116[];
|
||||
extern u8 newsm64_tex_117[];
|
||||
extern u8 newsm64_tex_118[];
|
||||
extern u8 newsm64_tex_119[];
|
||||
extern u8 newsm64_tex_120[];
|
||||
extern u8 newsm64_tex_121[];
|
||||
extern u8 newsm64_tex_122[];
|
||||
extern u8 newsm64_tex_123[];
|
||||
extern u8 newsm64_tex_124[];
|
||||
extern u8 newsm64_tex_125[];
|
||||
extern u8 newsm64_tex_126[];
|
||||
extern u8 newsm64_tex_127[];
|
||||
|
||||
extern uObjSprite newsm64_obj_dropshadow;
|
||||
@@ -1,18 +1,18 @@
|
||||
#include <ultra64.h>
|
||||
#include <PR/gs2dex.h>
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
#include "init.h"
|
||||
#include "debug.h"
|
||||
#include "s2d_error.h"
|
||||
|
||||
void s2d_init(void) {
|
||||
s2d_error_y = TEX_HEIGHT;
|
||||
if (IS_RUNNING_ON_EMULATOR)
|
||||
if (gIsEmulator)
|
||||
gSPLoadUcode(gdl_head++, s2d_text, s2d_data);
|
||||
}
|
||||
|
||||
void s2d_stop(void) {
|
||||
if (IS_RUNNING_ON_EMULATOR) {
|
||||
if (gIsEmulator) {
|
||||
gSPLoadUcode(gdl_head++, zex_text, zex_data);
|
||||
if deinit_cond {
|
||||
my_rdp_init();
|
||||
|
||||
@@ -1,14 +1,35 @@
|
||||
#include <ultra64.h>
|
||||
#include <PR/gs2dex.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
|
||||
#define s2d_text gspS2DEX2_fifoTextStart
|
||||
#define s2d_data gspS2DEX2_fifoDataStart
|
||||
#define zex_text gspF3DZEX2_PosLight_fifoTextStart
|
||||
#define zex_data gspF3DZEX2_PosLight_fifoDataStart
|
||||
|
||||
#ifdef L3DEX2_ALONE
|
||||
#define zex_text gspL3DEX2_fifoTextStart
|
||||
#define zex_data gspL3DEX2_fifoDataStart
|
||||
#elif F3DZEX_GBI_2
|
||||
#define zex_text gspF3DZEX2_PosLight_fifoTextStart
|
||||
#define zex_data gspF3DZEX2_PosLight_fifoDataStart
|
||||
#elif F3DZEX_NON_GBI_2
|
||||
#define zex_text gspF3DZEX2_NoN_PosLight_fifoTextStart
|
||||
#define zex_data gspF3DZEX2_NoN_PosLight_fifoDataStart
|
||||
#elif F3DEX2PL_GBI
|
||||
#define zex_text gspF3DEX2_PosLight_fifoTextStart
|
||||
#define zex_data gspF3DEX2_PosLight_fifoDataStart
|
||||
#elif F3DEX_GBI_2
|
||||
#define zex_text gspF3DEX2_fifoTextStart
|
||||
#define zex_data gspF3DEX2_fifoDataStart
|
||||
#else
|
||||
#error S2DEX Text Engine only works with other EX2 series microcodes
|
||||
#endif
|
||||
|
||||
extern void s2d_reset_defer_index();
|
||||
|
||||
extern void s2d_init(void);
|
||||
|
||||
extern void s2d_handle_deferred();
|
||||
|
||||
extern void s2d_stop(void);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <PR/gs2dex.h>
|
||||
#include <PR/gu.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
|
||||
#define ftoq FTOFIX32
|
||||
#define qtof FIX32TOF
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
#include "s2d_error.h"
|
||||
#include "s2d_print.h"
|
||||
|
||||
@@ -19,7 +19,7 @@ void s2d_reset_defer_index(void) {
|
||||
// TODO: these DO NOT work
|
||||
// pls debug :)
|
||||
void s2d_print_deferred(int x, int y, const char *str) {
|
||||
s2d_charBuffer[s2d_charBuffer_index] = str;
|
||||
s2d_charBuffer[s2d_charBuffer_index] = (char *) str;
|
||||
s2d_positions[s2d_charBuffer_index].x = x;
|
||||
s2d_positions[s2d_charBuffer_index].y = y;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <ultra64.h>
|
||||
#include "macros.h"
|
||||
#include <PR/gs2dex.h>
|
||||
|
||||
#ifndef S2D_CONFIG_H
|
||||
#define S2D_CONFIG_H
|
||||
@@ -25,8 +27,6 @@
|
||||
*****************************/
|
||||
|
||||
// magic macros and font header inclusion
|
||||
#define GLUE(a, b) a##b
|
||||
#define GLUE2(a, b) GLUE(a, b)
|
||||
#define STR(x) #x
|
||||
#define STR2(x) STR(x)
|
||||
|
||||
@@ -88,7 +88,7 @@ extern char *proutSprintf(char *dst, const char *src, size_t count);
|
||||
#define TEX_BITDEPTH 8
|
||||
|
||||
#define seg2virt segmented_to_virtual
|
||||
#define IS_RUNNING_ON_EMULATOR (IO_READ(DPC_PIPEBUSY_REG) == 0)
|
||||
#define gIsEmulator (!gIsConsole)
|
||||
|
||||
// Texture resolution (pixels on the texture per pixel on the framebuffer)
|
||||
#define TEX_RES 1
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
#include <ultra64.h>
|
||||
#include "mtx.h"
|
||||
#include "debug.h"
|
||||
|
||||
@@ -12,12 +12,16 @@ extern uObjMtx final_mtx, rot_mtx;
|
||||
extern int s2d_red, s2d_green, s2d_blue, s2d_alpha;
|
||||
|
||||
extern void s2d_rdp_init(void);
|
||||
extern void f3d_rdp_init(void);
|
||||
|
||||
extern void setup_font_texture(int idx);
|
||||
|
||||
extern void mtx_pipeline(uObjMtx *m, int x, int y);
|
||||
|
||||
extern void draw_s2d_glyph(char c, int x, int y, uObjMtx *mt);
|
||||
extern void draw_s2d_shadow(char c, int x, int y, uObjMtx *ds);
|
||||
extern void draw_s2d_dropshadow(char c, int x, int y, uObjMtx *ds);
|
||||
|
||||
extern void draw_f3d_glyph(char c, int x, int y, uObjMtx *mt);
|
||||
extern void draw_f3d_dropshadow(char c, int x, int y, uObjMtx *ds);
|
||||
|
||||
#endif
|
||||
9
src/s2d_engine/s2d_engine.h
Normal file
9
src/s2d_engine/s2d_engine.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "s2d_config.h"
|
||||
#include "init.h"
|
||||
#include "s2d_print.h"
|
||||
#include "mtx.h"
|
||||
#include "s2d_error.h"
|
||||
#include "s2d_ustlib.h"
|
||||
#include "s2d_optimized.h"
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
#include "s2d_print.h"
|
||||
#include "s2d_error.h"
|
||||
|
||||
|
||||
351
src/s2d_engine/s2d_optimized.c
Normal file
351
src/s2d_engine/s2d_optimized.c
Normal file
@@ -0,0 +1,351 @@
|
||||
#include <ultra64.h>
|
||||
#include <PR/gs2dex.h>
|
||||
#include <PR/gu.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "s2d_config.h"
|
||||
|
||||
#include "s2d_draw.h"
|
||||
#include "s2d_print.h"
|
||||
#include "s2d_ustdlib.h"
|
||||
#include "s2d_error.h"
|
||||
#include "s2d_ustdlib.h"
|
||||
#include "s2d_optimized.h"
|
||||
#include "mtx.h"
|
||||
|
||||
static int s2d_width(const char *str, int line, int len);
|
||||
static void s2d_snprint(int x, int y, int align, const char *str, int len);
|
||||
|
||||
extern void *s2d_calloc(size_t);
|
||||
|
||||
void insert_el_char(S2DList *s, S2DListNode *n) {
|
||||
if (n == NULL) return;
|
||||
|
||||
S2DListNode *pt = s->head;
|
||||
|
||||
while (pt->next != NULL) {
|
||||
if (pt->next == NULL) {
|
||||
pt->next = n;
|
||||
n->prev = pt;
|
||||
return;
|
||||
}
|
||||
|
||||
if (n->glyph >= pt->glyph
|
||||
&& n->glyph < pt->next->glyph)
|
||||
{
|
||||
S2DListNode *prev = pt;
|
||||
S2DListNode *next = pt->next;
|
||||
|
||||
n->next = next;
|
||||
prev->next = n;
|
||||
next->prev = n;
|
||||
n->prev = prev;
|
||||
s->len++;
|
||||
return;
|
||||
}
|
||||
pt = pt->next;
|
||||
}
|
||||
|
||||
pt->next = n;
|
||||
}
|
||||
|
||||
#define FTOFIX16(x) (long)((x) * (float)(1 << 2))
|
||||
void mtx_pipeline_op(uObjSubMtx *m, int x, int y, float scale) {
|
||||
m->m.BaseScaleX = FTOFIX32(scale);
|
||||
// m->m.B = 0;
|
||||
// m->m.C = 0;
|
||||
m->m.BaseScaleY = FTOFIX32(scale);
|
||||
|
||||
m->m.X = FTOFIX16((float)(x));
|
||||
m->m.Y = FTOFIX16((float)(y));
|
||||
}
|
||||
|
||||
void make_glyph(S2DList *s, int x, int y,
|
||||
int glyph,
|
||||
int r, int g, int b, int a,
|
||||
float scl,
|
||||
int d, int dx, int dy
|
||||
) {
|
||||
S2DListNode *t = (S2DListNode *) s2d_calloc(sizeof(S2DListNode));
|
||||
|
||||
t->mtx = (uObjSubMtx *) s2d_calloc(sizeof(uObjSubMtx));
|
||||
|
||||
mtx_pipeline_op(t->mtx, x, y, scl);
|
||||
|
||||
t->envR = r;
|
||||
t->envG = g;
|
||||
t->envB = b;
|
||||
t->envA = a;
|
||||
|
||||
t->glyph = glyph;
|
||||
|
||||
if (d == 1) {
|
||||
t->dropshadow = (uObjSubMtx *) s2d_calloc(sizeof(uObjSubMtx));
|
||||
// mtx_pipeline_op(t->dropshadow, x + dx, y + dy, scl);
|
||||
mtx_pipeline_op(t->dropshadow, dx, dy, scl);
|
||||
}
|
||||
|
||||
if (s->head == NULL) {
|
||||
s->head = t;
|
||||
s->len = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
insert_el_char(s, t);
|
||||
|
||||
}
|
||||
|
||||
#define CLAMP_0(x) ((x < 0) ? 0 : x)
|
||||
|
||||
void draw_all_glyphs(S2DList *s) {
|
||||
S2DListNode *tmp = s->head;
|
||||
|
||||
gDPPipeSync(gdl_head++);
|
||||
gDPSetCycleType(gdl_head++, G_CYC_COPY);
|
||||
gDPSetRenderMode(gdl_head++, G_RM_SPRITE, G_RM_SPRITE2);
|
||||
|
||||
while (tmp != NULL) {
|
||||
gDPPipeSync(gdl_head++);
|
||||
gDPSetEnvColor(gdl_head++, tmp->envR, tmp->envG, tmp->envB, tmp->envA);
|
||||
|
||||
if (tmp->prev == NULL) {
|
||||
gSPObjLoadTxtr(gdl_head++, &s2d_tex[tmp->glyph]);
|
||||
gDPLoadSync(gdl_head++);
|
||||
}
|
||||
else if (tmp->prev->glyph != tmp->glyph) {
|
||||
gSPObjLoadTxtr(gdl_head++, &s2d_tex[tmp->glyph]);
|
||||
gDPLoadSync(gdl_head++);
|
||||
}
|
||||
|
||||
if (tmp->dropshadow) {
|
||||
gDPPipeSync(gdl_head++);
|
||||
gDPSetEnvColor(gdl_head++,
|
||||
CLAMP_0(tmp->envR - 100),
|
||||
CLAMP_0(tmp->envG - 100),
|
||||
CLAMP_0(tmp->envB - 100),
|
||||
tmp->envA);
|
||||
gSPObjSubMatrix(gdl_head++, &tmp->dropshadow);
|
||||
gSPObjSprite(gdl_head++, &s2d_dropshadow);
|
||||
gDPPipeSync(gdl_head++);
|
||||
gDPSetEnvColor(gdl_head++, tmp->envR, tmp->envG, tmp->envB, tmp->envA);
|
||||
}
|
||||
|
||||
gSPObjSubMatrix(gdl_head++, tmp->mtx);
|
||||
gSPObjRectangleR(gdl_head++, &s2d_font);
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
gDPPipeSync(gdl_head++);
|
||||
gDPSetCycleType(gdl_head++, G_CYC_1CYCLE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void s2d_snprint(int x, int y, int align, const char *str, int len) {
|
||||
char *p = (char *) str;
|
||||
int tmp_len = 0;
|
||||
int orig_x = x;
|
||||
int orig_y = y;
|
||||
int line = 0;
|
||||
|
||||
if (*p == '\0') return;
|
||||
|
||||
s2d_rdp_init();
|
||||
|
||||
// resets parameters
|
||||
s2d_red = s2d_green = s2d_blue = 255;
|
||||
s2d_alpha = 255;
|
||||
drop_shadow = FALSE;
|
||||
|
||||
switch (align) {
|
||||
case ALIGN_CENTER:
|
||||
x = orig_x - s2d_width(str, line, len) / 2;
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
x = orig_x - s2d_width(str, line, len);
|
||||
}
|
||||
|
||||
S2DList *s2d_list = (S2DList *) s2d_calloc(sizeof(S2DList));
|
||||
|
||||
do {
|
||||
char current_char = *p;
|
||||
|
||||
switch (current_char) {
|
||||
case CH_SCALE:
|
||||
CH_SKIP(p);
|
||||
myScale = (f32)s2d_atoi(p, &p) / 100.0f;
|
||||
break;
|
||||
case CH_ROT:
|
||||
CH_SKIP(p);
|
||||
myDegrees = s2d_atoi(p, &p);
|
||||
break;
|
||||
case CH_TRANSLATE:
|
||||
CH_SKIP(p);
|
||||
orig_x = s2d_atoi(p, &p);
|
||||
line++;
|
||||
switch (align) {
|
||||
case ALIGN_LEFT:
|
||||
x = orig_x;
|
||||
break;
|
||||
case ALIGN_CENTER:
|
||||
x = orig_x - s2d_width(str, line, len) / 2;
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
x = orig_x - s2d_width(str, line, len);
|
||||
}
|
||||
CH_SKIP(p);
|
||||
CH_SKIP(p);
|
||||
orig_y = s2d_atoi(p, &p);
|
||||
y = orig_y;
|
||||
break;
|
||||
case CH_COLOR:
|
||||
CH_SKIP(p);
|
||||
s2d_red = s2d_atoi(p, &p);
|
||||
CH_SKIP(p); CH_SKIP(p);
|
||||
|
||||
s2d_green = s2d_atoi(p, &p);
|
||||
CH_SKIP(p); CH_SKIP(p);
|
||||
|
||||
s2d_blue = s2d_atoi(p, &p);
|
||||
CH_SKIP(p); CH_SKIP(p);
|
||||
|
||||
s2d_alpha = s2d_atoi(p, &p);
|
||||
break;
|
||||
case CH_DROPSHADOW:
|
||||
drop_shadow ^= 1;
|
||||
break;
|
||||
case '\n':
|
||||
line++;
|
||||
switch (align) {
|
||||
case ALIGN_LEFT:
|
||||
x = orig_x;
|
||||
break;
|
||||
case ALIGN_CENTER:
|
||||
x = orig_x - s2d_width(str, line, len) / 2;
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
x = orig_x - s2d_width(str, line, len);
|
||||
}
|
||||
y += TEX_HEIGHT / TEX_RES;
|
||||
break;
|
||||
case '\t':
|
||||
x += TAB_WIDTH_H / TEX_RES;
|
||||
break;
|
||||
case '\v':
|
||||
x += TAB_WIDTH_V / TEX_RES;
|
||||
y += TEX_HEIGHT / TEX_RES;
|
||||
break;
|
||||
// case CH_SEPARATOR:
|
||||
// CH_SKIP(p);
|
||||
// break;
|
||||
case CH_RESET:
|
||||
s2d_red = s2d_green = s2d_blue = 255;
|
||||
s2d_alpha = 255;
|
||||
drop_shadow = FALSE;
|
||||
drop_x = 0;
|
||||
drop_y = 0;
|
||||
myScale = 1;
|
||||
myDegrees = 0;
|
||||
break;
|
||||
default:
|
||||
if (current_char != '\0' && current_char != CH_SEPARATOR) {
|
||||
char *tbl = segmented_to_virtual(s2d_kerning_table);
|
||||
|
||||
if (current_char != ' ') {
|
||||
make_glyph(s2d_list, x, y,
|
||||
current_char,
|
||||
s2d_red, s2d_green, s2d_blue, s2d_alpha,
|
||||
myScale,
|
||||
drop_shadow, drop_x, drop_y
|
||||
);
|
||||
}
|
||||
|
||||
(x += (tbl[(int) current_char] * (BASE_SCALE * myScale)));
|
||||
}
|
||||
}
|
||||
if (*p == '\0') break;
|
||||
p++;
|
||||
tmp_len++;
|
||||
} while (tmp_len < len);
|
||||
myScale = 1.0f;
|
||||
myDegrees = 0;
|
||||
drop_shadow = FALSE;
|
||||
drop_x = 0;
|
||||
drop_y = 0;
|
||||
|
||||
draw_all_glyphs(s2d_list);
|
||||
}
|
||||
|
||||
void s2d_print_optimized(int x, int y, const char *str) {
|
||||
int len;
|
||||
|
||||
if (s2d_check_str((char *)str) != 0) return;
|
||||
|
||||
len = s2d_strlen((char *)str);
|
||||
|
||||
s2d_snprint(x, y, ALIGN_LEFT, str, len);
|
||||
}
|
||||
|
||||
static int s2d_width(const char *str, int line, int len) {
|
||||
char *p = (char *) str;
|
||||
int tmp_len = 0;
|
||||
int curLine = 0;
|
||||
int width = 0;
|
||||
int scale = 1;
|
||||
|
||||
if (*p == '\0') return width;
|
||||
|
||||
do {
|
||||
char current_char = *p;
|
||||
switch (current_char) {
|
||||
case CH_SCALE:
|
||||
CH_SKIP(p);
|
||||
scale = s2d_atoi(p, &p);
|
||||
break;
|
||||
case CH_ROT:
|
||||
CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
break;
|
||||
case CH_TRANSLATE:
|
||||
CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
curLine++;
|
||||
CH_SKIP(p);
|
||||
CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
break;
|
||||
case CH_COLOR:
|
||||
CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
CH_SKIP(p); CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
CH_SKIP(p); CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
CH_SKIP(p); CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
break;
|
||||
case CH_DROPSHADOW:
|
||||
case CH_RESET:
|
||||
break;
|
||||
case '\n':
|
||||
curLine++;
|
||||
break;
|
||||
case '\t':
|
||||
if (curLine == line)
|
||||
width += TAB_WIDTH_H / TEX_RES;
|
||||
break;
|
||||
case '\v':
|
||||
if (curLine == line)
|
||||
width += TAB_WIDTH_V / TEX_RES;
|
||||
break;
|
||||
default:
|
||||
if (current_char != '\0' && curLine == line)
|
||||
width += s2d_kerning_table[(int) current_char] * scale;
|
||||
}
|
||||
if (*p == '\0') break;
|
||||
p++;
|
||||
tmp_len++;
|
||||
} while (tmp_len < len && curLine <= line);
|
||||
return width;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user