Jump to content



0

Probably a stupid question, but...


10 replies to this topic

#1 Ze_ro OFFLINE  

Ze_ro

    Quadrunner

  • 8,511 posts
  • Welcome Back!

Posted Wed May 5, 2004 5:28 PM

I've noticed that a lot of people seem to use the timers to wait out the vertical blank, do whatever processing they need to do, and then watch INTIM until the time is up... I was going to do this myself, since I've been having some issues with overrunning a scanline during some of my calculations causing things to occaisionally shift by a single line... but what happens if you do a "sta WSYNC" (ie, to do an HMOVE, or time your sprite positioning) in the middle of this wait? The timer isn't in the 6507, so I'm guessing that while it's halted, the timer still behaves normally... is this correct?

Even assuming that the timer behaves as expected, I'm guessing you still have to be careful, since this will still lead to some wasted cycles (Up to 79 or so) depending on where the beam is when you happen to perform the sta WSYNC (which may change if you insert some code before it)...

--Zero

#2 johnnywc OFFLINE  

johnnywc

    Dragonstomper

  • 874 posts
  • Location:Putnam, Connecticut

Posted Thu May 6, 2004 8:01 AM

My guess is that the timer still works as expected even when you do a STA WSYNC, meaning that the timer will still count down even when the mircoprocessor is halted.

As for doing STA WSYNC's during the vblank - I believe this is common. It's done most often when reseting the horizontal position of sprites (RESP0, RESP1, etc). The calculation for this is generally done after a STA WSYNC and a certain delay so that you can calculate exactly where on the scanline the beam is.

You are correct - it does waste machine cycles but sometimes it's unavoidable. Of course, you can place your STA WSYNC's as close to the end of the previous scanline to reduce the amount of wasted cycles.

Hope this helps!!!

#3 Ze_ro OFFLINE  

Ze_ro

    Quadrunner

  • 8,511 posts
  • Welcome Back!

Posted Thu May 6, 2004 7:28 PM

Damn, I wish I had more time on my hands... once I get this worked into my program, it'll be quite literally done... Oh well, it'll have to wait until this weekend. Thanks for the advice!

--Zero

#4 EricBall OFFLINE  

EricBall

    Dragonstomper

  • 711 posts
  • Location:Markham, Ontario, Canada

Posted Thu May 6, 2004 9:33 PM

STx WSYNC causes the TIA to hold the 6507 RDY active until the "start" of the next line. This causes the 6507 to halt processing. The timer is part of the RIOT chip (so named because it contains RAM, I/O and a Timer).

In my 2600 programs I often include a STA WSYNC in my INTIM test loop simply to make the Z26.log smaller! Just be careful that you calculate the TIM64T value correctly or INTIM will start counting the number of cycles since the timer expired!

#5 Cybergoth ONLINE  

Cybergoth

    Quadrunner

  • 8,207 posts
  • This is Sparta!
  • Location:Bavaria

Posted Fri May 7, 2004 3:15 AM

Hi there!

Ze_ro said:

since I've been having some issues with overrunning a scanline during some of my calculations causing things to occaisionally shift by a single line...

If you have no clue what causes the extra scanline, compare the Z26 log of a "good" frame with a "bad" frame.

If it appears to just "shiver" between 261/2 for example, try increasing either the VBLANK or the Overscan timer. Or if it's 262/3 try decreasing them. Just toy a bit with these values.

Reason: If the timer value is choosen "bad" so that the timer will end near the end of a scannline, you might just hit one of the two by random, since you have a 5 cycle wide "blind spot" in the timer checking loop.

Greetings,
Manuel

#6 Ze_ro OFFLINE  

Ze_ro

    Quadrunner

  • 8,511 posts
  • Welcome Back!

Posted Fri May 7, 2004 5:43 AM

Cybergoth said:

If it appears to just "shiver" between 261/2 for example, try increasing either the VBLANK or the Overscan timer. Or if it's 262/3 try decreasing them. Just toy a bit with these values.

Well, the way I have it working right now is that I initially had a loop that would just sta WSYNC 37 times... as I needed more processing done, I'd just decrease that, and use the extra scanline to do a specific task in. It always seemed like an ugly way to do things, but it worked.

Unfortunately, after adding a few things, I get a "shiver" between 262/263 every once in a while, and I can't for the life of me figure out what's causing it. My joystick handling routines seem quite long, but the shiver is happening even when the program isn't going through the joystick routines!

--Zero

#7 Cybergoth ONLINE  

Cybergoth

    Quadrunner

  • 8,207 posts
  • This is Sparta!
  • Location:Bavaria

Posted Fri May 7, 2004 6:34 AM

Hi there!

In this case: Switch to the timer. No other solution.

Greetings,
Manuel

#8 Thomas Jentzsch OFFLINE  

Thomas Jentzsch

    Thrust, Jammed, SWOOPS!

  • 16,745 posts
  • Always left from right here!
  • Location:Düsseldorf, Germany

Posted Fri May 7, 2004 7:20 AM

Cybergoth said:

In this case: Switch to the timer. No other solution.
And the better solution too. :)

#9 Ze_ro OFFLINE  

Ze_ro

    Quadrunner

  • 8,511 posts
  • Welcome Back!

Posted Sat May 8, 2004 4:25 PM

Aha, switched everything to the timer, and it now works perfectly. Now all I have left to do is test the game on a real system using my Supercharger...

--Zero

#10 johnnywc OFFLINE  

johnnywc

    Dragonstomper

  • 874 posts
  • Location:Putnam, Connecticut

Posted Sat May 8, 2004 7:11 PM

Ze_ro - what game are we talking about anyway? :?

#11 Ze_ro OFFLINE  

Ze_ro

    Quadrunner

  • 8,511 posts
  • Welcome Back!

Posted Sat May 8, 2004 9:32 PM

It's a Simon clone... I just announced it over in this thread if you're interested in trying it. It's not much, but it's my first attempt at anything at all really.

Wow, I ran into a bunch of weird problems when I went to run this through my Supercharger... for one thing, the sound had a whole host of issues (mostly due to fact that I was actually fiddling with the AUDxx registers in two seperate places, which could occaisionally lead to having two sounds happen in the same scanline. Stella only ended up playing the second one, but the actual Atari handled it a bit different. I also found a spot where I was doing an 'lda $0F' instead of 'lda #$0F' (which was then stored into COLUP0)... Strangely enough, every single time I ran my program with Stella, loading a value out of $0F always ended up giving me white, which was what I wanted... the Atari gave me different stuff entirely. The colors needed some tweaking too... getting good greens and yellows isn't easy.

--Zero




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users