Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Original bug regarding SP stealer #129

Open
Pyrdacor opened this issue Feb 11, 2025 · 3 comments
Open

Original bug regarding SP stealer #129

Pyrdacor opened this issue Feb 11, 2025 · 3 comments

Comments

@Pyrdacor
Copy link
Owner

Pyrdacor commented Feb 11, 2025

I already fixed a bug where the SP was not calculated correctly. You can see it here: https://github.com/jhorneman/ambermoon/blob/52e36804e1f211330d884a79ecc5559138c4974d/src/COMBAT/COMBAT_M.S#L823C1-L823C8

This was the wrong register. You had to subtract d4 and not d0.

Now I found another bug. From this code line (https://github.com/jhorneman/ambermoon/blob/52e36804e1f211330d884a79ecc5559138c4974d/src/COMBAT/COMBAT_M.S#L856) and below, the register d5 is used to determine the size of the green globes which fly from the target to the caster.

I think this was copied over from the same code in the LP stealer.

However for the PP stealer, d5 is never filled. Instead d4 is filled. So it is quite random what is inside d5. If you are lucky it is not 0. If it is 0, the whole green globe is not shown at all. Otherwise the value determines the initial globe size between 1 and 20 pixels. But it is not dependent on the stolen PP, which is the intention here.

You can see the issue by comparing these two lines:

@Pyrdacor
Copy link
Owner Author

To fix it you can just replace d5 by d4 in the mentioned code sections including the .Modify sub-procedure. I fixed it in AA already as I had to implement a new spell animation in a similar way.

@a1exh
Copy link

a1exh commented Feb 11, 2025

It's nice to see the original source code files that @jurie provided match the final release close enough to be useful for debugging.

I assume you don't build from these files but instead use the disassembled sources you created using Ghidra?

@Pyrdacor
Copy link
Owner Author

Yes I use my own dissambly. Jurie's code misses some important parts like the 3D routines and the combat logic.

Moreover it does not contain all the bugfixes and extensions I added (like the unification of the executables and the externalisation of the text data).

My plan is to merge Jurie's code with mine at some point. But it requires some time and effort of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants