Skip to content

Commit

Permalink
Merge pull request #1 from diegoparrilla/first
Browse files Browse the repository at this point in the history
First commit
  • Loading branch information
diegoparrilla authored Aug 28, 2023
2 parents ff721d9 + 3aaae6e commit 6f7fde6
Show file tree
Hide file tree
Showing 12 changed files with 805 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build

# Trigger when a pull request is received
on:
pull_request:

jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ "3.10" ]
steps:
- name: Checkout the code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install AtariST Toolkit Docker image
run: curl -sL https://github.com/diegoparrilla/atarist-toolkit-docker/releases/download/latest/linux.sh | bash

- name: Run - remove interactive
run: sed -i 's/-it//' /usr/local/bin/stcmd

- name: Run - Build executable and not publish
run: ./build.sh ${GITHUB_WORKSPACE} all
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [ "3.10" ]
include:
- os: ubuntu-latest
firmware_name: FIRMWARE.IMG
boot_name: BOOT.BIN
steps:
- name: Checkout the code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install AtariST Toolkit Docker image
run: curl -sL https://github.com/diegoparrilla/atarist-toolkit-docker/releases/download/latest/linux.sh | bash

- name: Run - remove interactive
run: sed -i 's/-it//' /usr/local/bin/stcmd

- name: Run build and publish
run: ./build.sh ${GITHUB_WORKSPACE} release

- name: Upload the ROM image file
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/${{ matrix.firmware_name }}
asset_name: ${{ matrix.firmware_name }}
tag: ${{ github.ref }}
overwrite: true
- name: Upload the ROM image file to latest
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/${{ matrix.firmware_name }}
asset_name: ${{ matrix.firmware_name }}
tag: latest
overwrite: true
- name: Upload the trimmed ROM image file
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/${{ matrix.boot_name }}
asset_name: ${{ matrix.boot_name }}
tag: ${{ github.ref }}
overwrite: true
- name: Upload the trimmed ROM image file to latest
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/${{ matrix.boot_name }}
asset_name: ${{ matrix.boot_name }}
tag: latest
overwrite: true

8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,11 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

.history/
build/
dist/
test/
romloader/build/
romloader/dist/
romloader/test/
53 changes: 53 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Version from file
VERSION := $(shell cat version.txt)

# Folder and file names
ODIR = ./obj
SOURCES_DIR = ./src
BUILD_DIR = ./build
DIST_DIR = ./dist
BIN = BOOT.BIN

# VASM PARAMETERS
# _DEBUG: 1 to enable debug, 0 to disable them
# To disable debug, make target DEBUG_MODE=0
DEBUG_MODE = 1
VASMFLAGS=-Faout -quiet -x -m68000 -spaces -showopt -devpac -D_DEBUG=$(DEBUG_MODE)
VASM = vasm
VLINK = vlink

.PHONY: all
all: prepare dist

.PHONY: release
release: prepare dist

.PHONY: prepare
prepare: clean
mkdir -p $(BUILD_DIR)

clean-compile : clean main.o

main.o: prepare
$(VASM) $(VASMFLAGS) $(SOURCES_DIR)/main.s -o $(BUILD_DIR)/main.o

.PHONY: build
build: main.o
$(VLINK) $(BUILD_DIR)/$^ -brawbin1 -o $(BUILD_DIR)/$(BIN)


.PHONY: dist
dist: build
mkdir -p $(DIST_DIR)
cp $(BUILD_DIR)/$(BIN) $(DIST_DIR)

.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
rm -rf $(DIST_DIR)

## Tag this version
.PHONY: tag
tag:
git tag v$(VERSION) && git push origin v$(VERSION) && \
echo "Tagged: $(VERSION)"
46 changes: 46 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

# Ensure an argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <working_folder> all|release"
exit 1
fi

if [ -z "$2" ]; then
echo "Usage: $0 <working_folder> all|release"
exit 1
fi


working_folder=$1
build_type=$2

ST_WORKING_FOLDER=$working_folder/romloader stcmd make $build_type
ST_WORKING_FOLDER=$working_folder stcmd make $build_type

filename="./dist/FIRMWARE.IMG"

# Copy the BOOT.BIN file to a ROM size file for testing
ST_WORKING_FOLDER=$working_folder stcmd cp ./dist/BOOT.BIN $filename

# Determine the file size accordingly
filesize=$(ST_WORKING_FOLDER=$working_folder stcmd stat -c %s "$filename")

# Size for 64Kbytes in bytes
targetsize=$((64 * 1024))

# Check if the file is larger than 64Kbytes
if [ "$filesize" -gt "$targetsize" ]; then
echo "The file is already larger than 64Kbytes."
exit 2
fi

# Resize the file to 64Kbytes
ST_WORKING_FOLDER=$working_folder stcmd truncate -s $targetsize $filename

if [ $? -ne 0 ]; then
echo "Failed to resize the file."
exit 3
fi

echo "File has been resized to 64Kbytes."
80 changes: 80 additions & 0 deletions romloader/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Version from file
VERSION := $(shell cat version.txt)

# Folder and file names
ODIR = ./obj
SOURCES_DIR = ./src
BUILD_DIR = ./build
DIST_DIR = ./dist
EXE = ROMLOAD.TOS

# VASM PARAMETERS
# _DEBUG: 1 to enable debug, 0 to disable them
# To disable debug, make target DEBUG_MODE=0
VASMFLAGS=-Faout -quiet -x -m68000 -spaces -showopt -devpac -D_DEBUG=$(DEBUG_MODE)
VASM = vasm
VLINK = vlink

# LIBCMINI PARAMETERS
# IMPORTANT! There is functional verson of the LIBCMINI library in the docker image
# To reference the library, it must set the absolute path inside the container image
# The library is stored in /freemint/libcmini
# More info about the library: https://github.com/freemint/libcmini
LIBCMINI = /freemint/libcmini

# GCC PARAMETERS
CC = m68k-atari-mint-gcc
CFLAGS=-c -std=gnu99 -I$(LIBCMINI)/include -Os -DVERSION=\"$(VERSION)\"

# Check if DEBUG_MODE is not empty
ifneq ($(DEBUG_MODE),)
CFLAGS += -D_DEBUG=$(DEBUG_MODE)
endif

# LINKER PARAMETERS
# Add the -s option to strip the binary
LINKFLAGS=-nostdlib -L$(LIBCMINI)/lib -lcmini -lgcc -Wl,--traditional-format -s

_OBJS =

OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))

.PHONY: all
all: dist prepare

.PHONY: release
release: dist prepare

.PHONY: prepare
prepare: clean
mkdir -p $(BUILD_DIR)

clean-compile : clean main.o screen.o

# All C files
main.o: prepare
$(CC) $(CFLAGS) $(SOURCES_DIR)/main.c -o $(BUILD_DIR)/main.o

screen.o: prepare
$(CC) $(CFLAGS) $(SOURCES_DIR)/screen.c -o $(BUILD_DIR)/screen.o

main: main.o screen.o
$(CC) $(LIBCMINI)/lib/crt0.o \
$(BUILD_DIR)/screen.o \
$(BUILD_DIR)/main.o \
-o $(BUILD_DIR)/$(EXE) $(LINKFLAGS);

.PHONY: dist
dist: main
mkdir -p $(DIST_DIR)
cp $(BUILD_DIR)/$(EXE) $(DIST_DIR)

.PHONY: clean
clean:
rm -rf $(BUILD_DIR)

## Tag this version
.PHONY: tag
tag:
git tag v$(VERSION) && git push origin v$(VERSION) && \
echo "Tagged: $(VERSION)"
Loading

0 comments on commit 6f7fde6

Please sign in to comment.