Skip to content

Commit

Permalink
Merge pull request #273 from DigiDwrf/develop
Browse files Browse the repository at this point in the history
HiROM | FastROM support
  • Loading branch information
alekmaul authored Mar 20, 2024
2 parents 32ddd8e + 0e971e6 commit 79da463
Show file tree
Hide file tree
Showing 26 changed files with 814 additions and 421 deletions.
41 changes: 39 additions & 2 deletions devkitsnes/snes_rules
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ ifeq ($(origin SRC), undefined)
SRC := src
endif

LIBDIRSOBJS := $(PVSNESLIB_HOME)/pvsneslib/lib

# to avoid some bugs if the PVSNESLIB_HOME is not well defined, we let a small check here
ifeq ($(findstring \,$(PVSNESLIB_HOME)),\)
$(error "PVSNESLIB_HOME environment variable is not defined correctly: the path must be in Unix style (on Windows operating system too!). For example, use /c/snesdev instead of c:\snesdev")
Expand All @@ -18,6 +16,32 @@ DEBUG = 0
$(info The debug mode is NOT enabled, you can do it by executing "export PVSNESLIB_DEBUG=1")
endif

ifeq ($(HIROM),1)
HIROM = 1
$(info HiROM compilation is enabled)
ifeq ($(FASTROM),1)
LIBDIRSOBJS := $(PVSNESLIB_HOME)/pvsneslib/lib/HiROM_FastROM
else
LIBDIRSOBJS := $(PVSNESLIB_HOME)/pvsneslib/lib/HiROM_SlowROM
endif
else
HIROM = 0
$(info LoROM compilation is enabled)
ifeq ($(FASTROM),1)
LIBDIRSOBJS := $(PVSNESLIB_HOME)/pvsneslib/lib/LoROM_FastROM
else
LIBDIRSOBJS := $(PVSNESLIB_HOME)/pvsneslib/lib/LoROM_SlowROM
endif
endif

ifeq ($(FASTROM),1)
FASTROM = 1
$(info FastROM compilation is enabled)
else
FASTROM = 0
$(info SlowROM compilation is enabled)
endif

#---------------------------------------------------------------------------------
# on windows, linkfile can only manage path like E:\pvsneslib\lib\crt0_snes.obj
# this one doesn't work /e/pvsneslib/lib/crt0_snes.obj
Expand Down Expand Up @@ -85,7 +109,20 @@ export OFILES := $(BINFILES:.bin=.obj) $(CFILES:.c=.obj) $(SFILES:.asm=.obj)
#---------------------------------------------------------------------------------
%.ps: %.c
@echo Compiling to .ps ... $(notdir $<)
ifeq ($(HIROM),1)
ifeq ($(FASTROM),1)
$(CC) $(CFLAGS) -Wall -c $< -H -F -o $@
else
$(CC) $(CFLAGS) -Wall -c $< -H -o $@
endif
else
ifeq ($(FASTROM),1)
$(CC) $(CFLAGS) -Wall -c $< -F -o $@
else
$(CC) $(CFLAGS) -Wall -c $< -o $@
endif
endif

ifeq ($(DEBUG),1)
cp $@ [email protected]
endif
Expand Down
25 changes: 22 additions & 3 deletions pvsneslib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,35 @@ export PVSDOCSDIR := $(TOPDIR)/docs

all: include/snes/libversion.h pvsneslibversion release docs

HIROM_VALUES := 0 1
FASTROM_VALUES := 0 1
KEEP_LIB := 0

release: lib
$(MAKE) -C source all
@$(foreach HIROM, $(HIROM_VALUES), \
$(foreach FASTROM, $(FASTROM_VALUES), \
$(MAKE) HIROM=$(HIROM) FASTROM=$(FASTROM) build; \
$(MAKE) KEEP_LIB=1 clean; \
) \
)

build:
@$(MAKE) -C source all

lib:
@mkdir -p $@
@mkdir -p $@/LoROM_SlowROM
@mkdir -p $@/LoROM_FastROM
@mkdir -p $@/HiROM_SlowROM
@mkdir -p $@/HiROM_FastROM

clean:
$(MAKE) -C source clean
@rm -rf $(PVSDOCSDIR)/html
@rm -f pvsneslib_version.txt
@if [ "$(KEEP_LIB)" -eq 0 ]; then \
rm -rf $(PVSDOCSDIR)/html; \
rm -f pvsneslib_version.txt; \
rm -f lib/*ROM/*; \
fi

# Check if Doxygen is installed
doxygenInstalled := $(shell command -v doxygen -q 2> /dev/null)
Expand Down
43 changes: 40 additions & 3 deletions pvsneslib/source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,48 @@ export SNESOBJS = crt0_snes.obj libm.obj libtcc.obj libc.obj
#---------------------------------------------------------------------------------
%.ps: %.c
@echo $(notdir $<)

ifeq ($(HIROM),1)
ifeq ($(FASTROM),1)
$(CC) $(CFLAGS) -Wall -c $< -H -F -o $@
else
$(CC) $(CFLAGS) -Wall -c $< -H -o $@
endif
else
ifeq ($(FASTROM),1)
$(CC) $(CFLAGS) -Wall -c $< -F -o $@
else
$(CC) $(CFLAGS) -Wall -c $< -o $@
endif
endif
sed -i 's/.include "hdr.asm"//' $@

all: $(SNESOBJS)
@mv *.obj ../lib
reset_comp:
@echo "; HIROM / FASTROM definitions" > comp_defs.asm
ifeq ($(HIROM),1)
@echo ".DEFINE HIROM 1" >> comp_defs.asm
endif
ifeq ($(FASTROM),1)
@echo ".FASTROM" >> comp_defs.asm
@echo ".DEFINE FASTROM 1" >> comp_defs.asm
else
@echo ".SLOWROM" >> comp_defs.asm
endif

all: reset_comp $(SNESOBJS)
ifeq ($(HIROM),1)
ifeq ($(FASTROM),1)
@mv *.obj ../lib/HiROM_FastROM
else
@mv *.obj ../lib/HiROM_SlowROM
endif
else
ifeq ($(FASTROM),1)
@mv *.obj ../lib/LoROM_FastROM
else
@mv *.obj ../lib/LoROM_SlowROM
endif
endif
@rm -f *.ps

#---------------------------------------------------------------------------------
Expand All @@ -41,4 +78,4 @@ clean:
@echo clean ...
@rm -f libc_c.ps libc_c.asm libm_c.asm
@rm -f *.obj *.ps *.lst
@rm -f ../lib/*
@rm -f comp_defs.asm
Loading

0 comments on commit 79da463

Please sign in to comment.