Skip to content

Commit

Permalink
sync with master again
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Oct 8, 2023
1 parent 201b4c1 commit 7aba626
Show file tree
Hide file tree
Showing 28 changed files with 898 additions and 144 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_ps3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
id: compile
run: |
pacman -S make --noconfirm
export PSL1GHT=/usr/local/ps3dev
export PS3DEV=/usr/local/ps3dev
make ps3
Expand Down
2 changes: 1 addition & 1 deletion misc/dreamcast/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BUILD_DIR := build-dreamcast
SOURCE_DIRS := src
SOURCE_DIRS := src third_party/bearssl/src

C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o)))
Expand Down
6 changes: 4 additions & 2 deletions misc/vita/colored_alpha_f.cg
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
float4 main(
float4 out_color: COLOR) : COLOR
float4 main
(
float4 out_color: COLOR
) : COLOR
{
if (out_color.a < 0.5) discard;

Expand Down
6 changes: 4 additions & 2 deletions misc/vita/colored_f.cg
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
float4 main(
float4 out_color: COLOR) : COLOR
float4 main
(
float4 out_color : COLOR
) : COLOR
{
return out_color;
}
8 changes: 5 additions & 3 deletions misc/vita/textured_alpha_f.cg
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
float4 main(
float4 main
(
uniform sampler2D tex,
float4 out_color: COLOR,
float2 out_texcoord : TEXCOORD0) : COLOR
float4 out_color : COLOR,
float2 out_texcoord : TEXCOORD0
) : COLOR
{
float4 color = tex2D(tex, out_texcoord) * out_color;

Expand Down
8 changes: 5 additions & 3 deletions misc/vita/textured_f.cg
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
float4 main(
float4 main
(
uniform sampler2D tex,
float4 out_color: COLOR,
float2 out_texcoord : TEXCOORD0) : COLOR
float4 out_color : COLOR,
float2 out_texcoord : TEXCOORD0
) : COLOR
{
return tex2D(tex, out_texcoord) * out_color;
}
3 changes: 2 additions & 1 deletion misc/xbox/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ endif

XBE_TITLE = ClassiCube
GEN_XISO = ClassiCube-xbox.iso
SRCS = $(wildcard src/*.c)
SRCS = $(wildcard src/*.c) $(wildcard third_party/bearssl/src/*.c)
SHADER_OBJS = misc/xbox/vs_coloured.inl misc/xbox/vs_textured.inl misc/xbox/ps_coloured.inl misc/xbox/ps_textured.inl
NXDK_NET = y
NXDK_CFLAGS = -Ithird_party/bearssl/inc
NXDK_LDFLAGS = -stack:131072

include $(NXDK_DIR)/Makefile
117 changes: 117 additions & 0 deletions misc/xbox360/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:

#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITXENON)),)
$(error "Please set DEVKITXENON in your environment. export DEVKITXENON=<path to>devkitPPC")
endif

#---------------------------------------------------------------------------------
export LIBXENON_INC := $(DEVKITXENON)/usr/include
export LIBXENON_LIB := $(DEVKITXENON)/usr/lib
LDSCRIPT := $(DEVKITXENON)/app.lds

MACHDEP = -DXENON -m32 -maltivec -fno-pic -mpowerpc64 -mhard-float -L$(DEVKITXENON)/xenon/lib/32

export AS := xenon-as
export CC := xenon-gcc
export CXX := xenon-g++
export AR := xenon-ar


#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := ClassiCube-xbox360
BUILD := build
SOURCES := src

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------

CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
CXXFLAGS= $(CFLAGS)

LDFLAGS = -g $(MACHDEP) -Wl,--gc-sections -Wl,-Map,$(notdir $@).map

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lxenon -lm

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)

export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))

export DEPSDIR := $(CURDIR)/$(BUILD)

#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))

export LD := $(CC)
export OFILES := $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)

#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := -I$(LIBXENON_INC)

#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := -L$(LIBXENON_LIB)

export OUTPUT := $(CURDIR)/$(TARGET)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).elf32: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)

default: $(BUILD) $(OUTPUT).elf32
cp $(OUTPUT).elf32 /tftpboot/xenon
xenon-strip /tftpboot/xenon


#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@

#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).elf32

#---------------------------------------------------------------------------------
%.o: %.c
@$(CC) $(CFLAGS) -c $< -o $@

%.o: %.s
@$(CC) -x assembler-with-cpp $(ASFLAGS) -c $< -o $@

%.o: %.S
@$(CC) -x assembler-with-cpp $(ASFLAGS) -c $< -o $@

%.elf:
@echo linking ... $(notdir $@)
@$(LD) $^ $(LDFLAGS) $(LIBPATHS) $(LIBS) -n -T $(LDSCRIPT) -o $@

%.elf32: %.elf
@echo converting and stripping ... $(notdir $@)
@xenon-objcopy -O elf32-powerpc --adjust-vma 0x80000000 $< $@
@xenon-strip $@
4 changes: 2 additions & 2 deletions src/Animations.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static void LavaAnimation_Tick(void) {

size = min(Atlas2D.TileSize, LIQUID_ANIM_MAX);
mask = size - 1;
shift = Math_Log2(size);
shift = Math_ilog2(size);

if (!L_rndInited) {
Random_SeedFromCurrentTime(&L_rnd);
Expand Down Expand Up @@ -122,7 +122,7 @@ static void WaterAnimation_Tick(void) {

size = min(Atlas2D.TileSize, LIQUID_ANIM_MAX);
mask = size - 1;
shift = Math_Log2(size);
shift = Math_ilog2(size);

if (!W_rndInited) {
Random_SeedFromCurrentTime(&W_rnd);
Expand Down
6 changes: 3 additions & 3 deletions src/Audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1142,8 +1142,8 @@ static void Sounds_Play(cc_uint8 type, struct Soundboard* board) {
data.rate = 100;
data.volume = Audio_SoundsVolume;

/* https://minecraft.fandom.com/wiki/Block_of_Gold#Sounds */
/* https://minecraft.fandom.com/wiki/Grass#Sounds */
/* https://minecraft.wiki/w/Block_of_Gold#Sounds */
/* https://minecraft.wiki/w/Grass#Sounds */
if (board == &digBoard) {
if (type == SOUND_METAL) data.rate = 120;
else data.rate = 80;
Expand Down Expand Up @@ -1523,4 +1523,4 @@ static void OnFree(void) {
struct IGameComponent Audio_Component = {
OnInit, /* Init */
OnFree /* Free */
};
};
7 changes: 4 additions & 3 deletions src/Bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ cc_result Png_Decode(struct Bitmap* bmp, struct Stream* stream) {
cc_result res;

/* header variables */
static cc_uint32 samplesPerPixel[7] = { 1, 0, 3, 1, 2, 0, 4 };
static const cc_uint32 samplesPerPixel[7] = { 1, 0, 3, 1, 2, 0, 4 };
cc_uint8 col, bitsPerSample, bytesPerPixel;
Png_RowExpander rowExpander;
cc_uint32 scanlineSize, scanlineBytes;
Expand Down Expand Up @@ -395,7 +395,7 @@ cc_result Png_Decode(struct Bitmap* bmp, struct Stream* stream) {

bitsPerSample = tmp[8]; col = tmp[9];
rowExpander = Png_GetExpander(col, bitsPerSample);
if (rowExpander == NULL) return PNG_ERR_INVALID_COL_BPP;
if (!rowExpander) return PNG_ERR_INVALID_COL_BPP;

if (tmp[10] != 0) return PNG_ERR_COMP_METHOD;
if (tmp[11] != 0) return PNG_ERR_FILTER;
Expand Down Expand Up @@ -605,7 +605,8 @@ static void Png_MakeRow(const BitmapCol* src, cc_uint8* dst, int lineLen, cc_boo

static void Png_EncodeRow(const cc_uint8* cur, const cc_uint8* prior, cc_uint8* best, int lineLen, cc_bool alpha) {
cc_uint8* dst;
int bestFilter, bestEstimate = Int32_MaxValue;
int bestFilter = PNG_FILTER_SUB;
int bestEstimate = Int32_MaxValue;
int x, filter, estimate;

dst = best + 1;
Expand Down
2 changes: 0 additions & 2 deletions src/Chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,6 @@ static struct ChatCommand TeleportCommand = {
*------------------------------------------------------BlockEditCommand----------------------------------------------------*
*#########################################################################################################################*/
static cc_bool BlockEditCommand_GetInt(const cc_string* str, const char* name, int* value, int min, int max) {
int maxTexs = ATLAS1D_MAX_ATLASES;

if (!Convert_ParseInt(str, value)) {
Chat_Add1("&eBlockEdit: &e%c must be an integer", name);
return false;
Expand Down
10 changes: 6 additions & 4 deletions src/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ typedef cc_uint8 cc_bool;
#define CC_BUILD_NOSOUNDS
#define CC_BUILD_LOWMEM
#define CC_BUILD_HTTPCLIENT
#define CC_BUILD_BEARSSL
#undef CC_BUILD_FREETYPE
#elif defined XENON
/* libxenon also defines __linux__ (yes, really) */
Expand Down Expand Up @@ -266,29 +267,29 @@ typedef cc_uint8 cc_bool;
#define CC_BUILD_HTTPCLIENT
#define CC_BUILD_OPENAL
#define CC_BUILD_PSP
#define CC_BUILD_BEARSSL
#define CC_BUILD_LOWMEM
#define CC_BUILD_BEARSSL
#undef CC_BUILD_FREETYPE
#elif defined __3DS__
#define CC_BUILD_HTTPCLIENT
#define CC_BUILD_OPENAL
#define CC_BUILD_3DS
#define CC_BUILD_BEARSSL
#define CC_BUILD_LOWMEM
#define CC_BUILD_BEARSSL
#undef CC_BUILD_FREETYPE
#elif defined GEKKO
#define CC_BUILD_HTTPCLIENT
#define CC_BUILD_OPENAL
#define CC_BUILD_GCWII
#define CC_BUILD_BEARSSL
#define CC_BUILD_LOWMEM
#define CC_BUILD_BEARSSL
#undef CC_BUILD_FREETYPE
#elif defined __vita__
#define CC_BUILD_HTTPCLIENT
#define CC_BUILD_OPENAL
#define CC_BUILD_PSVITA
#define CC_BUILD_BEARSSL
#define CC_BUILD_LOWMEM
#define CC_BUILD_BEARSSL
#undef CC_BUILD_FREETYPE
#elif defined _arch_dreamcast
#define CC_BUILD_HTTPCLIENT
Expand All @@ -301,6 +302,7 @@ typedef cc_uint8 cc_bool;
#define CC_BUILD_OPENAL
#define CC_BUILD_PS3
#define CC_BUILD_LOWMEM
#define CC_BUILD_BEARSSL
#undef CC_BUILD_FREETYPE
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/EntityComponents.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ static double PhysicsComp_YPosAt(int t, float u) {
/* x(t, u) = Σv(t, u) from 0 to t (since we work in discrete timesteps) */
/* plugging into Wolfram Alpha gives 1 equation as */
/* (0.98^t) * (-49u - 196) - 4t + 50u + 196 */
double a = Math_Exp(-0.0202027 * t); /* ~0.98^t */
double a = Math_Exp2(-0.02914633510256746 * t); /* ~0.98^t */
return a * (-49 * u - 196) - 4 * t + 50 * u + 196;
}

Expand Down
Loading

0 comments on commit 7aba626

Please sign in to comment.