Author Topic: Axioms?  (Read 7260 times)

0 Members and 1 Guest are viewing this topic.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Axioms?
« on: October 06, 2010, 05:06:45 am »
I'm not quite sure where to post this, in here or in the ASM forum... but although Quigibo disabled axioms in 0.4.5, I decided to write one anyways ;) It's an 8x8, aligned, grayscale sprite routine that can write to arbitrary buffers! And at 15MHz it could draw OVER 9000 GRAYSCALE SPRITES PER SECOND!!! That is, if it worked... Running it as part of a program compiled with version 0.4.4 freezes my calculator (The axiom did partially work ONCE without crashing my calculator though, the first time I tried it). I'm not sure if the problem is in my code or the Axiom system.

Quigibo, was the Axiom system removed because it was damaged? Or is my code probably the damaged part, whether it's a problem with the axiom or how I use it in my program?

I don't know if assembly code should even be posted here, but if you want to look at the source and tell me the numerous things I did wrong (besides cheating the normal axiom argument system, that's intentional and should work fine), here it is:


EDIT: Changed iy usage to push/pop, still crashes my calculator.

EDIT 2: THE AXIOM FUNCTIONS WITHOUT CRASHING, YAY! But it still doesn't do what I want, which I presume is just a problem with my code. It seems that it's ignoring the row input and always drawing sprites to the 2nd sprite row (row 16 of the display). Any ideas?


EDIT 3: IT COMPLETELY WORKS!!! ;D If you want to use it (not in Axe 0.4.5 though), it's attached to this post.


Code: [Select]
.nolist
#include "ti83plus.inc"
.list
.org $9D95

#define var_r1 $83A5 ;Sprite column (0-11)
#define var_r2 $83A7 ;Sprite row (0-7)
#define var_r3 $83A9 ;Pointer to 8x8 grayscale sprite data
#define var_r4 $83AB ;Pointer to front buffer
#define var_r5 $83AD ;Pointer to back buffer

.dw $C0DE ;Header
.db $FF ;Shells
.db tPlot2,0 ;Token
.db 0 ;Replacement Type
.db 0 ;Arguments
.db 56 ;Size

;Calculate byte offset
ld a,(var_r2) ;[13] Sprite row (0-7) -> Multiply by 96 for byte offset (0-672)
add a,a ;[4] *2
add a,a ;[4] *4
add a,a ;[4] *8
add a,a ;[4] *16
add a,a ;[4] *32 (0-224)
ld h,0 ;[7] Move to hl to avoid overflow
ld l,a ;[4]
ld d,h ;[4] Copy hl to de to prepare for *3
ld e,l ;[4]
add hl,de ;[11]
add hl,de ;[11] *96 (0-672)
ld a,(var_r1) ;[13] Sprite column (0-11)
add a,l ;[4] Add to byte offset (will not overflow, l mod 32 = 0)
ld e,a ;[4] Move result to de
ld d,h ;[4]
ld hl,(var_r5) ;[16] Back buffer pointer
add hl,de ;[11] +offset
push hl ;[11] Save for later
;Prepare to copy sprite to buffers
ld hl,(var_r4) ;[16] Front buffer pointer
add hl,de ;[11] +offset
ld ix,(var_r3) ;[20] Sprite data
ld de,12 ;[10] Row increment
ld c,2 ;[7] Buffer counter
putSpriteLoop1:
ld b,8 ;[7] Row counter
putSpriteLoop2:
ld a,(ix) ;[19] Copy a byte from the sprite to the buffer
ld (hl),a ;[7]
inc ix ;[10] Move forward 1 byte in sprite
add hl,de ;[11] Move forward 12 bytes in buffer
djnz putSpriteLoop2 ;[13/8] Repeat for 8 rows
dec c ;[4] Decrease buffer counter
jr z,end ;[12/7] End if done with both buffers
pop hl ;[11] Retrieve back buffer pointer+offset
jr putSpriteLoop1 ;[10] Repeat for second buffer
end:

.end
« Last Edit: October 06, 2010, 06:20:28 pm by Runer112 »

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Axioms?
« Reply #1 on: October 06, 2010, 08:30:18 am »
You seem to be destroying the IY register, which is used by the OS (not to mention the undocumented opcodes that will crash a TI-Nspire). It is actually better to replace
Code: [Select]
       ld    iy,(var_r5)               ;[20]    Back buffer pointer
        add    iy,de                    ;[15]    +offset; de will be destroyed, so saving result in iy for later

...

.db $FD ;[4] Load second buffer pointer+offset back into hl from iy
ld d,h ;[4] Undocumented: ld h,iyh
.db $FD ;[4]
ld e,l ;[4] Undocumented: ld l,iyl
ex de,hl ;[4]

with

Code: [Select]
       ld    hl,(var_r5)               ;[16]    Back buffer pointer
        add    hl,de                    ;[11]    +offset; de will be destroyed, so saving result on stack for later
        push  hl                        ;[11]

...

        pop hl                          ;[10]   Pop second buffer pointer+offset back into hl from stack

Edit:
Fixed a glitch, simplified
« Last Edit: October 06, 2010, 08:32:38 am by calc84maniac »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axioms?
« Reply #2 on: October 06, 2010, 12:32:59 pm »
Wow, in my whole process of register juggling I completely forgot that pushes and pops exist lol. Silly me :)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Axioms?
« Reply #3 on: October 06, 2010, 01:37:25 pm »
There was a reason stated somewhere why Axioms were disabled in 0.4.5, but I totally forgot where and I am now curious as well why X.x

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axioms?
« Reply #4 on: October 06, 2010, 03:28:53 pm »
It looks like Axioms do in fact work! My routine works without crashing my calculator, and almost does exactly what I wanted it to! The only problem is that it seems to be ignoring the sprite row input and draws all sprites to the second sprite row (row 16 of the display). Anybody see a problem in my code that might be causing this?

EDIT: It completely works now! Although I realize this is a very specific routine, if you're drawing 8x8 aligned grayscale sprites, this routine can draw the sprites in about 2/3 of the time that the combination of Pt-Off() and Pt-Off()r can ;D
« Last Edit: October 06, 2010, 08:13:08 pm by Runer112 »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Axioms?
« Reply #5 on: October 06, 2010, 04:02:37 pm »
Good to hear it works :D

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Axioms?
« Reply #6 on: October 06, 2010, 04:40:19 pm »
They were disabled is for 2 reasons.

First of all, I wasn't sure if they still worked or not after mixing subroutines and data because I didn't do any testing with them after making this change.  But it sounds like they probably do work so I guess it's just lucky that it still functions without having debugged.  There might be other problems still with subroutines, token names, compatibility options, or at least some combination probably still doesn't work.

The other issue is that I am completely changing the axiom capability with "acalls".  The acalls  are similar to bcalls except they call axe routines instead of OS routines.  They're basically just jumps whose label gets automatically replaced by the parser with the label of the axe routine in the program, inserting the routine into the program if it doesn't already exist.  Works with all conditionals of jumps and calls too.  Another new feature is adding options for the r modifier or double rr modifier to be used with axioms.  There is also a new form for implicit storing where you can store to the function itself like how ->nib{} would work for example.  With all these changes, the code was completely under construction so rather than commenting it out and replacing it with the old code, I decided to just keep it there but have it disabled until I actually finish it.
« Last Edit: October 06, 2010, 04:43:02 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axioms?
« Reply #7 on: October 06, 2010, 05:01:25 pm »
They were disabled is for 2 reasons.

First of all, I wasn't sure if they still worked or not after mixing subroutines and data because I didn't do any testing with them after making this change.  But it sounds like they probably do work so I guess it's just lucky that it still functions without having debugged.  There might be other problems still with subroutines, token names, compatibility options, or at least some combination probably still doesn't work.

The other issue is that I am completely changing the axiom capability with "acalls".  The acalls  are similar to bcalls except they call axe routines instead of OS routines.  They're basically just jumps whose label gets automatically replaced by the parser with the label of the axe routine in the program, inserting the routine into the program if it doesn't already exist.  Works with all conditionals of jumps and calls too.  Another new feature is adding options for the r modifier or double rr modifier to be used with axioms.  There is also a new form for implicit storing where you can store to the function itself like how ->nib{} would work for example.  With all these changes, the code was completely under construction so rather than commenting it out and replacing it with the old code, I decided to just keep it there but have it disabled until I actually finish it.

Well don't change it too much, I have it working now and wouldn't want to have to completely reformat it for a new system :P

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Axioms?
« Reply #8 on: October 06, 2010, 05:01:34 pm »
wow! I hope I can restrain myself during the remaining 50% of progress that has still to come jet! how would acalls work exactly? can you already give a code example?
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline FinaleTI

  • Believe in the pony that believes in you!
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1830
  • Rating: +121/-2
  • Believe in the pony that believes in you!
    • View Profile
    • dmuckerman.tumblr.com
Re: Axioms?
« Reply #9 on: October 06, 2010, 05:16:34 pm »
It looks like Axioms do in fact work! My routine works without crashing my calculator, and almost does exactly what I wanted it to! The only problem is that it seems to be ignoring the sprite row input and draws all sprites to the second sprite row (row 16 of the display). Anybody see a problem in my code that might be causing this?

EDIT: It completely works now! Although I realize this is a very specific routine, if you're drawing 8x8 aligned grayscale sprites, this routine can draw the sprites almost twice as fast as the combination of Pt-Off() and Pt-Off()r ;D
Awesome! Pokemon TI uses an 8x8 aligned greyscale tilemapper, so this could be insanely useful...
What are the arguments by the way? I understand r1 and r2 and I'm assuming that r3 holds both layer's sprites, but what about r4 and r5? Would they just be pointing to where in the sprite the data for each layer is?


Spoiler For Projects:

My projects haven't been worked on in a while, so they're all on hiatus for the time being. I do hope to eventually return to them in some form or another...

Spoiler For Pokemon TI:
Axe port of Pokemon Red/Blue to the 83+/84+ family. On hold.

Spoiler For Nostalgia:
My big personal project, an original RPG about dimensional travel and a few heroes tasked with saving the world.
Coding-wise, on hold, but I am re-working the story.

Spoiler For Finale's Super Insane Tunnel Pack of Doom:
I will be combining Blur and Collision Course into a single gamepack. On hold.

Spoiler For Nostalgia Origins: Sky's Story:
Prequel to Nostalgia. On hold, especially while the story is re-worked.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Axioms?
« Reply #10 on: October 06, 2010, 05:20:56 pm »
r4 and r5 are the buffers to use (in case you don't want to use L6 and L3)
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline FinaleTI

  • Believe in the pony that believes in you!
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1830
  • Rating: +121/-2
  • Believe in the pony that believes in you!
    • View Profile
    • dmuckerman.tumblr.com
Re: Axioms?
« Reply #11 on: October 06, 2010, 05:22:11 pm »
Ah. Ok, thanks.

Edit: Is there some special way you have to compile Axioms? Because I can't figure out how.
« Last Edit: October 06, 2010, 06:04:42 pm by FinaleTI »


Spoiler For Projects:

My projects haven't been worked on in a while, so they're all on hiatus for the time being. I do hope to eventually return to them in some form or another...

Spoiler For Pokemon TI:
Axe port of Pokemon Red/Blue to the 83+/84+ family. On hold.

Spoiler For Nostalgia:
My big personal project, an original RPG about dimensional travel and a few heroes tasked with saving the world.
Coding-wise, on hold, but I am re-working the story.

Spoiler For Finale's Super Insane Tunnel Pack of Doom:
I will be combining Blur and Collision Course into a single gamepack. On hold.

Spoiler For Nostalgia Origins: Sky's Story:
Prequel to Nostalgia. On hold, especially while the story is re-worked.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axioms?
« Reply #12 on: October 06, 2010, 06:09:25 pm »
If you want the compiled Axiom, here it is. It draws 8x8 aligned grayscale sprites to arbitrary buffers. It uses the Plot2( token, and although the parenthesis would suggest otherwise, it's actually set not to accept any arguments. You have to store the arguments into r1-r5 manually, and don't put an ending parenthesis after Plot2(. The reason I did this is so you can save some processing time when displaying a whole tilemap by, instead of doing something like:

Code: [Select]
For(B,0,7)
For(A,0,11)
Plot2(A,B,calculation for sprite pointer,L₆,L₃)
End
End

You can do this:

Code: [Select]
L₆→r₄
L₃→r₅
For(r₂,0,7)
For(r₁,0,11)
calculation for sprite pointer→r₃
Plot2(
End
End

This saves a bit of processing time for a whole 12x8 tilemap by only storing one argument variable per iteration instead of five.

(In case you couldn't tell from the code example, the arguments are as follows)
  • r1 = Sprite row (0-11)
  • r2 = Sprite column (0-7)
  • r3 = Pointer to 8x8 grayscale sprite
  • r4 = Front buffer pointer (L6 if you're not doing anything special)
  • r5 = Back buffer pointer (L3 if you're not doing anything special)


EDIT:
Edit: Is there some special way you have to compile Axioms? Because I can't figure out how.

If you look at my Axiom source from the first post, you can see what the .z80 file should look like. Then you need to assemble it and convert it to an appvar. Personally, I deal with this conversion by sending the program to wabbitemu and using Calcsys to change its type.
« Last Edit: October 06, 2010, 06:22:29 pm by Runer112 »

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axioms?
« Reply #13 on: October 06, 2010, 06:46:41 pm »
I just wanted to pop in and say something.  Im worried that having a super faster routine for sprites isnt going to help your speed as much as you think it might.  I ran some tests with the regular Axe sprite routine and i was able to display over 4000 a second even in 6Mgz mode.  In the other thread you said you needed over 2000 per second, so im worried that some of the slowdown isnt coming from the sprite displaying.  Have you tried out your routine in the program?  Im eager to hear new details!  I really hope everything works out :)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axioms?
« Reply #14 on: October 06, 2010, 08:10:33 pm »
I just wanted to pop in and say something.  Im worried that having a super faster routine for sprites isnt going to help your speed as much as you think it might.  I ran some tests with the regular Axe sprite routine and i was able to display over 4000 a second even in 6Mgz mode.  In the other thread you said you needed over 2000 per second, so im worried that some of the slowdown isnt coming from the sprite displaying.  Have you tried out your routine in the program?  Im eager to hear new details!  I really hope everything works out :)

The routine works, and I can get 22 full redraws and DispGraphrr's per second vs. 20 with the normal sprite routine, so I'm happy with the result. I think that, for the animation speed I want, I'll only need to redraw the screen 12 times per second, which will then allow me to increase my number of DispGraphrr's per second and (hopefully) result in fairly smooth grays.