BGITool- main emulatorBGIPiler- a test to turn stack based vm code to something more readable.BGITracer- a basic opcode tracer, and engine hook, was used to fix a bug or 2 at one pointBGIExplorer- a bad attempt to make like a resource viewer kinda deal. mostly for textures, and has hardcoded paths.
note that there might be some hardcoded paths here and there or whatever.
in like around 2019 or 2020 or something i found the bgi engine, popped it in ida and saw it was just an interpreter, then i wanted to do an emulator.
iirc i started it off with the "EthornellTools" project and trying to make a image decoder instead of encoder. learning about huffman encoding in the process, then adding more formats and such.
anyway then i just expanded and added opcode handlers... not sure how i kept focus on that.
it should reach menu on most bgi games unless theres unimplemented opcodes opcodes. Installer is simpler than full game. I dont remember alot of the state of things.
rendering is flawed in some way, bgi heavily relies on bitmaps and grasyscale bitmaps for area testing. theres alot of bitmap blending and copying, and doing render targets for all that seems like a problem, might be better with a compute shader? theres also the bitmap layers i think i didnt like, think something about waiting to do bitmap operations until frame is rendered and doing it straight in script.
Anyway heres some points that i might remember:
- doesnt support specifying z for rendering, some games use this and copies output to a texture.
- dont think rendering does bitmap operations very well, and doing it straight with raw byte arrays then at the end copying every bitmap to the gpu was bad performance wise iirc. Compute shaders with bitmap targets might work, but not sure how viable it is.
think opentk window and input handling was annoying, think it was mainly just event driven while bgi does straight gdi calls and stuff.
probably alot of other design and structuring flaws.
one thing i notice is BGITime seems to have some wierd timing issues or something, not sure if it runs too fast or too slow. Doing some wierd clamping and dividing delta by 1.3 seems to kinda mitigate it, but isnt very good.
Theres no font rendering or whatever, plan was just to use freetype. no sound as well, opcodes are stubbed.
for opcodes alot of the tostring overwrites and the push and pop stack count is wrong, usually worked by copying some older opcode, changing the opcode number and then getting code to somehow work. For bgipiler or whatever this needs to be right otherwise output would be wrong.
i think some games require right product name to run, check SyscallGameGetProductName. think this is the main "license" check?
respect the credits
probably forgetting alot, but this is what i remember for credits
- EthornellTools. (licenced with MIT, probably mainly around BGITools.Format and some BGICore.Utils)
- BGICore/IO is based on rime readers, built by NF/orfeasz.
- theres probably alot of rendering code taken from opentk and related examples or projects, imgui examples, etc.