Page 1 of 1

[Solved] criptic vblank infinite loop

Posted: Sun May 08, 2016 11:21 pm
by vilxdryad
Hii, i am new by the forum; and like 2 days old on the EFnet IRC #nesdev channel, so yea; i literally started into assembly 6502 two days ago from the very scratch; i were pointed into the NintendoAge's Nerdy Nights tutorial, and so far i am loving it!... i managed to do a nice nametable and attribute arrangement to get a fully working background using Super Mario Bros. .CHR, all of this for learning purposes, thing is; that i got recommended to simplify the controller reading engine, and also to use variables for the sprite X and Y Position; i got a nice help from darrylrev all the way BUT now i do not know what to even do

The vblanktimers variables on my code seems to loop forever, like; they wait for vblank but that never happens for some reason that i can not spot yet so i can not move any sprite anywhere since pushing buttons on the joystick seems to do anything at all.

Here is my code, any pointer is greatly appreciated:
http://pastebin.com/aquYg1pK

EDIT: i am using NESASM and FCEUXD SP 1.07 that were provided by the NintendoAge's Nerdy Nights tutorial so far if that helps on anything.

EDIT2: as suggested by jero32 on the EFnet #nesdev IRC's channel; i am adjunting the rom itself here, also; i discovered that if i wait long enough, my code does go through the both vblanktimers BUT the code is somewhere forwarded here, and pretty much freezing the game:

$E008:22 UNDEFINED

also, as far as the FCEUXD SP 1.07's debugger tells me; the PPU keeps generating scanlines, so i can say the game keeps running code.

EDIT3: thanks to rainwarrior i got everything working as it should be. it turned out to be that i did not indented the RMI below the NMI part of the code at line 282. so this;

Code: Select all

RTI ;** <--- you forgot to return from interrupt after your NMI is called
should have been this, in order to make the whole code to work:

Code: Select all

  RTI ;** <--- you forgot to return from interrupt after your NMI is called
so everything i wanted is solved now. also; i deleted the rom i adjunted in this post before because, as rainwarrior pointed out; it contains the nes's super mario bros. CHR, and in order to avoid copyright inconvenients in this forum, i opted to wipe it.

Re: criptic vblank infinite loop

Posted: Mon May 09, 2016 9:22 am
by rainwarrior
You have this line in your pastebin:

Code: Select all

RTI ;** <--- you forgot to return from interrupt after your NMI is called
This line isn't in the ROM though. Your NMI routine simply ends with no NMI and the rest of the ROM is filled with $FF, which it begins executing. I think this is just that NESASM treats anything that is not indented as a label, so RTI doesn't turn into an actual RTI instruction there. (This is kind of a stupid thing about NESASM.)

Some other thoughts:

1. There's no particular reason to use such an ancient version of FCEUX. The current version still has a debugger, and it is much better. (Nintendulator also has a good debugger too. I don't like it as much as FCEUX's but it has slightly different information, and more accurate PPU emulation.)

2. You should replace the CHR tiles; we mostly avoid posting copyrighted material like that to this forum.

3. When you're ready, I would suggest a different assembler. I love ca65, though ASM6 is also popular here. NESASM is good enough to make a working ROM, but it has a huge laundry list of shortcomings (one of them you've just been bitten by).

Re: criptic vblank infinite loop

Posted: Mon May 09, 2016 10:06 am
by vilxdryad
Godddd i just indented that RTI you mentioned there and suddenly all is working like it should!!!!! !!!!!! !!!!1 you definitely are a legend.

now, referring to your other thoughts; that is cool to know, i just downloaded this one because it were provided by the NintendoAge's Nerdy Nights's tutorials, ones that despite being the best introduction to the 6502 nes's assembly, are pretty outdated lol also; my bad about the copyright, right now i am deleting the rom i adjunted here to avoid any inconvenient; i was heavily recommended to move from NESASM on the #nesdev IRC channel; thing i am looking forward to do right now BUT as far as i know, the syntax that ca65 uses differs from the one that NESASM reads to compile; so i may need to relearn how to code on ca65 to move there; any pointer on where i could find any read to how learn to code on the ca65 syntax?

Off topic: i really can not believe that the very one who introduced me into making my own chiptunes, also ripping NSF's since i saw your youtube fixing Star Tropics's music video, actually helped me into nes programming, there is so much i owe to you since i use your NESplay, NESimport and MarioPants most likely every day, also i am really desiring to play the final version of your lizard nes's project; your job there is really gorgeous, definitely the best nes homebrew i have ever played, one that actually is a demo. i am really amazed about the fact that one man could be that cool; you are one of the most fundamental reasons of how the nes scene have this far, i am really honored.

Re: criptic vblank infinite loop

Posted: Mon May 09, 2016 10:43 am
by rainwarrior
Thank you.

As for learning ca65, all of the standard 6502 instruction names are the same as in NESASM. The main difference is how you place code at a specific location (e.g. the vector table, NESASM's bank directive, org, etc.), and there are a number of cosmetic differences in syntax. It does have documentation, but it's got a lot of features, so that might be a lot to take in at once. ASM6 has a shorter manual, so it might be easier to get into by that route.

I try to open source most of my NES projects, but I also made a small ca65 example intended for beginners. There are other examples floating around this board but I'm not finding them easily searchable at the moment, unfortunately.

There's some useful learning information here, too: http://wiki.nesdev.com/w/index.php/Programming_guide

The Wiki, in general, is my primary reference for all things NES. We try to keep it up to date and correct.

Re: criptic vblank infinite loop

Posted: Tue May 10, 2016 10:27 pm
by vilxdryad
Really amazing documentation you got there, good read all the way; thank you a lot! i really appreciate your pointers.

I'm going forward to read your open source projects too, i find very handful to assimilate the way experienced developers work, you are very kind for sharing those