Page 1 of 4

intro storyline

Posted: Mon Jul 24, 2006 4:50 pm
by lynxsolaris
I was wondering if you guys could give me some direction on updating name tables for the storyline that I want to be seen before the main title screen of the game is displayed. Can I populate the name table, wait for the user to press A (once they've read the information), turn off the PPU, update the name table with the new information, wait for the player to press A, etc,etc. Is that doable and a proper way of updating the name table? What do you guys suggest.

Thanks.

Posted: Mon Jul 24, 2006 5:43 pm
by Memblers
Personally I think the best way is when it runs on it's own, but the player can press A to skip the delays.

The way you want to do it sounds fine. I would add "wait for vblank" in there.

if user presses A:
wait for vblank
disable PPU
draw screen
wait for vblank
enable PPU

If you don't wait before turning it on, the screen will jump.

It's also kinda fun to have delays between writing the characters of the text.. I did that in an unreleased thing and it was pretty cool. I made a little table of subtly varying delays it goes through, so it looks kinda like someone is typing it. heheh

Posted: Mon Jul 24, 2006 8:24 pm
by tokumaru
Fade-ins and fade-outs would be nice too... Combined with progressive drawing of the screen (something like Memblers said) it'll look damn good. You could, for example, fade-in each line of text at a time, from top to bottom (if it's just text). Then fade-out everything at once so you can fade-in the next screen the same way.

Posted: Tue Jul 25, 2006 8:16 pm
by lynxsolaris
Memblers wrote: If you don't wait before turning it on, the screen will jump.
When I wait for vblank before turning the screen back on the main window of nintendulator doesn't show my background. However, the name table screen, palette, and pattern tables all hold the correct information. Here is what I have ... probably did something stupid...

Code: Select all


  lda #$21
  sta $2006
  lda #$40
  sta $2006
  
  
  ldx #$00
 scene_one_loop:
  lda scene_one_data, X
  sta $2007
  inx
  cpx #$0A
  bne scene_one_loop
 jsr wait_for_vblank
 lda #%10001100
 sta $2000	
 lda #%00011010
 sta $2001	


....

 wait_for_vblank:
  lda nmihit
  beq wait_for_vblank
  lda #$00
  sta nmihit
  rts

....

nmi:
 lda #%10001100
 sta $2000	
 lda #$01
 sta nmihit
 lda #$00
 sta $2005
 sta $2005

It's also kinda fun to have delays between writing the characters of the text.. I did that in an unreleased thing and it was pretty cool. I made a little table of subtly varying delays it goes through, so it looks kinda like someone is typing it. heheh
Are you just counting frames for your delays between text?

tokumaru wrote: Fade-ins and fade-outs would be nice too... Combined with progressive drawing of the screen (something like Memblers said) it'll look damn good. You could, for example, fade-in each line of text at a time, from top to bottom (if it's just text). Then fade-out everything at once so you can fade-in the next screen the same way.
Yeah fade-ins and fade-outs do sound really cool. I'm not sure where to start especially since I can't get my darn background to display properly :)

Posted: Tue Jul 25, 2006 9:01 pm
by tokumaru
I don't think you should wait for VBlank and use NMI's. Maybe you should use the good old "wait for VBlank" in the intro, and use NMI's in the game itself. Of course you could use the NMI for everything, just jump to the desired routine (depending on what part of the game you are - title screen, intro, in game) in the begining of it (you can use a jump table for that).

As for the fade-ins and outs, I think you can mess with the high digit of each color. When the high digit is at it's maximum allowed value (3), colors are very bright, and when it's 0, the colors are very dark. For a fade-in from black, right after the black screen you can set the palette with the desired hues, but all with low brightness (high digit 0). Then, every few frames (or it'll be too fast, the NES does not have many colors), you increase the brightness of the colors until you reach the desired brightness of each one. Of course, some colors will get there first (the darkest ones), but I don't think that'll ruin the effect.

Posted: Wed Jul 26, 2006 5:08 am
by Disch
tokumaru wrote:I don't think you should wait for VBlank and use NMI's.
It looks like he's doing it the right way (that is, he's not polling $2002). He's just waiting for an NMI to trip and set his flag in RAM -- nothing wrong with that.

Posted: Wed Jul 26, 2006 7:30 am
by lynxsolaris
Disch wrote: It looks like he's doing it the right way (that is, he's not polling $2002). He's just waiting for an NMI to trip and set his flag in RAM -- nothing wrong with that.
I only polled $2002 @ startup (polled, cleared OAM, polled). Everything else after I used the flag in RAM.

Posted: Wed Jul 26, 2006 4:30 pm
by tokumaru
Oh, yeah, sorry, I missed that. Yes, this is a perfectly valid way to wait for Vblank.

This is what I get from taking a quick scan over the code! Sorry lynxsolaris, you got it right. Have you found what the problem is yet?

Posted: Wed Jul 26, 2006 6:49 pm
by lynxsolaris
tokumaru wrote:Oh, yeah, sorry, I missed that. Yes, this is a perfectly valid way to wait for Vblank.

This is what I get from taking a quick scan over the code! Sorry lynxsolaris, you got it right. Have you found what the problem is yet?

Yes I did. Thanks for asking. However, using the code I posted above, my tiles show up @ the top of the screen (instead of $2140 which is where I'm setting my name table to). It acts as if I'm setting the NT to $2000. The funny thing is in nintendulator's name table viewer shows the tiles show up in the right position. Just not in the actual execution window. It's probably something I'm overlooking ... just good to have another pair of eyes to see it.

Thanks.

Posted: Wed Jul 26, 2006 7:38 pm
by Memblers
lynxsolaris wrote: Are you just counting frames for your delays between text?
Yep.
Yes I did. Thanks for asking. However, using the code I posted above, my tiles show up @ the top of the screen (instead of $2140 which is where I'm setting my name table to).
You need to reset the $2006 register after writing also. Set it to $0000 or $2000. Usually I do that in the NMI code, but then you need to be careful when doing VRAM updates outside of the NMI routine (disable NMI first, or have that part of NMI skipped, so it doesn't interrupt your writing).

Otherwise it draws the background starting at whatever address $2006 was left at.

Posted: Wed Jul 26, 2006 7:50 pm
by tokumaru
Memblers wrote:You need to reset the $2006 register after writing also. Set it to $0000 or $2000.
Isn't setting $2005 correctly (as he does in the NMI routine) enough?

Posted: Wed Jul 26, 2006 7:55 pm
by tepples
Setting PPUSCROLL ($2005) and PPUCTRL ($2000) is enough, but you need to do it after drawing, at the end of your vblank code, just before you turn rendering back on in PPUMASK ($2001). Don't do it in your NMI handler unless your NMI handler is handling all the drawing.

Posted: Wed Jul 26, 2006 8:00 pm
by Memblers
tokumaru wrote:
Memblers wrote:You need to reset the $2006 register after writing also. Set it to $0000 or $2000.
Isn't setting $2005 correctly (as he does in the NMI routine) enough?
Nope. IIRC, the vertical scroll value doesn't take effect until the 2nd $2006 write.

In programs that change vertical scrolling mid-screen you'll see writes like this (ignoring loads):

Code: Select all

 sta $2006
 sta $2005
 sta $2005
 sta $2006

Posted: Wed Jul 26, 2006 8:04 pm
by tokumaru
Yes, midscreen. I was absolute sure that during VBlank, the 2 writes to $2005 would do the job. I'm not saying they do, but I really thought they did.

Posted: Wed Jul 26, 2006 8:07 pm
by Memblers
I always thought so also, until I did the mid-screen stuff later. But I guess since I always had writes to $2006 in my NMI, I wouldn't have noticed it (or emulators back then would've displayed wrongly).