Page 2 of 8
Posted: Thu Jul 28, 2005 3:21 pm
by Celius
Yeah it looked more like the maze than it did before. At first it was just glitchy flashing screen type things happening, but I actually see it helped a bit, but not completely, if that makes any sense.
Posted: Thu Jul 28, 2005 3:36 pm
by beneficii
Celius wrote:Yeah it looked more like the maze than it did before. At first it was just glitchy flashing screen type things happening, but I actually see it helped a bit, but not completely, if that makes any sense.
What do you do on the NMI? Is your NMI turned on?
Posted: Thu Jul 28, 2005 3:46 pm
by Celius
yes my nmi is enabled via $2000. Here is my code:
Code: Select all
;ines crap
.zp
vbl_count:
.ds 1
;vector info
.dw nmi
.dw reset
.dw irq ;I'm not even going to bother showing you my irq routine
reset:
lda #0
sta vbl_count
lda #%10000000
sta $2000
lda #%00011110
sta $2001
;pallete stuff
main_loop:
jsr wait_vbl
lda #HIGH(sprites)
sta $4014
jsr handle_joypad
jsr makemaze
jmp main_loop
wait_vbl:
lda vbl_count
wait_vbl_change:
cmp vbl_count
beq wait_vbl_change
rts
nmi:
inc vbl_count
rti
;maze data
;handle joypad
;etc.
Is there something wrong with this? or is it just really unreliable.

By the way, alot of this stuff I didn't include, because I'm too lazy. There really are variables I used for sprite DMA, I just didn't include them in this code right above.
Posted: Thu Jul 28, 2005 4:01 pm
by beneficii
At the beginning of the NMI, try setting $2006 to $0000 like this:
Code: Select all
lda $2002
lda #$00
sta $2006
sta $2006
Essentially, on every NMI you'll want to set $2006 to the nametable you want to show minus $2000. Since you want to show the $2000 nametable, then you should put it as $0000. If you wanted to show the $2800 nametable, then $0800 would be your way. You can also start in the middle of a nametable, like at $2305, which would become $0305.
If you do any $2006/$2007 writes, then afterward you will still need to set $2006 to what I mentioned in the paragraph. In other words, when you leave the NMI, you're going to need to have $2006 set to that value.
Understand?
Try it out btw. Post the results. ^_^
Posted: Thu Jul 28, 2005 4:14 pm
by Celius
Whoa, you can do that? so I could say this:
lda $2002
lda #$00
sta $2006
lda #$01
sta $2006
to start at the second line of the name table? or just in the middle of the name table, or wherever it is. But I tried your suggestion, and it still only works on Jnes and (if you give an att's rass) Nesticle. Nintedulator goes phsyco, VirtuaNes is kind of working more, it displays the top 4 rows of the maze, and is doing something kind of like fuzz on the tv, except its like lines, going insane on some of the tiles. It's weird. Do you want to see my FULL code to see if I did something wrong?
Posted: Thu Jul 28, 2005 4:44 pm
by beneficii
Celius wrote:Whoa, you can do that? so I could say this:
lda $2002
lda #$00
sta $2006
lda #$01
sta $2006
to start at the second line of the name table? or just in the middle of the name table, or wherever it is. But I tried your suggestion, and it still only works on Jnes and (if you give an att's rass) Nesticle. Nintedulator goes phsyco, VirtuaNes is kind of working more, it displays the top 4 rows of the maze, and is doing something kind of like fuzz on the tv, except its like lines, going insane on some of the tiles. It's weird. Do you want to see my FULL code to see if I did something wrong?
Pretty much. I'm simplifying things a bit. (That example will have it start on the second pixel of the first line.)
Anyway, if you're program's still not working, then perhaps you can send me the source code along with the ROM and I'll see what's wrong. K?
Posted: Thu Jul 28, 2005 5:27 pm
by Disch
I must speak up against this advice.
For one -- setting the PPU address to $0001 (what you do in your example, Celius) will start rendering from the second
column not the second row. That basically has the same effect as scrolling the screen left 8 pixels.
For two -- this is
exactly what $2005 is for. Not only is it MUCH easier to use for this kind of thing, but it also allows you to fine-scroll horizontally and vertically (scroll by pixels instead of by full 8-pixel tiles)
Using $2006 for scrolling should only be done when you're splitting the screen -- and the only reason it's recommended then is because it's manditory.
To start drawing from the second row... use this code instead:
Code: Select all
BIT $2002 ; same effect as LDA $2002, but does not change A
LDA #$00
STA $2000 ; select nametable 0 (ppu$2000)
STA $2005 ; set X scroll to 0 pixels
LDA #$08
STA $2005 ; set Y scroll to 8 pixels (one row)
After you set scroll values, do NOT mess with $2006 (do the above code after you've finished all your drawing). And make sure rendering is on before VBlank ends (flip on $2001.4 or $2001.3 or both)
Posted: Thu Jul 28, 2005 5:53 pm
by beneficii
Disch wrote:I must speak up against this advice.
For one -- setting the PPU address to $0001 (what you do in your example, Celius) will start rendering from the second
column not the second row. That basically has the same effect as scrolling the screen left 8 pixels.
For two -- this is
exactly what $2005 is for. Not only is it MUCH easier to use for this kind of thing, but it also allows you to fine-scroll horizontally and vertically (scroll by pixels instead of by full 8-pixel tiles)
Using $2006 for scrolling should only be done when you're splitting the screen -- and the only reason it's recommended then is because it's manditory.
To start drawing from the second row... use this code instead:
Code: Select all
BIT $2002 ; same effect as LDA $2002, but does not change A
LDA #$00
STA $2000 ; select nametable 0 (ppu$2000)
STA $2005 ; set X scroll to 0 pixels
LDA #$08
STA $2005 ; set Y scroll to 8 pixels (one row)
After you set scroll values, do NOT mess with $2006 (do the above code after you've finished all your drawing). And make sure rendering is on before VBlank ends (flip on $2001.4 or $2001.3 or both)
Yeah, I should have said tile, which would have fit with column more. That's right Celius, things get much more complicated.
Then again, I'm not sure if Celius
was trying to scroll.
Disch, I never did recommend that he do $2006 like that, I was just trying to explain the effects (which I did wrongly).
Posted: Thu Jul 28, 2005 6:10 pm
by Celius
Yeah, I wasn't trying to scroll. I am so bad at scrolling, it's embarrasing. I don't know too much about scrolling, and I will save that for a later day. But yes, I will send you my source, and we'll see what we can do, okay? okay.

Posted: Thu Jul 28, 2005 6:16 pm
by beneficii
Celius wrote:Yeah, I wasn't trying to scroll. I am so bad at scrolling, it's embarrasing. I don't know too much about scrolling, and I will save that for a later day. But yes, I will send you my source, and we'll see what we can do, okay? okay.

It's not that difficult. Just read from $2002, then the first write to $2005 will be the horizontal scroll (in pixels, not tiles) and the second write to $2005 will be the vertical scroll (again, in pixels). Try it!
BTW, how will I be receiving the source?
Posted: Thu Jul 28, 2005 6:20 pm
by Celius
I will email it to you, and you can just give me your address in a private message if you don't want it to be seen. By the way, when it scrolls like this:
lda #$01
sta $2005
will it just scroll 1 pixel per vblank? Or what is the timing?
Posted: Thu Jul 28, 2005 6:31 pm
by beneficii
Celius wrote:I will email it to you, and you can just give me your address in a private message if you don't want it to be seen. By the way, when it scrolls like this:
lda #$01
sta $2005
will it just scroll 1 pixel per vblank? Or what is the timing?
No, it won't. It'll simply set the scroll to one pixel over to the right (if that's the horizontal scroll) and there it will remain until the value is changed. Remember what Disch said: You also have to set $2006 as well to your current nametable. If you want one scroll per vblank, try something like:
Code: Select all
nmi:
pha
lda $2002
lda #$00
sta $2006
sta $2006
inc <$30
lda $2002
lda <$30
sta $2005
lda #$00
sta $2005
pla
rti
Remember to have zero page address $30 starting off at zero!
Posted: Thu Jul 28, 2005 9:21 pm
by Quietust
beneficii wrote:You also have to set $2006 as well to your current nametable.
No you don't - when you want to set your current nametable for rendering, you write to $2000 and specify your desired nametable in the bottom 2 bits (do this along with the reading $2002 and writing $2005 stuff).
Posted: Thu Jul 28, 2005 9:53 pm
by Disch
Celius wrote:
lda #$01
sta $2005
will it just scroll 1 pixel per vblank? Or what is the timing?
Setting the scroll is setting where the screen starts drawing from. Here's a few diagrams which might explain. The diagrams represent the two upper nametables (PPU $2000 [upper-left] and $2400 [upper-right]). dots (.) represent the part of the nametables which is not visible. # represents the areas that are visible:
Code: Select all
##########..........
##########..........
##########..........
##########..........
##########..........
This represents scroll values of 0 (X=0, Y=0). The upper-left portion of the # block is where the screen starts drawing from.
Now say you change scroll values so that you scroll halfway through the nametable (X=$80) :
Code: Select all
.....##########.....
.....##########.....
.....##########.....
.....##########.....
.....##########.....
The game is drawing the same nametables, it's just starting to draw from a different area. In this case, it's drawing from further right in the nametable (which will make the screen appear to be moved left)
Now -- you should be setting scroll values
every frame -- and the value you write for that frame is where the screen draws from in that frame. There is no "rate" or anything -- it just draws from where you tell it to. If you want to game to appear to scroll in a direction, you will have to constantly change the values you write.
For example, in beneficii's example, every frame he is writing a NEW value to the X scroll. He has is so that the X scroll will be 1 more than it was last frame (making the screen scroll 1 pixel per frame).
Although beneficii is still writing to $2006 -- which you shouldn't do. For now, you should
only be using $2006 for drawing (with $2007). For scrolling, you use only $2000, and $2005 (and $2002 to clear the toggle -- but you should only have to do that once at the start of NMI)
Posted: Thu Jul 28, 2005 10:47 pm
by Celius
I think i understand scrolling now. I think I am going to make a couple programs for my current projects. I could design them, I just am not so good with programming opening files and saving files. Do you think it will be alright to make programs with C, and not C++? Because I only know C at the moment. I am not sure how to just jump right into hibber jibber, and ouput stuff on the screen. I don't know how to make a program open a .chr file and put the data on the screen! Is it really hard? Do you know where I could find out how to?