Skip to content

Commit ff1a68f

Browse files
committed
Add demo
1 parent e9f6529 commit ff1a68f

17 files changed

+3318
-0
lines changed

demo/.devcontainer/Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.231.6/containers/ubuntu/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Ubuntu version (use hirsuite or bionic on local arm64/Apple Silicon): hirsute, focal, bionic
4+
ARG VARIANT="focal"
5+
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
6+
7+
# [Optional] Uncomment this section to install additional OS packages.
8+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
9+
# && apt-get -y install --no-install-recommends <your-package-list-here>
10+
11+
RUN sudo apt update && apt install -y curl zstd make jq
12+
13+
RUN curl -sL --fail -H "Accept: application/vnd.github.v3+json" \
14+
"https://api.github.com/repos/viciious/32XDK/releases/tags/20190504" \
15+
| jq -r ".assets | .[] | select(.name | test(\"chillys-sega-devkit-20190504-opt.tar.zst$\")) | .url" \
16+
| xargs curl -sL --fail -H "Accept: application/octet-stream" -O /dev/stdout | zstdcat | tar -C / -xa
17+
18+
RUN sudo apt -y install genisoimage

demo/.devcontainer/devcontainer.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.231.6/containers/ubuntu
3+
{
4+
"name": "Ubuntu",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
// Update 'VARIANT' to pick an Ubuntu version: hirsute, focal, bionic
8+
// Use hirsute or bionic on local arm64/Apple Silicon.
9+
"args": { "VARIANT": "focal" }
10+
},
11+
12+
// Set *default* container specific settings.json values on container create.
13+
"settings": {},
14+
15+
16+
// Add the IDs of extensions you want installed when the container is created in the array below.
17+
"extensions": [
18+
"ms-vscode.cpptools",
19+
"steventattersall.m68k",
20+
"ms-vscode.cpptools-extension-pack"
21+
],
22+
23+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
24+
// "forwardPorts": [],
25+
26+
// Use 'postCreateCommand' to run commands after the container is created.
27+
// "postCreateCommand": "uname -a",
28+
29+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
30+
"remoteUser": "vscode",
31+
"features": {
32+
"git": "os-provided"
33+
}
34+
35+
}

demo/.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.elf
2+
*.map
3+
*.o
4+
*.zip
5+
*.xdelta
6+
*.iso
7+
*.cue
8+
*.elf
9+
.github
10+
.vscode
11+
.cd
12+
cd
13+
CDROMPlayer.bin

demo/LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Joseph Fenton
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

demo/Makefile

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
ifdef $(GENDEV)
2+
ROOTDIR = $(GENDEV)
3+
else
4+
ROOTDIR = /opt/toolchains/sega
5+
endif
6+
7+
LDSCRIPTSDIR = $(ROOTDIR)/ldscripts
8+
9+
BOOTBLOCKDIR = $(ROOTDIR)/bootblocks
10+
BOOTBLOCK = $(BOOTBLOCKDIR)/US_BOOT.BIN
11+
#BOOTBLOCK = $(BOOTBLOCKDIR)/EU_BOOT.BIN
12+
#BOOTBLOCK = $(BOOTBLOCKDIR)/JP_BOOT.BIN
13+
14+
LIBPATH = -L$(ROOTDIR)/m68k-elf/lib -L$(ROOTDIR)/m68k-elf/lib/gcc/m68k-elf/4.6.2 -L$(ROOTDIR)/m68k-elf/m68k-elf/lib
15+
INCPATH = -I. -I../include -I$(ROOTDIR)/m68k-elf/include -I$(ROOTDIR)/m68k-elf/m68k-elf/include
16+
17+
CCFLAGS = -m68000 -Wall -O1 -c -fomit-frame-pointer
18+
HWFLAGS = -m68000 -Wall -O1 -c -fomit-frame-pointer
19+
LDFLAGS = -T $(LDSCRIPTSDIR)/cd.ld -Wl,-Map=output.map -nostdlib
20+
ASFLAGS = -m68000 --register-prefix-optional
21+
22+
PREFIX = $(ROOTDIR)/m68k-elf/bin/m68k-elf-
23+
CC = $(PREFIX)gcc
24+
AS = $(PREFIX)as
25+
LD = $(PREFIX)ld
26+
OBJC = $(PREFIX)objcopy
27+
28+
ASMZ80 = $(ROOTDIR)/bin/zasm
29+
FLAGSZ80 = -vb2
30+
31+
DD = dd
32+
RM = rm -rf
33+
34+
TARGET = CDROMPlayer
35+
LIBS = $(LIBPATH) -lc -lgcc -lnosys
36+
OBJS = crt0.o main.o hw_md.o
37+
FILES =
38+
39+
all: $(TARGET).bin
40+
41+
$(TARGET).bin: $(TARGET).elf
42+
$(OBJC) -O binary $< temp.bin
43+
$(DD) if=temp.bin of=$@ bs=2048 conv=sync
44+
45+
$(TARGET).elf: $(OBJS) $(FILES)
46+
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) $(FILES) -o $(TARGET).elf
47+
48+
%.o80: %.s80
49+
$(ASMZ80) $(FLAGSZ80) -o $@ $<
50+
51+
%.o: %.c
52+
$(CC) $(CCFLAGS) $(INCPATH) $< -o $@
53+
54+
%.o: %.s
55+
$(AS) $(ASFLAGS) $(INCPATH) $< -o $@
56+
57+
cd: $(TARGET).bin
58+
mkdir -p cd
59+
mkdir -p cd/ROMs
60+
cp $(TARGET).bin cd/APP.BIN
61+
cp -r ROMs/* cd/ROMs/
62+
genisoimage -sysid "SEGA SEGACD" -volid "CDROMPLAYER" -generic-boot $(BOOTBLOCK) -full-iso9660-filenames -o $(TARGET).iso cd
63+
64+
clean:
65+
$(RM) *.o *.o80 *.bin *.elf *.map *.log *.iso cd

demo/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# ROM Loader for the Mega 32X RAM Cart
2+
3+
This project shows an example of how to load files onto the 4MiB RAM cart.
4+
5+
## Description
6+
7+
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.
8+
9+
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.
10+
11+
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!
12+
13+
## "ROM Loader for the Mega 32X RAM Cart" Credits
14+
* Programming : Chilly Willy and Victor Luchits
15+
* Base Docker Code : Victor Luchits
16+
##
17+
18+
## License
19+
All original code is available under the MIT license.

demo/ROMs/Mode1PCM.bin

512 KB
Binary file not shown.

demo/ROMs/ReadMe.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Files go in this folder.
Binary file not shown.

demo/crt0.s

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
| SEGA CD support code
2+
| by Chilly Willy
3+
4+
.text
5+
6+
| CD startup at 0x8000
7+
8+
.global _start
9+
_start:
10+
move #0x2700,sr /* disable interrupts */
11+
12+
| Clear BSS
13+
lea __bss_start,a0
14+
lea __bss_end,a1
15+
moveq #0,d0
16+
1:
17+
move.l d0,(a0)+
18+
cmpa.l a0,a1
19+
bhi.b 1b
20+
21+
move.l sp,__stack_save /* save BIOS stack pointer */
22+
lea __stack,a0
23+
movea.l a0,sp /* set stack pointer to top of Program RAM */
24+
link.w a6,#-8 /* set up initial stack frame */
25+
26+
jsr init_hardware /* initialize the console hardware */
27+
28+
jsr __INIT_SECTION__ /* do all program initializers */
29+
jsr main /* call program main() */
30+
jsr __FINI_SECTION__ /* do all program finishers */
31+
32+
movea.l __stack_save,sp /* restore BIOS stack pointer */
33+
moveq #0,d0
34+
rts
35+
36+
37+
.data
38+
39+
.align 4
40+
41+
__stack_save:
42+
.long 0
43+
44+
.text
45+

demo/files.h

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#define NUM_FILES 5
2+
3+
extern char *fileName[NUM_FILES];
4+
extern int fileSize[NUM_FILES];
5+
extern int filePtr[NUM_FILES];

demo/files.s

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.text
2+
3+
.align 4
4+

0 commit comments

Comments
 (0)