lscharen / iigs-game-engine

A tile-based game engine for the Apple IIgs written in 65816 asssembly language
32 stars 1 forks source link

JS Error when generating assets in kfest2022 demos #25

Closed yoshisuga closed 11 months ago

yoshisuga commented 1 year ago

Hi there @lscharen ! I've watched your KFest presentations on the IIGS Game Engine and have been really interested in it over the past couple years, and got just barely started building enough background on GS assembly to have a sense of what's going on :sweat_smile:

I checked out your repo and started trying to build the kfest2022 demos since I thought they would be a good starting point. It looks like some preliminary steps are to create the assets in Tiled, and use your JS scripts to convert them to Merlin assembly data that can be referenced in the main source files. It totally makes sense to do it this way instead of hand-coding them - I had written a rudimentary PNG image converter to Merlin assembly in Swift when I was figuring out how to draw SHR graphics on the screen.

When generating the assets in kfest2022/demo-1 (and also tried demo-2), I ran into an issue where the pngjs library couldn't read the tile image supplied in the repo:

(base) yoshi@yoshimbpm1max demo-2 % npm run build:map  

> kfest-demo-2@1.0.0 build:map
> node $npm_package_config_tiled2iigs ./assets/tiled/world_1-1.json --empty-tile 33 --no-gen-tiles --output-dir ./gen

Reading Tiled JSON file from /Users/yoshi/Code/personal/6502-dev/iigs-game-engine/demos/kfest-2022/demo-2/assets/tiled/world_1-1.json
Parsing JSON file...
Looking for animated tiles...
{
  id: '136',
  animation: { frame: [ [Object], [Object], [Object], [Object] ] }
}
{
  id: '137',
  animation: { frame: [ [Object], [Object], [Object], [Object] ] }
}
{
  id: '168',
  animation: { frame: [ [Object], [Object], [Object], [Object] ] }
}
{
  id: '169',
  animation: { frame: [ [Object], [Object], [Object], [Object] ] }
}
Importing tileset "App.TileSet"
Reading PNG file from /Users/yoshi/Code/personal/6502-dev/iigs-game-engine/demos/kfest-2022/demo-2/assets/tilesets/smb-256-128-4bpp.png
Error: unrecognised content at end of stream
    at SyncReader.process (/Users/yoshi/Code/personal/6502-dev/iigs-game-engine/demos/kfest-2022/demo-2/node_modules/pngjs/lib/sync-reader.js:43:11)
    at module.exports (/Users/yoshi/Code/personal/6502-dev/iigs-game-engine/demos/kfest-2022/demo-2/node_modules/pngjs/lib/parser-sync.js:68:10)
    at exports.read (/Users/yoshi/Code/personal/6502-dev/iigs-game-engine/demos/kfest-2022/demo-2/node_modules/pngjs/lib/png-sync.js:7:10)
    at readPNG (/Users/yoshi/Code/personal/6502-dev/iigs-game-engine/demos/kfest-2022/demo-2/tools/png2iigs.js:124:26)
    at async main (/Users/yoshi/Code/personal/6502-dev/iigs-game-engine/demos/kfest-2022/demo-2/tools/png2iigs.js:265:21)

My node/npm info:

(base) yoshi@yoshimbpm1max demo-2 % node --version
v18.17.1
(base) yoshi@yoshimbpm1max demo-2 % npm --version
9.6.7
(base) yoshi@yoshimbpm1max demo-2 % npm list
kfest-demo-2@1.0.0 /Users/yoshi/Code/personal/6502-dev/iigs-game-engine/demos/kfest-2022/demo-2
├── pngjs@6.0.0
├── string-builder@0.1.8
├── watch@1.0.2
└── xml2json@0.12.0

I'm running this on my M1 Macbook and not sure if it only just works on Windows, but wanted to see if you ran into this before. Thanks so much for all your work!

lscharen commented 1 year ago

@yoshisuga I have some time to look into this. In the meantime, it looks like Git LFS could be a culprit causing the error in the png.js module. Do you have Git LFS installed? https://github.com/pngjs/pngjs/issues/235

yoshisuga commented 1 year ago

Hi! Thanks, no I don’t use git LFS. I also tried this on a windows 10 machine and got the same result. Is it the node version maybe?

On Sat, Sep 30, 2023 at 12:26 PM Lucas Scharenbroich < @.***> wrote:

@yoshisuga https://github.com/yoshisuga I have some time to look into this. In the meantime, it looks like Git LFS could be a culprit causing the error in the png.js module. Do you have Git LFS installed? pngjs/pngjs#235 https://github.com/pngjs/pngjs/issues/235

— Reply to this email directly, view it on GitHub https://github.com/lscharen/iigs-game-engine/issues/25#issuecomment-1741872390, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEJ4JQVGDTKEKX7YXAKQ4DX5CMA5ANCNFSM6AAAAAA4S6LN5M . You are receiving this because you were mentioned.Message ID: @.***>

yoshisuga commented 1 year ago

Just checked my node version and it's v18.17.1

yoshisuga commented 11 months ago

Spent a little more time on this, and I was able to run the npm run build:map command if I ran it more than once. I think the problem could be something with the file handle (maybe it was still open?) such that it can't read it, because it can read the same image file (the tiles image file) in npm run build:tiles.