Language…
5 users online: Hammerer, Maw, Rudi_Schrausch, Shiki_Makiro, Torchkas - Guests: 269 - Bots: 346
Users: 64,795 (2,377 active)
Latest user: mathew

Pausing and the OAM

I'm once again trying to make the DKC(R) sprite status bar appear when the game is paused. Last time I tried I failed, and I'm still not making huge progress, because drawing sprite tiles in a paused game is unexpectedly tricky.

Here's what I currently have, excluding unnecessary parts:

Code
org $00A25B ; runs when the game is paused
	autoclean JML Paused

freecode
Paused:
	JSL $7F8000
       	JSR StatusBarMain_handleLivesCounter ; this draws sprite tiles

	; (restore hijacked code and return)


So the first thing I did was hijack code that runs when the game is paused and run my status bar routines in there. That promptly crashed the game (I assume this is because I'm drawing sprite tiles). When I add the call to $7F8000, the game no longer crashes, but then removes tiles or draws garbled ones, which I also don't want.

It makes sense that you can't call $7F8000 when paused, because all the other sprite tiles won't be redrawn. But why does not calling it, then drawing sprite tiles, crash the game? That's kind of my first question. All the does is erase all on-screen sprite tiles, after all.

My second question is more important, but also more vague: what's up with pausing and the OAM? For example, why does my current code also draw a handful of garbled tiles at random positions? Is there some other routine you're supposed to be calling?

I can delve into p4's code for SMWCP2's status bar which pulled it off, but I was hoping someone already familiar with this whole thing could point me in the right direction before I reinvent the wheel.

 


 
it could very well be that your code is faulty, and thus worth (double-)checking

have you tried using a debugger, to see at what point its crashing?

edit: also youd have to run the routine that stores $0420+ to $0400, not sure if you are (assuming youre not storing to $0400 directly)
And a couple of hours later, I got it working! #tb{:D} Thanks so much for the reply, Ladida - you really put me on the right track there.

The first thing I did was write a custom version of $7F8000 that only clears status bar tiles (like p4 suggested in my 2014 C3 thread). That was the one thing I had never tried before, and it fixed the crash while not erasing too many sprite tiles.

Originally posted by Ladida
edit: also youd have to run the routine that stores $0420+ to $0400, not sure if you are (assuming youre not storing to $0400 directly)

Ah, good old $008494! I actually forgot all about that. My first mistake was not having called that.

After fixing it things looked somewhat better, but I was still getting more glitched graphics than desired - and it looked like SMWCP2's code wasn't doing anything special that I wasn't also doing.

Originally posted by Ladida
it could very well be that your code is faulty, and thus worth (double-)checking

And it turns out that was my second mistake! While drawing sprite tiles, I'd made the classic error of reading data from the wrong bank. welp.

</story_time>

Anyway, there we are. Why using $7F8000 during the pause crashes the game I may never know (couldn't really figure it out in the debugger), but I'm super glad things are working now. Thanks again for the input!