Header cleanup, NONMATCHING option

This commit is contained in:
Luke Street 2022-08-31 20:22:20 -04:00
parent 3e43c0878f
commit 174a2d98f7
7 changed files with 24 additions and 60 deletions

View File

@ -11,6 +11,9 @@ VERBOSE ?= 0
# If GENERATE_MAP set to 1, tells LDFLAGS to generate a mapfile, which makes linking take several minutes.
GENERATE_MAP ?= 0
# Enable non-matching code & various fixes
NONMATCHING ?= 0
ifeq ($(VERBOSE),0)
QUIET := @
endif
@ -111,7 +114,7 @@ ifeq ($(VERBOSE),0)
# this set of LDFLAGS generates no warnings.
LDFLAGS := $(MAPGEN) -fp fmadd -nodefaults -w off
endif
DEFINES = -DPRIME1 -DVERSION=$(VERSION_NUM)
DEFINES = -DPRIME1 -DVERSION=$(VERSION_NUM) -DNONMATCHING=$(NONMATCHING)
CFLAGS_BASE = -proc gekko -nodefaults -Cpp_exceptions off -RTTI off -fp hard -fp_contract on -O4,p -maxerrors 1 -enum int -inline auto -str reuse -nosyspath -MMD $(DEFINES) $(INCLUDES)
CFLAGS = $(CFLAGS_BASE) -use_lmw_stmw on -str reuse,pool,readonly -gccinc -inline deferred,noauto -common on
CFLAGS_RUNTIME = $(CFLAGS_BASE) -use_lmw_stmw on -str reuse,pool,readonly -gccinc -inline deferred,auto

View File

@ -143,7 +143,7 @@ private:
static const GXColor black = {0, 0, 0, 0};
GXSetFog(static_cast< GXFogType >(sGXState.x53_fogType), sGXState.x24c_fogParams.x0_fogStartZ, sGXState.x24c_fogParams.x4_fogEndZ,
sGXState.x24c_fogParams.x8_fogNearZ, sGXState.x24c_fogParams.xc_fogFarZ,
(sGXState.x56_blendMode & 0xE0) == 0x20 ? black : sGXState.x24c_fogParams.x10_fogColor);
(sGXState.x56_blendMode & (7 << 5)) == (GX_BL_ONE << 5) ? black : sGXState.x24c_fogParams.x10_fogColor);
}
static SGXState sGXState;

View File

@ -1,12 +1,15 @@
#ifndef _DOLPHIN_OS_H
#define _DOLPHIN_OS_H
#include "types.h"
#include <dolphin/types.h>
#ifdef __cplusplus
extern "C" {
#endif
// TODO OSInerrupt.h
typedef s16 __OSInterrupt;
// Upper words of the masks, since UIMM is only 16 bits
#define OS_CACHED_REGION_PREFIX 0x8000
#define OS_UNCACHED_REGION_PREFIX 0xC000
@ -20,6 +23,8 @@ extern "C" {
#else
#define AT_ADDRESS
#endif
typedef s64 OSTime;
typedef u32 OSTick;
u32 __OSBusClock AT_ADDRESS(OS_BASE_CACHED | 0x00F8); // sync with OSLoMem.h
u32 __OSCoreClock AT_ADDRESS(OS_BASE_CACHED | 0x00FC); // sync with OSLoMem.h
#define OS_BUS_CLOCK __OSBusClock

View File

@ -64,10 +64,13 @@ typedef int BOOL;
#define NULL 0
#endif
#endif
#ifndef __cplusplus
#if !defined(__cplusplus) || defined(__MWERKS__)
#ifndef nullptr
#define nullptr NULL
#endif
#ifndef override
#define override
#endif
#endif
#ifndef ATTRIBUTE_ALIGN

View File

@ -7,65 +7,11 @@
extern "C" {
#endif
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef signed char s8;
typedef signed short s16;
typedef signed int s32;
typedef signed long long s64;
typedef volatile u8 vu8;
typedef volatile u16 vu16;
typedef volatile u32 vu32;
typedef volatile u64 vu64;
typedef volatile s8 vs8;
typedef volatile s16 vs16;
typedef volatile s32 vs32;
typedef volatile s64 vs64;
typedef float f32;
typedef double f64;
typedef volatile float vf32;
typedef volatile double vf64;
typedef s16 __OSInterrupt;
typedef s64 OSTime;
typedef u32 OSTick;
#include <dolphin/types.h>
// Pointer to unknown, to be determined at a later date.
typedef void* unkptr;
#ifndef NULL
#define NULL 0
#endif
#ifndef nullptr
#define nullptr 0
#endif
#ifndef override
#define override
#endif
typedef int BOOL;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef ATTRIBUTE_ALIGN
#define ATTRIBUTE_ALIGN(num) __attribute__ ((aligned (num)))
#endif
// where should these go?
void srand(int);
int rand();
#ifdef __cplusplus
}
#endif

View File

@ -6,7 +6,12 @@
CGX::SGXState CGX::sGXState;
#if NONMATCHING
// Doesn't need to be so big
static GXVtxDescList sVtxDescList[12];
#else
static GXVtxDescList sVtxDescList[30];
#endif
void CGX::SetNumChans(u8 num) {
sGXState.x4e_numChans = num;
@ -198,7 +203,7 @@ void CGX::SetTexCoordGen(GXTexCoordID dstCoord, GXTexGenType fn, GXTexGenSrc src
STexState& state = sGXState.x228_texStates[dstCoord];
u32 vm = (mtx - GX_TEXMTX0) / 3;
u32 vp = postMtx - GX_PTTEXMTX0;
#ifdef NONMATCHING
#if NONMATCHING
// Similarly to GXTexMtx, this should also be divided by 3
vp /= 3;
#endif
@ -442,6 +447,7 @@ void CGX::SetStandardDirectTev_Compressed(GXTevStageID stageId, u32 colorArgs, u
SetTevColorOp_Compressed(stageId, colorOps);
SetTevAlphaOp_Compressed(stageId, alphaOps);
} else if (colorOps != state.x8_colorOps || colorOps != state.xc_alphaOps) {
// Fast path for GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true
state.xc_alphaOps = colorOps;
state.x8_colorOps = colorOps;
GXTevRegID outReg = static_cast< GXTevRegID >(ShiftRightAndMask(colorOps, 3, 9));

View File

@ -296,4 +296,5 @@ void CActor::DrawTouchBounds() const {}
bool CActor::CanRenderUnsorted(const CStateManager& mgr) const {
// if (GetModelData()->IsNull() && )
return false;
}