This page contains notes for the game Super Tetris 2 + Bombliss (PC-98).
Python 3 script for extracting graphics from RGB.DB and RGB.CNT: (requires Pillow)
#!/usr/bin/env python3
# Super Tetris 2 + Bombliss (PC-98) image unpacker
# by Revenant
import struct, math
from PIL import Image
entries = []
with open("RGB.CNT", 'rb') as cnt:
while True:
try:
name, offset = struct.unpack("16sI", cnt.read(20))
endpos = name.find(0)
if endpos >= 0:
name = name[:endpos]
name = name.decode('ascii', 'ignore')
entries.append((name, offset))
except struct.error:
break
with open("RGB.DB", 'rb') as db:
for entry in entries:
# seek
db.seek(entry[1], 0)
# get num. of colors
num_colors = db.read(1)[0]
colors = [0] * 768
for i in range(3 * num_colors):
colors[i] = db.read(1)[0]
colors[i] |= (colors[i] << 4)
# get image dimensions
width, height = struct.unpack("II", db.read(8))
stride = math.ceil(width / 8)
# get bitplanes
bitplanes = []
for i in range(4):
bitplanes.append(db.read(stride * height))
imagedata = []
for y in range(height):
for x in range(width):
offset = (y * stride) + (x // 8)
mask = 1 << (7 - (x % 8))
byte = 0
for p in range(4):
if bitplanes[p][offset] & mask:
byte |= (1 << p)
imagedata.append(byte)
image = Image.frombytes('P', (width, height), bytes(imagedata))
image.putpalette(bytes(colors))
image.save(entry[0] + '.png')
print("%s (%dx%d)" % (entry[0], width, height))