Tested on FCUEX 2.2.2 but no sprites on flashcard (solved!)

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
lazerbeat
Posts: 64
Joined: Tue Jul 09, 2013 7:13 am

Tested on FCUEX 2.2.2 but no sprites on flashcard (solved!)

Post by lazerbeat » Tue Sep 03, 2019 12:11 am

I am working on a little program to make test scroll across the screen based on a user entered string
scrollnesmod-1.png
scrollnesmod-1.png (1.62 KiB) Viewed 2454 times
This part works fine. I added in a little sprite field in the background on the scrolling text
scrollnesmod-0.png
scrollnesmod-0.png (2.24 KiB) Viewed 2454 times
which works fine on FCUEX 2.2.2 but when I try it on my flash cart, I am using a famicom everdrive, the sprites don't show up in the background.

Does anyone have any idea what the issue might be?

I put a paste bin of the code here if anyone would be kind enough to look at it

https://pastebin.com/Wi44YFBf
Attachments
scrollnesmod.nes
(40.02 KiB) Downloaded 93 times
Last edited by lazerbeat on Tue Sep 03, 2019 4:10 pm, edited 1 time in total.

User avatar
gauauu
Posts: 673
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: Tested fine on FCUEX 2.2.2 but no sprites on flashcard

Post by gauauu » Tue Sep 03, 2019 7:03 am

It looks like your sprite DMA call is too late in the frame, after VBlank has ended. You'll want to do any writes to the PPU as quickly as possible once VBlank starts.

User avatar
NOOPr
Posts: 67
Joined: Tue Feb 27, 2018 10:41 am
Location: Brazil
Contact:

Re: Tested fine on FCUEX 2.2.2 but no sprites on flashcard

Post by NOOPr » Tue Sep 03, 2019 7:53 am

The DMA routine must be called during V-Blank. So, try to call updatesprites in vblank.
Tip: try to change your code to work with NMI enabled rather than manual calling vblank and polling $2002, something like this:

Code: Select all

main_loop:
	lda #0
	sta nmiok
wait_nmi:
	lda nmiok
	beq wait_nmi

	; game logic here
	; ...

	jmp main_loop

Code: Select all

nmi:
	; preserve registers
	pha
	txa
	pha
	tya
	pha

	; Sprite DMA
	lda #$00
	sta $2003             
	lda #$02
	sta $4014   

	; other vblank stuff here
	; ...

	lda #1
	sta nmiok

	; restore registers
	pla
	tay
	pla
	tax
	pla
	rti
Another tip: You don't need to test your game on the Everdrive to see the error, just do it in Mesen or Nestopia

lazerbeat
Posts: 64
Joined: Tue Jul 09, 2013 7:13 am

Re: Tested on FCUEX 2.2.2 but no sprites on flashcard (solve

Post by lazerbeat » Tue Sep 03, 2019 4:12 pm

Thanks for the advice everyone that fixed the problem!
NOOPr wrote: Tip: try to change your code to work with NMI enabled rather than manual calling vblank and polling $2002, something like this:
I will add this into the next version of my code. Thanks for the suggestion.

Post Reply