BLooperZ / nutcracker

Tools for editing resources in SCUMM games.
GNU General Public License v3.0
42 stars 11 forks source link

akos support #13

Closed haywirephoenix closed 11 months ago

haywirephoenix commented 1 year ago

I noticed some AKOS related files in nutcracker source. There's very little work out there on AKOS and the fate of a remaster depends on extracting them!

BLooperZ commented 1 year ago

Hi, it's great to hear that you find the source useful (I think😅) can you please elaborate on what the issue is? AKOS support is currently in development - the frames already can be extracted but have problem with colors and metadata. if you'd like to try that, and have python 3.9.9 installed on your computer. the akos module can be invoked directly with:

python -m nutcracker.sputm.costume.akos /PATH/TO/GAME.LA0
haywirephoenix commented 1 year ago

Thanks! I'll try it right away. I'm so glad to hear it's being worked on. I can see from AkosView and ScummRev that there are issues with colours. I think that red is supposed to be black with opacity set by the brightness of red while the black is transparent.

It would be great if I could detect the transparent background colour from the pallette and export as transparent (incase upscaling doesn't work out on scumm)

AKOS has remained somewhat of a mystery over this many years, I'd love to see it solved once and for all.

haywirephoenix commented 1 year ago

Update! Many files fail to extract and throw an assertion error which is fixed by commenting out line 89 of akos.py:

assert any(x == data[:len(x)] for x in encs), (encs, data)

Without this line the prior missing images extract cleanly. The error shows a long encoded string. Does it throw an exception if it would fail to re-encode? Interestingly, this frame is blurred in engine so I don't know if there is data stored for that which is confusing it, or if the blur is performed elsewhere.

To reproduce

I've changed the loops at the bottom of akos.py to a single frame selector for faster testing and easy reference. Replace bottom of akos.py with the following and run on COMI.LA0. It succeeds if you comment out the assert (line 89).

rootnum = 0
roomnum = 6
akosnum = 1
framenum = 0

roots = list(root)

rooms = list(get_rooms(roots[rootnum]))

_, palette, _, _ = read_room_settings(rooms[roomnum])

akoslist = list(sputm.findall('AKOS', rooms[roomnum]))

currakos = read_akos_resource(akoslist[akosnum], palette)

next(currakos).save(f'AKOS_out/{basename}/{os.path.basename(rooms[roomnum].attribs["path"])}_{os.path.basename(akoslist[akosnum].attribs["path"])}_aframe_{framenum}.png')

I haven't touched python in years so I'm sure this can be improved. I bet I didn't need to use lists or sputm.findall but it works.

BLooperZ commented 1 year ago

did you use the latest version from git? I can't find such line. Please also provide full traceback of the error

haywirephoenix commented 1 year ago

oops, you're right. python installed an earlier version. This works now.

JeanxPereira commented 1 month ago

python -m nutcracker.sputm.costume.akos "D:\GamingLibrary\The Curse of Monkey Island\COMI.LA0"

Traceback (most recent call last):
  File "C:\Users\usuario\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\usuario\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\DownloadLibrary\nutcracker\src\nutcracker\sputm\costume\akos.py", line 214, in <module>
    for idx, ((xoff, yoff), im) in enumerate(
  File "D:\DownloadLibrary\nutcracker\src\nutcracker\sputm\costume\akos.py", line 173, in read_akos_resource
    locs, decoded = decode_frame(akhd, ci, cd, akpl)
  File "D:\DownloadLibrary\nutcracker\src\nutcracker\sputm\costume\akos.py", line 94, in decode_frame
    return (xoff, yoff), {
  File "D:\DownloadLibrary\nutcracker\src\nutcracker\sputm\costume\akos.py", line 65, in decode1
    assert d_data == data, (len(d_data), len(data))
AssertionError: (3276, 3277)