music in NMI

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
music in NMI
by on (#46868)
Sometimes why do I put music procedure to nmi in the screen demonstrate glitter, sometimes beats?

Code:
nmi:

    pha
    txa
    pha
    tya
    pha
    php

          lda #$00
     sta $2003
     lda #$02
     sta $4014
     jsr joy1p
   
    lda <scrollx
    sta $2005
    lda <scrolly
    sta $2005
    lda <vhi
    sta $2006
    lda <vlo
    sta $2006
   
    jsr music
nmi000:   
    pla
    tay
    pla
    tax
    pla
    plp
    rti

by on (#46869)
Read from the joystick AFTER you're done with everything on the screen, not before.

by on (#46871)
Code:

nmi:

    pha
    txa
    pha
    tya
    pha
    php

     jsr joy1p     :First it does then under do other thing ,is thet righr?

     lda #$00
     sta $2003
     lda #$02
     sta $4014
 
    jsr music
nmi000:   
    pla
    tay
    pla
    tax
    pla
    plp
    rti


I such understand Dwedit words , but I have tried, dodges as before

by on (#46882)
No, the joystick comes after everything related to graphics. Try putting "jsr joy1p" before or after "jsr music ".

by on (#46885)
The PLP instruction is in the wrong place. If it's the last thing pushed on the stack, it should be the first thing pulled.

Also you can remove both the PHP and PLP in that case because they aren't needed. The NMI automatically pushes the processor status, and RTI restores it.

by on (#46898)
Here is my files.
http://www.uushare.com/user/hd380000/file/1611206

I have made a change, but has not been able to solve the problem. :(

by on (#46918)
Using FCEU, Nestopia, Nintendulator, and NESten I only get a blank screen and no sound. Looking at RAM in the debugger, it looks totally uninitialized. You could try clearing RAM, maybe that's messing up the music engine. I don't know if it'll fix it, but it's always a good idea to clear RAM anyways.

I'd change the startup to this:
Code:
 
              CLD
              SEI

              ldx #$00
              stx $2000
              stx $2001
              dex
              txs
 inx
 txa
@loop:
 sta $00,x
 sta $200,x
 sta $300,x
 sta $400,x
 sta $500,x
 sta $600,x
 sta $700,x
 inx
 bne @loop


Also you'll want to clear VRAM (nametables and such), it won't matter on an emulator though.

by on (#46953)
If I look at the procedures shown in the time interval lengthened, then the phenomenon of flash will become less, which means that I did not do a good job Vblank Ming, is it?
Nmi is also not a design problem.
And cleanram is a good idea,Although there is no solution to the problem of flash。
Code:
mainloop:
   lda <time1
   cmp #$01
   bne jia
   inc <time1
   lda #$00
   sta $2001
   lda <vhi
   sta $2006
   lda <vlo
   sta $2006
   jsr vwait_start
   lda <tile
   sta $2007
   inc <vlo
   bne jia
   inc <tile
   inc <vhi
   lda <vhi
   cmp #$24
   bne jia
   lda #$20
   sta <vhi
 jia:
   jsr vwait_end
   lda #%00011110
   sta $2001
  jmp mainloop