No, it doesn't work. This is better:


Code:
:Repeat Ans
:getKey:If Ans
:Disp sub("ABC??DEFGHIJKLMNOPQRSTUVWXYZθ   .?",Ans-5iPart(.1Ans+4),1
:0:End


Edit: And I see you edited your code. Oh well. Smile
hey, I fixed it before you posted up your solution Razz

I'm wondering if _player1537 is writing a text-editing routine...
rthprog wrote:
hey, I fixed it before you posted up your solution Razz

I'm wondering if _player1537 is writing a text-editing routine...
I know you did, but I wrote my post last night and forgot to post it until this morning, at which point I saw your edit. Smile I bet _player1537 is indeed writing a text-editing routine.
lol, that wasn't what I was doing...but I might now

Anyways I was doing this for my programming GUI, so if you picked an "If" statement it would ask for the variable and you wouldn't have to press alpha then the variable.
Mouse Routine
This routine displays a mouse on the screen, gathers input to move it, and lets you draw anything in between without worrying about the mouse screwing it up. If A is set to one, a left click (2nd) occured, and if it is set to two, a right click (Alpha) occured. This is meant to be included in a loop, and getKey is stored to K at the beginning so you can use it. Additionally, the mouse coordanites are stored in LMOUSE so you can draw it yourself.


Code:
:While 1
:ClrDraw
:RecallPic 1
:getKey->K
:INSERT YOUR CODE HERE
:StorePic 1
:Insert your code to draw a mouse sprite here at LMOUSE(1), LMOUSE(2)
:K=21->A
:A+K=31->A
:LMOUSE(1)-K=24->LMOUSE(1
:LMOUSE(1)+K=26->LMOUSE(1
:LMOUSE(2)-K=35->LMOUSE(2
:LMOUSE(2)+K=25->LMOUSE(2
:End
Here's the same code, optimized and with several bugs fixed:


Code:
:31->A:45->B:Repeat K=21 or K=31
:ClrDraw
:RecallPic 1
:getKey->K
:INSERT YOUR CODE HERE
:StorePic 1
:Insert your code to draw a mouse sprite here at (A,B)=(row,col)
:A-(K=24)+(K=26->A
:B-(K=34)+(K=25->B
:End

Code:
:ClrDraw
:RecallPic 1


This is just begging to use xLib.

On a side note, I modified a project called xDCS a while back, and it does something similar. ( Get it here --> http://www.cemetech.net/programs/index.php?mode=file&path=/83plus/basic/programs/OPENxDCS.zip ) The mouse is accelerated, can be set to automatically snap to points on the screen, and (as with the original xDCS,) will draw windows, buttons, and such for you.


Here's a link to the original xDCS topic: (http://www.cemetech.net/forum/viewtopic.php?t=3595&highlight=xdcs)
8X8 Sprite to Hex


Inputs:
X- x position of sprite
Y- y position of sprite


Code:
"                                       .one space
For(A,0,15
Ans+sub("0123456789ABCDEF",sum(seq(2^(3-B)pxl-Test(Y+iPart(A/2),X+B+8fPart(A/2)),B,0,3))+1,1
End
sub(Ans,2,16


92 bytes assuming X and Y are 0.

edit: i just noticed the line is too large to be displayed correctly.. so as a note, there are only 5 lines in the actual program, even if 6 are displayed in the code box. lines 3 and 4 in the code box are meant to be one.
niemo wrote:
8X8 Sprite to Hex


Inputs:
X- x position of sprite
Y- y position of sprite


Code:
"                                       .one space
For(A,0,15
Ans+sub("0123456789ABCDEF",sum(seq(2^(3-B)pxl-Test(Y+iPart(A/2),X+B+8fPart(A/2)),B,0,3))+1,1
End
sub(Ans,2,16


92 bytes assuming X and Y are 0.

edit: i just noticed the line is too large to be displayed correctly.. so as a note, there are only 5 lines in the actual program, even if 6 are displayed in the code box. lines 3 and 4 in the code box are meant to be one.

What's B?
B is the variable used by seq()
niemo wrote:
B is the variable used by seq()


Ooops, didn't catch that. Never mind then.
rthprog wrote:
niemo wrote:
B is the variable used by seq()


Ooops, didn't catch that. Never mind then.
The optimizer in me wishes some of those closing parentheses could get lopped off, but that would require putting the seq( on a line by itself, and the sub needs Ans for itself. Smile
same with me kerm. you could probably modify it to get rid of 2^(3-B) and have that part as 2^B and modify the seq to pxl-test from right to left. i think that's more bytes, though. i'm unsure if my routine is the best though. i think it's just obfuscated.

half second faster, 20 bytes larger, ten times more neat:


Code:

" ->Str1      .1 space
"0123456789ABCDEF->Str2
For(A,0,7
sum(seq(2^(7-B)pxl-Test(A,B),B,0,7
Str1+sub(Str2,iPart(Ans/16)+1,1)+sub(Str2,16fPart(Ans/16)+1,1->Str1
End
sub(Ans,2,16
nemo wrote:
same with me Kerm. you could probably modify it to get rid of 2^(3-B) and have that part as 2^B and modify the seq to pxl-test from right to left. i think that's more bytes, though. i'm unsure if my routine is the best though. i think it's just obfuscated.
If only good sir Weregoose was here to offer his seal of approval or an alternative (cough, cough). I don't see anything you could do with the current code without making it longer though, so cheers on tight code, at any rate. It would have to be a conceptual change to make it smaller, imho.
i could only wish to optimize as well as Weregoose. the problem is you have to make 64 pxl-test()s, organizing them is the challenge. maybe you could make a program that reads each byte of the sprite rather than nibble.. i'm experimenting already.
edit: you would need an obnoxiously long string. i just realized.
nemo wrote:
i could only wish to optimize as well as Weregoose. the problem is you have to make 64 pxl-test()s, organizing them is the challenge. maybe you could make a program that reads each byte of the sprite rather than nibble.. i'm experimenting already.
edit: you would need an obnoxiously long string. i just realized.
True; you could generate the string on the fly, and cache it for multiple runs, but the 512-character string cost wouldn't be worth it, in my humble opinion. Smile
you actually don't need a large string. i edited two posts up and it shows some code that reads 8 pixels at a time. however, it uses two sub() calls Sad
Resistor Value to Color Code

This code turns an ohm value like 5700 in X into a color code value like 5,7,2 in A, B, C (57*10^2 ohms):

Code:
X/10^(int(log(X->A
int(10fPart(A->B
int(A->A
int(log(.1X->C
Check code speed

This code will test <code> to see how long it takes to execute. It will consistently return the same value for the same piece of code (as opposed to the other method that sometimes returns the same thing)


Code:
Starttimer->K
repeat Ans=2
checktimer(K
End
For(A,1,Iterations
<code>
End
Checktimer(K
(Ans-2)/Iterations
_player1537 wrote:
Check code speed

This code will test <code> to see how long it takes to execute. It will consistently return the same value for the same piece of code (as opposed to the other method that sometimes returns the same thing)


Code:
Starttimer->K
repeat Not(fpart(Ans
checktimer(K->B
End
For(A,1,Iterations
<code>
End
Checktimer(K
(Ans-B)/Iterations

Wouldn't you rather want to do:

Code:

repeat Ans
checktimer(K->B
End

so that it will actually wait until a second has started?

checkTmr as I said before doesn't use decimals, which is why it's inaccurate and needs an iteration method, along with after doing more than 500 iterations, plus or minus one fraction of a second doesn't mean almost anything.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3, 4, 5, 6 ... 13, 14, 15  Next
» View previous topic :: View next topic  
Page 5 of 15
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement