-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from venomix666/nano6502
Port to the nano6502
- Loading branch information
Showing
12 changed files
with
1,620 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from build.ab import normalrule | ||
from tools.build import mkdfs, mkcpmfs | ||
from build.llvm import llvmrawprogram | ||
from config import ( | ||
MINIMAL_APPS, | ||
MINIMAL_APPS_SRCS, | ||
BIG_APPS, | ||
BIG_APPS_SRCS, | ||
SCREEN_APPS, | ||
PASCAL_APPS, | ||
) | ||
|
||
llvmrawprogram( | ||
name="nano6502", | ||
srcs=["./nano6502.S"], | ||
deps=["include", "src/lib+bioslib"], | ||
linkscript="./nano6502.ld", | ||
) | ||
|
||
mkcpmfs( | ||
name="cpmfs", | ||
format="generic-1m", | ||
items={"0:ccp.sys@sr": "src+ccp", | ||
"1:colorfg.com": "src/arch/nano6502/utils+colorfg", | ||
"1:colorbg.com": "src/arch/nano6502/utils+colorbg", | ||
"1:ledtest.com": "src/arch/nano6502/utils+ledtest"} | ||
| MINIMAL_APPS | ||
| MINIMAL_APPS_SRCS | ||
| BIG_APPS | ||
| BIG_APPS_SRCS | ||
| SCREEN_APPS | ||
| PASCAL_APPS, | ||
) | ||
|
||
mkcpmfs( | ||
name="emptycpmfs", | ||
format="generic-1m", | ||
items="", | ||
) | ||
|
||
normalrule( | ||
name="diskimage", | ||
ins=[ | ||
".+cpmfs", | ||
".+emptycpmfs", | ||
".+nano6502", | ||
"src/bdos", | ||
], | ||
outs=["nano6502.img"], | ||
commands=["rm -f {outs[0]}","./src/arch/nano6502/buildimage.py"], | ||
label="IMG", | ||
) | ||
|
||
normalrule( | ||
name="sysimage", | ||
ins=[ | ||
".+cpmfs", | ||
".+nano6502", | ||
"src/bdos", | ||
], | ||
outs=["nano6502_sysonly.img"], | ||
commands=["rm -f {outs[0]}","./src/arch/nano6502/buildsysimage.py"], | ||
label="IMG", | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#!/usr/bin/python3 | ||
|
||
import sys | ||
import os | ||
|
||
bootsector_size = 512 | ||
bdos_offset = 512*256 | ||
cpmfs_offset = 512*256 | ||
cpmfs_size = 1024*1024 | ||
|
||
bios_filename = '.obj/src/arch/nano6502/+nano6502/+nano6502' | ||
bdos_filename = '.obj/src/bdos/+bdos/+bdos' | ||
cpmfs_filename = '.obj/src/arch/nano6502/+cpmfs/src/arch/nano6502/+cpmfs.img' | ||
cpmfs_empty_filename = '.obj/src/arch/nano6502/+emptycpmfs/src/arch/nano6502/+emptycpmfs.img' | ||
output_filename = '.obj/src/arch/nano6502/+diskimage/nano6502.img' | ||
|
||
size = os.path.getsize(bios_filename) | ||
|
||
outfile=open(output_filename, "wb") | ||
|
||
# Write boot sector | ||
# Boot sector format | ||
# Magic number: 0x6E, 0x61, 0x6E, 0x6F | ||
# SD sector to load - 4 bytes | ||
# Number of pages to load - 1 byte | ||
# Page to load data to - 1 byte | ||
# Total 10 bytes | ||
# Padding 502 bytes | ||
|
||
bootsector_data = [0x6E, 0x61, 0x6E, 0x6F, 0x00, 0x00, 0x00, 0x01, 0x05, 0x03] | ||
|
||
for d in bootsector_data: | ||
outfile.write(d.to_bytes(1, "little")) | ||
|
||
out=0 | ||
for i in range(bootsector_size - len(bootsector_data)): | ||
outfile.write(out.to_bytes(1, "little")) | ||
|
||
# Write BIOS | ||
|
||
infile=open(bios_filename, "rb") | ||
byte=infile.read(1) | ||
|
||
# Write BIOS | ||
while byte: | ||
outfile.write(byte) | ||
byte=infile.read(1) | ||
|
||
padding = bdos_offset - size - bootsector_size | ||
out = 0 | ||
|
||
while padding: | ||
outfile.write(out.to_bytes(1,"little")) | ||
padding = padding - 1; | ||
|
||
infile.close() | ||
|
||
# Write BDOS | ||
size = os.path.getsize(bdos_filename) | ||
|
||
infile = open(bdos_filename, "rb") | ||
|
||
byte=infile.read(1) | ||
while byte: | ||
outfile.write(byte) | ||
byte=infile.read(1) | ||
|
||
padding = cpmfs_offset - size; | ||
out = 0 | ||
|
||
while padding: | ||
outfile.write(out.to_bytes(1,"little")) | ||
padding = padding - 1; | ||
|
||
infile.close() | ||
|
||
# Write CPMFS | ||
size = os.path.getsize(cpmfs_filename) | ||
|
||
infile = open(cpmfs_filename, "rb") | ||
|
||
byte=infile.read(1) | ||
while byte: | ||
outfile.write(byte) | ||
byte=infile.read(1) | ||
|
||
padding = cpmfs_size - size; | ||
out=0 | ||
while padding: | ||
outfile.write(out.to_bytes(1,"little")) | ||
padding = padding - 1; | ||
|
||
infile.close() | ||
|
||
# Write empty drives B-O | ||
for i in range(15): | ||
size = os.path.getsize(cpmfs_empty_filename) | ||
|
||
infile = open(cpmfs_empty_filename, "rb") | ||
|
||
byte=infile.read(1) | ||
while byte: | ||
outfile.write(byte) | ||
byte=infile.read(1) | ||
|
||
padding = cpmfs_size - size; | ||
out=0 | ||
while padding: | ||
outfile.write(out.to_bytes(1,"little")) | ||
padding = padding - 1; | ||
|
||
infile.close() | ||
|
||
outfile.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/usr/bin/python3 | ||
|
||
import sys | ||
import os | ||
|
||
bootsector_size = 512 | ||
bdos_offset = 512*256 | ||
cpmfs_offset = 512*256 | ||
cpmfs_size = 1024*1024 | ||
|
||
bios_filename = '.obj/src/arch/nano6502/+nano6502/+nano6502' | ||
bdos_filename = '.obj/src/bdos/+bdos/+bdos' | ||
cpmfs_filename = '.obj/src/arch/nano6502/+cpmfs/src/arch/nano6502/+cpmfs.img' | ||
cpmfs_empty_filename = '.obj/src/arch/nano6502/+emptycpmfs/src/arch/nano6502/+emptycpmfs.img' | ||
output_filename = '.obj/src/arch/nano6502/+sysimage/nano6502_sysonly.img' | ||
|
||
size = os.path.getsize(bios_filename) | ||
|
||
outfile=open(output_filename, "wb") | ||
|
||
# Write boot sector | ||
# Boot sector format | ||
# Magic number: 0x6E, 0x61, 0x6E, 0x6F | ||
# SD sector to load - 4 bytes | ||
# Number of pages to load - 1 byte | ||
# Page to load data to - 1 byte | ||
# Total 10 bytes | ||
# Padding 502 bytes | ||
|
||
bootsector_data = [0x6E, 0x61, 0x6E, 0x6F, 0x00, 0x00, 0x00, 0x01, 0x05, 0x03] | ||
|
||
for d in bootsector_data: | ||
outfile.write(d.to_bytes(1, "little")) | ||
|
||
out=0 | ||
for i in range(bootsector_size - len(bootsector_data)): | ||
outfile.write(out.to_bytes(1, "little")) | ||
|
||
# Write BIOS | ||
|
||
infile=open(bios_filename, "rb") | ||
byte=infile.read(1) | ||
|
||
# Write BIOS | ||
while byte: | ||
outfile.write(byte) | ||
byte=infile.read(1) | ||
|
||
padding = bdos_offset - size - bootsector_size | ||
out = 0 | ||
|
||
while padding: | ||
outfile.write(out.to_bytes(1,"little")) | ||
padding = padding - 1; | ||
|
||
infile.close() | ||
|
||
# Write BDOS | ||
size = os.path.getsize(bdos_filename) | ||
|
||
infile = open(bdos_filename, "rb") | ||
|
||
byte=infile.read(1) | ||
while byte: | ||
outfile.write(byte) | ||
byte=infile.read(1) | ||
|
||
padding = cpmfs_offset - size; | ||
out = 0 | ||
|
||
while padding: | ||
outfile.write(out.to_bytes(1,"little")) | ||
padding = padding - 1; | ||
|
||
infile.close() | ||
|
||
# Write CPMFS | ||
size = os.path.getsize(cpmfs_filename) | ||
|
||
infile = open(cpmfs_filename, "rb") | ||
|
||
byte=infile.read(1) | ||
while byte: | ||
outfile.write(byte) | ||
byte=infile.read(1) | ||
|
||
padding = cpmfs_size - size; | ||
out=0 | ||
while padding: | ||
outfile.write(out.to_bytes(1,"little")) | ||
padding = padding - 1; | ||
|
||
infile.close() | ||
outfile.close() |
Oops, something went wrong.