diff --git a/misc/32x/Makefile b/misc/32x/Makefile index 0936c2ca1..cd9d5a617 100644 --- a/misc/32x/Makefile +++ b/misc/32x/Makefile @@ -14,12 +14,20 @@ SOURCE_DIRS = src src/32x misc/32x #--------------------------------------------------------------------------------- -# Code generation +# Compilable files #--------------------------------------------------------------------------------- C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) S_FILES = misc/32x/sh2_crt0.s OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.s=%.o))) +# Dependency tracking +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d +DEPFILES := $(OBJS:%.o=%.d) + + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- LDSCRIPTSDIR = $(ROOTDIR)/ldscripts LIBS = $(LIBPATH) -lc -lgcc -lgcc-Os-4-200 -lnosys @@ -44,10 +52,6 @@ MDPREFIX = $(ROOTDIR)/m68k-elf/bin/m68k-elf- MDAS = $(MDPREFIX)as MDLD = $(MDPREFIX)ld -# Dependency tracking -DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -DEPFILES := $(OBJS:%.o=%.d) - #--------------------------------------------------------------------------------- # main targets diff --git a/misc/3ds/Makefile b/misc/3ds/Makefile index 0aae01ae7..a134da5cc 100644 --- a/misc/3ds/Makefile +++ b/misc/3ds/Makefile @@ -12,8 +12,6 @@ TARGET = ClassiCube-3ds SOURCE_DIRS = src src/3ds third_party/bearssl # List of directories containing shader files SHDR_DIRS = misc/3ds -# List of directories containing more header files -INCLUDES = # Directory where object files are placed BUILD_DIR = build/3ds @@ -28,7 +26,7 @@ CIA_SPEC_RSF = misc/3ds/spec.rsf #--------------------------------------------------------------------------------- -# Code generation +# Compilable files #--------------------------------------------------------------------------------- S_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) @@ -37,20 +35,25 @@ OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o PICAFILES := $(foreach dir,$(SHDR_DIRS),$(notdir $(wildcard $(dir)/*.v.pica))) OBJS += $(addprefix $(BUILD_DIR)/, $(PICAFILES:.v.pica=.shbin.o)) +# Dependency tracking +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d +DEPFILES := $(OBJS:%.o=%.d) + + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- ARCH = -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft CFLAGS = -g -Wall -O2 -mword-relocations -ffunction-sections $(ARCH) $(INCLUDE) -D__3DS__ ASFLAGS = -g $(ARCH) LDFLAGS = -specs=3dsx.specs -g $(ARCH) LIBS = -lctru -lm +INCLUDES= CTRULIB = $(DEVKITPRO)/libctru INCLUDES += $(foreach dir, $(CTRULIB), -I$(dir)/include) -LDFLAGS += $(foreach dir, $(CTRULIB), -L$(dir)/lib) - -# Dependency tracking -DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -DEPFILES := $(OBJS:%.o=%.d) +LDFLAGS += $(foreach dir,$(CTRULIB), -L$(dir)/lib) #--------------------------------------------------------------------------------- diff --git a/misc/dreamcast/Makefile b/misc/dreamcast/Makefile index a0fd9607a..93ec9566e 100644 --- a/misc/dreamcast/Makefile +++ b/misc/dreamcast/Makefile @@ -14,27 +14,29 @@ BUILD_DIR := build/dc SOURCE_DIRS := src third_party/bearssl src/dreamcast # Name of the final output TARGET := ClassiCube-dc -# Additional libraries to link against -LIBS = -lm -lppp -lkosfat -# List of directories containing more header files -INCLUDES = #--------------------------------------------------------------------------------- -# Code generation +# Compilable files #--------------------------------------------------------------------------------- S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) -CFLAGS = -g -DNDEBUG -O3 -fipa-pta -fno-pie -flto=auto -fomit-frame-pointer -fbuiltin -ffast-math -ffp-contract=fast -mfsrra -mfsca -pipe -fno-math-errno -LDFLAGS = -g - # Dependency tracking DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d DEPFILES := $(OBJS:%.o=%.d) +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- +CFLAGS = -g -DNDEBUG -O3 -fipa-pta -fno-pie -flto=auto -fomit-frame-pointer -fbuiltin -ffast-math -ffp-contract=fast -mfsrra -mfsca -pipe -fno-math-errno +LDFLAGS = -g + +# Additional libraries to link against +LIBS = -lm -lppp -lkosfat + #--------------------------------------------------------------------------------- # Main targets #--------------------------------------------------------------------------------- @@ -80,13 +82,13 @@ $(TARGET).cdi: $(TARGET).iso # Object generation #--------------------------------------------------------------------------------- $(BUILD_DIR)/%.o: src/%.c - kos-cc $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@ + kos-cc $(CFLAGS) $(DEPFLAGS) -c $< -o $@ $(BUILD_DIR)/%.o: src/dreamcast/%.c - kos-cc $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@ + kos-cc $(CFLAGS) $(DEPFLAGS) -c $< -o $@ $(BUILD_DIR)/%.o: third_party/bearssl/%.c - kos-cc $(CFLAGS) $(INCLUDES) -c $< -o $@ + kos-cc $(CFLAGS) -c $< -o $@ $(BUILD_DIR)/%.o: src/dreamcast/%.S kos-cc $(DEPFLAGS) -c $< -o $@ diff --git a/misc/gba/Makefile b/misc/gba/Makefile index 7c604375f..fbfc70bfd 100644 --- a/misc/gba/Makefile +++ b/misc/gba/Makefile @@ -21,12 +21,20 @@ MAKER_CODE = 00 #--------------------------------------------------------------------------------- -# Code generation +# Compilable files #--------------------------------------------------------------------------------- S_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) +# Dependency tracking +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d +DEPFILES := $(OBJS:%.o=%.d) + + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- ARCH = -mthumb -mthumb-interwork CFLAGS = -g -Wall -O2 -DPLAT_GBA -ffunction-sections -fdata-sections -mcpu=arm7tdmi -mtune=arm7tdmi $(ARCH) ASFLAGS = -g $(ARCH) @@ -42,10 +50,6 @@ LIBTONC = $(DEVKITPRO)/libtonc INCLUDES += $(foreach dir, $(LIBTONC), -I$(dir)/include) LDFLAGS += $(foreach dir, $(LIBTONC), -L$(dir)/lib) -# Dependency tracking -DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -DEPFILES := $(OBJS:%.o=%.d) - #--------------------------------------------------------------------------------- # Main targets diff --git a/misc/gc/Makefile b/misc/gc/Makefile index 9ec6c2a7b..dcdcc07da 100644 --- a/misc/gc/Makefile +++ b/misc/gc/Makefile @@ -10,19 +10,26 @@ endif TARGET = ClassiCube-gc # List of directories containing source code SOURCE_DIRS = src src/gcwii third_party/bearssl -# List of directories containing more header files -INCLUDES = # Directory where object files are placed BUILD_DIR = build/gc #--------------------------------------------------------------------------------- -# Code generation +# Compilable files #--------------------------------------------------------------------------------- S_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) +# Dependency tracking +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d +DEPFILES := $(OBJS:%.o=%.d) + + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- + MACHDEP = -DGEKKO -mogc -mcpu=750 -meabi -mhard-float CFLAGS = -g -O2 -Wall $(MACHDEP) -I$(DEVKITPRO)/libogc/include @@ -30,10 +37,6 @@ LDFLAGS = -g $(MACHDEP) -L$(DEVKITPRO)/libogc/lib/cube # Additional libraries to link against LIBS = -lasnd -lbba -lfat -logc -lm -# Dependency tracking -DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -DEPFILES := $(OBJS:%.o=%.d) - #--------------------------------------------------------------------------------- # Compiler tools @@ -72,13 +75,13 @@ $(TARGET).dol: $(TARGET).elf # Object generation #--------------------------------------------------------------------------------- $(BUILD_DIR)/%.o: src/%.c - $(PPC_CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@ + $(PPC_CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@ $(BUILD_DIR)/%.o: src/gcwii/%.c - $(PPC_CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@ + $(PPC_CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@ $(BUILD_DIR)/%.o: third_party/bearssl/%.c - $(PPC_CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ + $(PPC_CC) $(CFLAGS) -c $< -o $@ #--------------------------------------------------------------------------------- diff --git a/misc/ps1/Makefile b/misc/ps1/Makefile index 9690dceac..fb475a64e 100644 --- a/misc/ps1/Makefile +++ b/misc/ps1/Makefile @@ -17,20 +17,24 @@ BUILD_DIR := build/ps1 #--------------------------------------------------------------------------------- -# Code generation +# Compilable files #--------------------------------------------------------------------------------- S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) -CINCLUDES := -I$(PSN00BSDK_ROOT)/include/libpsn00b - -CFLAGS := -DPLAT_PS1 -DPSN00BSDK=1 -g -Wa,--strip-local-absolute -ffreestanding -fno-builtin -nostdlib -fdata-sections -ffunction-sections -fsigned-char -fno-strict-overflow -msoft-float -march=r3000 -mtune=r3000 -mabi=32 -mno-mt -mno-llsc -Og -mdivide-breaks -G8 -fno-pic -mno-abicalls -mgpopt -mno-extern-sdata - # Dependency tracking DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d DEPFILES := $(OBJS:%.o=%.d) + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- +CINCLUDES := -I$(PSN00BSDK_ROOT)/include/libpsn00b + +CFLAGS := -DPLAT_PS1 -DPSN00BSDK=1 -g -Wa,--strip-local-absolute -ffreestanding -fno-builtin -nostdlib -fdata-sections -ffunction-sections -fsigned-char -fno-strict-overflow -msoft-float -march=r3000 -mtune=r3000 -mabi=32 -mno-mt -mno-llsc -Og -mdivide-breaks -G8 -fno-pic -mno-abicalls -mgpopt -mno-extern-sdata + # Additional libraries to link against # libpsxgpu -> $(PSN00BSDK_ROOT)/lib/libpsn00b/debug/libpsxgpu_exe_gprel.a PS1LIBS := libpsxgpu libpsxgte libpsxspu libpsxcd libpsxpress libpsxsio libpsxetc libpsxapi libsmd liblzp libc diff --git a/misc/ps2/Makefile b/misc/ps2/Makefile index 9873bc662..7c45fd88a 100644 --- a/misc/ps2/Makefile +++ b/misc/ps2/Makefile @@ -15,12 +15,20 @@ BUILD_DIR = build/ps2 #--------------------------------------------------------------------------------- -# Code generation +# Compilable files #--------------------------------------------------------------------------------- S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) +# Dependency tracking +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d +DEPFILES := $(OBJS:%.o=%.d) + + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- IOP_MODS := DEV9_irx.o NETMAN_irx.o SMAP_irx.o USBD_irx.o BDM_irx.o BDMFS_FATFS_irx.o USBMASS_BD_irx.o USBHDFSD_irx.o USBMOUSE_irx.o USBKBD_irx.o EE_OBJS = $(OBJS) $(patsubst %.o, $(BUILD_DIR)/%.o, $(IOP_MODS)) @@ -31,10 +39,6 @@ EE_CFLAGS := -D_EE -G0 -O2 -Wall -gdwarf-2 -gz -DPLAT_PS2 EE_LDFLAGS := -L$(PS2SDK)/ee/lib -Wl,-zmax-page-size=128 EE_LINKFILE := $(PS2SDK)/ee/startup/linkfile -# Dependency tracking -DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -DEPFILES := $(OBJS:%.o=%.d) - #--------------------------------------------------------------------------------- # Compiler tools diff --git a/misc/ps3/Makefile b/misc/ps3/Makefile index ec40625be..4912d36e2 100644 --- a/misc/ps3/Makefile +++ b/misc/ps3/Makefile @@ -16,12 +16,10 @@ include $(PS3DEV)/ppu_rules # 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-PS3 BUILD := build-ps3 SOURCES := src third_party/bearssl -INCLUDES := SHADERS := misc/ps3 TITLE := ClassiCube @@ -87,8 +85,7 @@ export OFILES := $(CFILES:.c=.o) $(sFILES:.s=.o) $(SFILES:.S=.o) \ #--------------------------------------------------------------------------------- # build a list of include paths #--------------------------------------------------------------------------------- -export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ +export INCLUDE := $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ $(LIBPSL1GHT_INC) \ -I$(CURDIR)/$(BUILD) diff --git a/misc/saturn/Makefile b/misc/saturn/Makefile index 856d6938c..759690547 100644 --- a/misc/saturn/Makefile +++ b/misc/saturn/Makefile @@ -30,12 +30,21 @@ IMAGE_1ST_READ_BIN = A.BIN #--------------------------------------------------------------------------------- -# Code generation +# Compilable files #--------------------------------------------------------------------------------- S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) SH_OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) +# Dependency tracking +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d +DEPFILES := $(SH_OBJS:%.o=%.d) + + + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- SH_CFLAGS = -Os -DPLAT_SATURN -Wstrict-aliasing \ -I$(YAUL_INSTALL_ROOT)/$(YAUL_ARCH_SH_PREFIX)/include/yaul @@ -45,10 +54,6 @@ SH_LDFLAGS = -static -Wl,--gc-sections \ SH_SPECS = yaul.specs yaul-main.specs -# Dependency tracking -DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -DEPFILES := $(SH_OBJS:%.o=%.d) - #--------------------------------------------------------------------------------- # Compiler tools diff --git a/misc/switch/Makefile b/misc/switch/Makefile index adf47c967..2340095e0 100644 --- a/misc/switch/Makefile +++ b/misc/switch/Makefile @@ -10,8 +10,6 @@ endif TARGET = ClassiCube-switch # List of directories containing source code SOURCE_DIRS = src src/switch third_party/bearssl -# List of directories containing more header files -INCLUDES = # Directory where object files are placed BUILD_DIR = build/switch @@ -22,18 +20,27 @@ APP_VERSION = 1.3.7 #--------------------------------------------------------------------------------- -# Code generation +# Compilable files #--------------------------------------------------------------------------------- S_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) +# Dependency tracking +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d +DEPFILES := $(OBJS:%.o=%.d) + + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- ARCH = -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE CFLAGS = -g -Wall -O2 -ffunction-sections $(ARCH) -D__SWITCH__ ASFLAGS = -g $(ARCH) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) LIBS = -lGLESv2 -lEGL -lglapi -ldrm_nouveau -lnx -lm +INCLUDES= LIBNX = $(DEVKITPRO)/libnx INCLUDES += $(foreach dir, $(LIBNX), -I$(dir)/include) @@ -43,10 +50,6 @@ PORTLIBS = $(DEVKITPRO)/portlibs/switch INCLUDES += $(foreach dir, $(PORTLIBS), -I$(dir)/include) LDFLAGS += $(foreach dir, $(PORTLIBS), -L$(dir)/lib) -# Dependency tracking -DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -DEPFILES := $(OBJS:%.o=%.d) - #--------------------------------------------------------------------------------- # Compiler tools diff --git a/misc/vita/Makefile b/misc/vita/Makefile index 2b8a363f2..f23039799 100644 --- a/misc/vita/Makefile +++ b/misc/vita/Makefile @@ -20,20 +20,24 @@ PROJECT_TITLEID = CUBE00200 #--------------------------------------------------------------------------------- -# Code generation +# Compilable files #--------------------------------------------------------------------------------- C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o))) +# Dependency tracking +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d +DEPFILES := $(OBJS:%.o=%.d) + + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- CFLAGS = -O1 LDFLAGS = -Wl,-q LIBS = -lm -lSceDisplay_stub -lSceCtrl_stub -lSceTouch_stub -lSceGxm_stub -lSceCommonDialog_stub -lSceAppUtil_stub -# Dependency tracking -DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -DEPFILES := $(OBJS:%.o=%.d) - #--------------------------------------------------------------------------------- # Compiler tools diff --git a/misc/wii/Makefile b/misc/wii/Makefile index 86bd1cf94..1731a4ffb 100644 --- a/misc/wii/Makefile +++ b/misc/wii/Makefile @@ -10,19 +10,25 @@ endif TARGET = ClassiCube-wii # List of directories containing source code SOURCE_DIRS = src src/gcwii third_party/bearssl -# List of directories containing more header files -INCLUDES = # Directory where object files are placed BUILD_DIR = build/wii #--------------------------------------------------------------------------------- -# Code generation +# Compilable files #--------------------------------------------------------------------------------- S_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) +# Dependency tracking +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d +DEPFILES := $(OBJS:%.o=%.d) + + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- MACHDEP = -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float CFLAGS = -g -O2 -Wall $(MACHDEP) -I$(DEVKITPRO)/libogc/include @@ -30,10 +36,6 @@ LDFLAGS = -g $(MACHDEP) -L$(DEVKITPRO)/libogc/lib/wii # Additional libraries to link against LIBS = -lasnd -lwiikeyboard -lwiiuse -lbte -lfat -logc -lm -# Dependency tracking -DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -DEPFILES := $(OBJS:%.o=%.d) - #--------------------------------------------------------------------------------- # Compiler tools @@ -72,13 +74,13 @@ $(TARGET).dol: $(TARGET).elf # Object generation #--------------------------------------------------------------------------------- $(BUILD_DIR)/%.o: src/%.c - $(PPC_CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@ + $(PPC_CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@ $(BUILD_DIR)/%.o: src/gcwii/%.c - $(PPC_CC) $(CFLAGS) $(INCLUDES) $(DEPFLAGS) -c $< -o $@ + $(PPC_CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@ $(BUILD_DIR)/%.o: third_party/bearssl/%.c - $(PPC_CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ + $(PPC_CC) $(CFLAGS) -c $< -o $@ #--------------------------------------------------------------------------------- diff --git a/misc/xbox/Makefile b/misc/xbox/Makefile index 21d2722ee..4f52a8a17 100644 --- a/misc/xbox/Makefile +++ b/misc/xbox/Makefile @@ -18,12 +18,20 @@ BUILD_DIR = build/xbox #--------------------------------------------------------------------------------- -# Code generation +# Compilable files #--------------------------------------------------------------------------------- S_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) +# Dependency tracking +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d +DEPFILES := $(OBJS:%.o=%.d) + + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- CFLAGS = -O1 -fno-math-errno -Wno-builtin-macro-redefined \ -I$(NXDK_DIR)/lib/net/lwip/src/include \ -I$(NXDK_DIR)/lib/net/nforceif/include \ @@ -43,10 +51,6 @@ LDFLAGS = -stack:196608 \ $(NXDK_DIR)/lib/nxdk_usb.lib \ $(NXDK_DIR)/lib/xboxkrnl/libxboxkrnl.lib -# Dependency tracking -DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -DEPFILES := $(OBJS:%.o=%.d) - #--------------------------------------------------------------------------------- # Tools @@ -85,7 +89,7 @@ $(TARGET).iso: $(TARGET).xbe $(TARGET).xbe: $(TARGET).exe $(CXBE) -OUT:$@ -TITLE:$(XBE_TITLE) $< -$(TARGET).exe : $(OBJS) +$(TARGET).exe: $(OBJS) nxdk-link $(NXDK_LDFLAGS) $(LDFLAGS) -out:$@ $^ diff --git a/misc/xbox360/Makefile b/misc/xbox360/Makefile index 9bcb2a25c..a7a5ee311 100644 --- a/misc/xbox360/Makefile +++ b/misc/xbox360/Makefile @@ -1,113 +1,86 @@ -#--------------------------------------------------------------------------------- -# Clear the implicit built in rules -#--------------------------------------------------------------------------------- -.SUFFIXES: - -#--------------------------------------------------------------------------------- ifeq ($(strip $(DEVKITXENON)),) $(error "Please set DEVKITXENON in your environment. export DEVKITXENON=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 +# Configurable options #--------------------------------------------------------------------------------- +# Name of the final output TARGET := ClassiCube-xbox360 -BUILD := build-360 -SOURCES := src third_party/bearssl +# Directory where object files are placed +BUILD_DIR := build/xbox360 +# List of directories containing source code +SOURCE_DIRS := src src/xbox360 third_party/bearssl + #--------------------------------------------------------------------------------- -# options for code generation +# Compilable files #--------------------------------------------------------------------------------- +S_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S)) +C_FILES = $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c)) +OBJS = $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o))) + +# Dependency tracking +DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d +DEPFILES := $(OBJS:%.o=%.d) + + +#--------------------------------------------------------------------------------- +# Code generation +#--------------------------------------------------------------------------------- +MACHDEP = -DXENON -m32 -maltivec -fno-pic -mpowerpc64 -mhard-float -L$(DEVKITXENON)/xenon/lib/32 +LDSCRIPT = $(DEVKITXENON)/app.lds CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) -CXXFLAGS= $(CFLAGS) +LDFLAGS = -g $(MACHDEP) -Wl,--gc-sections -Wl,-Map,$(notdir $@).map +LIBS = -lxenon -lm -lfat + +CFLAGS += -I$(DEVKITXENON)/usr/include +LDFLAGS += -L$(DEVKITXENON)/usr/lib -LDFLAGS = -g $(MACHDEP) -Wl,--gc-sections -Wl,-Map,$(notdir $@).map #--------------------------------------------------------------------------------- -# any extra libraries we wish to link with the project +# Main targets #--------------------------------------------------------------------------------- -LIBS := -lxenon -lm -lfat +default: $(BUILD_DIR) $(TARGET).elf32 + +clean: + rm -f $(TARGET).elf $(TARGET).elf32 $(OBJS) $(DEPFILES) + +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + #--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib +# Executable generation #--------------------------------------------------------------------------------- -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) - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -default: $(BUILD) $(TARGET).elf32 +$(TARGET).elf: $(OBJS) + xenon-gcc $^ $(LDFLAGS) $(LIBS) -n -T $(LDSCRIPT) -o $@ $(TARGET).elf32: $(TARGET).elf -$(TARGET).elf: $(OFILES) - - -#--------------------------------------------------------------------------------- -$(BUILD): - [ -d $@ ] || mkdir -p $@ - -#--------------------------------------------------------------------------------- -clean: - echo clean ... - rm -fr $(BUILD) $(TARGET).elf $(TARGET).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 $@ + + +#--------------------------------------------------------------------------------- +# Object generation +#--------------------------------------------------------------------------------- +$(BUILD_DIR)/%.o: src/%.c + xenon-gcc $(CFLAGS) $(DEPFLAGS) -c $< -o $@ + +$(BUILD_DIR)/%.o: src/xbox360/%.c + xenon-gcc $(CFLAGS) $(DEPFLAGS) -c $< -o $@ + +$(BUILD_DIR)/%.o: src/xbox360/%.S + xenon-gcc $(CFLAGS) $(DEPFLAGS) -c $< -o $@ + +$(BUILD_DIR)/%.o: third_party/bearssl/%.c + xenon-gcc $(CFLAGS) -c $< -o $@ + + +#--------------------------------------------------------------------------------- +# Dependency tracking +#--------------------------------------------------------------------------------- +$(DEPFILES): + +include $(wildcard $(DEPFILES)) diff --git a/src/ps2/Graphics_PS2.c b/src/ps2/Graphics_PS2.c index 222b7070e..4fa615796 100644 --- a/src/ps2/Graphics_PS2.c +++ b/src/ps2/Graphics_PS2.c @@ -131,7 +131,8 @@ static void InitDrawingEnv(void) { } static void InitPalette(void); -static unsigned tex_offset; +static void InitTextureMem(void); + void Gfx_Create(void) { primitive_type = 0; // PRIM_POINT, which isn't used here @@ -144,7 +145,7 @@ void Gfx_Create(void) { InitDrawingEnv(); InitPalette(); - tex_offset = graph_vram_allocate(256, 256, GS_PSM_32, GRAPH_ALIGN_BLOCK); + InitTextureMem(); // TODO maybe Min not actually needed? Gfx.MinTexWidth = 4; @@ -170,6 +171,62 @@ static CC_INLINE void DMAFlushBuffer(void) { dma_channel_send_chain(DMA_CHANNEL_GIF, dma_beg, Q - dma_beg, 0, 0); } + +/*########################################################################################################################* +*--------------------------------------------------VRAM transfer/memory---------------------------------------------------* +*#########################################################################################################################*/ +#define ALIGNUP(val, alignment) (((val) + (alignment - 1)) & -alignment) +static int vram_pointer; + +void Gfx_VRAM_Reset(void) { + vram_pointer = 0; +} + +static int AllocVRAM(int width, int height, int psm) { + width = ALIGNUP(width, 64); + + // Returns size in words + // TODO move the >> out ? + switch (psm) + { + case GS_PSM_4: + return width * (height >> 3); + case GS_PSM_8: + return width * (height >> 2); + case GS_PSM_16: + case GS_PSM_16S: + case GS_PSMZ_16: + case GS_PSMZ_16S: + return width * (height >> 1); + case GS_PSM_24: + case GS_PSM_32: + case GS_PSM_8H: + case GS_PSM_4HL: + case GS_PSM_4HH: + case GS_PSMZ_24: + case GS_PSMZ_32: + return width * height; + } + return 0; +} + +int Gfx_VRAM_Alloc(int width, int height, int psm) { + int size = AllocVRAM(width, height, psm); + int addr = vram_pointer; + + vram_pointer += size; + return addr; +} + +int Gfx_VRAM_AllocPaged(int width, int height, int psm) { + int size = AllocVRAM(width, height, psm); + int addr = vram_pointer; + + // Align to 2048 words / 8192 bytes (VRAM page alignment) + vram_pointer += ALIGNUP(size, 2048); + return addr; +} + static int CalcTransferBytes(int width, int height, int psm) { switch (psm) { @@ -263,7 +320,7 @@ static unsigned clut_offset; #define PaletteAddr(index) (clut_offset + (index) * 64) static void InitPalette(void) { - clut_offset = graph_vram_allocate(PAL_TOTAL_ENTRIES, 1, GS_PSM_32, GRAPH_ALIGN_BLOCK); + clut_offset = Gfx_VRAM_Alloc(PAL_TOTAL_ENTRIES, 1, GS_PSM_32); } static CC_INLINE int FindInPalette(BitmapCol* palette, int pal_count, BitmapCol color) { @@ -306,6 +363,27 @@ static void ApplyPalette(BitmapCol* palette, int pal_index) { } +/*########################################################################################################################* +*------------------------------------------------------Texture memory-----------------------------------------------------* +*#########################################################################################################################*/ +#define VRAM_SIZE_WORDS (1024 * 1024) + +// PS2 textures are always 64 word aligned minimum +#define TEXMEM_BLOCK_SIZE 64 + +#define TEXMEM_MAX_BLOCKS (VRAM_SIZE_WORDS / TEXMEM_BLOCK_SIZE) +static cc_uint8 tex_4hl_table[TEXMEM_MAX_BLOCKS / BLOCKS_PER_PAGE]; +static cc_uint8 tex_4hh_table[TEXMEM_MAX_BLOCKS / BLOCKS_PER_PAGE]; +static int texmem_4bpp_blocks; + +static unsigned tex_offset; +static void InitTextureMem(void) { + tex_offset = Gfx_VRAM_Alloc(256, 256, GS_PSM_32); + + texmem_4bpp_blocks = fb_colors[1].address / TEXMEM_BLOCK_SIZE; +} + + /*########################################################################################################################* *---------------------------------------------------------Textures--------------------------------------------------------* *#########################################################################################################################*/ diff --git a/src/ps2/Window_PS2.c b/src/ps2/Window_PS2.c index c51039a20..a421c3f93 100644 --- a/src/ps2/Window_PS2.c +++ b/src/ps2/Window_PS2.c @@ -69,27 +69,30 @@ void Window_Init(void) { void Window_Free(void) { } +extern void Gfx_VRAM_Reset(void); +extern int Gfx_VRAM_AllocPaged(int width, int height, int psm); + static void ResetDisplay(void) { graph_shutdown(); - graph_vram_clear(); + Gfx_VRAM_Reset(); fb_colors[0].width = DisplayInfo.Width; fb_colors[0].height = DisplayInfo.Height; fb_colors[0].mask = 0; fb_colors[0].psm = GS_PSM_24; - fb_colors[0].address = graph_vram_allocate(fb_colors[0].width, fb_colors[0].height, fb_colors[0].psm, GRAPH_ALIGN_PAGE); - - fb_depth.enable = 1; - fb_depth.method = ZTEST_METHOD_ALLPASS; - fb_depth.mask = 0; - fb_depth.zsm = GS_ZBUF_24; - fb_depth.address = graph_vram_allocate(fb_colors[0].width, fb_colors[0].height, fb_depth.zsm, GRAPH_ALIGN_PAGE); + fb_colors[0].address = Gfx_VRAM_AllocPaged(fb_colors[0].width, fb_colors[0].height, fb_colors[0].psm); fb_colors[1].width = DisplayInfo.Width; fb_colors[1].height = DisplayInfo.Height; fb_colors[1].mask = 0; fb_colors[1].psm = GS_PSM_24; - fb_colors[1].address = graph_vram_allocate(fb_colors[1].width, fb_colors[1].height, fb_colors[1].psm, GRAPH_ALIGN_PAGE); + fb_colors[1].address = Gfx_VRAM_AllocPaged(fb_colors[1].width, fb_colors[1].height, fb_colors[1].psm); + + fb_depth.enable = 1; + fb_depth.method = ZTEST_METHOD_ALLPASS; + fb_depth.mask = 0; + fb_depth.zsm = GS_ZBUF_24; + fb_depth.address = Gfx_VRAM_AllocPaged(fb_colors[0].width, fb_colors[0].height, fb_depth.zsm); } static void InitDisplay(framebuffer_t* fb) { diff --git a/src/Graphics_Xbox360.c b/src/xbox360/Graphics_Xbox360.c similarity index 94% rename from src/Graphics_Xbox360.c rename to src/xbox360/Graphics_Xbox360.c index 38a9cba8d..c1d13e6a7 100644 --- a/src/Graphics_Xbox360.c +++ b/src/xbox360/Graphics_Xbox360.c @@ -1,15 +1,15 @@ -#include "Core.h" -#ifdef CC_BUILD_XBOX360 -#include "_GraphicsBase.h" -#include "Errors.h" -#include "Window.h" +#include "../_GraphicsBase.h" +#include "../Errors.h" +#include "../Window.h" + #include #include -#include "../misc/xbox360/ps_coloured.h" -#include "../misc/xbox360/vs_coloured.h" -#include "../misc/xbox360/ps_textured.h" -#include "../misc/xbox360/vs_textured.h" +#include "../../misc/xbox360/ps_coloured.h" +#include "../../misc/xbox360/vs_coloured.h" +#include "../../misc/xbox360/ps_textured.h" +#include "../../misc/xbox360/vs_textured.h" + static struct XenosShader* shdr_tex_vs; static struct XenosShader* shdr_tex_ps; static struct XenosShader* shdr_col_vs; @@ -403,4 +403,3 @@ void Gfx_OnWindowResize(void) { void Gfx_SetViewport(int x, int y, int w, int h) { } void Gfx_SetScissor (int x, int y, int w, int h) { } -#endif diff --git a/src/Platform_Xbox360.c b/src/xbox360/Platform_Xbox360.c similarity index 95% rename from src/Platform_Xbox360.c rename to src/xbox360/Platform_Xbox360.c index 025b40536..ff5864032 100644 --- a/src/Platform_Xbox360.c +++ b/src/xbox360/Platform_Xbox360.c @@ -1,15 +1,13 @@ -#include "Core.h" -#if defined CC_BUILD_XBOX360 - #define CC_XTEA_ENCRYPTION -#include "_PlatformBase.h" -#include "Stream.h" -#include "Funcs.h" -#include "Utils.h" -#include "Errors.h" +#include "../_PlatformBase.h" +#include "../Stream.h" +#include "../Funcs.h" +#include "../Utils.h" +#include "../Errors.h" #define LWIP_SOCKET 1 #include +#include #include #include #include @@ -24,7 +22,8 @@ #include #include #include -#include "_PlatformConsole.h" + +#include "../_PlatformConsole.h" const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; @@ -346,4 +345,3 @@ static cc_result GetMachineID(cc_uint32* key) { Mem_Copy(key, MACHINE_KEY, sizeof(MACHINE_KEY) - 1); return 0; } -#endif diff --git a/src/Window_Xbox360.c b/src/xbox360/Window_Xbox360.c similarity index 93% rename from src/Window_Xbox360.c rename to src/xbox360/Window_Xbox360.c index 833310b5d..71833c7b7 100644 --- a/src/Window_Xbox360.c +++ b/src/xbox360/Window_Xbox360.c @@ -1,16 +1,15 @@ -#include "Core.h" -#if defined CC_BUILD_XBOX360 -#include "Window.h" -#include "Platform.h" -#include "Input.h" -#include "Event.h" -#include "Graphics.h" -#include "String.h" -#include "Funcs.h" -#include "Bitmap.h" -#include "Errors.h" -#include "ExtMath.h" -#include "VirtualKeyboard.h" +#include "../Window.h" +#include "../Platform.h" +#include "../Input.h" +#include "../Event.h" +#include "../Graphics.h" +#include "../String.h" +#include "../Funcs.h" +#include "../Bitmap.h" +#include "../Errors.h" +#include "../ExtMath.h" +#include "../VirtualKeyboard.h" + #include #include #include @@ -215,4 +214,3 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) { cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) { return ERR_NOT_SUPPORTED; } -#endif