Some useful tricks for game programming

All 680x0 related coding posts in this section please.

Moderators: simonsunnyboy, Mug UK, Zorro 2, exxos, Moderator Team

Re: Re:

Postby unseenmenace » Thu Nov 11, 2010 6:47 pm

TAD_uk wrote:
Gunstick wrote:also note that bresenham routine (that's what we are talking about here) for polygons or lines is also very useful to play modfiles. Maybe addx was first used for music players. That's where I first heard about it.


Thats where I used to use the ADDX trick to step through the sample at different rates.

Using 16.16 fixed point maths to store the position (offset.part = 32 bits) and step (integer.fraction = 32 bits) a 'normal' 16.16 fixed point add.l would be like this:

d0 = (offset.0) << 16 + (part)
d4 = (integer.0) << 16 + (fraction)

add.l d4, d0

but you'll need a swap to access the top 31..16 bits of d0 (the offset.0 value)

swap d0 ; swap offset <--> part
move.w d0, (a0)+ ; store the offset value
swap d0 ; restore d0 value

If you are careful you can also chain multiple ADDX together for more than 1 polygon edge OR sample voice step.

(example from my memory, so hopefully correct)

move.w d0-d3, (a0)+ ; store the integer offsets d0,d1,d2,d3
addx.l d4, d0
addx.l d5, d1
addx.l d6, d2
addx.l d7, d3

the set up of the d4 to d7 register use bits 31-16 as fractional step and bits 15-0 as the integer step BUT not in the normal way !!

If you set up your registers something like this:-

d0 = (part.1) << 16 + (offset.0)
d1 = (part.2) << 16 + (offset.1)
d2 = (part.3) << 16 + (offset.2)
d3 = (part.0) << 16 + (offset.3)


and STEP value like this:-

d4 = (fraction.1) << 16 + (integer.0)
d5 = (fraction.2) << 16 + (integer.1)
d6 = (fraction.3) << 16 + (integer.2)
d7 = (fraction.0) << 16 + (integer.3)

NOTE: The part.0 ... part.3 and fraction.0 ... 3 are 'out of sync' so one ADDX will increment both integer.X value as well as fraction.x+1 value.

Hope this all makes senses.

Cheers

TAD_uk


I have posted a new topic regarding the above: http://www.atari-forum.com/viewtopic.php?f=68&t=20168

If anyone can shed a bit more light on how this works I would be very grateful.
UNSEEN MENACE
Several STFM's, 4MB STE, 2MB TT with 1.2GB Hard Drive and 14MB Falcon with 540MB Hard Drive,
Lynx 2 and Jaguar with JagCD
Member of GamebaseST and AtariLegend team
Check out my website at http://unseenmenace.110mb.com
User avatar
unseenmenace
Atari God
Atari God
 
Posts: 1957
Joined: Tue Sep 21, 2004 9:33 pm
Location: Margate, Kent, UK

Re: Some useful tricks for game programming

Postby Altair » Fri May 27, 2011 1:08 am

Hello Illegal...

I did not expect to ear about you anymore, and well i end up there and see you are talking to mcoder,
lol what an unexpected discovery...

I actually have the same feeling for JC but now that i see you have kind of the same issue I start to think that what he told me what not just an excuse...
Seems like he just doesn't want to look back, I would like to be able not to look back myself either sometime but it's harder to do than to talk about it.

I ended up here, after one of these time googleing for "pascal de france"...
We last saw in 1998, in fact our last contact came through MIT, dunno if you remember him.

I was very stressed and under tremendous amount of pressure at that time, I was kind of hitting on everybody like some strange way of calling for help.

I learned later that Pascal died a few month later in that little castle close to Orleans,
that very same castle where I used to stay for a while when I was working at Chaman with Pascal.

I Remember that red room i was staying in, it was nice, we used to drink those two yellow and blue "abaye" liquors with pascal and few of his friends there.
I also remember watching mangas with Pascal as well as a video of his grand dad with The General de Gaule, Pascal was so proud showing it...
I remember his sister, we used to watch Starwars together with her young child, Pascal and his sister where big fans of Starwars.

"May the force be with you" was one of pascal's favorite sentences.

Pascal was an absolutely exceptional person, there are so much things I could tell about him, his mother's drawings,
his dreams about virtualizing himself into a computer for immortality, it was not just a joke, he was kinda serious about it.

Pascal was one of the most clever person I ever met and he also was a very sensible person.

I always felt responsible for his death to be honest.

But what does it matter now anyway...
Altair
Atarian
Atarian
 
Posts: 3
Joined: Fri May 27, 2011 12:48 am

Previous

Return to 680x0

Who is online

Users browsing this forum: CommonCrawl [Bot] and 0 guests