It is currently Fri Dec 15, 2017 10:51 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Thu Apr 27, 2017 4:32 pm 
Offline
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1516
dougeff wrote:
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.

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Last edited by DRW on Thu Apr 27, 2017 4:35 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Apr 27, 2017 4:35 pm 
Offline
User avatar

Joined: Mon Apr 24, 2017 5:52 am
Posts: 30
Location: West Allis, WI
text2data works without that second "song" (sound effect). But then what's the deal with sound effects? Would they be in a different Famitracker project?


Top
 Profile  
 
PostPosted: Thu Apr 27, 2017 4:37 pm 
Offline
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1516
Music: Works with text export and text2data.

Sound effects: Work with NSF export and nsf2data.

Sound effects can basically use any effect available in FamiTracker, including Cxx. They don't have the limitations of songs.

In a game, you would put all the music in one FamiTracker file and all the sound effects into another FamiTracker file since one has to be exported as txt and the other as nsf.

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Thu Apr 27, 2017 4:42 pm 
Offline
User avatar

Joined: Mon Apr 24, 2017 5:52 am
Posts: 30
Location: West Allis, WI
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 21 times
File comment: The generated music file.
walrush_music.asm [2.01 KiB]
Downloaded 19 times
File comment: The game file I actually compile.
walrush.asm [18.45 KiB]
Downloaded 22 times
Top
 Profile  
 
PostPosted: Thu Apr 27, 2017 6:38 pm 
Offline
User avatar

Joined: Mon Apr 24, 2017 5:52 am
Posts: 30
Location: West Allis, WI
Bump.


Top
 Profile  
 
PostPosted: Thu Apr 27, 2017 8:55 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1868
Location: DIGDUG
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


Top
 Profile  
 
PostPosted: Thu Apr 27, 2017 11:01 pm 
Offline
User avatar

Joined: Mon Apr 24, 2017 5:52 am
Posts: 30
Location: West Allis, WI
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?


Top
 Profile  
 
PostPosted: Fri Apr 28, 2017 4:36 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19347
Location: NE Indiana, USA (NTSC)
Detect TV system then store the value it produces. If it doesn't appear to be correcting pitch correctly, debug it to see what value it is producing.


Top
 Profile  
 
PostPosted: Fri Apr 28, 2017 8:04 am 
Offline
User avatar

Joined: Mon Apr 24, 2017 5:52 am
Posts: 30
Location: West Allis, WI
I've gotten that to work, thank you!

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?

Code attached. walrush_music.asm and famitone2.asm are unchanged.


Attachments:
File comment: The .chr file (can't believe I forgot to upload this).
walrush.chr [8 KiB]
Downloaded 18 times
File comment: The .asm file.
walrush.asm [18.83 KiB]
Downloaded 22 times
Top
 Profile  
 
PostPosted: Fri Apr 28, 2017 8:28 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1868
Location: DIGDUG
Just post the .nes file. Don't make me have to try to assemble it with only half the source files.

A lot of debugging is stepping slowly through the code in a debugger, watching for things happening outside of v-blank (writes to PPU). Learn that. You will be doing it 100+ times during development.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Fri Apr 28, 2017 8:49 am 
Offline
User avatar

Joined: Mon Apr 24, 2017 5:52 am
Posts: 30
Location: West Allis, WI
Sorry, I'll upload the .nes file.

EDIT: Never mind, I was able to fix it myself through trial and error. Still, thanks!


Attachments:
File comment: Here it is.
walrush.nes [24.02 KiB]
Downloaded 23 times
Top
 Profile  
 
PostPosted: Fri Apr 28, 2017 10:25 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1868
Location: DIGDUG
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.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Fri Apr 28, 2017 11:04 am 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
PostPosted: Fri Apr 28, 2017 11:30 am 
Offline
User avatar

Joined: Mon Apr 24, 2017 5:52 am
Posts: 30
Location: West Allis, WI
dougeff wrote:
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 :P. 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)?


Attachments:
File comment: The .nes file.
walrush.nes [24.02 KiB]
Downloaded 19 times
File comment: The .asm file.
walrush.asm [18.95 KiB]
Downloaded 21 times
Top
 Profile  
 
PostPosted: Fri Apr 28, 2017 12:34 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1868
Location: DIGDUG
Quote:
What else, if anything, do I need to do?


Let's talk BIG PICTURE.

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.

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 8 guests


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group