Page 2 of 4

Posted: Wed Jul 26, 2006 8:15 pm
by tokumaru
Strange... and loopy's doc would seem to confirm that the writes to $2005 are enough. Look:
2000 write:
t:0000110000000000=d:00000011

2005 first write:
t:0000000000011111=d:11111000
x=d:00000111

2005 second write:
t:0000001111100000=d:11111000
t:0111000000000000=d:00000111

frame start (line 0) (if background and sprites are enabled):
v=t
The writes to $2005 plus the write to $2000 should be enough to set everything correctly, according to what happens when the frame starts. Unless loopy is wrong, but people have been using this document as some sort of bible for a while now...

Posted: Wed Jul 26, 2006 8:22 pm
by Memblers
frame start (line 0) (if background and sprites are enabled):
v=t
Ah, I guess I didn't consider that part. You're right. $2006 still does need to be reset sometime, though (just after writing $2007 would be fine then).

Posted: Wed Jul 26, 2006 8:24 pm
by Quietust
$2006 doesn't need to be reset if you write $2000 and $2005+$2005 (during VBLANK, of course), since it affects the same internal register.

Posted: Wed Jul 26, 2006 8:26 pm
by tepples
Game loop should look like this:

Code: Select all

while (1) {
  end of frame
  NMI
  turn off rendering in PPUMASK ($2001)
  write to VRAM using PPUADDR ($2006) and PPUDATA ($2007)
  set PPUCTRL ($2000) and PPUSCROLL ($2005)
  turn on rendering in PPUMASK
  start of frame
}
Make sure that the writes to PPUSCROLL and PPUCTRL happen after the last access to PPUADDR or PPUDATA.

Posted: Wed Jul 26, 2006 8:27 pm
by lynxsolaris
I forgot to set $2006 back to $0000 after drawing to the screen (as Memblers said). That corrected my issue. I decided to do the write right after the drawing and not in NMI so that I don't encounter any unforeseen (to me) issues with that write in the future.


EDIT: Also, as far as giving the delay between text goes, whats a good number of frames to wait before "typing" the next word?

Posted: Wed Jul 26, 2006 8:50 pm
by tepples
Depends. Human speech runs at roughly 120 to 140 words per minute, or 26 to 30 frames per word. A word is about four to five letters plus space, or roughly 5 frames per character.

Watch TV with captions to get some ideas.

Posted: Wed Jul 26, 2006 8:52 pm
by Memblers
lynxsolaris wrote: Also, as far as giving the delay between text goes, whats a good number of frames to wait before "typing" the next word?
You should experiment and find out. I guess it depends on dramatic effect, length, or whatever. You can estimate it by knowing that 60 frames is one second. Just don't do it like Ikari Warriors 2, heheh. That had to be the slowest intro ever.

If it helps any (when you need the same number in multiple places, it sure does), you can do stuff like this:

Code: Select all

delay_time = 15

..
 ldx #delay_time

Posted: Wed Jul 26, 2006 8:54 pm
by tepples
Or if you're making an RPG or another game with a metric backsideload of text, put in user-selectable delay as in Actraiser for Super NES.

Posted: Wed Jul 26, 2006 9:04 pm
by tokumaru
lynxsolaris wrote:I forgot to set $2006 back to $0000 after drawing to the screen (as Memblers said). That corrected my issue.
Let me just ask you one more thing about this: were you using $2006 after you wrote 0's to $2005? The writes to $2005 (and to $2000) should be enough to keep the screen in the correct place, as long as you do them after you're done with $2006. I just wanna get this right... something is weird...

Posted: Thu Jul 27, 2006 3:49 am
by Bregalad
I usually write to $2000 last, after set two $2005 writes. Normally it wouldn't change anything if you do it the other way arround, but normally $2006 shouldn't be used in VBlank to set the scrolling, but only outside of VBlank, because all vertical scroll $2005 writes will be ignored, allowing you to scroll only horizontally.

As for text speed, I recommand it between 2 letters per frame and one letter for 3 frames, wich is the slowest you'd want to agrue. I hate too slow text !! I prefer when the text goes too fast, but let the user wait and press the 'A' button to say if he's finished reading. If you want an intro that doesn't need player's intevention, go for upload one letter each 2 frames or 3 frames. That should be slow enough for slow readers, but supportable for fast reader.

I now remember a game that have an awfully slow text intro : Final Fantasy Legend 3 for the Game Boy. Just Breed's intro was also a bit annoying I found.

Posted: Sun Jul 30, 2006 3:37 pm
by lynxsolaris
Ok I'm having a problem getting my text delays to work properly. This is what I did:

Code: Select all

wait_again:
 lda text_flag
 cmp #$99
 bne wait_again
..

nmi:
..
inc text_flag
..
My wait_again label is in between text prints. It displays both(all i have right now) characters @ once. Also, I'm doing all my text displays in my name tables and not from OAM. Is that okay? Or do I just have this whole thing screwed up??

Thanks again!

Posted: Sun Jul 30, 2006 5:49 pm
by Memblers
The code snippet doesn't show enough to tell anything. I don't see it resetting the frame counter, or the VRAM buffering and writing.

It looks like you're making it get stuck in that loop. That's OK though if it has nothing to do besides wait, but normally I would branch past the "=99 frames" code so other stuff can be put in the loop if needed.

Writing to the background rather than using OAM is the natural thing to do. OAM would be easy to use though if you only want 8 chars per line (really limiting for text).

Posted: Sun Jul 30, 2006 6:48 pm
by lynxsolaris
Memblers wrote:The code snippet doesn't show enough to tell anything. I don't see it resetting the frame counter, or the VRAM buffering and writing.
Sorry. Here is more of the code:

Code: Select all


 .zp
text_flag = $00
 
...
 
reset: 
 sei
 cld
 
...
 
 ldx #$ff
 txs
 inx
 stx $2000
 stx $2001
 stx text_flag
 
 jsr wait_vblank
 jsr wait_vblank
 
 ;load color palette first
 lda #$3F
 sta $2006
 lda #$00
 sta $2006
 
 ldx #$00
loop_pal:
 lda color_pal,X
 sta $2007
 inx
 cpx #$10
 bne loop_pal
 
 
 ; set the VRAM address 
 lda #$20
 sta $2006
 lda #$84
 sta $2006
 
 
 ; text demo will display "A(0B) B(0C)"

 
 lda #$0B
 sta $2007
 
 lda #$00
 sta $2006
 sta $2006
 
 lda #%00001000
 sta $2000
 lda #%00011000
 sta $2001

wait_again:
 lda text_flag
 cmp #$99
 bne wait_again
 lda #$00
 sta text_flag 
 
  
 lda #$00
 sta $2000
 sta $2001



 lda #$20
 sta $2006
 lda #$85
 sta $2006
 
 lda #$0C
 sta $2007
 
 lda #$00
 sta $2006
 sta $2006
 

 
 lda #%00001000
 sta $2000
 lda #%00011000
 sta $2001
 
 text_end:
  jmp text_end
 
wait_vblank:
 bit $2002
 bpl wait_vblank
 rts
 
 color_pal:
  .db $0D,$30,$22,$16,$0D,$00,$10,$30,$0D,$00,$16,$30,$0D,$3C,$1B,$09
 
 nmi:
  lda #%10001000
  sta $2000
  inc text_flag
...

With this code, A displays but B never does....

Thanks for the help.

[/code]

Posted: Sun Jul 30, 2006 9:41 pm
by Memblers
Looks to me like the NMI code will never run. The only place it gets enabled is.. inside the NMI routine itself.

Posted: Mon Jul 31, 2006 11:20 am
by lynxsolaris
Memblers wrote:Looks to me like the NMI code will never run. The only place it gets enabled is.. inside the NMI routine itself.
When I enable NMI the "A" just flashes and "B" never appears.