Skip to content

Commit

Permalink
Add demo
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Aug 18, 2024
1 parent e9f6529 commit ff1a68f
Show file tree
Hide file tree
Showing 17 changed files with 3,318 additions and 0 deletions.
18 changes: 18 additions & 0 deletions demo/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.231.6/containers/ubuntu/.devcontainer/base.Dockerfile

# [Choice] Ubuntu version (use hirsuite or bionic on local arm64/Apple Silicon): hirsute, focal, bionic
ARG VARIANT="focal"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

RUN sudo apt update && apt install -y curl zstd make jq

RUN curl -sL --fail -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/viciious/32XDK/releases/tags/20190504" \
| jq -r ".assets | .[] | select(.name | test(\"chillys-sega-devkit-20190504-opt.tar.zst$\")) | .url" \
| xargs curl -sL --fail -H "Accept: application/octet-stream" -O /dev/stdout | zstdcat | tar -C / -xa

RUN sudo apt -y install genisoimage
35 changes: 35 additions & 0 deletions demo/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.231.6/containers/ubuntu
{
"name": "Ubuntu",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Ubuntu version: hirsute, focal, bionic
// Use hirsute or bionic on local arm64/Apple Silicon.
"args": { "VARIANT": "focal" }
},

// Set *default* container specific settings.json values on container create.
"settings": {},


// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"ms-vscode.cpptools",
"steventattersall.m68k",
"ms-vscode.cpptools-extension-pack"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {
"git": "os-provided"
}

}
13 changes: 13 additions & 0 deletions demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.elf
*.map
*.o
*.zip
*.xdelta
*.iso
*.cue
*.elf
.github
.vscode
.cd
cd
CDROMPlayer.bin
21 changes: 21 additions & 0 deletions demo/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Joseph Fenton

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
65 changes: 65 additions & 0 deletions demo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ifdef $(GENDEV)
ROOTDIR = $(GENDEV)
else
ROOTDIR = /opt/toolchains/sega
endif

LDSCRIPTSDIR = $(ROOTDIR)/ldscripts

BOOTBLOCKDIR = $(ROOTDIR)/bootblocks
BOOTBLOCK = $(BOOTBLOCKDIR)/US_BOOT.BIN
#BOOTBLOCK = $(BOOTBLOCKDIR)/EU_BOOT.BIN
#BOOTBLOCK = $(BOOTBLOCKDIR)/JP_BOOT.BIN

LIBPATH = -L$(ROOTDIR)/m68k-elf/lib -L$(ROOTDIR)/m68k-elf/lib/gcc/m68k-elf/4.6.2 -L$(ROOTDIR)/m68k-elf/m68k-elf/lib
INCPATH = -I. -I../include -I$(ROOTDIR)/m68k-elf/include -I$(ROOTDIR)/m68k-elf/m68k-elf/include

CCFLAGS = -m68000 -Wall -O1 -c -fomit-frame-pointer
HWFLAGS = -m68000 -Wall -O1 -c -fomit-frame-pointer
LDFLAGS = -T $(LDSCRIPTSDIR)/cd.ld -Wl,-Map=output.map -nostdlib
ASFLAGS = -m68000 --register-prefix-optional

PREFIX = $(ROOTDIR)/m68k-elf/bin/m68k-elf-
CC = $(PREFIX)gcc
AS = $(PREFIX)as
LD = $(PREFIX)ld
OBJC = $(PREFIX)objcopy

ASMZ80 = $(ROOTDIR)/bin/zasm
FLAGSZ80 = -vb2

DD = dd
RM = rm -rf

TARGET = CDROMPlayer
LIBS = $(LIBPATH) -lc -lgcc -lnosys
OBJS = crt0.o main.o hw_md.o
FILES =

all: $(TARGET).bin

$(TARGET).bin: $(TARGET).elf
$(OBJC) -O binary $< temp.bin
$(DD) if=temp.bin of=$@ bs=2048 conv=sync

$(TARGET).elf: $(OBJS) $(FILES)
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) $(FILES) -o $(TARGET).elf

%.o80: %.s80
$(ASMZ80) $(FLAGSZ80) -o $@ $<

%.o: %.c
$(CC) $(CCFLAGS) $(INCPATH) $< -o $@

%.o: %.s
$(AS) $(ASFLAGS) $(INCPATH) $< -o $@

cd: $(TARGET).bin
mkdir -p cd
mkdir -p cd/ROMs
cp $(TARGET).bin cd/APP.BIN
cp -r ROMs/* cd/ROMs/
genisoimage -sysid "SEGA SEGACD" -volid "CDROMPLAYER" -generic-boot $(BOOTBLOCK) -full-iso9660-filenames -o $(TARGET).iso cd

clean:
$(RM) *.o *.o80 *.bin *.elf *.map *.log *.iso cd
19 changes: 19 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ROM Loader for the Mega 32X RAM Cart

This project shows an example of how to load files onto the 4MiB RAM cart.

## Description

Make sure the lower switch on the cart is set to "boot off the CD" position. Write the ISO file of this project to a CD-R and boot using the SegaCD addon.

After initial loading, the program will list files it was able to find on the CD. Select a ROM file from the CD and press A to write it onto the RAM cart. Pressing B will verify ROM/RAM contents with the selected file.

To boot off the previously written ROM, you need to toggle the lower switch to the off position and power cycle the console. Pressing the RESET button on the console will not work!

## "ROM Loader for the Mega 32X RAM Cart" Credits
* Programming : Chilly Willy and Victor Luchits
* Base Docker Code : Victor Luchits
##

## License
All original code is available under the MIT license.
Binary file added demo/ROMs/Mode1PCM.bin
Binary file not shown.
1 change: 1 addition & 0 deletions demo/ROMs/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Files go in this folder.
Binary file not shown.
45 changes: 45 additions & 0 deletions demo/crt0.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
| SEGA CD support code
| by Chilly Willy

.text

| CD startup at 0x8000

.global _start
_start:
move #0x2700,sr /* disable interrupts */

| Clear BSS
lea __bss_start,a0
lea __bss_end,a1
moveq #0,d0
1:
move.l d0,(a0)+
cmpa.l a0,a1
bhi.b 1b

move.l sp,__stack_save /* save BIOS stack pointer */
lea __stack,a0
movea.l a0,sp /* set stack pointer to top of Program RAM */
link.w a6,#-8 /* set up initial stack frame */

jsr init_hardware /* initialize the console hardware */

jsr __INIT_SECTION__ /* do all program initializers */
jsr main /* call program main() */
jsr __FINI_SECTION__ /* do all program finishers */

movea.l __stack_save,sp /* restore BIOS stack pointer */
moveq #0,d0
rts


.data

.align 4

__stack_save:
.long 0

.text

5 changes: 5 additions & 0 deletions demo/files.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#define NUM_FILES 5

extern char *fileName[NUM_FILES];
extern int fileSize[NUM_FILES];
extern int filePtr[NUM_FILES];
4 changes: 4 additions & 0 deletions demo/files.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.text

.align 4

Loading

0 comments on commit ff1a68f

Please sign in to comment.