Page 1 of 1
music in NMI
Posted: Sat May 16, 2009 5:28 am
by hd380000
Sometimes why do I put music procedure to nmi in the screen demonstrate glitter, sometimes beats?
Code: Select all
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
Posted: Sat May 16, 2009 5:31 am
by Dwedit
Read from the joystick AFTER you're done with everything on the screen, not before.
Posted: Sat May 16, 2009 5:47 am
by hd380000
Code: Select all
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
Posted: Sat May 16, 2009 1:07 pm
by tokumaru
No, the joystick comes after everything related to graphics. Try putting "jsr joy1p" before or after "jsr music ".
Posted: Sat May 16, 2009 1:42 pm
by Memblers
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.
Posted: Sun May 17, 2009 5:57 am
by hd380000
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.

Posted: Sun May 17, 2009 1:22 pm
by Memblers
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: Select all
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.
Posted: Mon May 18, 2009 4:27 am
by hd380000
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: Select all
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