Genesis programming optimisation tricks
Moderator: BigEvilCorporation
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Genesis programming optimisation tricks
I renamed the topic since my stuff doesn't only cover the 68000 CPU.
So here's the topic where we will concentrate all interesting tricks, optimisations, tweaks, cheats... for get the best from the genesis hardware
General
* Fast multiplication with log2 method (Z80 asm sources included) [++] :
http://www.devrs.com/gb/files/logmult.txt
* Fast 2D rotation [+] :
http://www.cfxweb.net/modules.php?name= ... le&sid=664
68000 assembly programming
* The most interesting part for me "Instead of Use ... Use ... Save x cycles, x bytes" [+++] :
http://www.mactech.com/articles/mactech ... index.html
* 68000 Tricks and traps [+] :
http://linux.cis.monroeccc.edu/~paulrsm ... ick68k.htm
* Fast 3D Transform for 68000 (very specific) [+] :
http://www.catalase.com/optrot3d.htm
So here's the topic where we will concentrate all interesting tricks, optimisations, tweaks, cheats... for get the best from the genesis hardware
General
* Fast multiplication with log2 method (Z80 asm sources included) [++] :
http://www.devrs.com/gb/files/logmult.txt
* Fast 2D rotation [+] :
http://www.cfxweb.net/modules.php?name= ... le&sid=664
68000 assembly programming
* The most interesting part for me "Instead of Use ... Use ... Save x cycles, x bytes" [+++] :
http://www.mactech.com/articles/mactech ... index.html
* 68000 Tricks and traps [+] :
http://linux.cis.monroeccc.edu/~paulrsm ... ick68k.htm
* Fast 3D Transform for 68000 (very specific) [+] :
http://www.catalase.com/optrot3d.htm
Last edited by Stef on Wed Jan 17, 2007 8:39 pm, edited 2 times in total.
-
- Interested
- Posts: 25
- Joined: Wed Jan 17, 2007 11:37 am
- Location: United Kingdom of Great Boredom
I think I know what you're talking about, and I'd advise a degree of caution. Some of the optimisations in the document may not be very helpful for the Megadrive, since (according to Wikipedia) the Megadrive's implementation of TAS is "broken" - it does not write to memory. (The Megadrive 3 had a "working" implementation of TAS, causing a few games to break.)
First post here, by the way, so hi from the UK.
First post here, by the way, so hi from the UK.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Welcome QuickmanQuickman wrote:I think I know what you're talking about, and I'd advise a degree of caution. Some of the optimisations in the document may not be very helpful for the Megadrive, since (according to Wikipedia) the Megadrive's implementation of TAS is "broken" - it does not write to memory. (The Megadrive 3 had a "working" implementation of TAS, causing a few games to break.)
First post here, by the way, so hi from the UK.
We're always happy to see some new guys here
I know about TAS instruction which actually can't lock the BUS on genesis hardware. I crushed it to get Gargoyles working correctly on Gens...
Seems you have a good knowledge of the genesis hardware, we need guys like you :p
The links i posted doesn't rely specifically on TAS instruction but on some general 68000 optimisations and even some more globals ones
-
- Interested
- Posts: 25
- Joined: Wed Jan 17, 2007 11:37 am
- Location: United Kingdom of Great Boredom
I have a moderately good knowledge, but it's fairly incomplete.
I was actually thinking of the optimisation document on TµEE's website, which suggests replacing e.g.
with
which might not quite work as expected. =P
I was actually thinking of the optimisation document on TµEE's website, which suggests replacing e.g.
Code: Select all
bset #7,dN
beq ???
Code: Select all
tas dN
bpl ???
-
- Very interested
- Posts: 2442
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
Yesterday I just read about TAS instruction, I read that it is good for multi CPU systems, but I didn't quite get it. what does it really do ? From that Wiki article I read that it wouldn't work on real HW.
Anyway I did quite fast 2D rotation in QB using only cos/sin table and additions, no muls/divs or any other slow stuff. It can be optimized a lot if I use fixed point instead float (I did as simple as possible to demonstrate stuff to my brother). If anyone wants, I can upload the code. I'm not very sure, but it had a flaw in it (did it quite some time ago).
Anyway I did quite fast 2D rotation in QB using only cos/sin table and additions, no muls/divs or any other slow stuff. It can be optimized a lot if I use fixed point instead float (I did as simple as possible to demonstrate stuff to my brother). If anyone wants, I can upload the code. I'm not very sure, but it had a flaw in it (did it quite some time ago).
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
2D rotation algo without any multiplications or divisions is always interesting
Does the rotation was accurate ?
About TAS instruction, actually this one handle semaphore for ressource acces.
It tests the bit 7 of a byte (memory or register). This bit should indicate if a ressource is free (0) or not (1).
- If the resource is not free (bit 7 = 1) then TAS do nothing.
- If the resource is free (bit 7 = 0), TAS instruction put it as no more free (set bit 7 to 1) then locks the BUS to access resource.
In multi CPU system, this prevent another CPU to access the protected resource at the same time.
Does the rotation was accurate ?
About TAS instruction, actually this one handle semaphore for ressource acces.
It tests the bit 7 of a byte (memory or register). This bit should indicate if a ressource is free (0) or not (1).
- If the resource is not free (bit 7 = 1) then TAS do nothing.
- If the resource is free (bit 7 = 0), TAS instruction put it as no more free (set bit 7 to 1) then locks the BUS to access resource.
In multi CPU system, this prevent another CPU to access the protected resource at the same time.
-
- Very interested
- Posts: 2442
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
My rotation stuff doesn't rotate, more like skews. It uses constants and additions. No rotation...
so TAS is not useful
so TAS is not useful
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 2442
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
TAS is pretty hard to put somewhere, I guess Sonic3 would have used it: bit7 indicates quite some in the SRAM (I did some hacking on it) but I guess they(Sonic team) couldn't make any good use of TAS.
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
Re: Genesis programming optimisation tricks
I've seen the 'Fast subroutine calls' optimization used in many arcade games. I always wondered why they did that way. Makes sense now!Stef wrote:* 68000 Tricks and traps [+] :
http://linux.cis.monroeccc.edu/~paulrsm ... ick68k.htm
I though maybe they were trying to obfuscate the code or something.
this link seems broken :
* Fast 2D rotation [+] :
http://www.cfxweb.net/modules.php?name= ... le&sid=664
Do someone got a cache copy ?
tia
* Fast 2D rotation [+] :
http://www.cfxweb.net/modules.php?name= ... le&sid=664
Do someone got a cache copy ?
tia
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
It work for me, i guess the site is now backPascal wrote:this link seems broken :
* Fast 2D rotation [+] :
http://www.cfxweb.net/modules.php?name= ... le&sid=664
Do someone got a cache copy ?
tia