Show Posts

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.


Messages - Runer112

Pages: 1 ... 54 55 [56] 57 58 ... 153
826
Axe / Re: Axe Q&A
« on: April 05, 2012, 08:42:58 pm »
Using a constant pointer like Str1 instead of a variable pointer like A is an optimization technique. Both methods will produce the same end results. But if you use a constant, your code will be smaller and faster.

827
Axe / Re: Axe Q&A
« on: April 05, 2012, 08:37:15 pm »
Depending upon usage, there are quite a few differences between using static pointers (constants) and variables. Most can simply be summarized with the fact that constants are more optimized. To cite the two examples from your code:
"Pic1"→I = 3 bytes (not counting the size of the string data)
→{I+2} = 8 bytes

Whereas with a constant:
"Pic1"→Str1 = 0 bytes (not counting the size of the string data)
→{Str1+2} = 4 bytes

I also just realized that the second code statement can be further optimized by making the store a full 2-byte store. It may sound counter-intuitive that saving 2 bytes instead of 1 byte is actually smaller, but it works out this way because Axe works with 2-byte values and the conversion to a 1-byte value costs a byte when storing to a constant address.
Note: You shouldn't always convert 1-byte stores to a constant address into 2-byte stores to save size, as many times, overwriting the second byte at the store address is undesired. However, in this case you'll end up overwriting a 0 with another 0, so it doesn't matter

828
Axe / Re: Axe Q&A
« on: April 05, 2012, 08:25:15 pm »
The issue is the line with the inline conditional. It's not treated as TI-BASIC experience may suggest, like this:
(K?-1,9)→{I+2}

It's treated like this:
K?(-1),(9→{I+2})

So with your current code, P=0 will select Pic0, but no other values of P have any effect because the store statement is not executed. To fix this, add the parentheses as shown in the first line of code. Alternatively, use the code I suggested in my previous post since it's more optimized anyway. ;)

829
Axe / Re: Axe Q&A
« on: April 05, 2012, 05:17:25 pm »
I know you didn't ask for this, but I'm just going to provide a few tips about how to improve the code:

Code: [Select]
"Pic1"→Str1                 .Use static instead of varaible data pointers
                            . whenever possible, they are more optimized
!If GetCalc("varP")         .Error handling is important!
 .Handle error
 .Return or Goto somewhere
End
(float{}??10)-1→{2+Str1}    .Omits storing and reloading the value returned by GetCalc()
                            . and restructures the conditional to omit the else branch

830
Axe / Re: Optimization Help
« on: April 04, 2012, 12:45:31 am »
Here's a simple, fairly optimized way to do what you are trying to achieve. I have detailed most of the optimizations in comments in the code, but I did not comment about the biggest optimization. This optimization is to draw sprites from a variable pointer, instead of requiring four different copies of the whole loop just for facing in different directions. For instance, here's the line I used to initialize the player sprite to the right-facing sprite:

:2*8+Pic1→S

If you're familiar with how this works, then go ahead and skip to looking at the code to see the final product with the rest of my suggested simple optimizations. If you're not familiar with how this works, I'll give a quick explanation. Because of how Axe includes data like sprites, the order in which you list data (like sprites) is exactly the order it will assume in the compiled program. Since each sprite is 8 bytes, that means that each successive sprite is found in memory 8 bytes after the previous sprite. Pic1 points to the start of the block of 4 sprites, so it points to the first one, the down-facing sprite. 2*8+Pic1 would point to the data 16 bytes after the down-facing sprite, which we know is the right-facing sprite because it's 2 sprites (remember, a sprite is 8 bytes) after the down-facing sprite. This offset from Pic1 logic is used to draw the proper sprite for facing in all 4 directions.


So here's my suggested fairly optimized and hopefully easy-to-understand solution:

Code: [Select]
:.AXETEST
:identity(3FFC3FFC30CF30CF300C300C0C300C303FFC3FFC330C330C3FFC3FFCF00FF00F)
:
:[]→Pic1
:[7E665A247EC37EC3] .DOWN
:[7ED242247E4A7EC3] .LEFT
:[7E4B42247E527EC3] .RIGHT
:[7E7E42247EC37EC3] .UP
:
:.START FACING RIGHT AT (0,56):
:2*8+Pic1→S
:0→X
:56→Y
:.THIS DOESN'T NEED TO BE INSIDE THE LOOP:
:StorePic
:
:While 1
: Pt-On(X,Y,S)
: DispGraph
: .ERASING WITH Pt-Change() UNNECESSARY BECAUSE:
: RecallPic
: If getKey(1)
:  Y+2→Y
:  0*8+Pic1→S
: End
: If getKey(2)
:  X-2→X
:  1*8+Pic1→S
: End
: If getKey(3)
:  X+2→X
:  2*8+Pic1→S
: End
: If getKey(4)
:  Y-2→Y
:  3*8+Pic1→S
: End
:.OPTIMIZED POST-CHECK LOOP:
:End!If getKey(15)





Now, if you want really optimized code... That can be arranged. :hyper: I'll leave figuring out how it works as an exercise.

Code: [Select]
:.AXETEST
:identity(3FFC3FFC30CF30CF300C300C0C300C303FFC3FFC330C330C3FFC3FFCF00FF00F)
:
:[]→Pic1
:[7ED242247E4A7EC3] .LEFT
:[7E7E42247EC37EC3] .UP
:[7E4B42247E527EC3] .RIGHT
:[7E665A247EC37EC3] .DOWN
:
:56→Y
: and 0→X
:→S
:
:While 1
: ClrDraw
: Pt-On(X,Y,S*8+16+Pic1)
: DispGraph
: If getKey(1)-getKey(4)
:  →S
:  *2+Y→Y
: End
: If getKey(3)-getKey(2)
:  -1→S+1
:  *2+X→X
: End
:EndIf getKey(15)

831
The Axe Parser Project / Re: Features Wishlist
« on: March 31, 2012, 02:16:52 pm »
Honestly I'm not sure this (probably large) feature is worth adding... It's a pretty high-level feature, and Axe is a pretty low-level language. A big issue I see is that it would require dynamic memory allocation for adding entries, and dynamic memory allocation does not work terribly well on our platform. Another issue I see is that Axe is a type-less language, so it would be challenging to properly handle the different types the dictionary could contain (it doesn't have to be <string, int>). Also, I'm not really sure what applications it would have to most users. Axe's main design purpose was to make games, whereas this sounds more like a feature that complex utilities would use.

The final reason why I don't believe it would be worth the size/difficulty of adding: if you really need a dictionary, you could actually implement it yourself in Axe. Since you're making it yourself and know what data types it will contain, that passes the hurdle of a type-less language keeping track of types. If you know it won't pass a size of 768 bytes, you could even skip the dynamic memory allocation and throw the dictionary into L₁ or L₃. But if you do need the dynamic memory allocation, you could still do it by putting the dictionary into an appvar and using MemKit to resize it as necessary when adding/removing entries.

832
The Axe Parser Project / Re: Display one character of a string?
« on: March 30, 2012, 04:55:34 pm »
Or, a much simpler and prettier way:

:"AB"[22]"DE"→Str1

 ;)

833
TI Z80 / Re: zStart - an app that runs on ram clears
« on: March 30, 2012, 11:50:54 am »
Yet another bug report :P
-pressing "prgm" while in program editor should lead to a token menu (whatever it is called).
-pressing "prgm" while in homescreen should lead to the program list.
Now, in program editor, pressing apps then clear does basically nothing but makes that pressing "prgm" (while in program editor) leads to the program list instead of the token menu.

(see screenshot, everything happen in the program editor. You see that the first time I press "prgm", everything is normal but the second time is wrong).

I've noticed this bug as well. But this is the fault of Omnicalc's quick apps feature, not zStart. And since Omnicalc is a dead project and won't be updated, I don't think it can/will be fixed. :(

834
The Axe Parser Project / Re: Features Wishlist
« on: March 28, 2012, 08:53:00 pm »
Whenever variables are rearranged in RAM (for instance, deleting any variable that's not the last variable in RAM), the pointers at these two locations are adjusted according to where the variable they point to/into has moved. asm_sym_ptr1 and asm_sym_ptr2 act similarly, except they track VAT entries.

835
The Axe Parser Project / Re: Features Wishlist
« on: March 28, 2012, 04:56:41 pm »
Variables can move around in RAM, so I believe that Axe should have built-in access to asm_data_ptr1 and asm_data_ptr2 for pointer storage. Eiyeron had big problems with this here, but the solution is as simple as having variables that point to these address to hold OS variable pointers. However, I would not expect the average Axe user to figure this out and know to add something like ?84EB?°V1 to their program and then use that custom variable.

So the solution should be as simple as having two default Axe variables that point to asm_data_ptr1 and asm_data_ptr2. I would suggest Y1T and Y2T; they're literally perfect. They're in a menu right next to their closest relatives, the archived variable pointers. And they share similar names, except with an added T for "Tracker." You could even have X1T and X2T point to asm_sym_ptr1 and asm_sym_ptr2. The only Axiom I know of that uses these as Axiom variables (MemKit) would not only still work, but it would work better.


EDIT: Fixed the second copy of the suggested variables (the sym pointers) to be X variables as they're supposed to be. I hope this didn't cause too much confusion.

836
What Eiyeron discovered isn't so much of an Axe bug as it is a lack of a feature that Axe really should have. The issue is that, in the process of deleting or recreating an OS variable, other variables in RAM may be shifted. A common instance of this would occur if your program creates a variable, and later deletes or recreates an OS variable that existed before your program started, then the pointer to the variable you originally created would be invalid.

This is not an issue that an Axe user should need to debug/solve. My identification of the issue required a knowledge of assembly and how the OS structures RAM, and my formulation of the proper solution required a knowledge of an OS feature only exposed to assembly programmers. The behavior Eiyeron saw would most certainly appear to be a bug without this knowledge, thus I do not believe that he should be penalized in any way for asking for assistance with a problem that is not his fault.



Here is my suggested solution for anyone having this issue. For up to two OS variables that you keep a pointer to for the duration of the program, the OS can automatically update the pointer if it moves. To take advantage of this feature, I would suggest putting the following one or two variable definitions in your program:

Code: [Select]
ᴇ84EB→°V1
ᴇ84ED→°V2

The names can be whatever you like, they don't have to be V1 and V2. And if you only need to keep track of one OS variable, you only need one of these definitions. In the body of your program, use these variables instead of standard variables to hold pointers to OS variables that you need to keep track of through possible deletions/recreations of other OS variables.

837
TI Z80 / Re: Fullrene
« on: March 26, 2012, 02:33:49 am »
I managed to cut down the non-83+BE version from 76 bytes to 67 66 bytes. I really don't think it's going to get much smaller, this is after an hour or two of trying every crazy optimization idea I can think of. Any challengers are welcome. :P

Note: I haven't actually tested it, so I hope it works.

EDIT: I thought of a really crazy way to save another byte when I woke up this morning: make the lddr run all the way through flash down to de=0. :hyper:

Code: [Select]
xor a
REP_NEXT
call unlockflash
REP_NEXT
call rVersionEnd
ld a, $10


unlockFlash:
di
push af
in a, (06)
push af

REP_NEXT
ld hl, returnPointz+$8138-$80FE
ld de, $8138

ld a, d
out (05), a
dec a
ld i, a
dec a
out (06), a

in a, (02)
and e
jr z, $+4
ld e, $02

ld b, d
ld c, e
lddr

ex de, hl
add hl, sp
ex de, hl
ld sp, $82A9+$4000

jp nz, $4529
call $4276


returnPointz:
ex de, hl
ld sp, hl

out (05), a
pop af
out (06), a
pop af
out ($25), a

bcall(_flashWriteDisable)
ret


rVersionEnd:

838
TI Z80 / Re: Snakecaster: a 3D Nibbles game, sort of
« on: March 23, 2012, 10:24:59 pm »
Thanks! This is my first time playing with raycasting. I learned it from http://www.permadi.com/tutorial/raycast/index.html (top Google search result, anyway) and I really recommend it if you want to learn.

Exactly how I learned, too. I think this is a magic tutorial.

Take a guess where my knowledge for YAAR came from. :P

839
Axe / Re: Getkey Values
« on: March 22, 2012, 03:49:24 pm »
http://www.omnimaga.org/index.php?action=ezportal;sa=page;p=21

Select the Axe/xLIB getKey setting and the numbers you want will show up under the keys.

840
The Axe Parser Project / Re: Features Wishlist
« on: March 19, 2012, 07:18:43 pm »
In retrospect, maybe it would have been better to make Fix # turn an option on and Fix #r turn the option off. But that would definitely break compatibility now :P

What if the old syntax was left in for compatibility, but a new syntax of Fix LETTER / Fix LETTERr was added? Letters might be easier to remember than numbers anyways.

Pages: 1 ... 54 55 [56] 57 58 ... 153