Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
root = true

[*]
insert_final_newline = false
trim_trailing_whitespace = true
charset = utf-8

[*.{nix,md,MD,sh,yml}]
insert_final_newline = true
end_of_line = lf
indent_style = space
indent_size = 2

[*.{c,C,h,H}]
indent_style = tab
indent_size = 4

[Makefile]
insert_final_newline = true
end_of_line = lf
indent_style = tab
23 changes: 23 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build main

on:
push:
branches:
- main

permissions:
contents: read
pages: write
id-token: write

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build
run: nix build -L --no-link --keep-going .#all
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ offset.txt
comport.txt
gcc_out.txt
overlay.ld
Makefile
rebuild_PC/result
/result

# Version tracker
tools/updater/.version
Expand Down
8 changes: 4 additions & 4 deletions decompile/General/232/232_35_AH_MaskHint_Update.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void DECOMP_AH_MaskHint_Update()
sdata->AkuAkuHintState++;
break;

case 1:
case 1: {
int absSpeedApprox = d->speedApprox;
if(absSpeedApprox < 0) absSpeedApprox = -absSpeedApprox;
if(absSpeedApprox > 0x31) return;
Expand Down Expand Up @@ -65,7 +65,7 @@ void DECOMP_AH_MaskHint_Update()
D232.maskWarppadDelayFrames = FPS_DOUBLE(60);

sdata->AkuAkuHintState++;
break;
} break;

case 2:

Expand Down Expand Up @@ -189,7 +189,7 @@ void DECOMP_AH_MaskHint_Update()
// stay here forever stuck
break;

case 4:
case 4: {
int lngIndex = 0;
int boolFound = 0;
short* ptrLngID = &D232.hintMenu_lngIndexArr[0];
Expand Down Expand Up @@ -270,7 +270,7 @@ void DECOMP_AH_MaskHint_Update()
// show map again
gGT->hudFlags &= ~(0x10);
}
break;
} break;

case 5:

Expand Down
4 changes: 2 additions & 2 deletions decompile/General/GHOST/GhostReplay_ThTick.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void DECOMP_GhostReplay_ThTick(struct Thread *t)
tape->packetID++;
break;

case 0x81: // Animation
case 0x81: { // Animation
int numAnimFrames = DECOMP_INSTANCE_GetNumAnimFrames(inst, buffer[1]);
inst->animIndex = (numAnimFrames < 1) ? 0 : buffer[1];
inst->animFrame = (buffer[2] == 0 || numAnimFrames <= buffer[2])
Expand All @@ -333,7 +333,7 @@ void DECOMP_GhostReplay_ThTick(struct Thread *t)
#endif

buffer += 3;
break;
} break;

case 0x82: // Boost
if (
Expand Down
1 change: 1 addition & 0 deletions decompile/General/LOAD/LOAD_A27_HowlSectorChainStart.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ int DECOMP_LOAD_HowlSectorChainStart(CdlFILE* cdlFileHWL, void* ptrDestination,
DECOMP_LOAD_HowlCallback(CdlComplete);

#endif
return 1;
}
2 changes: 1 addition & 1 deletion decompile/General/MAIN/MainDB_GetClipSize.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <common.h>

u_int DECOMP_MainDB_GetClipSize(u_int levelID, int numPlyrCurrGame)
int DECOMP_MainDB_GetClipSize(u_int levelID, int numPlyrCurrGame)
{
if(levelID == PAPU_PYRAMID || levelID == POLAR_PASS)
if (2 < numPlyrCurrGame)
Expand Down
5 changes: 5 additions & 0 deletions decompile/General/MEMPACK/MEMPACK_Init.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ void DECOMP_MEMPACK_Init(int ramSize)
// Visual Studio -> Properties -> Linker -> Advanced ->
// Base Address, Randomized Base Address, Fixed Base Address
ptrMempack->start = &memory[0];
printf(
"[CTR] Where does memory starts? (%s) %08x\n",
(ptrMempack->start < 0x01000000 ? "GOOD" : "BAD"),
ptrMempack->start
);
memset(memory, 0, 8*1024*1024);

ptrMempack->endOfAllocator = &memory[8*1024*1024 - 4];
Expand Down
8 changes: 4 additions & 4 deletions decompile/General/RaceFlag/RaceFlag_t11_GetOT.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include <common.h>

int DECOMP_RaceFlag_GetOT(void)
u_int* DECOMP_RaceFlag_GetOT(void)
{
short sVar1;
int iVar2;
struct GameTracker* gGT = sdata->gGT;

int* otDrawFirst_FarthestDepth;
int* otDrawLast_ClosestDepth;
u_int* otDrawFirst_FarthestDepth;
u_int* otDrawLast_ClosestDepth;

otDrawFirst_FarthestDepth = &gGT->pushBuffer[0].ptrOT[0x3FF];
otDrawLast_ClosestDepth = gGT->otSwapchainDB[gGT->swapchainIndex];
Expand Down Expand Up @@ -93,4 +93,4 @@ int DECOMP_RaceFlag_GetOT(void)
}

return otDrawLast_ClosestDepth;
}
}
8 changes: 5 additions & 3 deletions decompile/General/RaceFlag/RaceFlag_t13_DrawLoadingString.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void DECOMP_RaceFlag_DrawLoadingString(void)
char *pbVar8;
int iVar9;
int iVar10;
int uVar11;
u_int *uVar11;
char local_30;
char local_2f;

Expand Down Expand Up @@ -49,8 +49,10 @@ void DECOMP_RaceFlag_DrawLoadingString(void)
iVar10 =
(sdata->RaceFlag_Transition & 0xffff) -
(
((iVar3 << 0x10) >> 0x10) -
((iVar3 << 0x10) >> 0x1f) >> 1
(
((iVar3 << 0x10) >> 0x10) -
((iVar3 << 0x10) >> 0x1f)
) >> 1
);

iVar3 = FPS_HALF(sdata->RaceFlag_LoadingTextAnimFrame);
Expand Down
10 changes: 5 additions & 5 deletions decompile/General/RaceFlag/RaceFlag_t14_DrawSelf.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include <common.h>

#ifdef REBUILD_PC
int scratchpadBuf[0x1000];
u_int scratchpadBuf[0x1000];
#endif

force_inline char RaceFlag_CalculateBrightness(u_int sine, u_char darkTile)
{
if (darkTile)
{
return sine * -55 + 0x140000 >> 0xD;
return((sine * -55 + 0x140000) >> 0xD);
}
return sine * -125 + 0x1fe000 >> 0xD;
return((sine * -125 + 0x1fe000) >> 0xD);
}

void DECOMP_RaceFlag_DrawSelf()
Expand All @@ -20,7 +20,7 @@ void DECOMP_RaceFlag_DrawSelf()
u_char toggle;
short flagPos;
u_long *ot;
long *scratchpad;
u_int *scratchpad;
u_int screenlimit;
u_int dimensions;
int approx[2];
Expand Down Expand Up @@ -171,7 +171,7 @@ void DECOMP_RaceFlag_DrawSelf()
#ifdef REBUILD_PC
top = &scratchpadBuf[(toggle * 0x78 / 4) - 1];
toggle = toggle ^ 1;
bottom = &scratchpadBuf[(toggle * 0x78 / 4) - 0];
bottom = &scratchpadBuf[(toggle * 0x78 / 4)];
#else
top = (u_int *)((0x1f800000 + toggle * 0x78) - 4);
toggle = toggle ^ 1;
Expand Down
7 changes: 7 additions & 0 deletions decompile/General/zGlobal_SDATA.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

#include <common.h>

#if __GNUC__
char memcardBytes[0x1680];
#endif

struct sData sdata_static =
{
.langBufferSize = 0x3F04,
Expand Down Expand Up @@ -353,6 +357,9 @@ struct sData sdata_static =
#if NO_BSS
.ptrToMemcardBuffer1 = 0x800992e4,
.ptrToMemcardBuffer2 = 0x800992e4,
#elif __GNUC__
.ptrToMemcardBuffer1 = &memcardBytes[0],
.ptrToMemcardBuffer2 = &memcardBytes[0],
#else
.ptrToMemcardBuffer1 = &sdata_static.memcardBytes[0],
.ptrToMemcardBuffer2 = &sdata_static.memcardBytes[0],
Expand Down
25 changes: 25 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
inputs.nixpkgs.url = https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz;
outputs = { self, nixpkgs }: rec {
packages.x86_64-linux = with nixpkgs.legacyPackages.x86_64-linux; rec {
native32 = with pkgsi686Linux; {
gcc = callPackage ./rebuild_PC { ctrModSDK = self; };
clang = callPackage ./rebuild_PC { ctrModSDK = self; stdenv = clangStdenv; };
};
mingw32 = with pkgsCross.mingw32; {
gcc = callPackage ./rebuild_PC { ctrModSDK = self; };
clang = callPackage ./rebuild_PC { ctrModSDK = self; stdenv = clangStdenv; };
};
all = stdenvNoCC.mkDerivation {
name = "ctr-join";
dontUnpack = true;
dontBuild = true;
installPhase = ''
mkdir $out
ln -s ${native32.gcc} $out/native32-gcc
ln -s ${native32.clang} $out/native32-clang
ln -s ${mingw32.gcc} $out/mingw32-gcc
ln -s ${mingw32.clang} $out/mingw32-clang
'';
};
};
# default
package.x86_64-linux = packages.x86_64-linux.native32.gcc;
};
}
2 changes: 1 addition & 1 deletion include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
#include <ovr_231.h>
#include <ovr_232.h>
#include <ovr_233.h>
#include <math.h>
#include <ctr_math.h>
#include <regionsEXE.h>

#ifndef REBUILD_PC
Expand Down
File renamed without changes.
40 changes: 37 additions & 3 deletions rebuild_PC/CrashTeamRacingPC.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

// ======= Headers =============
#if __GNUC__
#include <SDL2/SDL.h>
#define _EnterCriticalSection(x)
#define EnterCriticalSection(x)
#define ExitCriticalSection()
#endif

#define _CRT_SECURE_NO_WARNINGS
#define REBUILD_PC
Expand Down Expand Up @@ -57,11 +62,15 @@ typedef enum {
// work in PsyXKeyboardHandler, workaround:
int NikoGetEnterKey()
{
#if __GNUC__
return 0;
#else
// dont use Windows.h
__declspec(dllimport) short __stdcall
GetAsyncKeyState(_In_ int vKey);
GetAsyncKeyState(int vKey);

return GetAsyncKeyState(0xd);
#endif
}

void PsyXKeyboardHandler(int key, char down)
Expand Down Expand Up @@ -90,11 +99,36 @@ int NikoCalcFPS()
printf("NikoCalcFPS: %d fps\n", (1000 * frameGap) / delta);
}

int main()
#ifndef CC
#if __GNUC__
#if _WIN32
#ifndef __clang__
#define CC "MINGW-GCC"
#else
#define CC "MINGW-CLANG"
#endif
#else
#ifndef __clang__
#define CC "GCC"
#else
#define CC "CLANG"
#endif
#endif
#elif defined(_MSC_VER)
#define CC "MSVC"
#else
#define CC "Unknown"
#endif
#endif

int main(int argc, char* argv[])
{
printf("[CTR] Built with: " CC "\n");
#ifdef USE_16BY9
printf("[CTR] USE_16BY9=1\n");
PsyX_Initialise("CTRPC", 1280, 720, 0);
#else
printf("[CTR] USE_16BY9=0\n");
PsyX_Initialise("CTRPC", 800, 600, 0);
#endif

Expand Down
20 changes: 20 additions & 0 deletions rebuild_PC/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: all

CFLAGS+=-std=c99 -DUSE_16BY9=1 -O2 \
-I./PsyCross/include -I../include \
`${PKG_CONFIG} --cflags sdl2`

# Clang is rigorous
CFLAGS+=-Wno-int-conversion -Wno-incompatible-function-pointer-types -Wno-implicit-function-declaration -Wno-return-type

LDLIBS+=-lpsycross \
`${PKG_CONFIG} --libs sdl2` \
`${PKG_CONFIG} --libs openal` \
-lstdc++ -lm

# Clang always needs "no-pie", some distros might add PIE to GCC too.
LDFLAGS+=-fno-pie -no-pie -Wl,-Ttext,0x00D00000

CrashTeamRacingPC: CrashTeamRacingPC.o

all: CrashTeamRacingPC
Loading