I had no problems. (note, I removed the 2nd song before exporting from 0.4.6)

Deleting a song doesn't solve the issue, it just circumvents it. You might still run into the problem once you want to use the sound effect.

JWinslow23 wrote:

I actually made it stop with Cxx, but apparently Famitone doesn't support that. What effect would do this?

Oh, right: If you want a song to stop in FamiTone, you have to create a silent pattern and make it loop itself.If you want a sound effect to stop, you can use Cxx, but sound effects are created from an NSF export with nsf2data.

That makes sense, I guess. Alright, I'll do those separately. Thank you!

EDIT: Well, now that the music is in the game, I'm not exactly sure what to do. The compiled .nes file not only doesn't play music, but my character just starts in the middle of the screen and I can't control it. The screen is scrolling, though.

Code attached. What am I doing wrong?

Attachments:

File comment: The library (had to put colons after every define for it to compile, but that's all I modified).famitone2.asm [28 KiB]
Downloaded 37 times

your include statements are outside of the bank statements / org statements, so they weren't included in the ROM. It probably started counting from $0000. So this statement...

JSR FamiToneUpdate

probably sent the program somewhere between $0000 and $7fff, where there is no code. It probably saw a BRK (00) and jumped to the IRQ/Break code, which you have none defined (except 0000), anyway infinitely finding BRK and jumping to address $0000 at that point. Occasionally, an NMI would fire, and it would jump to the start of the NMI code, do some auto-scrolling, and then get lost again once it reaches JSR FamiToneUpdate.

BTW, I don't use NESASM, but I don't think you are supposed to put colons on = statements. I pulled this from a source file I found...

sprite = $0200

It was not indented. But, definitely, no colon.

_________________nesdoug.com -- blog/tutorial on programming for the NES

Well, it was the only way it could compile, is if colons were put in front of the define statements.

Also, now I have put both includes at the beginning of $C000, and the music works! Only one thing: how do you properly check whether the game is running on a PAL or NTSC system? I'm checking with some code I saw in FamiTone's demo, but it doesn't seem to be correcting the pitch right. Any code I can put in to properly check the region?

The only thing is, now (not sure if this has to do with the music, or just faulty scroll update code), for one frame after the walrus falls past the bottom of the screen, the background gets shifted down weirdly, and then goes back to normal. Is there a JSR UpdateScroll I'm missing?

There is 1 frame of misaligned at the start. It's because you are turning rendering on at scanline 122, when it tries, mid-frame, to start rendering the top of the screen.

BG turns to red...

You are writing to the PPU (palette) on scanline 2. Then trying to set scroll mid-frame. And, not changing it during the next v-blank. Thus, the next frame is misaligned.

And, these should be reversed... JSR FamiToneUpdate ; Update the music JSR UpdateScroll ; Update the scroll values

As, every few frames, it doesn't get to updating the scroll position until 4+ scanlines of rendering have passed. It works, but it's poor timing.

Make sure you only write to screen during v-blank. Make sure that you only turn rendering ON or OFF during v-blank.

I literally copy-pasted the background code from Nerdy Nights back when I made my first demo, and I haven't bothered changing any of it . I did, however, after enabling NMI, do a JSR WaitFrame to wait until VBlank to enable rendering. I also reversed the positions of the calls to FamiToneUpdate and UpdateScroll.

tokumaru wrote:

Definitely reverse the music update and the scroll update! The music code can be executed after the end of vblank without problems, but the scroll update absolutely must happen while still in vblank.

JWinslow23 wrote:

I was able to fix it myself through trial and error.

Even if the problem is (or appears to be!) fixed, it's important to understand what's happening.

Well, to be honest, that was a spur-of-the-moment fix, and what I did exactly is call JSR WaitFrame right before JSR DeathAnimation in order to have that code start on VBlank, which I assumed would fix the problem.

My new source is attached, along with the .nes file. What else, if anything, do I need to do (or, what have I done wrong)?

Before you start coding, have an idea of how the game will play. Is this a platformer? or a shooter? Sketch up some levels in Photoshop.

You should divide the game into different 'modes'. Title mode. Game mode. Pause mode. Transition between level mode. Game over mode. Victory mode. Ideally, they would all share the same NMI code, but some modes might skip some things.

I would spend some time just getting the basic physics of the game working. *

I would then work on an automated system for drawing levels as you scroll. Preferably, by filling a vram update buffer, and setting a flag. Then, the NMI code will see the flag, and do an automated update.

I would then work on a sprite object system. Or, borrow someone else's working system. It should be an automated system, also. Like all you should have to do is tell it draw animation #2 at x = 50, y = 80, facing right, and it should arrange the tiles for you.

*Edit- for reference, no kidding, on a game I'm working on (not the Ninja game), the main character's movements alone takes up 1000 lines of code. That includes collision detections. It might take you MONTHS to get just the basics of the game in position.

_________________nesdoug.com -- blog/tutorial on programming for the NES

Last edited by dougeff on Fri Apr 28, 2017 12:48 pm, edited 1 time in total.

Who is online

Users browsing this forum: No registered users and 4 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum