Skip to content

Commit 595b3f6

Browse files
committed
Initial code commit of an open source ROM
1 parent 6cdbfe2 commit 595b3f6

7 files changed

Lines changed: 4231 additions & 4 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: FOSS-RCX-ROM CI
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# Following POSIX cron syntax, run every Monday morning at 5:30 AM UTC
7+
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07
8+
- cron: '30 5 * * 1'
9+
push:
10+
# branches: [ master ]
11+
pull_request:
12+
# branches: [ master ]
13+
14+
jobs:
15+
build:
16+
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [ ubuntu-latest ]
22+
23+
steps:
24+
- name: Checkout BrickEmu
25+
uses: actions/checkout@v4
26+
- name: apt-get update
27+
run: sudo apt-get --assume-yes update
28+
- name: Install build dependencies
29+
run: sudo apt-get --assume-yes install binutils-h8300-hms
30+
- name: Build ROM
31+
run: |
32+
make
33+
- name: Archive the Build Outputs
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: foss-rcx-rom_[runner~${{ matrix.os }}]_run${{ github.run_id }}.${{ github.run_number }}.${{ github.run_attempt }}
37+
path: |
38+
build/*
39+
- name: Test Install the Build
40+
run: |
41+
make install
42+
- name: Test Stow the Build
43+
run: |
44+
sudo make stow

.gitignore

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
# Build Folder
2+
build/
3+
14
# Prerequisites
25
*.d
36

4-
# Object files
7+
# Object Files
58
*.o
69
*.ko
710
*.obj
811
*.elf
912

10-
# Linker output
13+
# Linker Output
1114
*.ilk
1215
*.map
1316
*.exp
@@ -22,7 +25,7 @@
2225
*.la
2326
*.lo
2427

25-
# Shared objects (inc. Windows DLLs)
28+
# Shared Objects (inc. Windows DLLs)
2629
*.dll
2730
*.so
2831
*.so.*
@@ -36,7 +39,7 @@
3639
*.x86_64
3740
*.hex
3841

39-
# Debug files
42+
# Debug Files
4043
*.dSYM/
4144
*.su
4245
*.idb

Makefile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Development Packages:
2+
# * Required: h8300 binutils
3+
4+
# Using $(abspath x) here so that symlinks are NOT replaced
5+
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
6+
MAKEFILE_DIR := $(abspath $(dir $(MAKEFILE_PATH)))
7+
MAKEFILE_NAME := $(notdir $(MAKEFILE_PATH))
8+
9+
TARGET_ARCH = h8300-lego-coff
10+
11+
CROSSTOOLPREFIX ?= h8300-hitachi-coff-
12+
CROSSTOOLSUFFIX ?= -3
13+
14+
CROSSAS ?= $(CROSSTOOLPREFIX)as$(CROSSTOOLSUFFIX)
15+
CROSSLD ?= $(CROSSTOOLPREFIX)ld$(CROSSTOOLSUFFIX)
16+
CROSSOBJCOPY ?= $(CROSSTOOLPREFIX)objcopy$(CROSSTOOLSUFFIX)
17+
18+
SRC_DIR = src
19+
BUILD_DIR ?= build
20+
OBJ_DIR = $(BUILD_DIR)
21+
22+
BASENAME = foss-rom
23+
OUTPUT_TYPES ?= coff bin srec ld
24+
OUTPUT_FILES = $(OUTPUT_TYPES:%=$(BASENAME).%)
25+
OUTPUT_FILE_PATHS = $(OUTPUT_FILES:%=$(BUILD_DIR)/%)
26+
27+
# Installation Path Configuration
28+
DESTDIR ?=
29+
prefix ?= /opt/stow/foss-rcx-rom
30+
pkgtargetkerneldir ?= ${prefix}/${TARGET_ARCH}/boot
31+
32+
33+
all: $(OUTPUT_FILE_PATHS)
34+
35+
clean:
36+
rm -f -r $(BUILD_DIR)
37+
38+
realclean: clean
39+
40+
install: $(OUTPUT_FILE_PATHS)
41+
test -d $(DESTDIR)$(pkgtargetkerneldir) || mkdir -p $(DESTDIR)$(pkgtargetkerneldir)
42+
install -v --mode=644 $(OUTPUT_FILE_PATHS) "$(DESTDIR)$(pkgtargetkerneldir)"
43+
44+
uninstall:
45+
cd "$(DESTDIR)$(pkgtargetkerneldir) && rm -f $(OUTPUT_FILES)
46+
47+
48+
$(BUILD_DIR)/%.ld: $(SRC_DIR)/%.ld
49+
test -d $(BUILD_DIR) || mkdir -p $(BUILD_DIR)
50+
test -d $(OBJ_DIR) || mkdir -p $(OBJ_DIR)
51+
cp $< $@
52+
53+
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.s $(SRC_DIR)/%-lcd.s $(BUILD_DIR)/%.ld
54+
$(CROSSAS) -I $(SRC_DIR) -o $@ $<
55+
56+
$(BUILD_DIR)/%.coff: $(OBJ_DIR)/%.o $(SRC_DIR)/%.ld
57+
$(CROSSLD) -T $(word 2,$^) -relax -nostdlib $< -o $@
58+
59+
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.coff
60+
$(CROSSOBJCOPY) -I coff-h8300 -O binary $< $@
61+
62+
$(BUILD_DIR)/%.srec: $(BUILD_DIR)/%.coff
63+
$(CROSSOBJCOPY) -I coff-h8300 -O srec $< $@
64+
65+
66+
# Cancel default rules
67+
.SUFFIXES:
68+
69+
include $(MAKEFILE_DIR)/Makefile.utility

Makefile.utility

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
### ==========================================================================
2+
### $Id$ 2025-05-12 Matthew Sheets
3+
### FILE: Makefile.utility - Useful project-independent make targets
4+
### Includes support for
5+
### * Stow: Makes the process of managing manual installs/uninstalls cleaner
6+
### https://www.gnu.org/software/stow/
7+
### * Debugging and troubleshooting
8+
### - list-variables target: Outputs defined make variables & their values
9+
### - submake-list target: Outputs list-variables for a submake
10+
### --------------------------------------------------------------------------
11+
12+
# ----------------------------------------------------------------------------
13+
# Stow Support
14+
# ----------------------------------------------------------------------------
15+
16+
# Stow Variables
17+
#
18+
STOW_TARGET ?= /usr/local
19+
STOW_DIR ?= $(dir $(abspath $(prefix)))
20+
STOW_PACKAGE = $(shell basename $(abspath $(prefix)))
21+
STOW_STANDARD_ARGS = --dir=$(DESTDIR)$(STOW_DIR) --target=$(DESTDIR)$(STOW_TARGET) --verbose
22+
23+
# If STOW_DIR does not exist, the name of the target to execute to create it
24+
STOW_PREREQ_TARGET ?= install
25+
26+
# Stow Targets
27+
#
28+
29+
# Defining STOW_DIR as a prerequisite of stow and
30+
# install as a prerequitise of STOW_DIR still causes
31+
# the install target to executed every time, even if
32+
# configured as an order-only prerequisite. Thus,
33+
# we check for STOW_DIR and trigger install manually.
34+
stow: stow-check-package
35+
ifeq (,$(wildcard $(DESTDIR)$(STOW_DIR)))
36+
$(MAKE) $(STOW_PREREQ_TARGET)
37+
endif
38+
stow $(STOW_STANDARD_ARGS) --stow "$(STOW_PACKAGE)"
39+
40+
restow: stow-check-package
41+
stow $(STOW_STANDARD_ARGS) --restow "$(STOW_PACKAGE)"
42+
43+
unstow: stow-check-package
44+
stow $(STOW_STANDARD_ARGS) --delete "$(STOW_PACKAGE)"
45+
46+
stow-check-package:
47+
ifndef prefix
48+
$(error The "prefix" variable needed by Stow is undefined)
49+
else
50+
@echo "Stow package name identified as \"$(STOW_PACKAGE)\""
51+
endif
52+
53+
54+
# ----------------------------------------------------------------------------
55+
# Output information about the environment
56+
# ----------------------------------------------------------------------------
57+
list-variables:
58+
$(foreach v, \
59+
$(shell echo "$(filter-out .VARIABLES,$(.VARIABLES))" | tr ' ' '\n' | sort), \
60+
$(info $(shell printf "%-20s" "$(v)")= $(value $(v))) \
61+
)
62+
63+
submake-list:
64+
$(MAKE) list-variables
65+
66+
67+
# ----------------------------------------------------------------------------
68+
# Declare "phony" targets
69+
# ----------------------------------------------------------------------------
70+
.PHONY: stow restow unstow stow-check-package list-variables submake-list
71+
72+
### --------------------------------------------------------------------------
73+
### End of FILE: Makefile.utility
74+
### ==========================================================================

0 commit comments

Comments
 (0)