-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PC-88 version (and fixed C64 version)
- Loading branch information
1 parent
3392007
commit bd27d52
Showing
52 changed files
with
3,154 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.zx1 | ||
*.bin | ||
*.t88 | ||
*.d88 | ||
*.wav |
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,220 @@ | ||
#!/usr/bin/python3 | ||
|
||
# Conversion: | ||
# FM 1-6: | ||
# Same register numbers and values | ||
# FM6/DAC: | ||
# Disable | ||
# Data blocks: | ||
# ignore/skip | ||
# SSG>PSG: (r0-rf) | ||
# split data byte into register and data | ||
# -change data to 16-bit were needed | ||
# -noise on 1 channel(?) | ||
|
||
import sys | ||
|
||
""" Function defs """ | ||
|
||
def Usage(): | ||
print("Usage:\n\ | ||
$ 2612to2203.py /path/to/file.vgm\n") | ||
|
||
""" Conversion script """ | ||
|
||
# args test | ||
if len(sys.argv) < 2: | ||
Usage() | ||
|
||
# read in vgm file | ||
f = open(sys.argv[1], 'rb') | ||
inby = f.read() | ||
f.close() | ||
|
||
# file type test | ||
vgmstr = chr(inby[0]) + chr(inby[1]) + chr(inby[2]) + chr(inby[3]) | ||
vgmver = inby[8] | (inby[9] << 8) | ||
if((vgmstr != "Vgm ") and ((vgmver != 0x160) or (vgmver != 0x150))): | ||
print("Error: Not a valid VGM v1.50/1.60 file!") | ||
sys.exit() | ||
|
||
# main loop | ||
outsong = [] | ||
vgmptr = 0x34 + (inby[0x34] | (inby[0x35]<<8)) # 0x80 | ||
datstart = vgmptr | ||
i = 0 | ||
while i < datstart: | ||
outsong.append(inby[i]) | ||
i += 1 | ||
outsong.append(0x55) | ||
outsong.append(0x7) | ||
outsong.append(0b00111000) | ||
# 477 | ||
# 954 | ||
# 1907 | ||
while(vgmptr < len(inby)): | ||
if inby[vgmptr] == 0x67: # data block, skip | ||
vgmptr += 1 # 0x66 | ||
vgmptr += 1 # data type | ||
vgmptr += 1 # size low byte | ||
sz = inby[vgmptr] | (inby[vgmptr+1]<<8) | (inby[vgmptr+2]<<16) | (inby[vgmptr+3]<<24) | ||
vgmptr += sz + 3 | ||
print('data block skipped by ' + str(sz) + ' bytes') | ||
elif inby[vgmptr] == 0x50: | ||
vgmptr += 1 # data | ||
psgdat = inby[vgmptr] | ||
# format: | ||
# 10 bits - 0-2048 | ||
r = (inby[vgmptr] & 0b01110000) >> 4 | ||
# 3210 | ||
d = inby[vgmptr] & 0b00001111 | ||
d2 = 0 | ||
# 3579540 | ||
# 3993600 | ||
# 1ac <> d6 | ||
# get full data size for frequency | ||
if((r == 0) or (r == 2) or (r == 4)): | ||
vgmptr += 2 # data2 987654 | ||
#print(hex(inby[vgmptr])) | ||
d2 = (inby[vgmptr] & 0b00111111) << 4 | ||
#d2 = d2 >> 8 | ||
#print(hex(d+d2)) | ||
if(r==0): | ||
#print("tone 1 freq", end=' ') | ||
d = d + d2 | ||
d = int(d * 1.1157) | ||
# print('real', d) | ||
outsong.append(0x55) | ||
outsong.append(0) | ||
outsong.append(d & 0xff) | ||
outsong.append(0x55) | ||
outsong.append(1) | ||
outsong.append((d & 0xff00) >> 8) | ||
#print("PSG: r0,r1", hex(d & 0xff), hex((d & 0xff00) >> 8), end = ' ') | ||
|
||
elif(r==1): | ||
#print("tone 1 att", end=' ') | ||
if d == 0xf: | ||
d = 0 | ||
elif d == 0: | ||
d = 0 | ||
else: | ||
v = 14 | ||
if (d & 0b1000): | ||
v -= 8 | ||
if (d & 0b100): | ||
v -= 4 | ||
if (d & 0b10): | ||
v -= 2 | ||
if (d & 0b1): | ||
v -= 1 | ||
d = v | ||
outsong.append(0x55) | ||
outsong.append(8) | ||
outsong.append(d) | ||
#print("PSG: r8", d, end=' ') | ||
elif(r==2): | ||
#print("tone 2 freq", end=' ') | ||
#print("PSG: r2,r3", hex(d & 0xff), hex(d2), end = ' ') | ||
d = d + d2 | ||
d = int(d * 1.1157) | ||
outsong.append(0x55) | ||
outsong.append(2) | ||
outsong.append(d & 0xff) | ||
outsong.append(0x55) | ||
outsong.append(3) | ||
outsong.append((d & 0xff00) >> 8) | ||
#print("PSG: r2,r3", hex(d & 0xff), hex((d & 0xff00) >> 8), end = ' ') | ||
|
||
elif(r==3): | ||
#print("tone 2 att", end=' ') | ||
if d == 0xf: | ||
d = 0 | ||
elif d == 0: | ||
d = 0 | ||
else: | ||
v = 14 | ||
if (d & 0b1000): | ||
v -= 8 | ||
if (d & 0b100): | ||
v -= 4 | ||
if (d & 0b10): | ||
v -= 2 | ||
if (d & 0b1): | ||
v -= 1 | ||
d = v | ||
outsong.append(0x55) | ||
outsong.append(9) | ||
outsong.append(d) | ||
#print("PSG: r9", d, end=' ') | ||
elif(r==4): | ||
#print("tone 3 freq", end=' ') | ||
#print("PSG: r4,r5", hex(d & 0xff), hex(d2), end = ' ') | ||
d = d + d2 | ||
d = int(d * 1.1157) | ||
outsong.append(0x55) | ||
outsong.append(4) | ||
outsong.append(d & 0xff) | ||
outsong.append(0x55) | ||
outsong.append(5) | ||
outsong.append((d & 0xff00) >> 8) | ||
#print("PSG: r4,r5", hex(d & 0xff), hex((d & 0xff00) >> 8), end = ' ') | ||
elif(r==5): | ||
#print("tone 3 att", end=' ') | ||
if d == 0xf: | ||
d = 0 | ||
elif d == 0: | ||
d = 0 | ||
else: | ||
v = 14 | ||
if (d & 0b1000): | ||
v -= 8 | ||
if (d & 0b100): | ||
v -= 4 | ||
if (d & 0b10): | ||
v -= 2 | ||
if (d & 0b1): | ||
v -= 1 | ||
d = v | ||
outsong.append(0x55) | ||
outsong.append(10) | ||
outsong.append(d) | ||
#print("PSG: r10", d, end=' ') | ||
else: | ||
print('error', r, d) | ||
""" | ||
elif(r==6): | ||
print("noise ctl", end=' ') | ||
# frequency is 0-2, 3 is "tone #3 output"? | ||
d = d & 0b11 | ||
d = d << 2 # x4 for now? | ||
print("PSG: r6", d, end=' ') | ||
outsong.append(6) | ||
outsong.append(d & 0xf) | ||
elif(r==7): | ||
print("noise att", end=' ') | ||
d = 15-d | ||
d = int(d/2) | ||
d = 1 # io input off, noise off, tone on FIXME | ||
outsong.append(0x7) | ||
outsong.append(d) | ||
""" | ||
|
||
|
||
#print('') | ||
#print(d) | ||
elif inby[vgmptr] == 0x62: | ||
outsong.append(0x62) | ||
elif inby[vgmptr] == 0x66: | ||
outsong.append(0x66) | ||
vgmptr = len(inby) | ||
print("song end") | ||
vgmptr += 1 | ||
|
||
#print(outsong) | ||
f = open("outsong.vgm", 'wb') | ||
i = 0 | ||
while i < len(outsong): | ||
#print(type(outsong[i])) | ||
f.write(bytes([outsong[i]])) | ||
i += 1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,12 @@ | ||
GIMP Palette | ||
Name: C | ||
Columns: 16 | ||
# | ||
0 0 0 Untitled | ||
0 0 255 Untitled | ||
255 0 0 Untitled | ||
255 0 255 Untitled | ||
0 255 0 Untitled | ||
0 255 255 Untitled | ||
255 255 0 Untitled | ||
255 255 255 Untitled |
Binary file not shown.
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,36 @@ | ||
# Copyright Infringement for the PC-88 | ||
|
||
This is a port of a gay porn game that i made for numerous platforms, including the PC-88. | ||
This is sort of basic and only supports V1 and the Beeper, the Yamaha sound chip isn't being used as it should | ||
mostly due to the lack of suitable music for it and also because z88dk seemingly lacks FILE I/O for it (along with lacking support for adding files to the D88 image). | ||
|
||
# Usage | ||
|
||
To play the game, you have several options : | ||
- Floppies (.D88) | ||
- Tape/Casette (.WAV/.T88) | ||
|
||
The game loads entirely in RAM thus it should work from tape. | ||
For the floppy version, it is self booting but you should boot it from N88, not N80 as | ||
otherwise you'll only get B&W graphics. | ||
|
||
# Other technical aspects | ||
|
||
This uses Z88DK for the basic support of the PC-88 so many thanks to them ! | ||
I had to write my own python script for converting PNG images to the PC-88's V1 format. | ||
I haven't tried to figure out V2 too much but the only difference appears to be the remappable palette. | ||
|
||
Animating compressed graphics was a big problem on this. | ||
In the end, i resorted to using another algo called LZ48 and it was slightly faster than even ZX1-Mega | ||
while having decent compression ratios. | ||
|
||
I also sort of cheated by using the Red and Green layers as doing so reducing the overall effective size | ||
from 48kb to 32kb, which makes it more bearable and we still get 4 colors. | ||
Sure, no white color but it was a small loss in this case. | ||
|
||
In the end i sort of managed but you can still see some of the greenish remanants due to the green layer | ||
still updating too slowly... :/ | ||
I actually did get that even with uncompressed memcpy. | ||
The only way i could possibly reduce this is with an unrolled 640 LDI loop but i'm not even sure that would be enough. | ||
|
||
I don't believe this kind of FMVs had been done on the PC-88 anyway. |
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,85 @@ | ||
import sys | ||
import wave | ||
import struct | ||
|
||
def clamp(n, smallest, largest): | ||
return max(smallest, min(n, largest)) | ||
|
||
def convert_wav_to_adpcm(input_file, output_file): | ||
step_table = [ | ||
16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, | ||
73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, | ||
337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, | ||
1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, | ||
7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, | ||
32767 | ||
] | ||
|
||
index_table = [ | ||
-1, -1, -1, -1, 2, 4, 6, 8, | ||
-1, -1, -1, -1, 2, 4, 6, 8 | ||
] | ||
|
||
with wave.open(input_file, 'rb') as wav_file: | ||
n_channels, sampwidth, framerate, n_frames, _, _ = wav_file.getparams() | ||
assert n_channels == 1, "Input file must be mono" | ||
assert sampwidth == 1, "Input file must be 8-bit" | ||
|
||
wav_data = wav_file.readframes(n_frames) | ||
|
||
sample = 0 | ||
step_index = 0 | ||
adpcm_data = bytearray() | ||
|
||
for i in range(0, len(wav_data), 2): | ||
nibble1 = 0 | ||
nibble2 = 0 | ||
|
||
for j in range(2): | ||
diff = struct.unpack('b', wav_data[i + j:i + j + 1])[0] - sample | ||
|
||
sign = 0 | ||
|
||
if diff < 0: | ||
sign = 8 | ||
diff = -diff | ||
|
||
step = step_table[step_index] | ||
delta = step >> 3 | ||
|
||
if diff > step_table[step_index] >> 1: | ||
delta |= step >> 2 | ||
diff -= step_table[step_index] >> 1 | ||
|
||
if diff > step_table[step_index] >> 2: | ||
delta |= step >> 3 | ||
diff -= step_table[step_index] >> 2 | ||
|
||
step_index = clamp(step_index + index_table[delta & 0x0F], 0, len(step_table) - 1) | ||
|
||
delta |= sign | ||
sample += struct.unpack('b', struct.pack('B', (delta << 4) & 0xFF))[0] * step // 64 | ||
|
||
sample = clamp(sample, -128, 127) | ||
|
||
if j == 0: | ||
nibble1 = delta | ||
elif j == 1: | ||
nibble2 = delta | ||
|
||
adpcm_byte = ((nibble1 << 4) | nibble2) & 0xFF | ||
|
||
adpcm_data.append(adpcm_byte) | ||
|
||
with open(output_file, 'wb') as adpcm_file: | ||
adpcm_file.write(adpcm_data) | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 3: | ||
print("Usage: python wav_to_okim6258_adpcm.py <input_wav_file> <output_adpcm_file>") | ||
sys.exit(1) | ||
|
||
input_file = sys.argv[1] | ||
output_file = sys.argv[2] | ||
|
||
convert_wav_to_adpcm(input_file, output_file) |
Oops, something went wrong.