Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
19 June, 2013, 06:34:13 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: 1 [2] 3 4 ... 8   Go Down
  Print  
Author Topic: The Optimization Compilation -  (Read 10394 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Fast Crash
LV4 Regular (Next: 200)
****
Offline Offline

Gender: Male
Last Login: 14 September, 2012, 22:28:07
Date Registered: 18 December, 2010, 16:36:07
Location: France
Posts: 192


Total Post Ratings: +39

View Profile
« Reply #15 on: 30 December, 2010, 00:49:30 »
0

Very Nice tricks ! Congratulations !
Logged
calc84maniac
Epic z80 roflpwner
Coder Of Tomorrow
LV11 Super Veteran (Next: 3000)
*
Online Online

Gender: Male
Last Login: Today at 06:06:21
Date Registered: 28 August, 2008, 05:09:05
Location: Right behind you.
Posts: 2737


Total Post Ratings: +376

View Profile
« Reply #16 on: 30 December, 2010, 01:46:57 »
0

By the way, you can't have non-constant data as part of the Data() command.  And that whole inData() optimization only works for comparisons with numbers between 0-255.  You can optimize it to this always though:


1
!If A-EXP1 [16bit and] (A-EXP2)
Wait, but you can't use bitwise-and like a logical "and" the same way you can with "or".
Logged

"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman
kindermoumoute
LV8 Addict (Next: 1000)
********
Offline Offline

Last Login: 15 June, 2013, 17:17:59
Date Registered: 15 May, 2010, 17:53:56
Posts: 837


Total Post Ratings: +51

View Profile
« Reply #17 on: 30 December, 2010, 01:55:44 »
0

Wooooaa ! I need translate this in my french tutorial, can I ?  Love
Logged

Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%
squidgetx
Food.
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 16 June, 2013, 19:53:03
Date Registered: 30 May, 2010, 19:54:18
Location: eating somewhere
Posts: 1849


Topic starter
Total Post Ratings: +480

View Profile
« Reply #18 on: 30 December, 2010, 02:55:40 »
0

By the way, you can't have non-constant data as part of the Data() command.  And that whole inData() optimization only works for comparisons with numbers between 0-255.  You can optimize it to this always though:


1
!If A-EXP1 [16bit and] (A-EXP2)
Wait, but you can't use bitwise-and like a logical "and" the same way you can with "or".

Actually, yeah, i think calc84's right (I tried it today and it didn't work).

And kinder, go ahead Smiley
Logged

Read my webcomic! | My SoundCloud
Projects:

Check out the demo now!- Current progress: battle engine and stuff
Proud author of: Cuberunner | SpaceDash | The Psyche | XXEdit | AxeSynth | StickNinja | Gravity Guy | Embers:Phoenix | Zombie Gun
Axe: Need help optimizing?
User of Axe | zStart | TokenIDE | CalcGS | MirageOS
Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 31 May, 2013, 10:48:29
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Total Post Ratings: +1019

View Profile
« Reply #19 on: 30 December, 2010, 03:45:05 »
0

Oh you're right.  But I just realized that your other optimization doesn't work either. You cannot do this for AND:

1
!If A-EXP1 + (B-EXP2)
This doesn't work because there are more solutions than there should be.  For instance, if A were EXP2 and B were EXP1 the expression would be zero when it should be non-zero.

But you can do this for a compound OR:

1
If A=EXP1 + (B=EXP2)

And you can do this for a compound AND:

1
!If A-EXP1 [16-bit or] (B-EXP2)

And speaking of optimizations.  One major optimization that usually gets ignored is recycling large axe commands.  Axe is not like BASIC and so each command needs its own subroutine to add to your program.  For instance, lets say you use Pt-On() and Pt-Mask() in your code.  Each one has to bring its own 100+ byte subroutine into your program.  But you can probably get away with having just a Pt-Mask routine, recycling it to act like Pt-On by simply adding a 2nd layer to your sprite which is only 8 bytes extra instead of 100ish.  Or you could do the opposite too and only have Pt-On() and Pt-Change() to manually change both buffers at once.  This generally reduces the overall size of the program by a lot when you use the routines only once or very rarely in your code.  And I don't mean calling it rarely, it could be the most used routine in your code, I just mean rarely appears in your source.

More examples: You can draw pixels and boxes with just sprite commands.  Boxes can be drawn with just pixels or lines.  Strait lines can be drawn with just boxes or pixels.  Its best if you only have one type of DispGraph in your all your code.  Pre-flip sprites so you don't need the flip commands in your code.  etc.

The only downside is that it slightly reduces the speed since its not as specialized but its usually worth it because you save a lot of memory, especially in smaller programs.
« Last Edit: 30 December, 2010, 04:07:48 by Quigibo » Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
ztrumpet
The Rarely Active One
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: 11 June, 2013, 05:10:51
Date Registered: 08 November, 2009, 21:10:12
Location: Michigan
Posts: 5688


Total Post Ratings: +360

View Profile
« Reply #20 on: 30 December, 2010, 06:06:12 »
0

Awesome!  Thanks squidgetx! Grin
Logged

Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 06:01:48
Date Registered: 02 July, 2009, 06:38:05
Posts: 1695


Total Post Ratings: +498

View Profile
« Reply #21 on: 30 December, 2010, 06:46:14 »
0

In case anyone was wondering, here is the smallest loop structure that I know of in Axe. It will execute the loop n times, with A starting at n-1 and decreasing down to 0:


1
2
3
4
5
6
n
While
  -1→A
  ;Code
  A
End

And if Quigibo adds conditional jumps, this sort of Do...While loop would be even smaller (which he has not yet, so don't bother with this code as of Axe 0.4.7):


1
2
3
4
5
6
7
n
Lbl L
  →A
  ;Code
!If A-1
  Goto L
End


EDIT: As a side note in case you read this Quigibo, any chance for Do...While loops? They're more optimized than normal While loops.
« Last Edit: 30 December, 2010, 06:47:16 by Runer112 » Logged
Michael_Lee
LV9 Veteran (Next: 1337)
*********
Offline Offline

Gender: Male
Last Login: 31 May, 2013, 15:08:36
Date Registered: 05 August, 2010, 01:00:06
Posts: 1020

Total Post Ratings: +115

View Profile
« Reply #22 on: 30 December, 2010, 06:50:51 »
0

In case anyone was wondering, here is the smallest loop structure that I know of in Axe.

By smallest, do you mean in terms of size, or in terms of speed?  (or both?)
Logged

My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.
Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 06:01:48
Date Registered: 02 July, 2009, 06:38:05
Posts: 1695


Total Post Ratings: +498

View Profile
« Reply #23 on: 30 December, 2010, 07:01:33 »
0

Both Wink It's 8 bytes smaller and should save about 52 t-states per iteration.
Logged
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 06:03:02
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5645


Total Post Ratings: +589

View Profile
« Reply #24 on: 30 December, 2010, 07:25:28 »
0

Wow that is a great loop optimization shocked i think with all the optimizations present here i could shave hundreds of bytes off of all of my Axe projects shocked
Logged

squidgetx
Food.
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 16 June, 2013, 19:53:03
Date Registered: 30 May, 2010, 19:54:18
Location: eating somewhere
Posts: 1849


Topic starter
Total Post Ratings: +480

View Profile
« Reply #25 on: 30 December, 2010, 14:21:32 »
0

Quigibo, when I use "+" I meant 16 bit "or" (I think I wrote that there next to it...) and wow, nice, Runer Smiley

Also, edited those new opts into the first post
« Last Edit: 31 December, 2010, 02:48:48 by squidgetx » Logged

Read my webcomic! | My SoundCloud
Projects:

Check out the demo now!- Current progress: battle engine and stuff
Proud author of: Cuberunner | SpaceDash | The Psyche | XXEdit | AxeSynth | StickNinja | Gravity Guy | Embers:Phoenix | Zombie Gun
Axe: Need help optimizing?
User of Axe | zStart | TokenIDE | CalcGS | MirageOS
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Online Online

Gender: Male
Last Login: Today at 06:34:02
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50625


Total Post Ratings: +2636

View Profile WWW
« Reply #26 on: 31 December, 2010, 06:29:56 »
0

Nice, so would it be better to use this instead of a For( loop?
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
squidgetx
Food.
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 16 June, 2013, 19:53:03
Date Registered: 30 May, 2010, 19:54:18
Location: eating somewhere
Posts: 1849


Topic starter
Total Post Ratings: +480

View Profile
« Reply #27 on: 02 January, 2011, 17:43:11 »
0

^yes.

I'm adding another opt that is rather specific (ofc by Runer112) (moving around a sprite) but I think that people will appreciate it. i also commented it so that you can understand what it's doing more easily (because at first you can't even begin to decipher what it's doing lol)
« Last Edit: 02 January, 2011, 17:50:18 by squidgetx » Logged

Read my webcomic! | My SoundCloud
Projects:

Check out the demo now!- Current progress: battle engine and stuff
Proud author of: Cuberunner | SpaceDash | The Psyche | XXEdit | AxeSynth | StickNinja | Gravity Guy | Embers:Phoenix | Zombie Gun
Axe: Need help optimizing?
User of Axe | zStart | TokenIDE | CalcGS | MirageOS
Munchor
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: 13 June, 2013, 19:29:09
Date Registered: 16 October, 2010, 15:39:13
Location: Position
Posts: 6209


Total Post Ratings: +174

View Profile
« Reply #28 on: 02 January, 2011, 17:45:30 »
0

Nice squidget, the one from the other post, I went Crazy
Logged
squidgetx
Food.
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 16 June, 2013, 19:53:03
Date Registered: 30 May, 2010, 19:54:18
Location: eating somewhere
Posts: 1849


Topic starter
Total Post Ratings: +480

View Profile
« Reply #29 on: 04 January, 2011, 01:48:45 »
0

updated with discussion regarding +1 over 1 with respect to false expression testing (!If statements)

Again, thanks to Runer112 lol
Logged

Read my webcomic! | My SoundCloud
Projects:

Check out the demo now!- Current progress: battle engine and stuff
Proud author of: Cuberunner | SpaceDash | The Psyche | XXEdit | AxeSynth | StickNinja | Gravity Guy | Embers:Phoenix | Zombie Gun
Axe: Need help optimizing?
User of Axe | zStart | TokenIDE | CalcGS | MirageOS
Pages: 1 [2] 3 4 ... 8   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.516 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.