improve for out-of-tree usage
This commit is contained in:
parent
671fe92b12
commit
e36735f6c2
42
Makefile
42
Makefile
@ -1,44 +1,14 @@
|
||||
all: $(patsubst %.cpp,%.elf,$(wildcard example/*.cpp))
|
||||
|
||||
phony:
|
||||
|
||||
example/arm/%.bin: phony
|
||||
make -C example/arm $*.bin
|
||||
|
||||
include base.mk
|
||||
include common.mk
|
||||
include headers.mk
|
||||
|
||||
geometry/%.hpp: geometry/%.obj
|
||||
PYTHONPATH=regs/gen python tools/obj_to_cpp.py $< > $@.tmp
|
||||
mv $@.tmp $@
|
||||
MAKEFILE_PATH := $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST)))))
|
||||
CFLAGS += -I$(MAKEFILE_PATH)
|
||||
LIB ?= $(MAKEFILE_PATH)
|
||||
|
||||
%.data.h: %.data
|
||||
$(BUILD_BINARY_H)
|
||||
|
||||
%.data.pal.h: %.data.pal
|
||||
$(BUILD_BINARY_H)
|
||||
|
||||
%.alpha.h: %.alpha
|
||||
$(BUILD_BINARY_H)
|
||||
|
||||
%.alpha.o: %.alpha
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
%.alpha.pal.h: %.alpha.pal
|
||||
$(BUILD_BINARY_H)
|
||||
|
||||
%.alpha.pal.o: %.alpha.pal
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
%.vq.h: %.vq
|
||||
$(BUILD_BINARY_H)
|
||||
|
||||
%.vq.o: %.vq
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
build-fonts:
|
||||
./tools/ttf_outline 20 7f 20 0 little /usr/share/fonts/dejavu/DejaVuSans.ttf font/dejavusansmono/dejavusansmono.data
|
||||
./tools/ttf_outline 20 7f 20 1 little /usr/share/fonts/dejavu/DejaVuSans.ttf font/dejavusansmono/dejavusansmono_mono.data
|
||||
./tools/ttf_outline 20 7f 20 1 little /usr/share/fonts/terminus/ter-u20n.otb font/ter_u20n/ter_u20n.data
|
||||
include ip.mk
|
||||
|
||||
include example/example.mk
|
||||
include chess/chess.mk
|
||||
|
46
base.mk
46
base.mk
@ -34,19 +34,35 @@ define BUILD_BINARY_O
|
||||
$< $@
|
||||
endef
|
||||
|
||||
makefile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
makefile_path := $(dir $(abspath $(firstword $(MAKEFILE_LIST))))
|
||||
makefile_relative = $(shell realpath --relative-to $(makefile_path) $(1))
|
||||
as_obj_binary = _binary_$(subst .,_,$(subst /,_,$(subst .h,,$(call makefile_relative,$(1)))))
|
||||
|
||||
define BUILD_BINARY_H
|
||||
@echo gen $(call makefile_relative,$@)
|
||||
@echo '#pragma once' > $@
|
||||
@echo '#include <cstdint>' >> $@
|
||||
@echo '' >> $@
|
||||
@echo '#include <stdint.h>' >> $@
|
||||
@echo '' >> $@
|
||||
@echo '#ifdef __cplusplus' >> $@
|
||||
@echo 'extern "C" {' >> $@
|
||||
@echo '#endif' >> $@
|
||||
@echo '' >> $@
|
||||
@echo 'extern uint32_t $(call as_obj_binary,$@)_start __asm("$(call as_obj_binary,$@)_start");' >> $@
|
||||
@echo 'extern uint32_t $(call as_obj_binary,$@)_end __asm("$(call as_obj_binary,$@)_end");' >> $@
|
||||
@echo 'extern uint32_t $(call as_obj_binary,$@)_size __asm("$(call as_obj_binary,$@)_size");' >> $@
|
||||
@echo '' >> $@
|
||||
@echo '#ifdef __cplusplus' >> $@
|
||||
@echo '}' >> $@
|
||||
@echo '#endif' >> $@
|
||||
endef
|
||||
|
||||
%.txt.o: %.txt
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
%.txt.h: %.txt
|
||||
$(BUILD_BINARY_H)
|
||||
|
||||
%.bin.o: %.bin
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
@ -56,9 +72,33 @@ endef
|
||||
%.data.o: %.data
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
%.data.h: %.data
|
||||
$(BUILD_BINARY_H)
|
||||
|
||||
%.data.pal.o: %.data.pal
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
%.data.pal.h: %.data.pal
|
||||
$(BUILD_BINARY_H)
|
||||
|
||||
%.alpha.h: %.alpha
|
||||
$(BUILD_BINARY_H)
|
||||
|
||||
%.alpha.o: %.alpha
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
%.alpha.pal.h: %.alpha.pal
|
||||
$(BUILD_BINARY_H)
|
||||
|
||||
%.alpha.pal.o: %.alpha.pal
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
%.vq.h: %.vq
|
||||
$(BUILD_BINARY_H)
|
||||
|
||||
%.vq.o: %.vq
|
||||
$(BUILD_BINARY_O)
|
||||
|
||||
%.o: %.s
|
||||
$(AS) $(AARCH) $(AFLAGS) $(DEBUG) $< -o $@
|
||||
|
||||
@ -69,7 +109,7 @@ endef
|
||||
$(CXX) $(CARCH) $(CFLAGS) $(CXXFLAGS) $(OPT) $(DEBUG) $(DEPFLAGS) -MF ${<}.d -c $< -o $@
|
||||
|
||||
%.elf:
|
||||
$(LD) $(LDFLAGS) -T $(LDSCRIPT) $^ -o $@
|
||||
$(LD) $(LDFLAGS) -L $(LIB) -T $(LDSCRIPT) $^ -o $@
|
||||
|
||||
%.bin: %.elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
54
common.mk
54
common.mk
@ -1,7 +1,3 @@
|
||||
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
DIR := $(dir $(MAKEFILE_PATH))
|
||||
|
||||
LIB ?= .
|
||||
OPT ?= -O2
|
||||
GENERATED ?=
|
||||
|
||||
@ -9,7 +5,6 @@ AARCH = --isa=sh4 --little
|
||||
|
||||
CARCH = -m4-single-only -ml
|
||||
CFLAGS += -mfsca -funsafe-math-optimizations -ffast-math
|
||||
CFLAGS += -I"$(dir $(MAKEFILE_PATH))"
|
||||
|
||||
CXXFLAGS += -std=c++23
|
||||
|
||||
@ -18,41 +13,18 @@ OBJARCH = -O elf32-shl -B sh4
|
||||
TARGET = sh4-none-elf-
|
||||
|
||||
START_OBJ = \
|
||||
start.o \
|
||||
runtime.o \
|
||||
sh7091/cache.o
|
||||
$(LIB)/start.o \
|
||||
$(LIB)/runtime.o \
|
||||
$(LIB)/sh7091/cache.o
|
||||
|
||||
IP_OBJ = \
|
||||
systemid.o \
|
||||
toc.o \
|
||||
sg/sg_sec.o \
|
||||
sg_arejp.o \
|
||||
sg_areus.o \
|
||||
sg_areec.o \
|
||||
sg_are00.o \
|
||||
sg_are01.o \
|
||||
sg_are02.o \
|
||||
sg_are03.o \
|
||||
sg_are04.o \
|
||||
$(START_OBJ) \
|
||||
example/serial_transfer.o \
|
||||
sh7091/serial.o \
|
||||
serial_load.o \
|
||||
maple/maple.o \
|
||||
font/portfolio_6x8/portfolio_6x8.data.o \
|
||||
crc32.o
|
||||
#sg_ini.o \
|
||||
#aip.o
|
||||
geometry/%.hpp: geometry/%.obj
|
||||
PYTHONPATH=regs/gen python tools/obj_to_cpp.py $< > $@.tmp
|
||||
mv $@.tmp $@
|
||||
|
||||
%.o: %.obj
|
||||
$(OBJCOPY) -g \
|
||||
--rename-section IP=.text.$* \
|
||||
$< $@
|
||||
|
||||
ip.elf: $(IP_OBJ)
|
||||
$(LD) --orphan-handling=error --print-memory-usage -T $(LIB)/ip.lds $^ -o $@
|
||||
|
||||
include base.mk
|
||||
build-fonts:
|
||||
./tools/ttf_outline 20 7f 20 0 little /usr/share/fonts/dejavu/DejaVuSans.ttf font/dejavusansmono/dejavusansmono.data
|
||||
./tools/ttf_outline 20 7f 20 1 little /usr/share/fonts/dejavu/DejaVuSans.ttf font/dejavusansmono/dejavusansmono_mono.data
|
||||
./tools/ttf_outline 20 7f 20 1 little /usr/share/fonts/terminus/ter-u20n.otb font/ter_u20n/ter_u20n.data
|
||||
|
||||
sine.pcm: common.mk
|
||||
sox \
|
||||
@ -92,18 +64,18 @@ sine.pcm: common.mk
|
||||
/=./pcm/ELEC.PCM \
|
||||
/=./pcm/ECCLESIA.PCM
|
||||
|
||||
include headers.mk
|
||||
|
||||
clean:
|
||||
find -P \
|
||||
-regextype posix-egrep \
|
||||
-regex '.*\.(iso|o|d|bin|elf|cue|gch|scramble)$$' \
|
||||
-exec rm {} \;
|
||||
|
||||
phony:
|
||||
|
||||
.SUFFIXES:
|
||||
.INTERMEDIATE:
|
||||
.SECONDARY:
|
||||
.PHONY: all clean
|
||||
.PHONY: all clean phony
|
||||
|
||||
%: RCS/%,v
|
||||
%: RCS/%
|
||||
|
@ -1,3 +1,6 @@
|
||||
example/arm/%.bin: phony
|
||||
make -C example/arm $*.bin
|
||||
|
||||
VIDEO_OUTPUT_OBJ = \
|
||||
example/video_output.o \
|
||||
holly/video_output.o \
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "model/sheik/material.h"
|
||||
#include "model/sheik/model.h"
|
||||
|
||||
#include "memory.hpp"
|
||||
|
||||
void transfer_scene(float theta)
|
||||
{
|
||||
const uint32_t parameter_control_word = para_control::para_type::polygon_or_modifier_volume
|
||||
@ -122,23 +124,13 @@ void transfer_scene(float theta)
|
||||
sq_transfer_32byte(ta_fifo_polygon_converter);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void copy(T * dst, const T * src, const int32_t n) noexcept
|
||||
{
|
||||
int32_t n_t = n / (sizeof (T));
|
||||
while (n_t > 0) {
|
||||
*dst++ = *src++;
|
||||
n_t--;
|
||||
}
|
||||
}
|
||||
|
||||
void texture_init()
|
||||
{
|
||||
int length = (sizeof (material)) / (sizeof (material[0]));
|
||||
for (int i = 0; i < length; i++) {
|
||||
uint32_t offset = texture_memory_alloc::texture.start + material[i].pixel.vram_offset;
|
||||
|
||||
copy<volatile uint32_t>(&texture_memory64[offset / 4],
|
||||
memory::copy<volatile uint32_t>(&texture_memory64[offset / 4],
|
||||
reinterpret_cast<uint32_t *>(material[i].pixel.start),
|
||||
material[i].pixel.size);
|
||||
}
|
||||
|
29
ip.mk
Normal file
29
ip.mk
Normal file
@ -0,0 +1,29 @@
|
||||
IP_OBJ = \
|
||||
systemid.o \
|
||||
toc.o \
|
||||
sg/sg_sec.o \
|
||||
sg_arejp.o \
|
||||
sg_areus.o \
|
||||
sg_areec.o \
|
||||
sg_are00.o \
|
||||
sg_are01.o \
|
||||
sg_are02.o \
|
||||
sg_are03.o \
|
||||
sg_are04.o \
|
||||
$(START_OBJ) \
|
||||
example/serial_transfer.o \
|
||||
sh7091/serial.o \
|
||||
serial_load.o \
|
||||
maple/maple.o \
|
||||
font/portfolio_6x8/portfolio_6x8.data.o \
|
||||
crc32.o
|
||||
#sg_ini.o \
|
||||
#aip.o
|
||||
|
||||
%.o: %.obj
|
||||
$(OBJCOPY) -g \
|
||||
--rename-section IP=.text.$* \
|
||||
$< $@
|
||||
|
||||
ip.elf: $(IP_OBJ)
|
||||
$(LD) --orphan-handling=error --print-memory-usage -T $(LIB)/ip.lds $^ -o $@
|
@ -1,23 +1,23 @@
|
||||
namespace memory {
|
||||
|
||||
template <typename T>
|
||||
void move(T * dst, const T * src, const uint32_t n)
|
||||
void move(T * dst, const T * src, uint32_t n)
|
||||
{
|
||||
if (dst < src) {
|
||||
while (n > 0) {
|
||||
*d++ = *s++;
|
||||
*dst++ = *src++;
|
||||
n--;
|
||||
}
|
||||
} else {
|
||||
while (n > 0) {
|
||||
n--;
|
||||
d[n] = s[n];
|
||||
dst[n] = src[n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void copy(T * dst, const T * src, const uint32_t n)
|
||||
inline void copy(T * dst, const T * src, uint32_t n)
|
||||
{
|
||||
while (n > 0) {
|
||||
*dst++ = *src++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user