It is currently Tue Oct 16, 2018 1:19 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Tue Jul 31, 2018 9:59 pm 
Offline

Joined: Tue Jul 31, 2018 9:55 pm
Posts: 1
hello,
This past week, I decided to take Disch's advice and try separating my game logic from my NMI/Drawing code. The problem is, when I try this, the code in the game loop doesn't seem to execute.

Essentially, my problem is this -- when I put code in the main game loop (which, in the working version, just loops forever while we wait for an NMI, and the NMI handles all of the game code like in Super Mario Bros), none of this code actually executes. Specifically, controllers aren't read, the game engine doesn't do anything, and test tones don't play. The screen still scrolls, but that happens during NMI.

Here is a link to the main file on pastebin. The sound engine is empty right now and the reset file has basic initialization routines that I haven't changed in moving the logic code to a separate loop. The only really relevant code in reset.asm is

lda #$00
sta sleep_flag
sta draw_flag
so that sleep_flag and draw_flag are both initially not set.

When the main game loop has content besides an unconditional jump to create a forever loop, that code doesn't appear to execute. If I put in a test tone, like so:

LDA #%00111000
STA $4000
LDA #C2
ASL A
TAY
LDA note_table, y
STA SQ1_LOW
LDA note_table+1, y
STA SQ1_HIGH
that code also does not execute -- I hear no tone, even though the same code works inside the NMI.

Any ideas as to what could cause this? I'm at a loss...I'm also a pretty new 6502 programmer. What I find really odd is that the code works perfectly fine if

jsr ReadController
jsr GameEngine
are in the NMI. However, Disch recommends putting this logic outside the NMI, which makes sense. I would like to figure out what's going on so I don't encounter this same problem in the future.

Thank you so much for your help!

_________________
Egg bacon and SPAM


Top
 Profile  
 
PostPosted: Tue Jul 31, 2018 10:16 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10892
Location: Rio de Janeiro - Brazil
Looks like you forgot the pastebin link, so there's not much I can say, except that this is very similar to this other post that was made recently: viewtopic.php?f=2&t=17555


Top
 Profile  
 
PostPosted: Wed Aug 01, 2018 12:21 am 
Offline
User avatar

Joined: Thu Sep 15, 2016 6:29 am
Posts: 773
Location: Denmark (PAL)
You really need to get used to using a debugger. Even if people can look at your code and guess the issue, this is a perfect example of a problem that can easily be solved using a debugger, something that I feel is absolutely necessary in any kind of development if you want to solve your problems, rather than just dig around blindly for days, using abstract methods such as playing a test tone.
FCEUX is the typical go-to for debugging, but I'd recommend Mesen as it has an extremely user friendly interface, and a ton of useful tools.

For an issue like this where it seems like the game never enters the main loop, I'd just put a breakpoint at the reset vector, and step through all the code, seeing where it goes, to find the point where it doesn't go to your main loop, or whereever you expected it to.
Or maybe start out with a breakpoint slightly further in, such as the start of the loop, to see if it does enter it, but simply refuses to loop back after NMI has been executed. And if it never hits that breakpoint, place one slightly further back.

Right now, as I haven't seen your code, my best guess is that either your sleep flag never gets unset (I assume the main loop sets it when it reaches the end, and loops until it's reset in NMI?), or something causes your code to never reach the main game logic in the first place.


Top
 Profile  
 
PostPosted: Thu Aug 02, 2018 4:32 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20656
Location: NE Indiana, USA (NTSC)
The post appears to be copy-pasted from this 4-month-old thread on Reddit. Signature neutralized (again).


Top
 Profile  
 
PostPosted: Thu Aug 02, 2018 7:41 am 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 1996
Location: Fukuoka, Japan
ouch! This one seemed legit at first (but out of nowhere) but now that I talked with Koitsu on the subject then it would ends in my suspicious list. We will have to be careful about new users posts from now.


Top
 Profile  
 
PostPosted: Thu Aug 02, 2018 10:28 am 
Offline

Joined: Sat Apr 25, 2015 1:47 pm
Posts: 420
Location: FL
Is there a particular reason for keeping these threads open (or even keeping them at all) after they're determined to be spam?


Top
 Profile  
 
PostPosted: Fri Aug 03, 2018 1:09 am 
Offline
User avatar

Joined: Thu Sep 15, 2016 6:29 am
Posts: 773
Location: Denmark (PAL)
Well then.
I hope the spambot appreciated my help :|


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group