1141
The Axe Parser Project / Re: Bug Reports
« on: December 29, 2010, 11:45:03 am »
Oh ok, I see. I have a bad habit of using 96 as the x coordinate instead of 95 when I want to draw a line all the way across the screen
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to. 1141
The Axe Parser Project / Re: Bug Reports« on: December 29, 2010, 11:45:03 am »
Oh ok, I see. I have a bad habit of using 96 as the x coordinate instead of 95 when I want to draw a line all the way across the screen
1142
Miscellaneous / Re: One-Year Thank You / Reflection« on: December 29, 2010, 11:36:35 am »
Happy belated birthday Nice to know I've made an impact...one way or another
1143
TI Z80 / Re: Axe Cuberunner« on: December 28, 2010, 04:40:00 pm »
W00T IMMA NECRO'ING MY OWN TOPIC
yeah. well, here is a small update (version 1.2) that was driven by the release of axe .4.7 and the icon command. Basically, I optimized a bit and fixed a lot of bugs, namely the glitchy menu and pause command. Also, your settings are now saved between rounds and between running of the program because they are now stored in the highscore appvar. The game also runs a bit faster. 1144
Humour and Jokes / 241543903« on: December 28, 2010, 01:58:41 pm »
Google image search "241543903"
LOL 1145
Axe / The Optimization Compilation« on: December 28, 2010, 12:17:53 pm »
Optimization Compilation: The Quick & Dirty Guide to Optimizing in Axe
This is intended to be a guide for every Axe programmer with general optimization For demonstration purposes, I will always use the variable A. Of course, you can do these optimizations with any other var or memory address. Most opts are either in code boxes or on bullet points. Part I: The BASIC Stuff Many of the tricks we've learned from BASIC can also be applied to Axe. However, not all of them are applicable. Let's take a look: Boolean Stuff: As with BASIC, we can optimize Code: [Select] If VAR?0 to simply Code: [Select] If VAR However, be warned that this may not always work with compound statements (If A and B). Because the logic operators are bitwise operations, the statement "2 or 0" will return 0. This means that unless you are certain that A and B are always boolean values (1 or 0), you need to do If A?0 and (B?0) instead of If A and B Another random thing is to ALWAYS CLOSE YOUR QUOTES AND PARENTHESES. Unlike BASIC, the store arrow does not close them for you. Unlike BASIC, leaving them out does NOT improve the size of your program; it is unrelated to optimization but I figured I'd just stick it here since it is a good coding habit and makes code more readable. Pre-evaluating expressions: Especially in games that heavily reference arrays throughout a section of code, it is often good both for speed and memory to pre-evaluate expressions that do not change throughout the loop. Look at this code for drawing a scrolling 16x16 tilemapper with X and Y positions in pixels: Code: [Select] For(A,0,11) There is a HUGE speed gain from simply preevaluating some of the expressions before entering the loop:Code: [Select] X/8->E Pixel Testing Pixel testing can be a mean and nasty cycle stealer from many programs. But never fear, it can be optimized...a lot. Remember that we have access to the screen buffer in L6. If you are pixel testing a constant pixel, like pxl-Test(20,20), you can more than halve the speed of this command with the following optimization: Code: [Select] {20*12+L6+2}^^re4 This optimization relies on the fact that the numbers can basically be pre-computed: use the following formula to derive the numbers you should use: Code: [Select] {Y*12+L6+(X/8)}e(X^8) So for another example, the command pxl-Test(8,1) becomes {12+L6}e1.The speed gain from this is so great that you can even still save (although not as much) even with a variable Y value. How you treat the constant X value remains the same as before, but simply substitute in your variable Y value in the above code. So for example, pxl-Test(31,Y) becomes {Y*12+L6+3}e7. Part II: General Equality Checks: Code: [Select] If A=EXP optimizes to Code: [Select] !If A xor EXP Note that you should use !If A – EXP if it is an optimized addition/subtraction (See Optimized Math)Code: [Select] If A=EXP and (B=EXP) optimizes to Code: [Select] !If A-EXP + (B-EXP) where + is the 16bit 'or' operator.Now, if you are checking the same variable for more than one possible expression, then it yields a greater optimization to do this: Code: [Select] If A=EXP1 or (A=EXP2) to Code: [Select] If inData(A,Data(EXP1,EXP2,0)) You just have to make sure that you take care of the 0 case first, since this will return a non-zero value if the variable=0 Also, as Quigibo pointed out, this only works with constant, 8bit values. Simple Math Stuff
Optimized Math Some operations are hard-coded optimized versions that don’t use the usual arithmetic operations. A complete list of them can be found in the following spoiler which I stole from Runer112’s handy list of command speed/size Spoiler For Optimized Math: Part III: "HL is the Ans of Axe" -Runer112 Like BASIC, Axe also has an Ans-counterpart, a register called HL. It is written to every time you "load" an expression or constant. This yields a multitude of small optimizations: -Duplicate Arguments: Code: [Select] Text(0,0,PTR) optimizes to Code: [Select] Text(0,,PTR) See how that works? When Axe goes to parse the second argument of Text(, it would normally load the second argument into HL and then use that as the Y position of the text. However, in the optimized piece it doesn't find anything to load for the second argument, so it just uses what was already in HL, namely, 0.This, extended, yields further optimization opportunities: -More Omitted Arguments: Not only does loading arguments in commands write to HL, so does loading arguments in normal math and control structure operations. This means that we can omit lots of things, saving more space and speed. For example... Code: [Select] If A>3: 1?B becomes Code: [Select] If A>3: ?B But wait! What if you want to use this optimization on an equality check? Normally, If A=1:?B would work, but if we wanted to optimize the equality check as well, it doesn't work quite right. !If A-1 returns zero if true (or rather, if false), so you might then think that it's probably best to skip this particular optimization and go Code: [Select] !If A-1:1?B However, although it may seem counterintuitive, the following is actually smaller and faster: Code: [Select] !If A-1:+1?B Similarly, Code: [Select] If EXP: -1?B:End (with a minus sign) is preferable to Code: [Select] If EXP:0?B:End Code: [Select] 0?B: 0?A becomes Code: [Select] 0?B?A note: When initializing variables that are 2 or less apart, it also yields further optimization to do this:Code: [Select] 0?A: 1?B: 3?C to Code: [Select] 0?A+1?B+2?C An example of HL abuse in a subroutine:Code: [Select] sub(LBL,EXP).....Lbl LBL: EXP*2?{L1} to Code: [Select] sub(LBL,EXP)....Lbl LBL:*2?{L1] -Here's another abuse of HL, creating the fastest and smallest loop structure (by Runer 112) It will execute the loop n times, with A starting at n-1 and decreasing down to 0: Moving around a sprite Check this out: again courtesy of Runer112: (comments by me) Code: [Select] :.SMILE I can't post every possible abuse of HL here: there are so many ways to use it. Study these examples to see how they work and you can apply it in your own programs. Much of HL abuse has been obsoleted by Axe's peephole optimizer. However, you can still make use of some of these tricks. While the weird syntax is not always necessary, remember to arrange your code and operations such that the peephole optimizer can target it. I left the section somewhat intact so that you can look through it to understand the concept; the optimizer is useless if your code isn’t written intelligently. Part IV: Subroutines Subroutines probably are capable of saving the most space than any other type of optimization. And they are easy to use, too. There are only a couple rules of thumb to follow: 1. If you are rewriting a section of code more than once (and it is more than just one command), best put it into a subroutine. 2. If you aren't, then don't put it in a subroutine. Routine calls are around 3-5 bytes, and an additional 3 bytes for every argument you load. Using the recursive subroutine feature that saves your arguments (sub(LBLr....) costs you 15 bytes per argument. Tail Call Optimization This is lesser known and lesser used, but it is still worth sticking here I guess: If you are calling subroutines from a subroutine as the last line, then you can use a process known as Tail Call Optimization to change this: Code: [Select] Lbl A : Stuff : sub(B) : Return to this: Code: [Select] Lbl A: Stuff : Goto B The Return is not needed because you end up "stealing" subroutine B's return instead of having to return to A and then return again to the main program.Part V: Speed over Size These are all optimizations for aggressive speed gain at the expense of size. Short Circuit Evaluation: In most cases, it yields a (rather impressive) speed gain to change Code: [Select] If EXP1 and EXP2 to Code: [Select] If EXP1 : If EXP2 Make sure to have EXP1 (the outside If block) be the expression that is less likely to be true to gain the most speed.Factoring Constants (and powers of 2); When multiplying and dividing by multiples of powers of 2, it yields an optimization to factor the number first. Code: [Select] EXP*96 to Code: [Select] EXP*32*3
All the stuff I couldn't fit into another category...
Also, a little-known fact regarding printing text at constant coordinates:
Quote from: Quigibo 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. ...And that's all I've got. Happy coding! Let me know if you have any questions, comments, additions, or corrections and I'll be happy to accommodate you This post will also be updated with any new major optimizations found. Also special thanks to Quigibo and Runer112 who are the main contributors of all these optimizations Oh and....666th POST [/list] 1146
Art / Re: Availability/Skill level of artists« on: December 27, 2010, 05:18:00 pm »
Thanks everyone
@Graphmastur: I used to really badly, and I actually have a few plotlines/drafts, etc. I might try it later on as a side thing (definitely going to take art classes in college). It's a split between that and some type of comp sci thing I don't have a deviantart, but I will probably get one soon. 1147
Ash: Phoenix / Re: Ash: Phoenix« on: December 27, 2010, 04:53:07 pm »
Thanks everyone
Ok, a little update before the demo: I've FINISHED all the maps and tiles that I'm planning to go into the demo. This entails 7 different maps linked together, with 96 different tiles. The demo as of now will enclose the first village shown in the screenshot in the last page as well as the first dungeon/boss (the wastelands). If I have time, I will add a route out of the village (an Eastern Mountain Pass) and possibly the next city over (Maghada) (I have a world map laid out on paper, so I sort of have an idea of the order of events and such) NPC's have lots of new abilities now, one of the coolest ones I think is one that enables them to write temporarily to the current map. For example, if I wanted to have a guard blocking a door, I could make it so that talking to him "unlocks" the door. Other ones that I've added are the capability to heal, shop, and start battles. I've also finished the cutscene routine that will be used at the beginning of the game (and in some other places in the final game). Cutscenes are basically slideshows of 3 lvl gray pictures linked together by a nice fade animation, accompanied by text run from the NPC engine. I will be able to promise some reallly nice pixel art here (96x64 is a lot after spending hours drawing 12x12 tiles ) Also, I've optimized a lot. Remember when I said I was going to move the NPC engine out of the main program? The NPC engine took up about 2k then, and at that point I had 1200 bytes left in the app after moving it out. Currently, the NPC engine is BACK in the main app, and I have around 700 bytes left And I finally added luck to the battle engine. If you're twice as lucky as your opponent, you have a chance of inflicting twice as much damage than usual, etc. Things left to do: Move animations for at least the first few moves Scrolls (a type of item) to teach moves Allowing NPCs to teach moves Finalize the opening cutscene (this means work on story a little bit ) Oh...and does anyone remember when my calc was having that weird ERR: LINK thing? When it would throw that error every time I turned on the calc? Well, heh heh, it's happened again Fortunately I could still connect it to the computer so I didn't lose anything but...this makes it, what, twice now that this project has made me do a full mem clear? LOL 1148
The Axe Parser Project / Re: Bug Reports« on: December 27, 2010, 10:20:10 am »
Using the new line command with any X argument over 95 cuts the line really short. For example drawing a line from 0,0 to 96,0 draws a line on screen from 0,0 to....somewhere around 32,0 I think
1149
The Axe Parser Project / Re: Axe Parser« on: December 26, 2010, 09:35:19 am »
I'll test 1.0.0 too A:P's source is around 70k, and I'm constantly compiling lots of other smaller things like its map editor.
Also, awesome new updates edit: wow, new version shaved off 112 bytes off of A:P's main engine O.o 1150
Art / Re: Availability/Skill level of artists« on: December 25, 2010, 03:04:52 pm »
well I got a pen tablet for Christmas, and seeing as how I wasn't quite ever satisfied with it, I decided to redo it digitally Let me know what you think
1151
TI Z80 / Re: Axe game : Avoid« on: December 25, 2010, 11:21:44 am »
What saves more, this opt or the inData() trick? (assuming that the inData() routine already exists...and that there is only 1 comparison...iirc inData() with 1 comparison is like 12 or 13 bytes)
Also, nice game Fast Crash 1152
The Axe Parser Project / Re: Features Wishlist« on: December 24, 2010, 08:13:32 am »
Damn, all these improvements are sounding really nice. I can see potential uses for all that stuff.
By the way, where's the "hidden buffer"? I want to make sure that while I'm hunting down potential freeram areas that aren't in L1-L6 (like in $8000) that I won't accidentally use that area too 1153
Humour and Jokes / Re: Weird/funny pictures thread« on: December 22, 2010, 05:28:16 pm »edit: got some more 1154
News / Re: DJ Omnimaga resigns from Omnimaga manager« on: December 21, 2010, 08:07:51 pm »
I can definitely see where you're coming from, and I hope you enjoy your break. It's definitely a well deserved one.
Keep in mind everyone that he's not leaving us forever active posting,and that he won't even not be as admin for that long: (most likely for the entire holiday vacations)(not that I'm holding it to you to un-retire as soon as holidays are over ) Also to DJ, remember that we have 4 other admins and 10 staff that can help you out on the moderating side; we'll always (at least, most of the time ) be here to support you 1155
Ash: Phoenix / Re: Ash: Phoenix« on: December 21, 2010, 05:50:51 pm »
Hm, I should probably post some screenies
Showing off here my new map-linking routines and new tiles Also, as a note, there are 16 files you will have to send to your calc. They all go into archive though, so it should make the installation process relatively easy. The total size is around 140k, but I'm anticipating at least 50k more data that needs to go in. However, there's currently no compression, so hopefully the filesize will go down. How much archive does the 83+ get again? I forget X.x |
|