Some useful tricks for game programming

All 680x0 related coding posts in this section please.

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

Postby fredfm » Sat Nov 10, 2007 1:20 am

mcoder wrote:Hi Arnaud !

leonard wrote:Btw technically speaking Equinox's routs were faster almost at the same period (2 or 4bitplan routines)


Well, let's describe the chronology:

1. somewhere in 1989-1990: an Amiga group released the first 3D demo in 50 fps (I'm not sure which group, maybe SpreadPoint)
2. a few weeks later, I got this demo, and fell instantly in love with it
3. as usual, I tried to convert it to the ST, and I discover that the Amiga version uses blitter filling :?
4. I started then to write code to display a 3D cube on my ST, but the cube was quite small after a few weeks
5. I realized then that I needed new ideas, and thus I recruit Ziggy and Algernon, with the goal of writing a 3D game (thus no precomputation)
6. a few months later, we integrate Zarathustra, but due to a leaked 16 colors demo (I guess with the Brainstorm group, who were writing the official demo for Atari), he's kicked out of our group :(
7. several weeks later, we give a demo (my version) to Illegal, so he could show it at a party in England, and I got a greeting from The Lost Boys, who saw our preview.
8. meanwhile, Ziggy writes a sphere and ellipse routine, in a few days (!)
9. later, we heard that Equinox got the demo (Illegal was their good friend)
10. after that, there were rumors that TCB would release a 3D demo, so we started to code as crazies to release this screen (we worked 1 year and a half on it, and didn't want to lose the first posting place !)
11. the screen is released in the European Demos, and we can start to breathe, we were the first ! I guess the screen was pretty much a shock for both ST and Amiga users, due to the amount of work we spent.
12. although we concentrated on the 16 colors routines, nothing is released with that, and our game is cancelled.
13. a few months later, Equinox released their screen, so I rewrote my plane filler (unreleased version, but Mr Bee got all my sources and I hope he released some screens), and I quit the demo-scene. Ziggy released the fullscreen 3D demo timer.
14. TCB released their 3D demos several months later, but I don't remember the screen, it may not have been very impressive
15. Algernon worked more and more on the 3D, and coded Darkstone for Delphine, which is the only game I played from them !

So, you see that we had to urge to release this demo, since there were so many leaks.
As our main goal was to ultimately write a game, we didn't even think about delta-animation, neither logs instead of muls.

So, yes, if another group would have released a 3D screen, we would have easily improved the routines !

leonard wrote:And last but nor least, to me the best 3d technical demo is the 3d screen by Rapido (Synergy). Very impressive, especially the last part (3d dots) which use a very, very fast real time 3d transform!


Yes, I saw that right now.
It's a nice demo, but a little bit long (and yes, their display routines are very fast).
It should have been impressive at that time, but now, it's quite outdated.

JC


Hi JC,

I was from the Future Minds group, I remember meeting you at the TB2 coding party. I'm happy to see the ST is not dead... That night you "crashed" my screen with your machine (labelled '2060ST' IIRC) thinking your shifter was messing up my syncscroller. The truth was that I used to add stabilization code at the beginning of the scan line, and not at the end as I should have done. Vincent pushed for my screen to end up in Disk 1, that was cool... ;-)

Your 3D was simply awesome, are you still seeing Vincent BTW?

The only thing a little bit unethical with the 3D screens at the time was the fact you guys were fiddling with 8 screens to buffer up processor time to handle the case where you had 3 faces visible on the screen for the cube, as this didn't "fit" in 1 single VBL otherwise. I myself used to work hard on 3D routines and decided to call Vincent one night to ask him how he did to display this whole darn cube on the screen!

Other great tricks were Illegal's synchronized-trace protection, S. was a really cool guy, feel free to forward him my email if you're still in touch with him (not sure if email is publicly visible on this forum).
Also, I heard something went horribly wrong with Pascal, is that true?

Another great but less known trick was used in Chaos' World of Commodore'92 on the Amiga with an adaptation of the giant bit-bend zooming scroller on the ST, where Chaos used EOR.L to simulate the blitter "vertically" and filling an arbitrary one-plane surface covering the whole screen in 50 fps, regardless of its complexity! (by using EOR.L vertically, over the 4th bitplane and 1st bitplane of the next 16 pixels, thus handling 32 pixels with 1 instruction iterating over the entire height of the screen to fill up any arbitrary area).

What a great time we all had.
fredfm
Atarian
Atarian
 
Posts: 3
Joined: Sat Nov 10, 2007 12:55 am
Location: Redmond, WA (USA)

Postby leonard » Sat Nov 10, 2007 2:21 pm

The only thing a little bit unethical with the 3D screens at the time was the fact you guys were fiddling with 8 screens to buffer up processor time to handle the case where you had 3 faces visible on the screen for the cube, as this didn't "fit" in 1 single VBL otherwise.


Yes great technique, we used it too when seeing so much screens in memory :-)

But it requires a *lot* of memory, that's why I prefer the Equinox method. First because it's much more elegant, and second because it's close to the now famous "multi-threading" :-) Equinox draw their objects in 2 bitplans only, and use MOVEM.L to clear the screen (only clearing 16Kb instead of 32). In the same time, they compute all mathematics (vertex transform and rasterizzer settings) in the main thread, while the VBL thread only display polygons. If we refer to the mythic "blue cube", Equinox routine in Vodka demo is better than Megatridi.
Of course it's no use to say MegaTridi was a fantastic part of code, and everybody fall down on the ass when seeing it!

Last but not least the "biggest" cube in real time is the one at the end of the Rapido demo (Synergy demo). (if we exclude the Oxygene big fullscreen blue cube of course :-))

Other great tricks were Illegal's synchronized-trace protection, S. was a really cool guy, feel free to forward him my email if you're still in touch with him (not sure if email is publicly visible on this forum).


Yes trace routine with video counter is great for protection, but as I love "history of code", are you sure Illegal invented this? I know Rob northen made trace vertor code (no video sync), and Cuddly demo use trace vector in their boot sector, but don't remember if it uses video sync. Are you sure illegal invented that technic first?

Another great but less known trick was used in Chaos' World of Commodore'92 on the Amiga with an adaptation of the giant bit-bend zooming scroller on the ST, where Chaos used EOR.L to simulate the blitter "vertically" and filling an arbitrary one-plane surface covering the whole screen in 50 fps, regardless of its complexity! (by using EOR.L vertically, over the 4th bitplane and 1st bitplane of the next 16 pixels, thus handling 32 pixels with 1 instruction iterating over the entire height of the screen to fill up any arbitrary area).


Totally agree with you. That technic was adapted to ST by Chaos himself, and it's strange that almost nobody noticed it. His screen should deserve a better success.

It's cool to speak about demo history and coding :-)
Leonard/OXYGENE.
User avatar
leonard
Moderator
Moderator
 
Posts: 529
Joined: Thu May 23, 2002 10:48 pm

Postby mcoder » Sat Nov 10, 2007 9:05 pm

fredfm wrote:I was from the Future Minds group, I remember meeting you at the TB2 coding party. I'm happy to see the ST is not dead... That night you "crashed" my screen with your machine (labelled '2060ST' IIRC) thinking your shifter was messing up my syncscroller. The truth was that I used to add stabilization code at the beginning of the scan line, and not at the end as I should have done. Vincent pushed for my screen to end up in Disk 1, that was cool... ;-)


Sorry, I don't remember you, but it reminds something.
It's true that I had (and still possess) one of the earlier Atari ST. It had weird timings...

fredfm wrote:Your 3D was simply awesome, are you still seeing Vincent BTW?

No, I lost contact with Vincent, but his father contacted me about a distributed project.

fredfm wrote:The only thing a little bit unethical with the 3D screens at the time was the fact you guys were fiddling with 8 screens to buffer up processor time to handle the case where you had 3 faces visible on the screen for the cube, as this didn't "fit" in 1 single VBL otherwise. I myself used to work hard on 3D routines and decided to call Vincent one night to ask him how he did to display this whole darn cube on the screen!


It's not unethical.
Since the demo is realtime, every mean is ok.

fredfm wrote:Other great tricks were Illegal's synchronized-trace protection, S. was a really cool guy, feel free to forward him my email if you're still in touch with him (not sure if email is publicly visible on this forum).
Also, I heard something went horribly wrong with Pascal, is that true?


I quitted in bad terms with Illegal, because he cracked Toki, with a lame intro. I have been very patient with him, and he didn't deserve my time.
So cluck him !

Pascal died several years ago. He was quite young.
The official reason was an home accident, but I think he committed suicide.

fredfm wrote:Another great but less known trick was used in Chaos' World of Commodore'92 on the Amiga with an adaptation of the giant bit-bend zooming scroller on the ST, where Chaos used EOR.L to simulate the blitter "vertically" and filling an arbitrary one-plane surface covering the whole screen in 50 fps, regardless of its complexity! (by using EOR.L vertically, over the 4th bitplane and 1st bitplane of the next 16 pixels, thus handling 32 pixels with 1 instruction iterating over the entire height of the screen to fill up any arbitrary area).

What a great time we all had.


Never seen this technique.

And yes, speaking of the past is sure fun !

JC
mcoder
Atari maniac
Atari maniac
 
Posts: 90
Joined: Thu Oct 04, 2007 6:42 pm
Location: France

Postby mcoder » Sat Nov 10, 2007 9:19 pm

leonard wrote:But it requires a *lot* of memory, that's why I prefer the Equinox method. First because it's much more elegant, and second because it's close to the now famous "multi-threading" :-) Equinox draw their objects in 2 bitplans only, and use MOVEM.L to clear the screen (only clearing 16Kb instead of 32). In the same time, they compute all mathematics (vertex transform and rasterizzer settings) in the main thread, while the VBL thread only display polygons. If we refer to the mythic "blue cube", Equinox routine in Vodka demo is better than Megatridi.
Of course it's no use to say MegaTridi was a fantastic part of code, and everybody fall down on the ass when seeing it!


I remember that when I encountered Ziggy, he was not very good technically.
He has a very sharp sense of spectacle, and is able to beautify any effect, but he was not an optimizing expert.
Without any doubt, his version was awesome, even for our group (Algernon and I were amazed !).
As I said, our goal was to build a game system, so we used routines for game programming, not for a 3D demo !

Once everybody realizes that it is possible, new techniques appear, with faster filling, but Ziggy did an impressive first 3D demo !

leonard wrote:
Yes trace routine with video counter is great for protection, but as I love "history of code", are you sure Illegal invented this? I know Rob northen made trace vertor code (no video sync), and Cuddly demo use trace vector in their boot sector, but don't remember if it uses video sync. Are you sure illegal invented that technic first?


No, Illegal was a cracker.
The inventors are Altair and Zarathustra (Pascal).
Altair is the author of nice packers, and Zarathustra was a very good technician (but the laziest coder I ever met).

It's cool to speak about demo history and coding :-)


Agreed.
mcoder
Atari maniac
Atari maniac
 
Posts: 90
Joined: Thu Oct 04, 2007 6:42 pm
Location: France

Postby fredfm » Sun Nov 11, 2007 2:42 am

Yes great technique, we used it too when seeing so much screens in memory :-)

But it requires a *lot* of memory, that's why I prefer the Equinox method. First because it's much more elegant, and second because it's close to the now famous "multi-threading" :-) Equinox draw their objects in 2 bitplans only, and use MOVEM.L to clear the screen (only clearing 16Kb instead of 32). In the same time, they compute all mathematics (vertex transform and rasterizzer settings) in the main thread, while the VBL thread only display polygons. If we refer to the mythic "blue cube", Equinox routine in Vodka demo is better than Megatridi.
Of course it's no use to say MegaTridi was a fantastic part of code, and everybody fall down on the ass when seeing it!


The MOVEM.L over four bitplanes to clear out two a 2-bitplane screen could have been used in the mega Tridi demo, but there was a two-bitplane starfield in the background which prevented that - this effect was pretty, and relatively cheap (probably using generated code).

Last but not least the "biggest" cube in real time is the one at the end of the Rapido demo (Synergy demo). (if we exclude the Oxygene big fullscreen blue cube of course :-))


Sure, although I personally think that after the Mega Tridi demo, there was very little challenge left. I remember seeing linear texture mapping in another demo but can't remember the name of it. That was interesting too.

Yes trace routine with video counter is great for protection, but as I love "history of code", are you sure Illegal invented this? I know Rob northen made trace vertor code (no video sync), and Cuddly demo use trace vector in their boot sector, but don't remember if it uses video sync. Are you sure illegal invented that technic first?


I am almost sure of that (can't be totally sure, since this was close to 16 years ago, probably early 1991), as I used to eat him with every Saturday night along with two other very good friends in the 13th quarter at that time. Rob Northen protections weren't using sync, just a trace function to wire-up to ADebug's own trace routine, decoding the following instruction and sometimes re-encoding the previous one.
Another example of a protection making use of video registers was written by Pascal, switching to high-res back and forth. Remember this little noise on the monitor when booting the European demos?

Totally agree with you. That technic was adapted to ST by Chaos himself, and it's strange that almost nobody noticed it. His screen should deserve a better success.


Probably one of the most impressive demo makers of all times. In the Elysium demo, with a starwars scroller, vectorbobs and a neat 50 fps zoomer using a nice combination of blitter BLTs (to scale down the picture horizontally) and a copper list different for every frame to finish the job eg. scaling down the image vertically by selecting which scanlines should be visible. What a remarkable trick using all the power of the Amiga.
Then in WOC'92 with the roto-zoom and the giant EOR.L scroll.
He more recently wrote a First Person Shooter in 96KB that was pretty successful (http://www.theprodukkt.com).
I'll stop here since we're in an Atari forum ;-), but that was just to remind JC of how good Amiga programmers could be...

It's cool to speak about demo history and coding :-)


Definitely.
fredfm
Atarian
Atarian
 
Posts: 3
Joined: Sat Nov 10, 2007 12:55 am
Location: Redmond, WA (USA)

Postby fredfm » Sun Nov 11, 2007 6:37 pm

Sorry, I don't remember you, but it reminds something.
It's true that I had (and still possess) one of the earlier Atari ST. It had weird timings...


No way you could remember me!... but for the young teenager that I was at that time, chatting with MCoder and having Ziggy Stardust explaining me one trick or two was quite a memorable moment! Actually in a way this probably remains one of the most enjoyable moments of my life.

No, I lost contact with Vincent, but his father contacted me about a distributed project.


The very few discussions I had with Vincent (eg during TB2 or Snork) were very interesting, he was a guy very receptive, willing to help. I didn't have quite the same experience with Pascal.

And yes, speaking of the past is sure fun !


The early 90's were so incredibly exciting.

I should probably start a new thread, but do you guys out here know if it's possible to find pictures or a video of the Transbeauce 2, Snork or even Saturn coding party?
I'm sure if I look in my attic well enough I could find the full Stniccc video (wasn't there, and I can't remember how I got the video).
I'll follow up on with another thread if I don't get any answer.

Greetings to everybody!
fredfm
Atarian
Atarian
 
Posts: 3
Joined: Sat Nov 10, 2007 12:55 am
Location: Redmond, WA (USA)

Postby cb » Sun Nov 11, 2007 6:44 pm

See this thread to get a video from Transbeauce 2:

http://www.atari-forum.com/viewtopic.php?t=10389
Heghlu'meH QaQ jajvam!
Image
User avatar
cb
Fuji Shaped Bastard
Fuji Shaped Bastard
 
Posts: 3365
Joined: Sat Apr 27, 2002 7:03 pm
Location: somewhere in time

Postby bod/STAX » Sun Nov 11, 2007 7:04 pm

I'm sure if I look in my attic well enough I could find the full Stniccc video


If you can't find it, it's now available on DVD from Richard Karsmakers:

http://www.stniccc.com/
User avatar
bod/STAX
Captain Atari
Captain Atari
 
Posts: 496
Joined: Wed Nov 24, 2004 8:13 pm
Location: Halesowen, West Midlands, England

Postby keops » Mon Nov 12, 2007 5:27 pm

I'm glad some people eventually took some time to compare the code without talking out of their ass like some lamers did back in the days.

For too long a few Overlanders/Pendragons people spread that rumor about Equinox's 3D code being ripped from Ziggy and Mcoder.

Any guy with a brain and the skills to compare code can figure out they were totally different as far as I can remember.

I was there during the whole process, when Starlion did the his 3D rout from scratch and the code was everything but ripped.

Mcoder: cool releases by the way, I'm sure a lot of people will love all that stuff. I wish I had more free time to check it all :)
User avatar
keops
Atari Super Hero
Atari Super Hero
 
Posts: 515
Joined: Mon Jul 26, 2004 3:39 pm
Location: Canada

Postby terence » Mon Nov 12, 2007 10:15 pm

keops wrote:For too long a few Overlanders/Pendragons people spread that rumor about Equinox's 3D code being ripped from Ziggy and Mcoder.


personnaly i don't remember that

the main concern about equinox and ovr/pendragons were that on one side we had some drinking uncivilised guys and on the other side the good students of the classroom. that was not possible for them to estimate each others.

(i will always remember at the transbeauce 1 or 2, seeing an equinox guy moving another one who was coma drunk, from his seat to the toilets, pulling him on the floor... i think it could have shocked some other people which had not the same education.)

and from my point of view, education goes before good coding.
but everyone sees noon at his step. and does what he wants.
terence
Atari nerd
Atari nerd
 
Posts: 46
Joined: Fri Jul 01, 2005 11:36 am

Postby keops » Tue Nov 13, 2007 1:21 am

fredfm : http://www.pouet.net/prod.php?which=29527

Image

The video is one hour long and shows most french sceners from that period. If you read the comments you will find all the names of the people present on that video.
User avatar
keops
Atari Super Hero
Atari Super Hero
 
Posts: 515
Joined: Mon Jul 26, 2004 3:39 pm
Location: Canada

Postby mcoder » Tue Nov 13, 2007 7:45 pm

keops wrote:For too long a few Overlanders/Pendragons people spread that rumor about Equinox's 3D code being ripped from Ziggy and Mcoder.


I didn't hear such rumors. But I'm pretty sure you took a look at our routines ;-)
It's fair, since it's the way I learned how to code demos (I disassembled a lot of 68000 code, and converted/improved a lot of Amiga demos).

In fact, I even met Equinox' crew at your HQ a long time ago.
Competition was good for the demo scene.

keops wrote:Mcoder: cool releases by the way, I'm sure a lot of people will love all that stuff. I wish I had more free time to check it all :)


I still have some unreleased screens (based on Amiga effects), but I don't know if somebody is interested to release them...
Last edited by mcoder on Fri Nov 16, 2007 11:04 pm, edited 1 time in total.
mcoder
Atari maniac
Atari maniac
 
Posts: 90
Joined: Thu Oct 04, 2007 6:42 pm
Location: France

Postby bod/STAX » Thu Nov 15, 2007 7:00 pm

I still have some unreleased screens (based on Amiga effects), but I don't know if somebody is interested to release them...


I'd love to see them :)
User avatar
bod/STAX
Captain Atari
Captain Atari
 
Posts: 496
Joined: Wed Nov 24, 2004 8:13 pm
Location: Halesowen, West Midlands, England

yop

Postby C-Rem » Fri Nov 16, 2007 5:26 pm

Of course !!
C-Rem
Captain Atari
Captain Atari
 
Posts: 385
Joined: Wed May 01, 2002 6:45 pm

Postby lotek_style » Fri Nov 16, 2007 9:04 pm

[quote="mcoder"]
I still have some unreleased screens (based on Amiga effects), but I don't know if somebody is interested to release them...[/quote]

Of course we are interested... I suggest you should release them at next years Outline party. The biggest atari-scene event of the year. Maybe you can put a little intro together? :)
lotek style / the sirius cybernetics corporation
- musician - ascii-artist - swapper - archivist -

Stay atari!

lotek style / the sirius cybernetics corp.^ym rockerz

http://demozoo.org/
http://www.tscc.de/
http://www.lotekstyle.de/
http://ymrockerz.atari.org/
http://fading-twilight.atari.org/
User avatar
lotek_style
Mod(ul)erator
Mod(ul)erator
 
Posts: 1923
Joined: Sat May 11, 2002 2:39 pm
Location: germany

Postby Marcer » Fri Nov 16, 2007 10:11 pm

a bit off-topic.. and im drunk. but How to Code "IK+ 2" ??? :P
- Atari ST/F/FM/E - Mega ST/STe - Portfolio - Falcon 030/060 -- Atari 7800/Lynx/Jaguar -
- http://marcer.mine.nu - Trackers Heaven + Game DVD Updates + More
- Atari Legend (Games all-a-round)
- Paradize (Chip Music)
- Elite (Atari Softs)
- The Legion (Demos)
- Alive Maggie Team
_/|\_YM-RockerZ_/|\_
User avatar
Marcer
Atarilegend
Atarilegend
 
Posts: 3942
Joined: Wed Mar 10, 2004 6:21 pm
Location: sweden

Postby mcoder » Fri Nov 16, 2007 11:12 pm

lotek_style wrote:
Of course we are interested... I suggest you should release them at next years Outline party. The biggest atari-scene event of the year. Maybe you can put a little intro together? :)


No, I'm not interested into coding anything.
I still have a ton of code to write, related to PCs, and much more interesting for me (I have to program the next AZPC programming contest, and a distributed project about crosswords).
So I'll pass finishing these screens (I already sent them to MrBee, but I don't know if they were released).
If any coder is willing to release some screens, I'll be glad to donate all the source codes.
mcoder
Atari maniac
Atari maniac
 
Posts: 90
Joined: Thu Oct 04, 2007 6:42 pm
Location: France

Postby leonard » Sat Nov 17, 2007 12:58 am

keops wrote:Any guy with a brain and the skills to compare code can figure out they were totally different as far as I can remember.


Totally agree. I personaly never though that because you can notice it without looking at the code: the equinox 3d rout as often a "covered" pixel on some object's edges. (because there is some small overdraw (gfx bug?) and they *really* are two bitplans). OVR is one bitplan only.

Btw another thing I wonder since a while, maybe someone can answer this. Who invented the very beautifull and tricky

addx.l dx,dy

to compute edge coords?

I really was amazed when I discovered that under debugger when I was jounger, on the OVR tridi demo. I firstly don't enderstand the routine. I remember to enderstand it as a "flash" in a boring deutch course at school :-)
There is nothing like demo coding... :-)

Who invented "addx.l" usage for tridi? Demo coder? Game coder?
Leonard/OXYGENE.
User avatar
leonard
Moderator
Moderator
 
Posts: 529
Joined: Thu May 23, 2002 10:48 pm

Postby mcoder » Sat Nov 17, 2007 12:10 pm

leonard wrote:Btw another thing I wonder since a while, maybe someone can answer this. Who invented the very beautifull and tricky

addx.l dx,dy

to compute edge coords?

I really was amazed when I discovered that under debugger when I was jounger, on the OVR tridi demo. I firstly don't enderstand the routine. I remember to enderstand it as a "flash" in a boring deutch course at school :-)
There is nothing like demo coding... :-)

Who invented "addx.l" usage for tridi? Demo coder? Game coder?


I think I found this trick in a game, but I'm not sure (it may be myself)...
There was a 3D game that had impressive code, but I don't remember which one it was (I remember it had an impressive keyboard routine too).

About the addx.l trick, I remember that Algernon figured the trick instantly.
Maybe Equinox didn't use 0.5 for the first coordinate (we use $8000).
This allows rounding of the coordinates, and avoids some bugs when computing the edges.
mcoder
Atari maniac
Atari maniac
 
Posts: 90
Joined: Thu Oct 04, 2007 6:42 pm
Location: France

Postby leonard » Sat Nov 17, 2007 2:50 pm

About the addx.l trick, I remember that Algernon figured the trick instantly.


I work with Algernon since a while, and I'm often joking at him for its "edge routine" long time ago :-)

So you don't know who invented that trick? Should be very interesting to know.

For the $8000 (well +0.5) I use it in my last GBA filled vector routine (only for pleasure, for programer contest :-))

Anyone else has information about the addx.l inventor?
Leonard/OXYGENE.
User avatar
leonard
Moderator
Moderator
 
Posts: 529
Joined: Thu May 23, 2002 10:48 pm

Postby Maartau » Sat Nov 17, 2007 2:58 pm

Hi Leonard :D

Maybe Pierre (Zappy/Holocaust) could help about that.

I don't remind some stuffs he explained me in the past, you should try to get in touch with him... We're no more neighbours as he now lives in Zurich :) .

P.s ; I refind his page...


http://codercorner.com/Pierre.htm
Member of -aTaRi LeGeND-, -eLiTe-, -NoExTrA-

[smilie=greencolorz4_pdt_20.gif]"anew active, enough motivate...[smilie=greencolorz4_pdt_13.gif]...to be back to the goo' ol' skoooool" [smilie=greencolorz4_pdt_14.gif]
User avatar
Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
 
Posts: 2088
Joined: Thu Dec 15, 2005 2:15 am
Location: France

Postby RA_pdx » Sun Nov 18, 2007 12:48 pm

This "addx.l dx,dy" trick sounds very interesting. Never heard about it.
Can someone explain me how this trick works?
RA_pdx
Captain Atari
Captain Atari
 
Posts: 207
Joined: Sun Feb 02, 2003 12:01 pm
Location: Nuernberg/GERMANY

Postby Kalms » Sun Nov 18, 2007 7:49 pm

RalfZenker:

you can find a general description of the addx technique over at http://membres.lycos.fr/amycoders/opt/innerloops.html.

Short version however is:

normally you have your X coordinate stored as 16.16 fixed point, with integer portion in upper half and fractional portion in lower half, and you step like this (stepping repeated 4 times):
Code: Select all
add.l d1,d0
add.l d1,d0
add.l d1,d0
add.l d1,d0
... etc

However if you swap fractional & integer halves, your stepping code looks like:
Code: Select all
move.l d1,d2  ; "setup" for the addx chain...
clr.w d2      ; ... isolate fractional part...
add.l d2,d0   ; ... and step only fractional part
addx.l d1,d0
addx.l d1,d0
addx.l d1,d0
addx.l d1,d0
... etc

The advantage with the above sequence is that the integer portion of the X coordinate will be immediately available in the lower half of d0. Biggest disadvantage is that you must not use any instruction that mangles the X flag between the ADDXes.

I think I learned of the technique from some BBS (either through source code, or through a FidoNet message) back in 93-94. I was probably still doing rasterbars and sinescrollers back when this technique was invented :)
Kalms
Retro freak
Retro freak
 
Posts: 11
Joined: Sat Oct 28, 2006 10:18 am
Location: Linkoping, Sweden

Postby mcoder » Sun Nov 18, 2007 11:19 pm

The exact routine is something like:

Code: Select all
   add   #.jmpline2-.jmpline1,REGDATA

   swap   XA
   swap   XB      ;poids fort = virgule*4
            ;poids faible = partie entiere*4
   addq   #2,XA      ;X+1/2

   jmp   .jmpline1(PC,REGDATA.W)
.jmpline1
      REPT   nblig-1
      MOVE   XA,(PTRY)+
      ADDX.L   XB,XA
      ENDR
.jmpline2
jmpline
      MOVE   XA,(PTRY)


Where:
XA contains the first X coordinate * 4
XB contains dx/dy

Note that computing one coordinate is done in 2 instructions (move/addx.l)
Also, I used X coordinates multiplied by 4 to avoid late shifting.

When using convex 3D objects, you just have to test if an object is visible with 2 multiplications, then all lines that go down are right borders, and all lines that go up are left borders (if you use clockwise order).
Once you computed all left and right borders, you just have to fill horizontal lines.
mcoder
Atari maniac
Atari maniac
 
Posts: 90
Joined: Thu Oct 04, 2007 6:42 pm
Location: France

Postby RA_pdx » Mon Nov 19, 2007 10:43 am

Thanks, Kalms and Mcoder for the explanations!

Now i remember that i have seen this in some texture mappers and zoomers before.
RA_pdx
Captain Atari
Captain Atari
 
Posts: 207
Joined: Sun Feb 02, 2003 12:01 pm
Location: Nuernberg/GERMANY

PreviousNext

Return to 680x0

Who is online

Users browsing this forum: CommonCrawl [Bot], jvas and 1 guest