Jump to content
Rybags

Another use for paddles - short duration timers

Recommended Posts

Well, not paddles really, but the POTx registers.

 

On the 8-bit, the paddles are read by storing to POTGO ($D20B) then waiting for POKEY to generate the value.

 

According to the HW manual, capacitor dump transistors charge, and return a value from 0 to 227.

 

This is useful to us, since whilst generating a POTx value, the registers count up from 0 at the rate of 1 per scanline (exactly). In Fast Scan mode, the scan takes 2 scanlines - which equates to 228 machine cycles.

 

So, instead of tight timing loops which are affected by DMA and Refresh we can set fast pot scan and just wait until POTx reaches the delay value required.

 

Or, in standard mode, we can get delays by x scanlines - which is more precise than ANTIC's VCOUNT as it only has 2 line resolution.

 

This method has distinct advantages over POKEY timers as they are more involved to setup and monitor, plus it costs you a sound channel. The other advantage is that you don't need wasteful delay loops - you just periodically check the counter value.

 

The downside, though, is that you can't have a paddle plugged into that port because the POTn register might not count as high as you want it to.

Although, on the XL/XE, POT4-7 are not connected so are free to use. On 400/800 you just have to trust the user not to have paddles plugged into Port 4.

 

Downside #2 is that Atari800Win doesn't seem to emulate fast scan mode at all - the countup is instant.

 

Here's an example using POT7 for speech timing. Binary load file - press START or SELECT once it loads. Note that it won't work properly on the emulator:

 

potdemo.zip (warning - contains profanities)

 

 

 

Below is a visual representation of POT7 value as the screen is drawn. The glitches towards the right are where the value changes. Note how it stops at value 227 (brownish colour).

By storing into POTGO at a specific time, the counter can be reset. In this case, it is the OS VBI routine. But, it is quite fine to store again at a time of your own chosing, which starts the countup process again.

 

post-7804-1150903963_thumb.jpg

Edited by Rybags

Share this post


Link to post
Share on other sites

Yes. Fast mode could be handy, all you need is

LDA # <delay factor in cycles>

STA $D20B

WAIT CMP $D20B

BCC WAIT

 

Much more efficient than POKETs timers.

 

I've played around with standard mode - not 100% sure but the change of value seems to take place around the same time each scanline regardless of when you do POTGO.

Share this post


Link to post
Share on other sites

That is seriously cool. What a versatile piece of hardware.

 

Stephen Anderson

Share this post


Link to post
Share on other sites

Awesome demonstration, Rybags!

 

Scared the crap out of me!

 

BTW, your demo runs reasonably well using Atari++ ver 1.46 (Windows) emulator. Just a slight bit of static but it could be my less than state-of-the-art PC.

 

 

- Steve Sheppard

Edited by a8isa1

Share this post


Link to post
Share on other sites

I think it's a great discovery, but I'm a long way from needing to use it. Possibly it goes over the head of most members of the forum.

Share this post


Link to post
Share on other sites

actually, any timing source I can get my hands on for game development makes perfect sense, and since this is perfectly timed to the horizontal colour clocks, it would be great for all sorts of things in a DLI. muaahahaha, why didn't I think of this? :-D especially, since upon reading the entry for POTGO in the Atari 400/800 hardware manual, it seems so @#($#@$(#@$#@ OBVIOUS!

 

-Thom

Share this post


Link to post
Share on other sites

Sadly none of the emulators seem to do fast mode at all. Although I tried it on Ver 1.45 (older) of Atari ++

 

The one big limitation other than that is the fact that if someone has a paddle plugged into the relevant port, then the technique is rendered useless - although that's only a problem on the 400/800.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...