improve common.mk

This makes it possible to produce more than one iso/cue, lifting a bit more work
to the outside Makefile.
This commit is contained in:
Zack Buhman 2023-01-24 23:24:56 -08:00
parent e31d2c55fd
commit 102304e841
4 changed files with 23 additions and 18 deletions

View File

@ -1,10 +1,10 @@
LIB ?= .
OPT ?= -Og
AARCH = --isa=sh2 --big
AFLAGS = -g -gdwarf-4
CFLAGS = -I$(LIB)
CFLAGS += -ffunction-sections -fshort-enums -ffreestanding -nostdlib
CFLAGS += -Wall -Werror -Wfatal-errors -Wno-error=unused-variable -g -gdwarf-4 -Og
CFLAGS += -Wall -Werror -Wfatal-errors -Wno-error=unused-variable -g -gdwarf-4 $(OPT)
CXXFLAGS = -fno-exceptions -fno-rtti
CARCH = -m2 -mb
@ -16,8 +16,6 @@ LD = $(TARGET)ld
OBJCOPY = $(TARGET)objcopy
OBJDUMP = $(TARGET)objdump
all: main.iso
$(LIB)/sys_%.o: $(LIB)/segasmp/lib/sys_%.o
$(OBJCOPY) -I coff-sh -O elf32-sh -g \
--rename-section .text=.text.$* \
@ -42,9 +40,6 @@ SYS_IP_OBJ += $(LIB)/smpsys.o
%.o: %.cpp
$(CXX) $(CFLAGS) $(CXXFLAGS) $(CARCH) -c $< -o $@
%.elf:
$(LD) --print-memory-usage -T $(LIB)/sys_ip.lds $^ -o $@
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
@ -54,11 +49,11 @@ SYS_IP_OBJ += $(LIB)/smpsys.o
--rename-section .data=.rodata,alloc,load,readonly,data,contents \
$< $@
sys_ip.elf: $(SYS_IP_OBJ)
%.elf:
$(LD) --print-memory-usage -T $(LIB)/sh2.lds $^ -o $@
main.elf: $(MAIN_OBJ)
$(LD) --print-memory-usage \
-T $(LIB)/sh2.lds $^ -o $@
sys_ip.elf: $(SYS_IP_OBJ)
$(LD) --print-memory-usage -T $(LIB)/sys_ip.lds $^ -o $@
# mkisofs sorts file names alphabetically, it does not place the files in the
# generated directory descriptors the order given on the command-line.
@ -78,7 +73,7 @@ main.elf: $(MAIN_OBJ)
# that do check this).
#
# `-graft-points` is used to enable the "path grafting" pathspec syntax.
main.iso: main.bin sys_ip.bin
%.iso: %.bin sys_ip.bin
mkisofs \
-sysid "SEGA SEGASATURN" \
-volid "SAMPLE_GAME_TITLE" \
@ -92,11 +87,16 @@ main.iso: main.bin sys_ip.bin
-G sys_ip.bin \
-o $@ \
-graft-points \
/0main.bin=./main.bin \
/0${<}=./${<} \
/=$(LIB)/segasmp/smp_cpy.txt \
/=$(LIB)/segasmp/smp_abs.txt \
/=$(LIB)/segasmp/smp_bib.txt
%.cue: %.iso
@echo "FILE \"${<}\" BINARY" > $@
@echo " TRACK 01 MODE1/2048" >> $@
@echo " INDEX 01 00:00:00" >> $@
clean:
rm -f *.iso *.o *.bin *.elf

View File

@ -1,3 +0,0 @@
FILE "main.iso" BINARY
TRACK 01 MODE1/2048
INDEX 01 00:00:00

3
sh2.h
View File

@ -1,3 +1,5 @@
#pragma once
#include "type.h"
typedef struct sh2_reg {
@ -98,6 +100,7 @@ typedef struct sh2_reg {
static_assert((sizeof (struct sh2_reg)) == 0x200);
static_assert((offsetof (struct sh2_reg, OCRAB)) == 0x014);
static_assert((offsetof (struct sh2_reg, BCR1)) == 0x1e0);
static_assert((offsetof (struct sh2_reg, DVSR)) == 0x100);
struct sh2 {
sh2_reg reg;

5
vdp2.h
View File

@ -101,8 +101,13 @@ typedef struct vdp2_reg {
reg16 SCYN3; /* SCREEN SCROLL VALUE (NBG3, VERTICAL) */
reg16 ZMCTL; /* REDUCTION ENABLE */
reg16 SCRCTL; /* LINE AND VERTICAL CELL SCROLL CONTROL (NBGO, NBG1) */
union {
struct {
reg16 VCSTAU; /* VERTICAL CELL SCROLL TABLE ADDRESS (NBGO, NBG1) */
reg16 VCSTAL; /* VERTICAL CELL SCROLL TABLE ADDRESS (NBGO, NBG1) */
};
reg32 VCSTA;
};
reg16 LSTA0U; /* LINE SCROLL TABLE ADDRESS (NBG0) */
reg16 LSTA0L; /* LINE SCROLL TABLE ADDRESS (NBG0) */
reg16 LSTA1U; /* LINE SCROLL TABLE ADDRESS (NBG1) */