It is currently Sun Dec 10, 2017 11:03 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 60 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject:
PostPosted: Wed Nov 16, 2005 9:53 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2142
Location: Minneapolis, Minnesota, United States
Okay! it sort of worked! It's kind of cool, here, see for yourself at my site. It's "hello2.zip". By the way, what do you think of my site? Anyways, I noticed some really bad bugs where it will all of the sudden just stop when the Sprite 0 hit flag is set. This is good! I'm actually learning many things that I have just been having so much trouble with on NES! Like, before, I never used $2002 ever. I was just like "Screw this, just say LDA+CMP+BEQ for everything!" Here's my response to myself saying that "Your a dumbass!" no, I didn't know, so it's okay. But see what you think could be fixed, and see if you can spot that bug! You probably will, when the screen stops moving, and you can't move your player, haha. But I was wondering, do you have to use sprite 0 hits for everything like this? Now I'm really wondering how the hell Cosmic Epsilon and the 3D battles of the World Runner pulled this off... Thanks again! 8)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 12:45 am 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
Celius wrote:
and see if you can spot that bug!


They both seemed to work fine for me.

Quote:
But I was wondering, do you have to use sprite 0 hits for everything like this? Now I'm really wondering how the hell Cosmic Epsilon and the 3D battles of the World Runner pulled this off... Thanks again! 8)


Well like I said it's a lot easier with mapper IRQs. Although games like Rad Racer just count the cycles and change the scroll every scanline (every 113.6667 CPU cycles).

If you wanted to split the screen twice with just sprite 0 hit -- you could watch for sprite-0 once.. change the scroll, then have the CPU loop for 3410 cycles (30 scanlines), then change the scroll again to split the screen again.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 3:08 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2142
Location: Minneapolis, Minnesota, United States
Okay, how could I count CPU cycles? Sorry for all the questions, I'm trying to figure things out on my own, but I need to know this...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 3:30 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
To give the link again:

http://www.obelisk.demon.co.uk/6502/reference.html

Each instruction takes a certain number of cycles to complete. You can make a bunch of instructions which don't really do anything other than "waste time".. but you have them waste just the right amount of time (however many cycles you want to wait).

For example, the following code will wait for exactly 3 scanlines (counts 341 cycles):

Code:
  ldx #$43   ;2 cycles

  ; each time this loop repeats, it takes 5 cycles.
  ; it will repeat $42 times ($42*5 = 330 cycles)
  ; plus it will dex one more time and not take the branch (+4 more cycles)

: dex
  bne :-

  ;2 + 330 + 4 = 336 cycles so far

  ldx $00  ; +3 = 339
  nop      ; +2 = 341

  ; here is exactly 341 cycles after the start of this code
  ; (exactly 3 scanlines)


Note that if that bne crosses a 256-byte page boundary (like say it goes from $8101 to $80FE), this timing will be off, since the branch will use up an extra cycle every time that loop continues. So use caution when using branches in timed code.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 6:03 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2142
Location: Minneapolis, Minnesota, United States
Oh! Sorry, I forgot about that! Oops! I made yet another cool demo! It's kind of an inacurrate demo. It's just the NMI routine fighting with itself. I say restore scroll at the beggining of the NMI, then I tell it to load <30 into horizontal scroll, then I increment <30. What happens is, the hello world text splits into two "Hello World" text things, and one scrolls horizontal, when the other scrolls verticly! Weird! But yeah, check it out on my site, if you want. Okay, my other demo, with the sprite 0 hit checks, in Nintendulator, if you dink around near the upper W in the hello world strings, it will eventually say "Bad opcode, CPU blocked." But FCEUXD ultra just freezes, because it doesn't really have error messages. I was also wondering how I should set my scroll after waiting for the CPU cycles. And I'm doing this in my NMI, correct? Yeah, I'm pretty sure, because doing it not in your NMI, or in vblank is a bad idea, and is not good at all! It scrolls 114 pixles per second, if you do it that way. But I need to figure this out. I don't think I need to bit test $2002 in any way if I'm doing it in my NMI, and I'm not using sprite hits. I know how to wait CPU cycles, so should I just wait, then set scroll, then wait, then set scroll if I want to have multiple scrolls on the Name Table? and should I be doing this in my NMI? I'm sure I am, but just making sure. Thanks. 8)

P.S. Do you like my site? Just wondering.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 6:37 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
Quote:
Okay, my other demo, with the sprite 0 hit checks, in Nintendulator, if you dink around near the upper W in the hello world strings, it will eventually say "Bad opcode, CPU blocked."


Hrm, yeah that's bad. You must be jumping to garbage code or something somewhere.

Quote:
And I'm doing this in my NMI, correct?


You definatly won't be splitting the screen when in VBlank if that's what you mean --- since if you're in VBlank you're not really splitting the screen, you're just setting the scroll =P.

But anyway .. where in your code you do it doesn't matter. It's WHEN you do it that matters. Whatever routine you decide to put this in will work.. as long as you change the scroll at the right time in the frame.

The PPU and CPU run side by side. While the PPU is drawing, the CPU can still do things which change how the screen gets displayed. From the time that an NMI is raised... you have about 2387 CPU cycles until actual pixel rendering starts (20 scanlines of VBlank + 1 prerender scanline -- see my previous diagram of the frame layout). After those 2387 cycles have passed, every 113.6667 cycles that pass is another scanline that has rendered to the screen. To split the screen.. all you need to do is time your scroll writes so that they lie between the scanlines you want to split.

I think you're best bet is to tinker around with more demos until you get a better understanding. I've done about all the explaining I can =).

Quote:
P.S. Do you like my site? Just wondering.


*shrugs* it's a site. Don't know what else to say about it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 8:41 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2142
Location: Minneapolis, Minnesota, United States
Okay, sorry, I'm just having a little bit of trouble, but I've created yet another demo. I realized my other one sucked, it was just increasing the scroll, storing the value in $2005. And I was wondering, how is it going up and over? Oh, wait. I was never storing #$00 in the vertical scroll! So it would just put the value in horizontal scroll, then in verticle, because it was reading it as a second write to $2005, which made it scroll verticly. But I made a firewave type demo! It's really good this time, I promise. It waits 114 cycles (due to know fractions in 6502), and after it waits 114 cycles, it increases the scroll value, then waits 114 more, and decreases the scroll value, creating a firewave! See at my site. I realized that other demo was REALLY DUMB. So I took it off. But I was wondering like how I could do parrallax with such a thing. I would have to do this in my endless loop, but it would scroll very fast! I'm sort of figuring things out as I go in this post. So check out my firewave demo on my site, it's in place of my crappy demo. But yes, how would I increase the scroll slowly, instead of at 114 pixels per vblank? I don't know how! Do you know? It's hard to explain. Any suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 8:54 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
Celius wrote:
It waits 114 cycles (due to know fractions in 6502), and after it waits 114 cycles, it increases the scroll value, then waits 114 more, and decreases the scroll value,


Just to clarify... if it was 114, I would've said 114 -- but it's actually 113.66667 ;P

You can simulate this by waiting 114, 114, 113, 114, 114, 113, etc instead of 114 every time. You could probably get away with 114... but you'll get further and further away from your desired time the further in the frame you get (you could even end up a whole scanline or two off from where you meant to be)

Quote:
But yes, how would I increase the scroll slowly, instead of at 114 pixels per vblank? I don't know how! Do you know? It's hard to explain. Any suggestions?


Erm... I don't know what you mean. If you don't want it to scroll so fast... then don't make it scroll so fast. =P And 114 pixels per vblank? I don't know what you're talking about there.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 11:39 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2142
Location: Minneapolis, Minnesota, United States
Sorry, I was kind of doing something when writing that post, and I wasn't very clear at all. Okay, if you increase something in an endless loop, it will increase from #$00 to #$72 by the time NMI is excecuted. Okay, nevermind about that. If you scroll in your endless loop, and not in vblank, it will scroll at unnecisarrily fast rates! and I'm not sure how to slow it down. Any ideas? I know you can't do it durning vblank, because it won't have the same effect, it will just shake the screen, it won't be scrolling at different rates. Yeah, I have to go now. I may make more sense, I may not, I'm not sure. Thanks. 8)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 12:27 am 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
Quote:
Okay, if you increase something in an endless loop, it will increase from #$00 to #$72 by the time NMI is excecuted


Erm... not necessarily. It depends how much CPU time is left until the next VBlank.

You should regulate the speed of your program flow by using the framerate. No matter how much work your program is doing... frames will always happen at a constant rate (one frame every 1/60th of a second) -- so you can use them to manage how much work your game does.

The wait-for-next-vblank loop should probably never do ANYTHING but wait for the next vblank. All motion/logic is usually driven by the framerate.

If you want to scroll 60 pixels per second... just change the scroll every frame. If you want 30 pixels per second, do it every other frame. For 120 pixels per second... scroll 2 pixels every frame. Etc.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 4:05 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2142
Location: Minneapolis, Minnesota, United States
Okay, I'm sorry, I'm really trying to understand, I'm just stuck, and I appreciate your help. I don't understand how you can wait for say 16 scanlines, and then scroll those scanlines 1 pixel per vblank! Because waiting for 16 scanlines is definitely not a long wait compared to waiting for vblank. and by the time 16 scanlines have gone by, you need to increment the scroll! and if vblank is not ready by the time 16 scanlines have gone by (which is the case), it won't work. It will increment the scroll of the whole name table, as apossed to seperate scanlines. Yesterday, my mother came home from las vegas, I was helping my brother with something, I was kind of preoccupied, and I needed to finish posting, and I ended up not making sense, and I'm sorry. But do you have any suggestions about doing that? thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 6:39 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
Let me introduce you to a wonderful programming concept called "variables"

Variables are these little containers which will hold any number you want, for a long as you want. You can use these variables to store any kind of information you want.. so that you can use the information at a later time.

How can variables help you?

Rather than trying to figure out the scroll as it's time to scroll... figure out what all scroll values you want in VBlank, and write those scroll values to a variable. When it comes time to actually change the scroll, simply load your variable.

For an example:

Code:

; define a variable to hold the scroll for the bottom of the screen
  botscroll = $80  ;to be placed at $0080 in RAM

; infinite wait loop -- wait for next NMI
loopforever:
  JMP loopforever

; routine called on NMI
nmi_routine:
  JSR do_sprite_dma

  BIT $2002  ; clear ppu write toggle

  LDA #0
  STA $2006
  STA $2006  ; clear PPU address (clear scroll)

  JSR turn_on_screen_and_enable_nmis

  ; increase our desired scroll by 1 pixel (one pixel per frame)
  INC botscroll

  ; wait for sprite 0 hit
: BIT $2002
  BVS :-
: BIT $2002
  BVC :-

  ; sprite 0 is hit -- change the horizontal scroll
  LDA botscroll
  STA $2005

  RTI  ; exit NMI routine (return to infinite loop)



If you're still working on basic programming fundamentals such as this -- then I'd suggest staying away from more complicated things like splitting the screen until you're more familiar with the system. Make some simple games... like a tetris clone or something. That'll get you familiar with most of the things you'll need to know for programming.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 7:03 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2142
Location: Minneapolis, Minnesota, United States
...-_-.... I can't believe I never thought of that. WHY!? THAT is dumb! Thank you! But I can't believe i didn't think of that! -_-... No, that is really really dumb that I didn't think of that! But trust me, I know what variables are, and I know how to use them. My game on the 2005 minigame compo: The game, and on my site, is pretty much made out of variables. Not a very good thing, because I used pretty much nothing but variables, and that's not very good. I know where I stand in my knowledge of the 6502, thank you very much. I made a good split scroll that works, thank you for your help! I remember in June when I was like following the Gba guy's tutorials, and I was just like "Oh, I understand NES programming". Yeah, um, you learn about .001% of all NES programming aspects there, and that is don't follow his tutorials, haha. And you were explaining scrolling to me, just regular scrolling, and I would copy and paste it into my code, and be like "it doesn't work". And I knew like 2 instructions: LDA, STA. But yes, I actually understand now. I do understand. I'm not lying. I don't have the greatest level of common sense, and I need things to be explained very well to me, as you've noticed. But I'm slowly getting the hang of things. If someone asked me to make a demo for them about something, I would probably be able to. Well, thanks for your help. I really appreciate it! I'll create something really cool and put it on my site! Thanks! :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 19, 2005 2:23 pm 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
Celius, sometimes I get the impression that you'll do what looks cool on the screen, without actually knowing what you did. When I read your posts, I do understand: "I was trying to do xxxx, but then effect yyyy showd up, and it looked so weird and cool, so I'll leave it like this!"

You have to understand what every piece of code in your games/demos does, our you'll be in trouble sooner or later. NEVER copy and paste code to see what happens. Read the code until you do understand what it is supposed to do, see if it fits to your needs, and code your own version of the stuff. Code posted here is for example, not for direct copy and use.

If you leave stuff in your code just because it "seems" to work, you'll surelly have a lot of trouble when trying to run your stuff on real hardware.

I know you refuse to listen to us and work on simpler projects, but you are not ready for a Final Fantasy remake or something like this, yet. Someday you probably will be, since you are very interested and you practice a lot, ask a lot of questions and such. These are great qualities for a person who is learning about game programming, but please, consider less complicated things for now.

You probably won't listen, again, but at least try to understand EVERYTHING you're doing when programming. Don't do stuff just because it seems to work, ok?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 20, 2005 12:04 am 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2142
Location: Minneapolis, Minnesota, United States
This is the way things were a while ago. I was making a reference to when I first started NESdev, I don't copy/paste code anymore. I try to understand most of what is posted. Dang it, we talk about this in every dang forum I make! I know alot more than I did awhile ago. And I post "I did xxxx, and yyyy happend! Weird!" then I go and try and find out what happened, I don't just leave it like that. And I know what I'm doing alot more than you think, but I probably know what I'm doing a lot less than I think. Can we not mention this anymore? I really hate talking about this in every forum I post in/make! I understand what you're trying to tell me: Slow down, don't try to make complex games yet. I wasn't planning on starting the real game of FFVII yet, I was going to make a tech demo of the first sequence. I'd really appreciate a little more faith in me than I get. I'm sorry, it just puts me down, and makes me feel like I'm never going to be able to make a good game, I'll be making pacman for the rest of my life. No more talking about this. We're done. I got the message. Sorry, don't mean to be an ass.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google Adsense [Bot] and 12 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