Linux/GCC Support (#28)

* Initial Linux/GCC support commit

* Add instructins for linux in the README

* apply suggestions by @Erotemic and @Emill

* Fix python 3.10 symlink line

* Fix func_80041E80 type mismatch (#3)

Type mismatch functions.h:664

* Makefile: clean OTRExporter/libultraship/ZAPDTR with distclean and fix CXX_FILES

* Makefile: find C/CXX_FILES automatically

* Makefile: remove ugly conditions in find commands

* cleanup _MSC_VER usage

* fix Windows build

* cleanup extraction scripts

* fix Windows build

* Fix Windows path separator issue

* fix rumble support for linux

* use glew-cmake in dockerfile

* add pulseaudio backend

* fix ZAPDTR linkage

* Check for "soh.elf" in directory (#6)

hide second button if `soh.exe` or `soh.elf` is present

* Fix hardcoded segment addresses (#5)

* fix condition

* hack lus -> soh dep for ZAPDTR

Co-authored-by: sholdee <102821812+sholdee@users.noreply.github.com>
Co-authored-by: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com>
Co-authored-by: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com>
This commit is contained in:
Random 2022-05-12 02:18:24 +09:00 committed by GitHub
commit 09432ee7f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
116 changed files with 1403 additions and 4054 deletions

11
soh/.gitignore vendored
View file

@ -25,6 +25,10 @@ docs/doxygen/
*.map
*.dump
out.txt
shipofharkinian.ini
imgui.ini
oot.otr
oot_save.sav
# Tool artifacts
tools/mipspro7.2_compiler/
@ -279,7 +283,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
@ -375,7 +379,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
@ -384,7 +388,7 @@ ASALocalRun/
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
# MFractors (Xamarin productivity tool) working folder
.mfractor/
*.out
@ -397,6 +401,7 @@ ZAPDUtils/ZAPDUtils.a
build/
ZAPDUtils/build/
ZAPD/BuildInfo.h
cvars.cfg
DebugObj/*
ReleaseObj/*

158
soh/Makefile Normal file
View file

@ -0,0 +1,158 @@
CXX := g++
CC := gcc
LD := lld
AR := ar
FORMAT := clang-format-11
ZAPD := ../ZAPDTR/ZAPD.out
LIBULTRASHIP := ../libultraship/libultraship.a
ZAPDUTILS := ../ZAPDTR/ZAPDUtils/ZAPDUtils.a
ASAN ?= 0
DEBUG ?= 1
OPTFLAGS ?= -O0
LTO ?= 0
WARN := \
-Wno-return-type \
-funsigned-char \
-m32 -mhard-float -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -fno-toplevel-reorder -ffreestanding -fwrapv \
CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib -march=i386
CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib -march=i386
LDFLAGS := -m32
CPPFLAGS := -MMD
ifneq ($(DEBUG),0)
CXXFLAGS += -g
CFLAGS += -g
endif
ifneq ($(ASAN),0)
CXXFLAGS += -fsanitize=address
LDFLAGS += -fsanitize=address
endif
ifneq ($(LTO),0)
CXXFLAGS += -flto
LDFLAGS += -flto
endif
TARGET := soh.elf
INC_DIRS := $(addprefix -I, \
. \
assets \
build \
include \
src \
../ZAPDTR/ZAPDUtils \
../libultraship/libultraship \
../libultraship/libultraship/Lib/spdlog/include \
../libultraship/libultraship/Lib/Fast3D/U64 \
../libultraship/libultraship/Lib/Fast3D/U64/PR \
)
LDDIRS := $(addprefix -L, \
../external \
../libultraship/ \
)
LDLIBS := \
$(ZAPDUTILS) \
$(addprefix -l, \
X11 \
dl \
bz2 \
z \
pthread \
atomic \
SDL2 \
GL \
GLEW \
storm \
pulse\
ultraship \
) \
ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*")
ASSET_FILES_XML := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.xml))
ASSET_FILES_BIN := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.bin))
ASSET_FILES_OUT := $(foreach f,$(ASSET_FILES_XML:.xml=.c),$f) \
$(foreach f,$(ASSET_FILES_BIN:.bin=.bin.inc.c),build/$f)
TEXTURE_FILES_PNG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.png))
TEXTURE_FILES_JPG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.jpg))
TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),build/$f) \
$(foreach f,$(TEXTURE_FILES_JPG:.jpg=.jpg.inc.c),build/$f) \
CXX_FILES := \
$(shell find soh -type f -name *.cpp)
C_FILES := \
$(shell find soh -type f -name *.c) \
$(shell find src/boot -type f -name *.c) \
$(shell find src/buffers -type f -name *.c) \
$(shell find src/code -type f -name *.c) \
$(shell find src/overlays -type f -name *.c) \
src/libultra/gu/coss.c \
src/libultra/gu/guLookAt.c \
src/libultra/gu/guLookAtHilite.c \
src/libultra/gu/guPerspectiveF.c \
src/libultra/gu/guPosition.c \
src/libultra/gu/guS2DInitBg.c \
src/libultra/gu/ortho.c \
src/libultra/gu/rotate.c \
src/libultra/gu/sins.c \
src/libultra/gu/sintable.c \
src/libultra/libc/sprintf.c
O_FILES := \
$(C_FILES:%.c=build/%.o) \
$(CXX_FILES:%.cpp=build/%.o)
D_FILES := $(O_FILES:%.o=%.d)
# create build directory
SRC_DIRS := $(shell find . -type d -a -not -path "*build*")
$(shell mkdir -p $(SRC_DIRS:%=build/%))
all:
$(MAKE) -C ../libultraship
$(MAKE) $(TARGET)
setup:
cd ../OTRExporter && python3 extract_baserom.py
$(MAKE) mpq
mpq:
$(MAKE) -C ../libultraship
$(MAKE) -C ../OTRExporter/OTRExporter
$(MAKE) -C ../ZAPDTR
rm -rf ../OTRExporter/oot.otr
cd ../OTRExporter && python3 extract_assets.py
cp ../OTRExporter/oot.otr .
distclean: clean
$(RM) -r baserom/
$(MAKE) clean -C ../libultraship
$(MAKE) clean -C ../OTRExporter/OTRExporter
$(MAKE) clean -C ../ZAPDTR
clean:
rm -rf build $(TARGET)
.PHONY: all clean distclean setup mpq
build/%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) $< -o $@
build/%.o: %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(OPTFLAGS) $(INC_DIRS) $< -o $@
# make soh depend on libultraship
$(TARGET): $(LIBULTRASHIP)
$(TARGET): $(O_FILES)
$(CXX) $^ -o $@ $(LDFLAGS) -fuse-ld=$(LD) $(LDDIRS) $(LDLIBS)
-include $(D_FILES)

View file

@ -1,7 +1,7 @@
#ifndef ALLOCA_H
#define ALLOCA_H
void* alloca(u32);
// void* alloca(u32);
//#define alloca __builtin_alloca
#define alloca malloc

View file

@ -14,7 +14,7 @@ extern "C"
#if defined(INCLUDE_GAME_PRINTF) && !defined(NDEBUG)
#define osSyncPrintf(fmt, ...) lusprintf(__FILE__, __LINE__, 0, fmt, __VA_ARGS__)
#else
#define osSyncPrintf(fmt, ...) osSyncPrintfUnused(fmt, __VA_ARGS__)
#define osSyncPrintf(fmt, ...) osSyncPrintfUnused(fmt, ##__VA_ARGS__)
#endif
f32 fabsf(f32 f);

View file

@ -4,8 +4,8 @@
#include "functions.h"
#include "variables.h"
#include "macros.h"
#include "soh\OTRGlobals.h"
#include "soh\Enhancements\gameconsole.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/gameconsole.h"
#include "Cvar.h"

View file

@ -205,6 +205,14 @@ extern GraphicsContext* __gfxCtx;
#define ALIGNED8
#endif
#define SEG_ADDR(seg, addr) (addr | (seg << 24) | 0xF0000000)
#define SEG_ADDR(seg, addr) (addr | (seg << 24) | 1)
#ifdef _MSC_VER
#define BOMSWAP16 _byteswap_ushort
#define BOMSWAP32 _byteswap_ulong
#else
#define BOMSWAP16 __builtin_bswap16
#define BOMSWAP32 __builtin_bswap32
#endif
#endif

View file

@ -1,6 +1,9 @@
#ifndef ULTRA64_H
#define ULTRA64_H
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#include "ultra64/types.h"
#include "unk.h"

View file

@ -278,6 +278,7 @@
<ClCompile Include="src\code\z_actor_dlftbls.c" />
<ClCompile Include="src\code\z_bgcheck.c" />
<ClCompile Include="src\code\z_camera.c" />
<ClCompile Include="src\code\z_cheap_proc.c" />
<ClCompile Include="src\code\z_collision_btltbls.c" />
<ClCompile Include="src\code\z_collision_check.c" />
<ClCompile Include="src\code\z_common_data.c" />

View file

@ -18,7 +18,7 @@ extern "C" {
extern GlobalContext* gGlobalCtx;
}
#include "cvar.h"
#include "Cvar.h"
#define CMD_REGISTER SohImGui::BindCmd

View file

@ -4,6 +4,7 @@
#include <vector>
#include <string>
#include <cmath>
extern "C" {
#include <z64.h>

View file

@ -3,7 +3,7 @@
#include <ultra64.h>
#include <z64.h>
#include "cvar.h"
#include "Cvar.h"
#define MAX_CVARS 2048

View file

@ -11,10 +11,14 @@
#include "Window.h"
#include "z64animation.h"
#include "z64bgcheck.h"
#include "../soh/enhancements/gameconsole.h"
#include "Enhancements/gameconsole.h"
#include <ultra64/gbi.h>
#include <Animation.h>
#ifdef _WIN32
#include <Windows.h>
#else
#include <time.h>
#endif
#include <Vertex.h>
#include <CollisionHeader.h>
#include <Array.h>
@ -22,10 +26,11 @@
#include <Texture.h>
#include "Lib/stb/stb_image.h"
#include "AudioPlayer.h"
#include "../soh/Enhancements/debugconsole.h"
#include "../soh/Enhancements/debugger/debugger.h"
#include "Enhancements/debugconsole.h"
#include "Enhancements/debugger/debugger.h"
#include "Utils/BitConverter.h"
#include "variables.h"
#include "macros.h"
#include <Utils/StringHelper.h>
OTRGlobals* OTRGlobals::Instance;
@ -59,7 +64,7 @@ extern "C" void InitOTR() {
OTRGlobals::Instance = new OTRGlobals();
auto t = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("version");
if (!t->bHasLoadError)
if (!t->bHasLoadError)
{
//uint32_t gameVersion = BitConverter::ToUInt32BE((uint8_t*)t->buffer.get(), 0);
uint32_t gameVersion = *((uint32_t*)t->buffer.get());
@ -72,6 +77,7 @@ extern "C" void InitOTR() {
Debug_Init();
}
#ifdef _WIN32
extern "C" uint64_t GetFrequency() {
LARGE_INTEGER nFreq;
@ -86,6 +92,21 @@ extern "C" uint64_t GetPerfCounter() {
return ticks.QuadPart;
}
#else
extern "C" uint64_t GetFrequency() {
return 1000; // sec -> ms
}
extern "C" uint64_t GetPerfCounter() {
struct timespec monotime;
clock_gettime(CLOCK_MONOTONIC, &monotime);
uint64_t remainingMs = (monotime.tv_nsec / 1000000);
// in milliseconds
return monotime.tv_sec * 1000 + remainingMs;
}
#endif
// C->C++ Bridge
extern "C" void Graph_ProcessFrame(void (*run_one_game_iter)(void)) {
@ -185,7 +206,7 @@ extern "C" void OTRResetScancode()
OTRGlobals::Instance->context->GetWindow()->lastScancode = -1;
}
extern "C" uint32_t ResourceMgr_GetGameVersion()
extern "C" uint32_t ResourceMgr_GetGameVersion()
{
return OTRGlobals::Instance->context->GetResourceManager()->GetGameVersion();
}
@ -309,7 +330,7 @@ extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) {
if (res->cachedGameAsset != nullptr)
return (char*)res->cachedGameAsset;
else
else
{
Vec3s* data = (Vec3s*)malloc(sizeof(Vec3s) * res->scalars.size());
@ -429,7 +450,7 @@ extern "C" int ResourceMgr_OTRSigCheck(char* imgData)
{
uintptr_t i = (uintptr_t)(imgData);
if (i == 0xD9000000 || i == 0xE7000000 || (i & 0xF0000000) == 0xF0000000)
if (i == 0xD9000000 || i == 0xE7000000 || (i & 1) == 1)
return 0;
if ((i & 0xFF000000) != 0xAB000000 && (i & 0xFF000000) != 0xCD000000 && i != 0) {
@ -823,24 +844,24 @@ extern "C" int16_t OTRGetRectDimensionFromRightEdge(float v) {
}
extern "C" void bswapSoundFontSound(SoundFontSound* swappable) {
swappable->sample = (SoundFontSample*)_byteswap_ulong((u32)swappable->sample);
swappable->tuningAsU32 = _byteswap_ulong((u32)swappable->tuningAsU32);
swappable->sample = (SoundFontSample*)BOMSWAP32((u32)swappable->sample);
swappable->tuningAsU32 = BOMSWAP32((u32)swappable->tuningAsU32);
}
extern "C" void bswapDrum(Drum* swappable) {
bswapSoundFontSound(&swappable->sound);
swappable->envelope = (AdsrEnvelope*)_byteswap_ulong((u32)swappable->envelope);
swappable->envelope = (AdsrEnvelope*)BOMSWAP32((u32)swappable->envelope);
}
extern "C" void bswapInstrument(Instrument* swappable) {
swappable->envelope = (AdsrEnvelope*)_byteswap_ulong((u32)swappable->envelope);
swappable->envelope = (AdsrEnvelope*)BOMSWAP32((u32)swappable->envelope);
bswapSoundFontSound(&swappable->lowNotesSound);
bswapSoundFontSound(&swappable->normalNotesSound);
bswapSoundFontSound(&swappable->highNotesSound);
}
extern "C" void bswapSoundFontSample(SoundFontSample* swappable) {
u32 origBitfield = _byteswap_ulong(swappable->asU32);
u32 origBitfield = BOMSWAP32(swappable->asU32);
swappable->codec = (origBitfield >> 28) & 0x0F;
swappable->medium = (origBitfield >> 24) & 0x03;
@ -848,29 +869,29 @@ extern "C" void bswapSoundFontSample(SoundFontSample* swappable) {
swappable->unk_bit25 = (origBitfield >> 21) & 0x01;
swappable->size = (origBitfield) & 0x00FFFFFF;
swappable->sampleAddr = (u8*)_byteswap_ulong((u32)swappable->sampleAddr);
swappable->loop = (AdpcmLoop*)_byteswap_ulong((u32)swappable->loop);
swappable->book = (AdpcmBook*)_byteswap_ulong((u32)swappable->book);
swappable->sampleAddr = (u8*)BOMSWAP32((u32)swappable->sampleAddr);
swappable->loop = (AdpcmLoop*)BOMSWAP32((u32)swappable->loop);
swappable->book = (AdpcmBook*)BOMSWAP32((u32)swappable->book);
}
extern "C" void bswapAdpcmLoop(AdpcmLoop* swappable) {
swappable->start = (u32)_byteswap_ulong((u32)swappable->start);
swappable->end = (u32)_byteswap_ulong((u32)swappable->end);
swappable->count = (u32)_byteswap_ulong((u32)swappable->count);
swappable->start = (u32)BOMSWAP32((u32)swappable->start);
swappable->end = (u32)BOMSWAP32((u32)swappable->end);
swappable->count = (u32)BOMSWAP32((u32)swappable->count);
if (swappable->count != 0) {
for (int i = 0; i < 16; i++) {
swappable->state[i] = (s16)_byteswap_ushort(swappable->state[i]);
swappable->state[i] = (s16)BOMSWAP16(swappable->state[i]);
}
}
}
extern "C" void bswapAdpcmBook(AdpcmBook* swappable) {
swappable->order = (u32)_byteswap_ulong((u32)swappable->order);
swappable->npredictors = (u32)_byteswap_ulong((u32)swappable->npredictors);
swappable->order = (u32)BOMSWAP32((u32)swappable->order);
swappable->npredictors = (u32)BOMSWAP32((u32)swappable->npredictors);
for (int i = 0; i < swappable->npredictors * swappable->order * sizeof(s16) * 4; i++)
swappable->book[i] = (s16)_byteswap_ushort(swappable->book[i]);
swappable->book[i] = (s16)BOMSWAP16(swappable->book[i]);
}
extern "C" bool AudioPlayer_Init(void) {
@ -900,7 +921,7 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) {
}
extern "C" int Controller_ShouldRumble(size_t i) {
for (const auto& controller : Ship::Window::Controllers.at(i))
for (const auto& controller : Ship::Window::Controllers.at(i))
{
float rumble_strength = CVar_GetFloat(StringHelper::Sprintf("gCont%i_RumbleStrength", i).c_str(), 1.0f);

View file

@ -12,12 +12,12 @@ OSViMode osViModeNtscLan1;
OSViMode osViModeMpalLan1;
OSViMode osViModeFpalLan1;
OSViMode osViModePalLan1;
AudioContext gAudioContext;
unk_D_8016E750 D_8016E750[4];
// AudioContext gAudioContext;
// unk_D_8016E750 D_8016E750[4];
u8 gLetterTLUT[4][32];
u8 gFontFF[999];
DmaEntry gDmaDataTable[0x60C];
u8 D_80133418;
// u8 D_80133418;
u16 gAudioSEFlagSwapSource[64];
u16 gAudioSEFlagSwapTarget[64];
u8 gAudioSEFlagSwapMode[64];

View file

@ -12,7 +12,7 @@ void OTRGameplay_InitScene(GlobalContext* globalCtx, s32 spawn);
s32 OTRScene_ExecuteCommands(GlobalContext* globalCtx, Ship::Scene* sceneCmd);
//Ship::OTRResource* OTRGameplay_LoadFile(GlobalContext* globalCtx, RomFile* file) {
Ship::Resource* OTRGameplay_LoadFile(GlobalContext* globalCtx, const char* fileName)
Ship::Resource* OTRGameplay_LoadFile(GlobalContext* globalCtx, const char* fileName)
{
auto res = OTRGlobals::Instance->context->GetResourceManager()->LoadResource(fileName);
return res.get();
@ -28,7 +28,7 @@ extern "C" void OTRGameplay_SpawnScene(GlobalContext* globalCtx, s32 sceneNum, s
//osSyncPrintf("\nSCENE SIZE %fK\n", (scene->sceneFile.vromEnd - scene->sceneFile.vromStart) / 1024.0f);
std::string scenePath = StringHelper::Sprintf("scenes\\%s\\%s", scene->sceneFile.fileName, scene->sceneFile.fileName);
std::string scenePath = StringHelper::Sprintf("scenes/%s/%s", scene->sceneFile.fileName, scene->sceneFile.fileName);
globalCtx->sceneSegment = (Ship::Scene*)OTRGameplay_LoadFile(globalCtx, scenePath.c_str());
@ -47,7 +47,7 @@ extern "C" void OTRGameplay_SpawnScene(GlobalContext* globalCtx, s32 sceneNum, s
//gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment);
OTRGameplay_InitScene(globalCtx, spawn);
osSyncPrintf("ROOM SIZE=%fK\n", func_80096FE8(globalCtx, &globalCtx->roomCtx) / 1024.0f);
}
@ -72,7 +72,7 @@ void OTRGameplay_InitScene(GlobalContext* globalCtx, s32 spawn) {
->GetResourceManager()
->LoadResource("object_link_child\\object_link_childVtx_01FE08")
.get());
auto data2 = ResourceMgr_LoadVtxByCRC(0x68d4ea06044e228f);*/
volatile int a = 0;

View file

@ -72,7 +72,7 @@ bool func_800985DC(GlobalContext* globalCtx, Ship::SceneCommand* cmd) {
else
{
ActorEntry* entries = (ActorEntry*)malloc(cmdActor->entries.size() * sizeof(ActorEntry));
for (int i = 0; i < cmdActor->entries.size(); i++)
{
entries[i].id = cmdActor->entries[i].actorNum;
@ -241,7 +241,7 @@ bool func_800987F8(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
globalCtx->setupEntranceList[i].room = otrEntrance->entrances[i].roomToLoad;
globalCtx->setupEntranceList[i].spawn = otrEntrance->entrances[i].startPositionIndex;
}
otrEntrance->cachedGameData = globalCtx->setupEntranceList;
}
@ -252,11 +252,11 @@ bool func_800987F8(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool func_8009883C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetSpecialObjects* otrSpecial = (Ship::SetSpecialObjects*)cmd;
if (otrSpecial->globalObject != 0)
globalCtx->objectCtx.subKeepIndex = Object_Spawn(&globalCtx->objectCtx, otrSpecial->globalObject);
if (otrSpecial->elfMessage != 0)
if (otrSpecial->elfMessage != 0)
{
auto res = (Ship::Blob*)OTRGameplay_LoadFile(globalCtx, sNaviMsgFiles[otrSpecial->elfMessage - 1].fileName);
globalCtx->cUpElfMsgs = (ElfMessage*)res->data.data();
@ -436,7 +436,7 @@ extern "C" void* func_800982FC(ObjectContext * objectCtx, s32 bankIndex, s16 obj
bool func_8009899C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetObjectList* cmdObj = (Ship::SetObjectList*)cmd;
s32 i;
s32 j;
s32 k;
@ -743,7 +743,7 @@ bool func_8009918C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
}
// Scene Command 0x18: Alternate Headers
bool func_800991A0(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool func_800991A0(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetAlternateHeaders* cmdHeaders = (Ship::SetAlternateHeaders*)cmd;
@ -754,7 +754,7 @@ bool func_800991A0(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
//osSyncPrintf("\n[ZU]sceneset time =[%X]", ((void)0, gSaveContext.cutsceneIndex));
//osSyncPrintf("\n[ZU]sceneset counter=[%X]", ((void)0, gSaveContext.sceneSetupIndex));
if (gSaveContext.sceneSetupIndex != 0)
if (gSaveContext.sceneSetupIndex != 0)
{
std::string desiredHeader = cmdHeaders->headers[gSaveContext.sceneSetupIndex - 1];
Ship::Scene* headerData = nullptr;
@ -798,7 +798,7 @@ bool func_800991A0(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
}
// Scene Command 0x17: Cutscene Data
bool func_8009934C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool func_8009934C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetCutscenes* cmdCS = (Ship::SetCutscenes*)cmd;
@ -810,7 +810,7 @@ bool func_8009934C(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
}
// Scene Command 0x19: Misc. Settings (Camera & World Map Area)
bool func_800993C0(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
bool func_800993C0(GlobalContext* globalCtx, Ship::SceneCommand* cmd)
{
Ship::SetCameraSettings* cmdCam = (Ship::SetCameraSettings*)cmd;

View file

@ -246,7 +246,7 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) {
retry:
case ADSR_STATE_LOOP:
adsr->delay = (s16)_byteswap_ushort(adsr->envelope[adsr->envIndex].delay);
adsr->delay = (s16)BOMSWAP16(adsr->envelope[adsr->envIndex].delay);
switch (adsr->delay) {
case ADSR_DISABLE:
adsr->action.s.state = ADSR_STATE_DISABLED;
@ -255,7 +255,7 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) {
adsr->action.s.state = ADSR_STATE_HANG;
break;
case ADSR_GOTO:
adsr->envIndex = (s16)_byteswap_ushort(adsr->envelope[adsr->envIndex].arg);
adsr->envIndex = (s16)BOMSWAP16(adsr->envelope[adsr->envIndex].arg);
goto retry;
case ADSR_RESTART:
adsr->action.s.state = ADSR_STATE_INITIAL;
@ -266,7 +266,7 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) {
if (adsr->delay == 0) {
adsr->delay = 1;
}
adsr->target = (s16)_byteswap_ushort(adsr->envelope[adsr->envIndex].arg) / 32767.0f;
adsr->target = (s16)BOMSWAP16(adsr->envelope[adsr->envIndex].arg) / 32767.0f;
adsr->target = adsr->target * adsr->target;
adsr->velocity = (adsr->target - adsr->current) / adsr->delay;
adsr->action.s.state = ADSR_STATE_FADE;

View file

@ -1058,7 +1058,7 @@ void AudioLoad_InitSwapFontSampleHeaders(SoundFontSample* sample, uintptr_t romA
size_t maxSoundFontSize = 0x3AA0; // soundFont 0 is the largest size at 0x3AA0
AdpcmLoop* loop;
AdpcmBook* book;
if (((uintptr_t)sample->loop > maxSoundFontSize) || ((uintptr_t)sample->book > maxSoundFontSize) ) {
bswapSoundFontSample(sample);
@ -1093,7 +1093,7 @@ void AudioLoad_InitSwapFont(void) {
SoundFontSound* sfxList;
SoundFontSound* sfx;
Instrument** instList;
Instrument* inst;
Instrument* inst;
// Only up to (numFonts - 1) as final font has garbage data to prevent corruption and is never used
for (fontId = 0; fontId < (numFonts - 1); fontId++) {
@ -1110,12 +1110,12 @@ void AudioLoad_InitSwapFont(void) {
numInstruments = font->numInstruments;
// drums
ptrs[0] = (void*)_byteswap_ulong((uintptr_t)ptrs[0]);
ptrs[0] = (void*)BOMSWAP32((uintptr_t)ptrs[0]);
if ((ptrs[0] != NULL) && (numDrums != 0)) {
drumList = (Drum**)BASE_ROM_OFFSET(ptrs[0]);
for (i = 0; i < numDrums; i++) {
drumList[i] = (Drum*)_byteswap_ulong((uintptr_t)drumList[i]);
drumList[i] = (Drum*)BOMSWAP32((uintptr_t)drumList[i]);
if (drumList[i] != NULL) {
drum = (Drum*)BASE_ROM_OFFSET(drumList[i]);
@ -1128,7 +1128,7 @@ void AudioLoad_InitSwapFont(void) {
}
// sfxs
ptrs[1] = (void*)_byteswap_ulong((u32)ptrs[1]);
ptrs[1] = (void*)BOMSWAP32((u32)ptrs[1]);
if ((ptrs[1] != NULL) && (numSfxs != 0)) {
sfxList = (SoundFontSound*)BASE_ROM_OFFSET(ptrs[1]);
@ -1151,7 +1151,7 @@ void AudioLoad_InitSwapFont(void) {
instList = (Instrument**)(&ptrs[2]);
for (i = 0; i < numInstruments; i++) {
instList[i] = (Instrument*)_byteswap_ulong((uintptr_t)instList[i]);
instList[i] = (Instrument*)BOMSWAP32((uintptr_t)instList[i]);
if (instList[i] != NULL) {
inst = BASE_ROM_OFFSET(instList[i]);
@ -1159,15 +1159,15 @@ void AudioLoad_InitSwapFont(void) {
if (inst->normalRangeLo != 0) {
sample = (SoundFontSample*)BASE_ROM_OFFSET(inst->lowNotesSound.sample);
AudioLoad_InitSwapFontSampleHeaders(sample, romAddr);
AudioLoad_InitSwapFontSampleHeaders(sample, romAddr);
}
sample = (SoundFontSample*)BASE_ROM_OFFSET(inst->normalNotesSound.sample);
AudioLoad_InitSwapFontSampleHeaders(sample, romAddr);
AudioLoad_InitSwapFontSampleHeaders(sample, romAddr);
if (inst->normalRangeHi != 0x7F) {
sample = (SoundFontSample*)BASE_ROM_OFFSET(inst->highNotesSound.sample);
AudioLoad_InitSwapFontSampleHeaders(sample, romAddr);
AudioLoad_InitSwapFontSampleHeaders(sample, romAddr);
}
}
}

View file

@ -1323,14 +1323,14 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
case 0xB2:
offset = (u16)parameters[0];
// OTRTODO: Byteswap added for quick audio
channel->unk_22 = _byteswap_ushort(*(u16*)(seqPlayer->seqData + (uintptr_t)(offset + scriptState->value * 2)));
channel->unk_22 = BOMSWAP16(*(u16*)(seqPlayer->seqData + (uintptr_t)(offset + scriptState->value * 2)));
break;
case 0xB4:
channel->dynTable = (void*)&seqPlayer->seqData[channel->unk_22];
break;
case 0xB5:
// OTRTODO: Byteswap added for quick audio
channel->unk_22 = _byteswap_ushort(((u16*)(channel->dynTable))[scriptState->value]);
channel->unk_22 = BOMSWAP16(((u16*)(channel->dynTable))[scriptState->value]);
break;
case 0xB6:
scriptState->value = (*channel->dynTable)[0][scriptState->value];

View file

@ -1162,7 +1162,7 @@ Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisS
if (temp_v0 < nSamplesToLoad) {
repeats = ((nSamplesToLoad - temp_v0 + 0x3F) / 0x40);
if (repeats != 0) {
aDuplicate(cmd++, repeats, DMEM_UNCOMPRESSED_NOTE, DMEM_UNCOMPRESSED_NOTE + 0x80, 0x80);
aDuplicate(cmd++, repeats, DMEM_UNCOMPRESSED_NOTE, DMEM_UNCOMPRESSED_NOTE + 0x80);
}
}
synthState->samplePosInt = samplePosInt;
@ -1225,6 +1225,6 @@ Acmd* AudioSynth_NoteApplyHeadsetPanEffects(Acmd* cmd, NoteSubEu* noteSubEu, Not
aSaveBuffer(cmd++, DMEM_NOTE_PAN_TEMP + bufLen, &synthState->synthesisBuffers->panResampleState[0x8],
ALIGN16(panShift));
}
aAddMixer(cmd++, ALIGN64(bufLen), DMEM_NOTE_PAN_TEMP, dest, 0x7FFF);
aAddMixer(cmd++, ALIGN64(bufLen), DMEM_NOTE_PAN_TEMP, dest);
return cmd;
}

View file

@ -3,7 +3,9 @@
//#include <string.h>
#ifdef _MSC_VER
extern void* __cdecl memset(_Out_writes_bytes_all_(_Size) void* _Dst, _In_ int _Val, _In_ size_t _Size);
#endif
s32 D_8012D280 = 1;

View file

@ -7,13 +7,13 @@
#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h"
#include "objects/object_bdoor/object_bdoor.h"
#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(__GNUC__)
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#endif
#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(__GNUC__)
#include "textures/place_title_cards/g_pn_49.h"
#include "textures/place_title_cards/g_pn_01.h"
#include "textures/place_title_cards/g_pn_02.h"
@ -765,7 +765,7 @@ void TitleCard_InitBossName(GlobalContext* globalCtx, TitleCardContext* titleCtx
titleCtx->texture = texture;
titleCtx->isBossCard = true;
titleCtx->hasTranslation = hasTranslation;
titleCtx->hasTranslation = hasTranslation;
titleCtx->x = x;
titleCtx->y = y;
titleCtx->width = width;
@ -774,7 +774,7 @@ void TitleCard_InitBossName(GlobalContext* globalCtx, TitleCardContext* titleCtx
titleCtx->delayTimer = 0;
}
void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCtx, char* texture, s32 x, s32 y,
void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCtx, void* texture, s32 x, s32 y,
s32 width, s32 height, s32 delay) {
SceneTableEntry* loadedScene = globalCtx->loadedScene;
@ -4272,8 +4272,6 @@ s32 func_80035124(Actor* actor, GlobalContext* globalCtx) {
return ret;
}
#include "z_cheap_proc.c"
u8 func_800353E8(GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);

View file

@ -4031,7 +4031,7 @@ s32 func_80041E4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
/**
* unused
*/
u32 func_80041E80(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
s32 func_80041E80(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF;
}

View file

@ -26,7 +26,7 @@ s32 Camera_CheckWater(Camera* camera);
#define FLG_ADJSLOPE (1 << 0)
#define FLG_OFFGROUND (1 << 7)
#include "z_camera_data.c"
#include "z_camera_data.inc"
/*===============================================================*/

View file

@ -2105,7 +2105,7 @@ void Cutscene_HandleConditionalTriggers(GlobalContext* globalCtx) {
}
void Cutscene_SetSegment(GlobalContext* globalCtx, void* segment) {
if (SEGMENT_NUMBER(segment) != 0)
if (SEGMENT_NUMBER(segment) != 0)
{
globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(segment);
} else {

View file

@ -19,9 +19,9 @@ Gfx __sCircleDList[] = {
G_AC_NONE | G_ZS_PIXEL | G_RM_XLU_SURF | G_RM_XLU_SURF2), // 4
gsDPSetCombineMode(G_CC_BLENDPEDECALA, G_CC_BLENDPEDECALA), // 5
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), // 6
gsDPLoadTextureBlock(0xF8000000, G_IM_FMT_I, G_IM_SIZ_8b, 16, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, // 7
gsDPLoadTextureBlock(SEG_ADDR(8, 0), G_IM_FMT_I, G_IM_SIZ_8b, 16, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, // 7
G_TX_NOMIRROR | G_TX_CLAMP, 4, 6, G_TX_NOLOD, G_TX_NOLOD),
gsSPDisplayList(0xF9000000), // 8
gsSPDisplayList(SEG_ADDR(9, 0)), // 8
gsSPVertex(sCircleWipeVtx, 32, 0), // 9
gsSP2Triangles(0, 1, 2, 0, 1, 3, 4, 0), // 10
gsSP2Triangles(3, 5, 6, 0, 5, 7, 8, 0), // 11

View file

@ -654,7 +654,7 @@ u8 sEyeMouthIndexes[][2] = {
* from adult Link's object are used here.
*/
#if defined(MODDING) || (_MSC_VER)
#if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__)
//TODO: Formatting
void* sEyeTextures[2][8] = {
{ gLinkAdultEyesOpenTex, gLinkAdultEyesHalfTex, gLinkAdultEyesClosedfTex, gLinkAdultEyesRollLeftTex,
@ -670,7 +670,7 @@ void* sEyeTextures[] = {
};
#endif
#if defined(modding) || defined(_MSC_VER)
#if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__)
void* sMouthTextures[2][4] = {
{
gLinkAdultMouth1Tex,
@ -726,7 +726,7 @@ void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable,
if (eyeIndex > 7)
eyeIndex = 7;
#if defined(MODDING) || (_MSC_VER)
#if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__)
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[gSaveContext.linkAge][eyeIndex]));
#else
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[eyeIndex]));
@ -738,7 +738,7 @@ void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable,
if (mouthIndex > 3)
mouthIndex = 3;
#if defined(MODDING) || (_MSC_VER)
#if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__)
gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[gSaveContext.linkAge][mouthIndex]));
#else
gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[eyeIndex]));

View file

@ -863,7 +863,7 @@ void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader
char animPath[2048];
sprintf(animPath, "misc\\link_animetion\\gPlayerAnimData_%06X", (((uintptr_t)linkAnimHeader->segment - 0x07000000)));
sprintf(animPath, "misc/link_animetion/gPlayerAnimData_%06X", (((uintptr_t)linkAnimHeader->segment - 0x07000000)));
//printf("Streaming %s, seg = %08X\n", animPath, linkAnimHeader->segment);
@ -877,7 +877,7 @@ void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader
{
ramPtr[i] = i * 7;
}*/
//DmaMgr_SendRequest2(&entry->data.load.req, ram,
//LINK_ANIMATION_OFFSET(linkAnimHeader->segment, ((sizeof(Vec3s) * limbCount + 2) * frame)),

View file

@ -42,7 +42,7 @@ Gfx* VisMono_DrawTexture(VisMono* this, Gfx* gfx)
s32 y;
s32 height = 3;
//u16* tex = D_0F000000;
u16* tex = 0xFF000000;
u16* tex = SEG_ADDR(0xF, 0);
gDPPipeSync(gfx++);
gDPSetOtherMode(gfx++,

View file

@ -210,7 +210,7 @@ static Vec3f sAudioVec = { 0.0f, 0.0f, 50.0f };
// OTRTODO: This code appears to cause the game to gradually crash...
// Might be an OoB write. For now it's disabled.
void BossGanondrof_ClearPixels8x8(s16* texture, u8* mask, s16 index)
void BossGanondrof_ClearPixels8x8(s16* texture, u8* mask, s16 index)
{
//texture = ResourceMgr_LoadTexByName(texture);
if (mask[index]) {
@ -248,18 +248,18 @@ void BossGanondrof_ClearPixels32x16(s16* texture, u8* mask, s16 index) {
}
}
void BossGanondrof_ClearPixels16x32(s16* texture, u8* mask, s16 index) {
void BossGanondrof_ClearPixels16x32(s16* texture, u8* mask, s16 index) {
//texture = ResourceMgr_LoadTexByName(texture);
if (mask[index]) {
s16 i = ((index & 0xF) * 2) + ((index & 0xF0) * 2);
ResourceMgr_WriteTexS16ByName(texture, i + 1, 0);
ResourceMgr_WriteTexS16ByName(texture, i, 0);
//texture[i + 1] = 0;
//texture[i] = 0;
}
}
void BossGanondrof_ClearPixels(u8* mask, s16 index) {

View file

@ -1505,9 +1505,9 @@ void FileChoose_LoadGame(GameState* thisx) {
(gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KNIFE)) {
gSaveContext.equips.buttonItems[0] = ITEM_NONE;
swordEquipMask = _byteswap_ushort(gEquipMasks[EQUIP_SWORD]) & gSaveContext.equips.equipment;
swordEquipMask = BOMSWAP16(gEquipMasks[EQUIP_SWORD]) & gSaveContext.equips.equipment;
gSaveContext.equips.equipment &= gEquipNegMasks[EQUIP_SWORD];
gSaveContext.inventory.equipment ^= (gBitFlags[swordEquipMask - 1] << _byteswap_ushort(gEquipShifts[EQUIP_SWORD]));
gSaveContext.inventory.equipment ^= (gBitFlags[swordEquipMask - 1] << BOMSWAP16(gEquipShifts[EQUIP_SWORD]));
}
}
}

View file

@ -624,10 +624,10 @@ void Select_Init(GameState* thisx) {
this->pageDownIndex = dREG(82);
}
R_UPDATE_RATE = 1;
#ifndef _MSC_VER
#if !defined(_MSC_VER) && !defined(__GNUC__)
this->staticSegment = GameState_Alloc(&this->state, size, "../z_select.c", 1114);
DmaMgr_SendRequest1(this->staticSegment, _z_select_staticSegmentRomStart, size, "../z_select.c", 1115);
#endif
#endif
gSaveContext.cutsceneIndex = 0x8000;
gSaveContext.linkAge = 1;
}

View file

@ -34,7 +34,7 @@ void Title_PrintBuildInfo(Gfx** gfxp) {
#ifdef _MSC_VER
GfxPrint_Printf(&printer, "MSVC SHIP");
#else
GfxPrint_Printf(printer, "GCC SHIP");
GfxPrint_Printf(&printer, "GCC SHIP");
#endif
GfxPrint_SetPos(&printer, 5, 4);

View file

@ -119,7 +119,7 @@ void KaleidoScope_DrawPlayerWork(GlobalContext* globalCtx) {
func_8009214C(globalCtx, pauseCtx->playerSegment, &pauseCtx->playerSkelAnime, &pos, &rot, scale,
CUR_EQUIP_VALUE(EQUIP_SWORD), CUR_EQUIP_VALUE(EQUIP_TUNIC) - 1, CUR_EQUIP_VALUE(EQUIP_SHIELD),
CUR_EQUIP_VALUE(EQUIP_BOOTS) - 1);
gsSPResetFB(globalCtx->state.gfxCtx->polyOpa.p++, fbTest);
gsSPResetFB(globalCtx->state.gfxCtx->polyOpa.p++);
}
void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) {