It is currently Fri May 24, 2019 10:54 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Mon Feb 04, 2019 7:25 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 4077
Location: A world gone mad
This code is wrong still:

1. The code in your VBLANK label does not return from the interrupt, yet you're setting NMI in the 6502 vectors section to that label/address. This is bad. You need an rti as your last instruction, otherwise your jmp Infinite is technically running inside of NMI.

2. Again in your VBLANK routine: you're clearing bit 7 too soon. There's a known race condition on the NES where if you do this too soon you end up skipping NMI entirely. See last bullet point item here https://wiki.nesdev.com/w/index.php/PPU ... #PPUSTATUS as well as this: https://wiki.nesdev.com/w/index.php/NMI#Race_condition

If you don't want to deal with that, just add two nop instructions prior to the bit $2002 (and loop against the bit $2002 line, not the two nops) which will waste 4 cycles.

3. The code in your VECTORS section for IRQ/BRK vector uses .word 0, which literally means .word $0000, which means your IRQ/BRK vector is pointing to $0000 (i.e. the first and second bytes of zero page). Stop/pause for a moment and think what you want: you essentially, right now, want it to point to some code that essentially does, nothing, right? Pretty simple:

Code:
IRQ:
  rti

.segment "VECTORS"
    .word VBLANK
    .word RESET
    .word IRQ

IRQs are particularly weird on the NES due to how DMC/PCM works (digital audio samples), and with things like scanline counters on certain mappers. It's not worth the risk of pointing it to $0000 and assuming it'll never get executed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 9 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