badvision / lawless-legends

Open-source code and assets from Lawless Legends and its supporting tools
Apache License 2.0
67 stars 15 forks source link

newer ProRWTS2 #34

Closed peterferrie closed 3 years ago

badvision commented 4 years ago

@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.

peterferrie commented 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.

badvision commented 3 years ago

@peterferrie thanks a lot for this! I'll need some help from @martinhaye and/or @dschmenk to review if they have a few moments.

martinhaye commented 3 years ago

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.

peterferrie commented 3 years ago

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.

martinhaye commented 3 years ago

Finally got the initialization order fixed. Now I can review this PR; I may not finish today.

peterferrie commented 3 years ago

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).

peterferrie commented 3 years ago

+!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.

peterferrie commented 3 years ago

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.

martinhaye commented 3 years ago

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

peterferrie commented 3 years ago

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.

martinhaye commented 3 years ago

Wow, thanks for the quick debugging and fixes. I'll try to test out the fixes this evening or tomorrow morning.

--Martin

martinhaye commented 3 years ago

Superseded by https://github.com/badvision/lawless-legends/pull/39. Closing.