This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Wait for a NMI [?]

Wait for a NMI [?]
by on (#55743)
- AFAIK, the JMP $current_pc is used to wait for a NMI.
- Is there another way? I'd like to improve my NSF player.

by on (#55745)
Here's the handler I use:
  inc nmis
  lda nmis
  cmp nmis
  beq :-

'nmis' is a 1-byte variable in an area of RAM into which the NSF itself is forbidden to write.

by on (#55777)
vblank equ [some byte in zp]

 INC vblank
 ~more code~

 LDA #$00
 STA vblank
 LDA vblank
 BEQ Wait_For_Vblank_Loop

This is how I do it. Obviously not as compact. :P

by on (#55781)
My neshla version:
interrupt.nmi int_nmi() {

function int_nmi_func() {
   ldx #1
   stx inVBlank
...Other code

inline int_waitVbl() {
   and #CR_NMI
   if(true) {
      do {
         lda inVBlank
      } while(zero)
      lda #0
      sta inVBlank
   } else {
//Call our nmi routine because interrupts are not set

inline vblank_wait()
      lda PPU.STATUS
   while(is plus)

inline unvblank_wait()
      lda PPU.STATUS
   while(is minus)

by on (#55789)
- Huh ?? /Bregalad :)

- Well, the forbidden RAM location bothers me. Actually, I use 4018-403F as free space and put my NSF code there. I use C for the sync code; with NMI, I can take it out and use pure ASM.

by on (#55960)
What's so wrong with having the return from the NMI go to JMP $current_pc if you don't need a frame counter?