Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Munchor on March 22, 2011, 05:43:37 pm

Title: Simple Axe Questions
Post by: Munchor on March 22, 2011, 05:43:37 pm
I've been working on a few things have the following questions:

1. How to write white text in black background? So if I have Rect(0,96,96,64 and then want to use Text( and make it white over dark background. How can I do it? I can't DrawInv everything by the way.
2. I have 2 pictures (two FFFFFFFFFFFFFFFF Pics) and I want to check collision between them, I have (X,Y) for the upper left corner of one of them and (A,B) for the upper left corner of the other one. How can I make them both stop when they collide with each other. So, if one hits the other, they'll both block, collide and can't move unless if they turn around. Thanks.


Notes: I'm not using the x256 mode (I never use/used it). Thanks
Title: Re: Simple Axe Questions
Post by: Michael_Lee on March 22, 2011, 05:57:04 pm
1] Use one of the 'Fix' commands.
Code: [Select]
.TEST
ClrDraw
DrawInv
Fix 3

Text(10,10,"Hello World")
Text(10,20,"More Text")
Dispgraph

Repeat getKey(15)
End

Fix 4
.Don't forget to call Fix 4 to return the text to normal.


2.
If you want to use only the coordinates provided, try measuring the X and Y distance between the two points.  If both distances are less then or equal to 8 (or perhaps 7 or 9, tweaking needed), then you know that they collided.  Making them stop depends on how you implemented your physics.
Title: Re: Simple Axe Questions
Post by: willrandship on March 22, 2011, 06:00:15 pm
Remember, with all the fix commands, though, you should switch it back at the end, otherwise the OS will be messed up. It doesn't matter so much on some, but it does on others.
Title: Re: Simple Axe Questions
Post by: Munchor on March 22, 2011, 06:07:20 pm
Concerning the Fix command, thanks but I still have a problem:

Code: [Select]
Fix 3
Text(0,10,"TITLE
Fix 4

The thing is, it's gray on black background :S

Thanks.

EDIT: It's not gray but it's constantly rewriting itself, it's in a loop, but still :S

EDIT 2:
Concerning collision,
I can check their distances, but is their a simpler method, using pxl-Test, etc.?
Title: Re: Simple Axe Questions
Post by: Michael_Lee on March 22, 2011, 06:11:46 pm
Concerning the Fix command, thanks but I still have a problem:

Code: [Select]
Fix 3
Text(0,10,"TITLE
Fix 4

The thing is, it's gray on black background :S

Thanks.

EDIT: It's not gray but it's constantly rewriting itself, it's in a loop, but still :S


Did you add 'Fix 5' to the start of the program so that text is drawn to the buffer?  Because if you didn't, it drew to the screen directly, and will probably keep redrawing itself to the screen every time you repeat that command, and that causes flickering/is very slow.
Title: Re: Simple Axe Questions
Post by: Munchor on March 22, 2011, 06:14:40 pm
@Michael: You're a god.

Code: [Select]
ClrDraw
Fix 5
Repeat getKey(15)
Fix 3
Text(0,0,"TEXT
Fix 2
DispGraph
End
Fix 4

Thanks :)
Title: Re: Simple Axe Questions
Post by: yunhua98 on March 22, 2011, 06:18:00 pm
@Michael: You're a god.

Code: [Select]
ClrDraw
Fix 5
Repeat getKey(15)
Fix 3
Text(0,0,"TEXT
Fix 2
DispGraph
End
Fix 4

Thanks :)

okay, so you can use multiple Fix commands at once?

also, I find this kinda funny since you're the one who wrote that awesome Fix tutorial.  :P
Title: Re: Simple Axe Questions
Post by: Munchor on March 22, 2011, 06:23:19 pm
@Michael: You're a god.

Code: [Select]
ClrDraw
Fix 5
Repeat getKey(15)
Fix 3
Text(0,0,"TEXT
Fix 2
DispGraph
End
Fix 4

Thanks :)

okay, so you can use multiple Fix commands at once?

also, I find this kinda funny since you're the one who wrote that awesome Fix tutorial.  :P

It's fun lol, I forgot about the fixes.
Title: Re: Simple Axe Questions
Post by: Raylin on March 22, 2011, 06:26:53 pm
How do you shake the screen in Axe?

Or am I being a donk and there's a command for it?
Title: Re: Simple Axe Questions
Post by: Munchor on March 22, 2011, 06:28:09 pm
How do you shake the screen in Axe?

Or am I being a donk and there's a command for it?

I think you could run a loop through all pixels and move them left (Pxl-On, Pxl-Test) but that sounds too much work, any simpler ideas?
Title: Re: Simple Axe Questions
Post by: Michael_Lee on March 22, 2011, 06:29:30 pm
Use a bunch of Horizontal/Vertical commands?

The only bad thing is that the edges will then be pure-white/pure-black, so you'd have to redraw the screen after all the shaking if you were worried about graphics.

I'm also interested in knowing if there's a better way then using Horizontal/Vertical.
Title: Re: Simple Axe Questions
Post by: Munchor on March 22, 2011, 06:30:46 pm
Use a bunch of Horizontal/Vertical commands?

The only bad thing is that the edges will then be pure-white/pure-black, so you'd have to redraw the screen after all the shaking if you were worried about graphics.

I'm also interested in knowing if there's a better way then using Horizontal/Vertical.

Horizontal -/Vertical- (+, ++, etc) seems way better than my idea as a start.
Title: Re: Simple Axe Questions
Post by: Happybobjr on March 22, 2011, 06:31:43 pm
for(...)
horizontal+
dispgraph
Horizontal-
dispgraph
end

like that?

Edit: double ninja'd
Title: Re: Simple Axe Questions
Post by: Runer112 on March 22, 2011, 06:37:24 pm
The "proper" way to shake the screen is with the z-addressing feature of the display driver. However, Axe does not have a command for this. With a little bit of assembly, I used z-addressing in my otherwise entirely Axe crazy tunnel (http://ourl.ca/9322/177233). You could use z-addressing with something like:
Code: [Select]
Zsub(Z)

Lbl Z
  Asm(147DE63FF640D310)
Return

The input would be taken mod 64 and then applied as the screen's z-address. A z-address of 0 would mean the screen is in its normal state, and for every increase by 1, the screen would be shifted down 1 pixel. Pixels that are shifted off the bottom of the screen wrap around back to the top. This doesn't change the buffer data at all, it just changes how it is mapped to the display.
Title: Re: Simple Axe Questions
Post by: Raylin on March 22, 2011, 06:41:17 pm
GOD.

I need to learn effin' ASM.

>:\
Title: Re: Simple Axe Questions
Post by: DJ Omnimaga on March 22, 2011, 07:38:51 pm
Yeah what Runer112 suggested is kinda what Reuben Quest and ROL2 used for earthquake effects.

HOWEVER, keep in mind this doesn't work on the TI-Nspire (it will do nothing) and will not work all the time on WabbitEmu.
Title: Re: Simple Axe Questions
Post by: Raylin on March 22, 2011, 08:16:44 pm
How do you do collision detection with sprites in Axe?
Title: Re: Simple Axe Questions
Post by: Happybobjr on March 22, 2011, 08:19:27 pm
In a monochrome map.  You can store the "physical" objects in both buffers.  Then you can check if there is a pxl on the back buffer at the spot you are moving to.
Title: Re: Simple Axe Questions
Post by: Builderboy on March 22, 2011, 08:23:58 pm
How do you do collision detection with sprites in Axe?

To detect if two 8x8 sprites are colliding, simple do

If abs(X1-X2)<8 && (abs(Y1-Y2)<8

I'm sure it could be optimized, but its just a demonstration :P
Title: Re: Simple Axe Questions
Post by: Raylin on March 22, 2011, 08:36:41 pm
How do you test for an enemy or a wall?
Can you distinguish the two pixels?

EDIT: Oh wait. I'm an idiot.
Title: Re: Simple Axe Questions
Post by: Darl181 on March 22, 2011, 08:43:00 pm
Can someone explain what and, or, and xor do in axe?
Not in If statements, but otherwise.  It's not very descriptive in the commands list :P
Title: Re: Simple Axe Questions
Post by: Happybobjr on March 22, 2011, 08:47:16 pm
It is the exact same thing though. (methinks)
If you and it, the outcome will be 1 iff both inputs are 1.
If you or it, the outcome will be 1 iff any of the inputs are 1.
If you xor it, the outcome will be 1 iff only one input is 1.


Although I might be completely wrong.
Note:  for those who may not know, in the us,  "iff" stands for, "If and only if"
Title: Re: Simple Axe Questions
Post by: Runer112 on March 22, 2011, 09:13:31 pm
By the way, I think a few people have gotten confused a bit. This is not the general Axe Q&A thread, this is just a thread that Scout started to ask a few specific questions for his program. If you want to ask short questions, in the future it would probably be better to ask them in the general Axe Q&A (http://ourl.ca/9165) thread made for this purpose.


Can someone explain what and, or, and xor do in axe?
Not in If statements, but otherwise.  It's not very descriptive in the commands list :P

I think Wikipedia (http://en.wikipedia.org/wiki/Bitwise_operation#Bitwise_operators) can explain the bitwise operations better than I can. The examples they give are for 4-bit numbers, whereas Axe uses 16-bit numbers. The and, or, xor, and not() commands only operate on the low 8 bits (the high 8 bits will simply be copied from one of the arguments). The ยท, ?, ?, and not()r commands perform the operation on the full 16 bits.
Title: Re: Simple Axe Questions
Post by: Munchor on March 23, 2011, 10:37:23 am
Runer, I'm afraid I'm not very comfortable with the Axe Q&A topic, since a lot of people are asking questions in the same thread :S

I have one more question:

3. How to get arguments in a label that is a subroutine. I want to call it like sub(DW,"HEY",1 and in the Lbl DW I want to get the arguments. Thanks.
Title: Re: Simple Axe Questions
Post by: Deep Toaster on March 23, 2011, 10:44:41 am
Runer, I'm afraid I'm not very comfortable with the Axe Q&A topic, since a lot of people are asking questions in the same thread :S

I have one more question:

3. How to get arguments in a label that is a subroutine. I want to call it like sub(DW,"HEY",1 and in the Lbl DW I want to get the arguments. Thanks.

r1 is the first argument, r2 is the second, etc. They're all accessed from VARS > Y-VARS > 3:Polar....
Title: Re: Simple Axe Questions
Post by: Munchor on March 23, 2011, 10:46:28 am
Runer, I'm afraid I'm not very comfortable with the Axe Q&A topic, since a lot of people are asking questions in the same thread :S

I have one more question:

3. How to get arguments in a label that is a subroutine. I want to call it like sub(DW,"HEY",1 and in the Lbl DW I want to get the arguments. Thanks.

r1 is the first argument, r2 is the second, etc. They're all accessed from VARS > Y-VARS > 3:Polar....

Woooh thanks seems good help :)
Title: Re: Simple Axe Questions
Post by: Deep Toaster on March 23, 2011, 10:55:48 am
Btw, it's all in the documentation (commands.html) ;)
Title: Re: Simple Axe Questions
Post by: Munchor on March 23, 2011, 12:00:15 pm
Yeah Deep, thanks.

I have a new question now, is there any way I can extend r1-r6 to 37?
Title: Re: Simple Axe Questions
Post by: Deep Toaster on March 23, 2011, 12:19:33 pm
Yeah Deep, thanks.

I have a new question now, is there any way I can extend r1-r6 to 37?

37? What do you mean?

If you mean r7, nope, there's a max of 6 args. When would you use 7?

You can always pass more args as variables, though.
Title: Re: Simple Axe Questions
Post by: turiqwalrus on March 23, 2011, 02:19:00 pm
meh... Somehow, I managed to forget how to display a grayscale sprite :(
anyone?
Title: Re: Simple Axe Questions
Post by: Munchor on March 23, 2011, 02:20:37 pm
What was in this post has been removed since I found a way to get through it.

EDIT:

How to optimize this?:

Code: [Select]
Pxl-On(90,1
Pxl-On(91,2
Pxl-On(92,3
Pxl-On(93,2
Pxl-On(94,1
Pxl-On(90,5
Pxl-On(91,4
Pxl-On(93,4
Pxl-On(94,5

I made it with a For( loop or nested For( loops, and I did it! I really did, but I lost the source code (deleted it in Doors CS7 by mistake) and rewrote 900bytes of code (phew) but can't remember how to make a cross with a loop... I can't make it now (even though I did it before).
Thanks.
Title: Re: Simple Axe Questions
Post by: Deep Toaster on March 23, 2011, 05:26:57 pm
meh... Somehow, I managed to forget how to display a grayscale sprite :(
anyone?

You need to have the sprite stored as two 8x8 sprites (one for the front buffer, one for the back). Then use Pt-On() to display the first one and Pt-On()r to display the second.

Whatever's black on the buffer is black on the screen; whatever's white on the buffer and black on the back-buffer is gray on the screen; whatever's white on both buffers is white.

What was in this post has been removed since I found a way to get through it.

EDIT:

How to optimize this?:

Code: [Select]
Pxl-On(90,1
Pxl-On(91,2
Pxl-On(92,3
Pxl-On(93,2
Pxl-On(94,1
Pxl-On(90,5
Pxl-On(91,4
Pxl-On(93,4
Pxl-On(94,5

I made it with a For( loop or nested For( loops, and I did it! I really did, but I lost the source code (deleted it in Doors CS7 by mistake) and rewrote 900bytes of code (phew) but can't remember how to make a cross with a loop... I can't make it now (even though I did it before).
Thanks.

Use a sprite? That makes it several times smaller.
Title: Re: Simple Axe Questions
Post by: Runer112 on March 23, 2011, 05:48:44 pm
How to optimize this?:

Code: [Select]
Pxl-On(90,1
Pxl-On(91,2
Pxl-On(92,3
Pxl-On(93,2
Pxl-On(94,1
Pxl-On(90,5
Pxl-On(91,4
Pxl-On(93,4
Pxl-On(94,5

Pixel method: 117 bytes not counting the pixel routine, 158 bytes with it; 2853 cycles
 

Code: [Select]
Pt-On(88,0,[0022140814220000])

Aligned sprite method: 24 bytes not counting the sprite routine, 150 bytes with it; 918 cycles
Title: Re: Simple Axe Questions
Post by: Munchor on March 26, 2011, 09:07:55 am
How to optimize this?:

Code: [Select]
Pxl-On(90,1
Pxl-On(91,2
Pxl-On(92,3
Pxl-On(93,2
Pxl-On(94,1
Pxl-On(90,5
Pxl-On(91,4
Pxl-On(93,4
Pxl-On(94,5

Pixel method: 117 bytes not counting the pixel routine, 158 bytes with it; 2853 cycles
 

Code: [Select]
Pt-On(88,0,[0022140814220000])

Aligned sprite method: 24 bytes not counting the sprite routine, 150 bytes with it; 918 cycles

But it's supposed to be Pxl-Off( so how do I make the sprite White?
Title: Re: Simple Axe Questions
Post by: Happybobjr on March 26, 2011, 09:37:10 am
Pt-change(80,0,[FFFFFFFFFFFFFFF])
Pt-Change(88,0,[0022140814220000])

I think that would work
Title: Re: Simple Axe Questions
Post by: Munchor on March 26, 2011, 09:39:30 am
Pt-change(80,0,[FFFFFFFFFFFFFFF])
Pt-Change(88,0,[0022140814220000])

I think that would work

Hum, all I needed was Pt-Change(88,0,[0022140814220000])

Thanks, I had used Pt-On( before.
Title: Re: Simple Axe Questions
Post by: Happybobjr on March 26, 2011, 09:41:50 am
/me slaps himself awake.

Opps, thanks scout.
Title: Re: Simple Axe Questions
Post by: Munchor on March 26, 2011, 09:42:57 am
/me slaps himself awake.

Opps, thanks scout.

No! I have to thank you, you helped me :P
Title: Re: Simple Axe Questions
Post by: leafy on March 29, 2011, 02:46:34 am
How do you shift one row on the buffer to the right or the left? Just one row, not like horizontal whwere it shifts the entire screen.
Title: Re: Simple Axe Questions
Post by: Runer112 on March 29, 2011, 03:12:21 am
Not easily/efficiently in Axe code. I believe this would do it though. This can also be easily modified to work with buffers besides L6 if you need that.

Code: [Select]
.Example call
63sub(SRL)

.Shift Row Left
Lbl SRL
Asm(140140937DE6C0B4C02C7D87856F292909060C2BCB1610FBC9)

.Shift Row Right
Lbl SRR
Asm(140140937DE6C0B4C07D87856F292909060C2BCB1E10FBC9)