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