From c1eea9b09f72d2596233b017846802f6b797265e Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 20 Oct 2024 16:20:51 +1100 Subject: [PATCH] Amiga: Separate makefile --- .gitignore | 13 ++++++++--- Makefile | 14 +++++------- misc/amiga/Makefile_68k | 44 +++++++++++++++++++++++++++++++++++++ src/Graphics_PS1.c | 45 ++++++++++++++++++++++++-------------- src/Platform_NDS.c | 24 +++++++++++++++++--- third_party/gldc/src/sh4.c | 14 ++---------- 6 files changed, 111 insertions(+), 43 deletions(-) create mode 100644 misc/amiga/Makefile_68k diff --git a/.gitignore b/.gitignore index c35a8ce3e..1fd71b55c 100644 --- a/.gitignore +++ b/.gitignore @@ -26,20 +26,24 @@ xcuserdata/ # Nintendo Console build results build-3ds/ -build-gc/ build-nds/ +build-dsi/ build-n64/ +build-gc/ build-wii/ build-wiiu/ build-switch/ classicube.nds + # SEGA console build results +build-32x/ +build-saturn/ build-dc/ IP.BIN ISO_FILES/ third_party/gldc/libGLdc.a -build-saturn/ cd/ + # Microsoft console build results build-360/ main.exe @@ -48,6 +52,7 @@ misc/xbox/ps_coloured.inl misc/xbox/ps_textured.inl misc/xbox/vs_coloured.inl misc/xbox/vs_textured.inl + # Sony console build results build-ps2/ build-ps3/ @@ -58,10 +63,12 @@ PARAM.SFO param.sfo eboot.bin +# Desktop build results +build-amiga-68k/ + # Build results [Dd]ebug/ [Rr]elease/ -[Rr]eleases/ x64/ x86/ build/ diff --git a/Makefile b/Makefile index 58774631a..0b154ede0 100644 --- a/Makefile +++ b/Makefile @@ -146,12 +146,6 @@ ifeq ($(PLAT),dos) BUILD_DIR = build-dos endif -ifeq ($(PLAT),amiga_68k) - CC = m68k-amiga-elf-gcc - CFLAGS += -DPLAT_AMIGA - BUILD_DIR = build-amiga_68k -endif - ifdef SDL2 CFLAGS += -DCC_WIN_BACKEND=CC_WIN_BACKEND_SDL2 @@ -214,8 +208,6 @@ irix: $(MAKE) $(TARGET) PLAT=irix dos: $(MAKE) $(TARGET) PLAT=dos -amiga_68k: - $(MAKE) $(TARGET) PLAT=amiga_68k # Default overrides sdl2: $(MAKE) $(TARGET) SDL2=1 @@ -267,7 +259,11 @@ macclassic_68k: $(MAKE) -f misc/macclassic/Makefile_68k macclassic_ppc: $(MAKE) -f misc/macclassic/Makefile_ppc - +amiga_68k: + $(MAKE) -f misc/amiga/Makefile_68k +amiga_ppc: + $(MAKE) -f misc/amiga/Makefile_ppc + clean: $(RM) $(OBJECTS) diff --git a/misc/amiga/Makefile_68k b/misc/amiga/Makefile_68k new file mode 100644 index 000000000..880fa0fa5 --- /dev/null +++ b/misc/amiga/Makefile_68k @@ -0,0 +1,44 @@ +AS=m68k-amiga-elf-as +CC=m68k-amiga-elf-gcc +CXX=m68k-amiga-elf-g++ + +CFLAGS :=-O1 -fno-math-errno -DPLAT_AMIGA +TARGET := ClassiCube-68k +BUILD_DIR := build-amiga-68k +SOURCE_DIR := src +LDFLAGS := -nostdlib + +C_SOURCES := $(wildcard $(SOURCE_DIR)/*.c) +C_ASSEMS := $(patsubst $(SOURCE_DIR)/%.c, $(BUILD_DIR)/%.S, $(C_SOURCES)) +C_OBJECTS := $(patsubst $(SOURCE_DIR)/%.c, $(BUILD_DIR)/%.o, $(C_SOURCES)) + +# Dependency tracking +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d +DEPFILES := $(C_OBJECTS:%.o=%.d) + + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +default: $(BUILD_DIR) $(TARGET).elf + +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +$(TARGET).elf: $(C_OBJECTS) + $(CC) $(LDFLAGS) -o $(TARGET).elf $(C_OBJECTS) + + +#--------------------------------------------------------------------------------- +# object generation +#--------------------------------------------------------------------------------- +$(C_OBJECTS): $(BUILD_DIR)/%.o : $(BUILD_DIR)/%.S + $(AS) $< -o $@ + +$(C_ASSEMS): $(BUILD_DIR)/%.S : $(SOURCE_DIR)/%.c + $(CC) $(CFLAGS) $(DEPFLAGS) -S -c $< -o $@ + +# Dependency tracking +$(DEPFILES): + +include $(wildcard $(DEPFILES)) diff --git a/src/Graphics_PS1.c b/src/Graphics_PS1.c index 6a3ecebde..1ba39a26d 100644 --- a/src/Graphics_PS1.c +++ b/src/Graphics_PS1.c @@ -108,8 +108,7 @@ void Gfx_Create(void) { InitGeom(); gte_SetGeomOffset(Window_Main.Width / 2, Window_Main.Height / 2); - // Set screen depth (basically FOV control, W/2 works best) - gte_SetGeomScreen(Window_Main.Width / 2); + gte_SetGeomScreen(Window_Main.Height / 2); } void Gfx_Free(void) { @@ -523,13 +522,7 @@ static struct MatrixRow mvp_row1, mvp_row2, mvp_row3, mvp_trans; #define ToFixed(v) (int)(v * (1 << 12)) static void LoadTransformMatrix(struct Matrix* src) { - // https://math.stackexchange.com/questions/237369/given-this-transformation-matrix-how-do-i-decompose-it-into-translation-rotati - MATRIX mtx; - - mtx.t[0] = (int)(src->row4.x); - mtx.t[1] = (int)(src->row4.y); - mtx.t[2] = (int)(src->row4.z); - + // https://math.stackexchange.com/questions/237369/given-this-transformation-matrix-how-do-i-decompose-it-into-translation-rotati mvp_trans.x = XYZFixed(1) * ToFixed(src->row4.x); mvp_trans.y = XYZFixed(1) * ToFixed(src->row4.y); mvp_trans.z = XYZFixed(1) * ToFixed(src->row4.z); @@ -550,23 +543,30 @@ static void LoadTransformMatrix(struct Matrix* src) { mvp_row3.z = ToFixed(src->row3.z); mvp_row3.w = ToFixed(src->row3.w); - //Platform_Log3("X: %f3, Y: %f3, Z: %f3", &src->row1.x, &src->row1.y, &src->row1.z); - //Platform_Log3("X: %f3, Y: %f3, Z: %f3", &src->row2.x, &src->row2.y, &src->row2.z); - //Platform_Log3("X: %f3, Y: %f3, Z: %f3", &src->row3.x, &src->row3.y, &src->row3.z); - //Platform_Log3("X: %f3, Y: %f3, Z: %f3", &src->row4.x, &src->row4.y, &src->row4.z); + //Platform_Log4("X: %f3, %f3, %f3, %f3", &src->row1.x, &src->row2.x, &src->row3.x, &src->row4.x); + //Platform_Log4("Y: %f3, %f3, %f3, %f3", &src->row1.y, &src->row2.y, &src->row3.y, &src->row4.y); + //Platform_Log4("Z: %f3, %f3, %f3, %f3", &src->row1.z, &src->row2.z, &src->row3.z, &src->row4.z); + //Platform_Log4("W: %f3, %f3, %f3, %f3", &src->row1.w, &src->row2.w, &src->row3.w, &src->row4.w); //Platform_LogConst("===="); + // Use w instead of z + // (row123.z = row123.w, only difference is row4.z/w being different) + MATRIX mtx; + mtx.t[0] = (int)(src->row4.x); + mtx.t[1] = (int)(src->row4.y); + mtx.t[2] = (int)(src->row4.w); + mtx.m[0][0] = ToFixed(src->row1.x); mtx.m[0][1] = ToFixed(src->row1.y); - mtx.m[0][2] = ToFixed(src->row1.z); + mtx.m[0][2] = ToFixed(src->row1.w); mtx.m[1][0] = ToFixed(src->row2.x); mtx.m[1][1] = ToFixed(src->row2.y); - mtx.m[1][2] = ToFixed(src->row2.z); + mtx.m[1][2] = ToFixed(src->row2.w); mtx.m[2][0] = ToFixed(src->row3.x); mtx.m[2][1] = ToFixed(src->row3.y); - mtx.m[2][2] = ToFixed(src->row3.z); + mtx.m[2][2] = ToFixed(src->row3.w); gte_SetRotMatrix(&mtx); gte_SetTransMatrix(&mtx); @@ -655,6 +655,19 @@ static int Transform(IVec3* result, struct PS1VertexTextured* a) { result->x = (x * 160 / w) + 160; result->y = (y * -120 / w) + 120; result->z = (z * OT_LENGTH / w); + + /*SVECTOR coord; + POLY_FT4 poly; + coord.vx = a->x; coord.vy = a->y; coord.vz = a->z; + gte_ldv0(&coord); + gte_rtps(); + gte_stsxy(&poly.x0); + + int X = (short)poly.x0, Y = (short)poly.y0; + Platform_Log3("X: %i, %i, %i", &x, &result->x, &X); + Platform_Log3("Y: %i, %i, %i", &y, &result->y, &Y); + Platform_LogConst("=======");*/ + return z > w; } diff --git a/src/Platform_NDS.c b/src/Platform_NDS.c index 0739ad197..ae2b1b7cd 100644 --- a/src/Platform_NDS.c +++ b/src/Platform_NDS.c @@ -460,6 +460,25 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) { return res; } +static void LogWifiStatus(int status) { + switch (status) { + case ASSOCSTATUS_SEARCHING: + Platform_LogConst("Wifi: Searching.."); return; + case ASSOCSTATUS_AUTHENTICATING: + Platform_LogConst("Wifi: Authenticating.."); return; + case ASSOCSTATUS_ASSOCIATING: + Platform_LogConst("Wifi: Connecting.."); return; + case ASSOCSTATUS_ACQUIRINGDHCP: + Platform_LogConst("Wifi: Acquiring.."); return; + case ASSOCSTATUS_ASSOCIATED: + Platform_LogConst("Wifi: Connected successfully!"); return; + case ASSOCSTATUS_CANNOTCONNECT: + Platform_LogConst("Wifi: FAILED TO CONNECT"); return; + default: + Platform_Log1("Wifi: status = %i", &status); return; + } +} + static void InitNetworking(void) { #ifdef BUILD_DSI if (!DSiWifi_InitDefault(INIT_ONLY)) { @@ -481,12 +500,11 @@ static void InitNetworking(void) { int status = DSiWifi_AssocStatus(); #else int status = Wifi_AssocStatus(); -#endif +#endif + LogWifiStatus(status); if (status == ASSOCSTATUS_ASSOCIATED) return; - Platform_Log1("STATUS: %i", &status); if (status == ASSOCSTATUS_CANNOTCONNECT) { - Platform_LogConst("Can't connect to WIFI"); net_supported = false; return; } swiWaitForVBlank(); diff --git a/third_party/gldc/src/sh4.c b/third_party/gldc/src/sh4.c index c5c3e58f1..ade322558 100644 --- a/third_party/gldc/src/sh4.c +++ b/third_party/gldc/src/sh4.c @@ -300,7 +300,7 @@ extern void ProcessVertexList(Vertex* v3, int n, void* sq_addr); void SceneListSubmit(Vertex* v3, int n) { sq = (uint32_t*)MEM_AREA_SQ_BASE; - for(int i = 0; i < n; ++i, ++v3) + for (int i = 0; i < n; i++, v3++) { PREFETCH(v3 + 1); switch(v3->flags & 0xFF000000) { @@ -313,21 +313,11 @@ void SceneListSubmit(Vertex* v3, int n) { continue; }; - // Quads [0, 1, 2, 3] -> Triangles [{0, 1, 2} {2, 3, 0}] + // Quads [0, 1, 2, 3] -> Triangles [{0, 1, 2} {2, 3, 0}] Vertex* const v0 = v3 - 3; Vertex* const v1 = v3 - 2; Vertex* const v2 = v3 - 1; - uint8_t visible_mask = v3->flags & 0xFF; - - // Stats gathering found that when testing a 64x64x64 sized world, at most - // ~400-500 triangles needed clipping - // ~13% of the triangles in a frame needed clipping (percentage increased when less triangles overall) - // Based on this, the decision was made to optimise for rendering quads there - // were either entirely visible or entirely culled, at the expensive at making - // partially visible quads a bit slower due to needing to be split into two triangles first - // Performance measuring indicated that overall FPS improved from this change - // to switching to try to process 1 quad instead of 2 triangles though switch(visible_mask) { case V0_VIS | V1_VIS | V2_VIS | V3_VIS: // All vertices visible