cleaned up tools directory; vic dual color PROM

This commit is contained in:
Steven Hugg 2017-04-10 13:39:48 -04:00
parent 333636fe33
commit 90ec9ba94d
26 changed files with 302 additions and 58 deletions

View File

@ -205,8 +205,8 @@ div.bitmap_editor {
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="?platform=vcs" id="item_platform_vcs">Atari VCS</a></li>
<!--<li><a class="dropdown-item" href="?platform=apple2" id="item_platform_apple2">Apple ][</a></li>-->
<li><a class="dropdown-item" href="?platform=mw8080bw" id="item_platform_mw8080bw">Midway 8080 B&amp;W</a></li>
<li><a class="dropdown-item" href="?platform=vicdual" id="item_platform_vicdual">VIC Dual</a></li>
<li><a class="dropdown-item" href="?platform=mw8080bw" id="item_platform_mw8080bw">Midway 8080 B&amp;W</a></li>
<li><a class="dropdown-item" href="?platform=galaxian-scramble" id="item_platform_galaxian_scramble">Scramble hardware</a></li>
<li><a class="dropdown-item" href="?platform=vector-z80color" id="item_platform_vector_z80color">Atari Color Vector (Z80)</a></li>
<li><a class="dropdown-item" href="?platform=williams-z80" id="item_platform_williams_z80">Williams (Z80)</a></li>

View File

@ -1,8 +1,38 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Playing music on the Atari VCS can be challenging since
;; the frequencies rarely line up with the desired notes of a
;; musical scale, and if they do, they're likely out of tune.
;; There are only 32 divisors to configure pitch for a channel,
;; and three possible base clocks that produce square tones --
;; a total of 96 possible frequencies.
;;
;; This demo implements fractional frequencies by duty cycling
;; the frequency divisor.
;; This extends the number of audible pitches to 768.
;;
;; We have a lookup table with AUDF, AUDC, and a duty cycle
;; bitmask for each note. Every 2 msec, we rotate the bitmask
;; and add the next bit to the divisor -- cycling between
;; two neighboring divisors.
;;
;; The pitches are modulated 8 times per frame, but could
;; be reduced to 1 or 2 times per frame, but "vibrato"
;; would be more apparent.
;;
;; The song file format is simple:
;; - High bit set: delay (0-126)
;; - High bit clear: note (0-63)
;; - $FF: done
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
processor 6502
include "vcs.h"
include "macro.h"
include "xmacro.h"
org $f000
Chan0dur equ $e0 ; current note duration channel 0
@ -447,3 +477,4 @@ PFBitmap5
org $fffc
.word Start
.word Start

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
"use strict";
"use strict";
var VICDUAL_PRESETS = [
{id:'minimal.c', name:'Minimal Example'},
{id:'hello.c', name:'Hello World'},
@ -46,14 +46,10 @@ var VicDualPlatform = function(mainElement) {
];
var colorprom = [
0,0,0,0,0,0,0,0,
7,3,1,3,6,3,2,6,
7,0,0,0,0,0,0,0,
0,1,2,3,4,5,6,7,
0,0,0,0,0,0,0,0,
7,7,7,7,3,3,3,3,
0,0,0,0,0,0,0,0,
7,7,7,7,7,7,7,7,
0xe0,0x60,0x20,0x60, 0xc0,0x60,0x40,0xc0,
0x20,0x40,0x60,0x80, 0xa0,0xc0,0xe0,0x0e,
0xe0,0xe0,0xe0,0xe0, 0x60,0x60,0x60,0x60,
0xe0,0xe0,0xe0,0xe0, 0xe0,0xe0,0xe0,0xe0,
];
// videoram 0xc000-0xc3ff
@ -69,14 +65,16 @@ var VicDualPlatform = function(mainElement) {
var code = ram.mem[vramofs+xx];
var data = ram.mem[0x800 + (code<<3) + yy];
var col = (code>>5) + (palbank<<4);
var color1 = palette[colorprom[col]];
var color2 = palette[colorprom[col+8]];
var color1 = palette[(colorprom[col] >> 1) & 7];
var color2 = palette[(colorprom[col] >> 5) & 7];
for (var i=0; i<8; i++) {
var bm = 128>>i;
pixels[outi] = (data&bm) ? color2 : color1;
/* TODO
if (framestats) {
framestats.layers.tiles[outi] = (data&bm) ? colorprom[col+8] : colorprom[col];
}
*/
outi++;
}
}
@ -169,6 +167,9 @@ var VicDualPlatform = function(mainElement) {
}
this.loadROM = function(title, data) {
if (data.length >= 0x4020 && (data[0x4000] || data[0x401f])) {
colorprom = data.slice(0x4000,0x4020);
}
rom = padBytes(data, 0x4040);
self.reset();
}

View File

@ -1,40 +0,0 @@
%-pf.hex: %-pf.pbm p4_to_pfbytes.py
python p4_to_pfbytes.py $< > $@
%-48.hex: %-48.pbm p4_to_48pix.py
python p4_to_48pix.py $< > $@
%-pf.pbm: %.jpg
convert $< -resize 40x192\! -colorspace Gray -dither FloydSteinberg $@
%-48.pbm: %.jpg
convert $< -resize 48x192\! -colorspace Gray -dither FloydSteinberg $@
%.tga: %.png
convert $< -resize 192 $<.gif
convert $<.gif +dither -type palette -depth 4 -compress RLE -colors 8 -flip $@
convert $@ $@.png
%.pcx: %.png
convert $< -format raw -type palette -compress none -colors 15 +dither $@
%.rle.pcx: %.png
convert $< -format raw -type palette -compress rle -colors 15 +dither $@
%.4.pcx: %.png
convert $< -format raw -type palette -compress none -colors 4 +dither $@
ship1.pbm: ship1.png
convert ship1.png -negate -flop ship1.pbm
%.h:
cat $* | hexdump -v -e '"\n" 128/1 "0x%02x,"'
%.prom:
cat $* | hexdump -v -e '" \n defb " 32/1 "$$%02x,"' | cut -c 2-134
%.rot.pbm: %.pbm
convert $< -transpose -bordercolor white -border 4x4 $@
baddies-horiz.rot.pbm: baddies-horiz.png
convert $< +dither -brightness-contrast 50x50 -fill black -transpose -negate $@
convert $@ foo.png

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
tools/images/baddies.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
tools/images/bob.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

2
tools/mw8080/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.c
*.pbm

View File

@ -1,10 +1,10 @@
all: cp437.mw8080.c c64.mw8080.c baddies-horiz.rot.c scrappy.rot.c
cp437.mw8080.c: ../cp437-8x8.bdf
cp437.mw8080.c: ../fonts/cp437-8x8.bdf
python ../parsebdf8.py $< -f -r -C > $@
c64.mw8080.c: ../c64.bdf
c64.mw8080.c: ../fonts/c64.bdf
python ../parsebdf8.py $< -f -r -C -s 32 -e 94 > $@
%.h:
@ -17,10 +17,10 @@ c64.mw8080.c: ../c64.bdf
#%.rot.pbm: %.pbm
# convert $< -transpose -bordercolor white -border 4x4 $@
baddies-horiz.rot.pbm: ../baddies-horiz.png
baddies-horiz.rot.pbm: ../images/baddies-horiz.png
convert $< +dither -brightness-contrast 50x50 -fill black -transpose -negate $@
scrappy.rot.pbm: ../scrappy48x64.pbm
scrappy.rot.pbm: ../images/scrappy48x64.pbm
convert $< -transpose -bordercolor white -border 4x4 $@

43
tools/scramble/rom_scramble.py Executable file
View File

@ -0,0 +1,43 @@
#!/usr/bin/python
import sys, zipfile
OUTFILE = 'scramble.zip'
ROMS = [
( "s1.2d", 0x0000, 0x0800),
( "s2.2e", 0x0800, 0x0800),
( "s3.2f", 0x1000, 0x0800),
( "s4.2h", 0x1800, 0x0800),
( "s5.2j", 0x2000, 0x0800),
( "s6.2l", 0x2800, 0x0800),
( "s7.2m", 0x3000, 0x0800),
( "s8.2p", 0x3800, 0x0800),
# ROM_REGION( 0x10000, "audiocpu", 0 )
( "ot1.5c", 0x0000, 0x0800),
( "ot2.5d", 0x0800, 0x0800),
( "ot3.5e", 0x1000, 0x0800),
# ROM_REGION( 0x1000, "gfx1", 0 )
( "c2.5f", 0x4000, 0x0800),
( "c1.5h", 0x4800, 0x0800),
# ROM_REGION( 0x0020, "proms", 0 )
( "c01s.6e", 0x5000, 0x0020),
]
fn = sys.argv[1]
with open(fn, 'rb') as f:
data = f.read()
print "Read %d bytes of %s" % (len(data), fn)
with zipfile.ZipFile(OUTFILE, 'w') as zipf:
for name,start,length in ROMS:
romdata = data[start:start+length]
if len(romdata) != length:
print "*** No data for %s (offset 0x%x)" % (name,start)
romdata = '\0' * length
zipf.writestr(name, romdata)
else:
print 'Wrote %s (%d bytes)' % (name, length)
zipf.writestr(name, romdata)

13
tools/vcs/Makefile Normal file
View File

@ -0,0 +1,13 @@
%-pf.hex: %-pf.pbm p4_to_pfbytes.py
python p4_to_pfbytes.py $< > $@
%-48.hex: %-48.pbm p4_to_48pix.py
python p4_to_48pix.py $< > $@
%-pf.pbm: %.jpg
convert $< -resize 40x192\! -colorspace Gray -dither FloydSteinberg $@
%-48.pbm: %.jpg
convert $< -resize 48x192\! -colorspace Gray -dither FloydSteinberg $@

58
tools/vcs/p4_to_48pix.py Executable file
View File

@ -0,0 +1,58 @@
#!/usr/bin/python
import sys, struct
# playfield bytes, one array for each of 6 columns
output = [[],[],[],[],[],[]]
# reverse byte
def rev(n):
return int('{:08b}'.format(n)[::-1], 2)
# output bits in given range
def out(i, pix, lb, hb, reverse=0, shift=0):
x = (pix >> lb) & ((1<<(hb-lb))-1)
if reverse:
x = rev(x)
if shift:
x = x << shift
assert(x>=0 and x<=255)
output[i].append(x)
# read PBM (binary P4 format) file
with open(sys.argv[1],'rb') as f:
# read PBM header
header = f.readline().strip()
assert(header == 'P4')
dims = f.readline().strip()
if dims[0] == '#':
dims = f.readline().strip()
width,height = map(int, dims.split())
assert(width==48)
# read bitmap rows
for y in range(0,height):
row = bytes(f.read(6) + '\0\0') # pad to 8 bytes
# convert to 64-bit integer
pix = struct.unpack('<q',row)[0]
#print '%010lx' % pix
# generate playfield bytes
out(0, pix, 0, 8, 0)
out(1, pix, 8, 16, 0)
out(2, pix, 16, 24, 0)
out(3, pix, 24, 32, 0)
out(4, pix, 32, 40, 0)
out(5, pix, 40, 48, 0)
# output bitmap tables
for c in range(0,6):
print "\talign $100"
print "Bitmap%d" % c
print "\thex 00"
s = '\thex '
for i in range(0,height):
s += '%02x' % output[c][height-i-1]
if i % 16 == 15:
print s
s = '\thex '
if len(s)>5:
print s

62
tools/vcs/p4_to_pfbytes.py Executable file
View File

@ -0,0 +1,62 @@
#!/usr/bin/python
import sys, struct
# playfield bytes, one array for each of 6 columns
output = [[],[],[],[],[],[]]
# reverse byte
def rev(n):
return int('{:08b}'.format(n)[::-1], 2)
# output bits in given range
def out(i, pix, lb, hb, reverse=0, shift=0):
x = (pix >> lb) & ((1<<(hb-lb))-1)
if reverse:
x = rev(x)
if shift:
x = x << shift
assert(x>=0 and x<=255)
output[i].append(x)
# read PBM (binary P4 format) file
with open(sys.argv[1],'rb') as f:
# read PBM header
header = f.readline().strip()
assert(header == 'P4')
dims = f.readline().strip()
if dims[0] == '#':
dims = f.readline().strip()
width,height = map(int, dims.split())
assert(width==40)
# read bitmap rows
for y in range(0,height):
row = bytes(f.read(5) + '\0\0\0') # pad to 8 bytes
# convert bytes from MSB first to LSB first
row2 = ''
for i in range(0,8):
row2 += chr(rev(ord(row[i])))
# convert to 64-bit integer
pix = struct.unpack('<q',row2)[0]
#print '%010lx' % pix
# generate playfield bytes
out(0, pix, 0, 4, 0, 4)
out(1, pix, 4, 12, 1)
out(2, pix, 12, 20, 0)
out(3, pix, 20, 24, 0, 4)
out(4, pix, 24, 32, 1)
out(5, pix, 32, 40, 0)
# output bitmap tables
for c in range(0,6):
#print "\talign $100"
print "PFBitmap%d" % c
#print "\thex 00"
s = '\thex '
for i in range(0,height):
s += '%02x' % output[c][height-i-1]
if i % 16 == 15:
print s
s = '\thex '
if len(s)>5:
print s

View File

@ -1,10 +1,10 @@
all: cp437.vicdual.c c64.vicdual.c
cp437.vicdual.c: ../cp437-8x8.bdf
cp437.vicdual.c: ../fonts/cp437-8x8.bdf
python ../parsebdf8.py $< -r -C > $@
c64.vicdual.c: ../c64.bdf
c64.vicdual.c: ../fonts/c64.bdf
python ../parsebdf8.py $< -r -C > $@
%.h:

44
tools/vicdual/rom_carnival.py Executable file
View File

@ -0,0 +1,44 @@
#!/usr/bin/python
import sys, zipfile
OUTFILE = 'carnival.zip'
ROMS = [
( "epr-651.u33", 0x0000, 0x0400 ),
( "epr-652.u32", 0x0400, 0x0400 ),
( "epr-653.u31", 0x0800, 0x0400 ),
( "epr-654.u30", 0x0c00, 0x0400 ),
( "epr-655.u29", 0x1000, 0x0400 ),
( "epr-656.u28", 0x1400, 0x0400 ),
( "epr-657.u27", 0x1800, 0x0400 ),
( "epr-658.u26", 0x1c00, 0x0400 ),
( "epr-659.u8", 0x2000, 0x0400 ),
( "epr-660.u7", 0x2400, 0x0400 ),
( "epr-661.u6", 0x2800, 0x0400 ),
( "epr-662.u5", 0x2c00, 0x0400 ),
( "epr-663.u4", 0x3000, 0x0400 ),
( "epr-664.u3", 0x3400, 0x0400 ),
( "epr-665.u2", 0x3800, 0x0400 ),
( "epr-666.u1", 0x3c00, 0x0400 ),
( "316-633", 0x4000, 0x0020 ),
( "epr-412", 0x4040, 0x0400 ),
( "316-0206.u14", 0x4020, 0x0020 )
]
fn = sys.argv[1]
with open(fn, 'rb') as f:
data = f.read()
print "Read %d bytes of %s" % (len(data), fn)
with zipfile.ZipFile(OUTFILE, 'w') as zipf:
for name,start,length in ROMS:
romdata = data[start:start+length]
if len(romdata) != length:
print "*** No data for %s (offset 0x%x)" % (name,start)
romdata = '\0' * length
zipf.writestr(name, romdata)
else:
zipf.writestr(name, romdata)

18
tools/williams/Makefile Normal file
View File

@ -0,0 +1,18 @@
all: baddies.4.pcx.h badspacerobots.tga
%.h: %
cat $* | hexdump -v -e '"\n" 128/1 "0x%02x,"' > $@
%.tga: %.png
convert $< -resize 192 $<.gif
convert $<.gif +dither -type palette -depth 4 -compress RLE -colors 8 -flip $@
convert $@ $@.png
%.pcx: %.png
convert $< -format raw -type palette -compress none -colors 15 +dither $@
%.rle.pcx: %.png
convert $< -format raw -type palette -compress rle -colors 15 +dither $@
%.4.pcx: %.png
convert $< -format raw -type palette -compress none -colors 4 +dither $@

BIN
tools/williams/baddies.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB