Closed peterferrie closed 3 years ago
More significant point - the ProRWTS init function must be called before you copy ROM to LC RAM, otherwise you can't run from a subdirectory on a hard disk.
@peterferrie thanks a lot for this! I'll need some help from @martinhaye and/or @dschmenk to review if they have a few moments.
Hmm, that is a good point Peter. Also, I can't see a reason not to grab the newer RWTS code. People have reported floppy mode not working sometimes, and there's hope this could fix that.
At this point I'm fearful to pick up little optimizations to the game code (past experience has led me to expect unexpected and hard-to-debug issues), so I may set those aside for now and focus on RWTS -- and the interrupt fix of course.
Sorry to have taken so long with this Peter.
Hmm, that is a good point Peter. Also, I can't see a reason not to grab the newer RWTS code. People have reported floppy mode not working sometimes, and there's hope this could fix that.
Yes, floppy handling is improved in the new code. Nox Archaist has no reports from good floppy drives. Failing drives are a dice roll, of course.
At this point I'm fearful to pick up little optimizations to the game code (past experience has led me to expect unexpected and hard-to-debug issues), so I may set those aside for now and focus on RWTS -- and the interrupt fix of course.
Sorry to have taken so long with this Peter.
I understand completely. If you don't absolutely need the optimisations for memory or speed, there's no compelling reason to take them on.
Finally got the initialization order fixed. Now I can review this PR; I may not finish today.
Something else to note: the save file needs to be pre-allocated to be as large as it will ever become, with at least one non-zero byte per block so that it does not become sparse. I don't have sparse writing support enabled in the regular file-access code (only available in RWTS mode, which you're not using).
+!if load_aux = 1 {
- sta SETAUXWR + (load_banked * 4) ;SETAUXWR or SETAUXZP
I think this is a bug: when load_aux and load_banked are both set, this line seems to set aux ZP.
It's used to set aux main or LC access.
That in turn causes the plp 5 lines later to pull from uninitialized aux stack.
That's the bug. I never used it in combination with floppy control. There should be nothing on the stack before switching. I'll fix it in a moment.
+!if load_aux = 1 {
- sta SETAUXWR + (load_banked * 4) ;SETAUXWR or SETAUXZP
When I fix that, the initialization gets further though still crashes. I have to keep on tracing...
I can look, too, if you want to share a current image.
When I fix that, the initialization gets further though still crashes. I have to keep on tracing...
If you're writing to aux main, then writes intended for main memory are failing. I'll fix that next.
Ah, my fix wasn't really a fix then. If it's useful, here's a (temporary) link to a current build image: https://www.dropbox.com/s/9l3zndf7onez3j8/game-rwts2.2mg?dl=0
I made a new PR with the fixes in place. The loader does not crash, but does show a missing resource message in HDD mode, because namlo/hi are set in main memory instead of aux memory prior to calling ProRWTS. In floppy mode, there's a call to unrblocklo instead of opendir (lands at $D003 instead of $D000), which misses the call to turn on the floppy drive, resulting in a hang in FDD mode.
Wow, thanks for the quick debugging and fixes. I'll try to test out the fixes this evening or tomorrow morning.
--Martin
Superseded by https://github.com/badvision/lawless-legends/pull/39. Closing.
@martinhaye thoughts on this pull request? Lots of optimisations but it looks like a buffer moved from $e00 to $1e00 and I'm unsure of that affects anything.