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:
parent
e31d2c55fd
commit
102304e841
26
common.mk
26
common.mk
@ -1,10 +1,10 @@
|
|||||||
LIB ?= .
|
LIB ?= .
|
||||||
|
OPT ?= -Og
|
||||||
|
|
||||||
AARCH = --isa=sh2 --big
|
AARCH = --isa=sh2 --big
|
||||||
AFLAGS = -g -gdwarf-4
|
AFLAGS = -g -gdwarf-4
|
||||||
CFLAGS = -I$(LIB)
|
|
||||||
CFLAGS += -ffunction-sections -fshort-enums -ffreestanding -nostdlib
|
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
|
CXXFLAGS = -fno-exceptions -fno-rtti
|
||||||
CARCH = -m2 -mb
|
CARCH = -m2 -mb
|
||||||
|
|
||||||
@ -16,8 +16,6 @@ LD = $(TARGET)ld
|
|||||||
OBJCOPY = $(TARGET)objcopy
|
OBJCOPY = $(TARGET)objcopy
|
||||||
OBJDUMP = $(TARGET)objdump
|
OBJDUMP = $(TARGET)objdump
|
||||||
|
|
||||||
all: main.iso
|
|
||||||
|
|
||||||
$(LIB)/sys_%.o: $(LIB)/segasmp/lib/sys_%.o
|
$(LIB)/sys_%.o: $(LIB)/segasmp/lib/sys_%.o
|
||||||
$(OBJCOPY) -I coff-sh -O elf32-sh -g \
|
$(OBJCOPY) -I coff-sh -O elf32-sh -g \
|
||||||
--rename-section .text=.text.$* \
|
--rename-section .text=.text.$* \
|
||||||
@ -42,9 +40,6 @@ SYS_IP_OBJ += $(LIB)/smpsys.o
|
|||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(CXX) $(CFLAGS) $(CXXFLAGS) $(CARCH) -c $< -o $@
|
$(CXX) $(CFLAGS) $(CXXFLAGS) $(CARCH) -c $< -o $@
|
||||||
|
|
||||||
%.elf:
|
|
||||||
$(LD) --print-memory-usage -T $(LIB)/sys_ip.lds $^ -o $@
|
|
||||||
|
|
||||||
%.bin: %.elf
|
%.bin: %.elf
|
||||||
$(OBJCOPY) -O binary $< $@
|
$(OBJCOPY) -O binary $< $@
|
||||||
|
|
||||||
@ -54,11 +49,11 @@ SYS_IP_OBJ += $(LIB)/smpsys.o
|
|||||||
--rename-section .data=.rodata,alloc,load,readonly,data,contents \
|
--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)
|
sys_ip.elf: $(SYS_IP_OBJ)
|
||||||
$(LD) --print-memory-usage \
|
$(LD) --print-memory-usage -T $(LIB)/sys_ip.lds $^ -o $@
|
||||||
-T $(LIB)/sh2.lds $^ -o $@
|
|
||||||
|
|
||||||
# mkisofs sorts file names alphabetically, it does not place the files in the
|
# mkisofs sorts file names alphabetically, it does not place the files in the
|
||||||
# generated directory descriptors the order given on the command-line.
|
# generated directory descriptors the order given on the command-line.
|
||||||
@ -78,7 +73,7 @@ main.elf: $(MAIN_OBJ)
|
|||||||
# that do check this).
|
# that do check this).
|
||||||
#
|
#
|
||||||
# `-graft-points` is used to enable the "path grafting" pathspec syntax.
|
# `-graft-points` is used to enable the "path grafting" pathspec syntax.
|
||||||
main.iso: main.bin sys_ip.bin
|
%.iso: %.bin sys_ip.bin
|
||||||
mkisofs \
|
mkisofs \
|
||||||
-sysid "SEGA SEGASATURN" \
|
-sysid "SEGA SEGASATURN" \
|
||||||
-volid "SAMPLE_GAME_TITLE" \
|
-volid "SAMPLE_GAME_TITLE" \
|
||||||
@ -92,11 +87,16 @@ main.iso: main.bin sys_ip.bin
|
|||||||
-G sys_ip.bin \
|
-G sys_ip.bin \
|
||||||
-o $@ \
|
-o $@ \
|
||||||
-graft-points \
|
-graft-points \
|
||||||
/0main.bin=./main.bin \
|
/0${<}=./${<} \
|
||||||
/=$(LIB)/segasmp/smp_cpy.txt \
|
/=$(LIB)/segasmp/smp_cpy.txt \
|
||||||
/=$(LIB)/segasmp/smp_abs.txt \
|
/=$(LIB)/segasmp/smp_abs.txt \
|
||||||
/=$(LIB)/segasmp/smp_bib.txt
|
/=$(LIB)/segasmp/smp_bib.txt
|
||||||
|
|
||||||
|
%.cue: %.iso
|
||||||
|
@echo "FILE \"${<}\" BINARY" > $@
|
||||||
|
@echo " TRACK 01 MODE1/2048" >> $@
|
||||||
|
@echo " INDEX 01 00:00:00" >> $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.iso *.o *.bin *.elf
|
rm -f *.iso *.o *.bin *.elf
|
||||||
|
|
||||||
|
3
sh2.h
3
sh2.h
@ -1,3 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
|
|
||||||
typedef struct sh2_reg {
|
typedef struct sh2_reg {
|
||||||
@ -98,6 +100,7 @@ typedef struct sh2_reg {
|
|||||||
static_assert((sizeof (struct sh2_reg)) == 0x200);
|
static_assert((sizeof (struct sh2_reg)) == 0x200);
|
||||||
static_assert((offsetof (struct sh2_reg, OCRAB)) == 0x014);
|
static_assert((offsetof (struct sh2_reg, OCRAB)) == 0x014);
|
||||||
static_assert((offsetof (struct sh2_reg, BCR1)) == 0x1e0);
|
static_assert((offsetof (struct sh2_reg, BCR1)) == 0x1e0);
|
||||||
|
static_assert((offsetof (struct sh2_reg, DVSR)) == 0x100);
|
||||||
|
|
||||||
struct sh2 {
|
struct sh2 {
|
||||||
sh2_reg reg;
|
sh2_reg reg;
|
||||||
|
5
vdp2.h
5
vdp2.h
@ -101,8 +101,13 @@ typedef struct vdp2_reg {
|
|||||||
reg16 SCYN3; /* SCREEN SCROLL VALUE (NBG3, VERTICAL) */
|
reg16 SCYN3; /* SCREEN SCROLL VALUE (NBG3, VERTICAL) */
|
||||||
reg16 ZMCTL; /* REDUCTION ENABLE */
|
reg16 ZMCTL; /* REDUCTION ENABLE */
|
||||||
reg16 SCRCTL; /* LINE AND VERTICAL CELL SCROLL CONTROL (NBGO, NBG1) */
|
reg16 SCRCTL; /* LINE AND VERTICAL CELL SCROLL CONTROL (NBGO, NBG1) */
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
reg16 VCSTAU; /* VERTICAL CELL SCROLL TABLE ADDRESS (NBGO, NBG1) */
|
reg16 VCSTAU; /* VERTICAL CELL SCROLL TABLE ADDRESS (NBGO, NBG1) */
|
||||||
reg16 VCSTAL; /* 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 LSTA0U; /* LINE SCROLL TABLE ADDRESS (NBG0) */
|
||||||
reg16 LSTA0L; /* LINE SCROLL TABLE ADDRESS (NBG0) */
|
reg16 LSTA0L; /* LINE SCROLL TABLE ADDRESS (NBG0) */
|
||||||
reg16 LSTA1U; /* LINE SCROLL TABLE ADDRESS (NBG1) */
|
reg16 LSTA1U; /* LINE SCROLL TABLE ADDRESS (NBG1) */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user