-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Investigating memory corruption at Illien #66
Comments
EDIT: it seems the bug is reproducible entering/exiting Pelanis Palace/Illien multiple times, but only when using the WHDLoad slave 2.1 |
Then you might tell Wepl about it. |
Reported in your WHD thread about Ambermoon 1.16 release... |
Oh no, I had a strange issue also running 1.16 from WB: when sleeping I got msgs truncated like "Luca0150" instead of usual "Luca regained 150 magic points...", it could still be something in 1.1.6, after using Crystal Ball and recharging it with a spell to recharge items, and after a flight with the Eagle... can't find a simple pattern.... or maybe are just randomic issues due to the strange memory allocations by this game 😰 |
Can you please open a new issue for the text stuff? |
Let me investigate if I can reproduce it first, I'll also degrade emu speed etc. |
ATM all I can say is that it's reproducible even with the original game 1.08 EDIT: it could be a problem introduced with unified exe (saved in my savegame probably). With 1.08 up to your 1.13 I can reproduce it only once ( = when entering first time in Illien). If I enter and exit Illien, from now on I can't reproduce it anymore with pre 1.14 versions from my checks... Using 1.16 I can reproduce it easily and often just entering Illien. |
V1.07 and below were the originals |
Ok. Tested up to 1.13: my savegame above entering Illien twice solves the problem (sort of fixes by itself). With 1.14+ I can reproduce it every time. |
Testing like crazy with all versions of the game, including 1.07... Repro steps:
|
Started a new game with 1.16 in the meanwhile and, using cheat with Netsrak's Staff, I got the flute to call the Giant Eagle to fly to the nearest town: I found NewLake and I noticed the same issue with (wrong) wall textures the first time I entered the gate! |
Not a WHDLoad + 060 bug. |
Not that it matters but the last "original games" were 1.05 (DE) and 1.07 (Eng). Bugs like this have been reported in the past but no-one ever posted real technical information that could be debugged. e.g. Someone called st-th (who is now unreachable) posted some tiny tiny fractions of details. |
Ouch! So there are a lot of code bugs indeed... I love this game 😫 |
Maybe. He never published his work. But some of his posts were extremely technical and led to bug fixes. |
I wish I had that information back then. I had to find those two bugs on my own. His item slot format description is not 100% correct but it's amazing to see how much knowledge about the game formats he had back then. It's a shame he never published it. Today I guess I am aware of most bugs outside of the executables and know all the file formats in detail. While I develop AA, I also found some more bugs in code and also decoded more bits and bytes of the file formats. But most of the bugs are minor or only lead to problems with additional content. Just recently I found one. There is the spell Blink which is the only spell in the game which targets a free battle field. All other spells target monsters, players, items or nothing at all. Such spells as Blink are stored in a list of pointers with some additional data. Something like "FieldTargetedSpells". Each entry starts with a long, where the first word is the spell school and the second word is the spell index. Then follows a pointer to the function which does the target selection routine. Then some code loops over the list and checks for a spell match. There is an end marker of 0xffff in the spell list. However the code which loops checks for 0xffffffff. So in case it couldn't find the spell for some reason, it would interpret the word 0xffff as the spell school and the next word (following data) as the spell index. This won't match either so it keeps going until it finds a 0xffffffff by luck. This shouldn't hurt, but still is a bug. The code is only used for the spells with that target type so only for Blink. And of course it will match instantly. If someone sets the target type of a spell to "field" and don't add the table entries correctly, the code may search through the whole memory in worst case and eventually even crash when reaching the memory boundary etc. |
Perhaps you discovered it before we started working together. This bug was in my spreadsheet in full detail including a link to that page . You even cross reference my spreadsheet entry (Unfixed 46) when you committed the change. 16f305b#diff-970d9d07a7064d52efff7f30b4c4f0bfdd786a721e4c1a1d7e83fa97e12805af |
Yeah I knew the bug from your spreadsheet of course but most likely overlooked the link. ;) Most of the times, the link only contained the description of the bug. I had no clue that someone really posted some details about the actual fix or even description of code errors. So maybe I just skipped that link which turned out to be a mistake now. |
Just as a reminder and backlink to keep track of these threads: |
Is the texture issue temporary? How long does it occur? |
The pattern to reproduce ithis issue is:
|
I mean: is the texture changing while you move on the map or is it constant as long as you be on the same map? |
Won't change till I re-enter/exit a door in the city. So it seems a problem in the texture loading when switching 2D->3D. |
It looks more like some tiles have the wrong texture index so the map data is somewhat broken. |
It happens randomly anyway and only following the instruction. If I enter/exit Illien city 10 times in a row it won't happen. If I move to another town flying there with the eagle, and then go back to Illien there is a higher chance to see the bug... |
I hope my memory doesn't fool me here but in Ambermoon Advanced I think there were some issues as well. Also when changing some maps a few times. It was also a 3D map and you enter it from a "world map". You also enter Illien from the world map so this might be related. World maps have a special flag bit set. I think the one flag is important, which controls how the 2D player is drawn. This changes a lot of stuff in the original code so there might be a specific bug when you move from a "world map" to a 3D map. In the original code there is a "map type" variable. While the data only specifies 2D and 3D as a type, the game differentiates 4 types:
The main reason for splitting them is drawing I guess but also some changes in logic. In our cases a change from the first one to the third one happens. And I think exactly that transition might have a flaw. But it will be hard to find it. |
It would be interesting if the bug is persistent when it once happens. If it occurs, can you try to revert or change it by moving again to another town and back? Moreover does it affect the whole town of Illien or only some parts? From the screenshots it is in the lower part of the map. Would be interesting if it also happens in the top part as well. |
It's random (but only after some patterns described above, or at least that is the easy way...) and not persistent: just entering shops/houses in the town and exiting multiple times usually fixes it... Will check for the N vs S map towns but I don't think will change.,, |
This sounds like wrong branching or memory access during map load then. As only some tiles are affected, I think it can't be no major memory error but is most likely a slightly incorrect index calculation. Would be interesting to have a 1:1 comparison of changed tiles. For example: is very wall of type X after the bug of type Y? Or is it totally random? This would provide some clues in which data loading the error happens. The data is 2 part. The lab data which stored the textures for walls and objects (and other stuff) and the map itself which references those walls and objects via index. So either the index on the map is wrong or the texture index in the lab data (or just the wrong gfx is loaded into memory for that index). |
It's always the same corrupt appearance for all instances (X -> Y), and identical everywhere is used. Following my repro-steps above, with my savegame everyone should be able to reproduce it. |
I will have a closer look at it soon. Thanks for investigating. |
News? |
Exiting and entering Pelanis palace a couple of times after I fly with Giant Eagle to Illien can randomly cause strange gfx corruption like this:

Sometimes the walls have the wrong tile with windows or plaques at every wall tile (???).
Still investigating a reproducible pattern...
The text was updated successfully, but these errors were encountered: