CEMETECH
Leading The Way To The Future
Login [Register]
Username:
Password:
Autologin:

Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 132 users online: 7 members, 94 guests and 31 bots.
Members: alanclem, HOMER-16, nsg, ordelore, PolandFun.
Bots: VoilaBot (2), Spinn3r (2), Magpie Crawler (4), VoilaBot (7), Googlebot (15), MSN/Bing (1).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
    » Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
» View previous topic :: View next topic  
Author Message
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55763
Location: Earth, Sol, Milky Way

Posted: 18 Feb 2010 09:47:05 am    Post subject:

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
_________________


Back to top
rthprog


Expert


Joined: 21 Sep 2007
Posts: 726
Location: Pittsburgh, PA

Posted: 18 Feb 2010 12:13:33 pm    Post subject:

hey, I fixed it before you posted up your solution Razz

I'm wondering if _player1537 is writing a text-editing routine...
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55763
Location: Earth, Sol, Milky Way

Posted: 18 Feb 2010 03:03:07 pm    Post subject:

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.
_________________


Back to top
_player1537


Guru-in-Training


Joined: 25 Nov 2009
Posts: 2958

Posted: 20 Feb 2010 07:54:16 pm    Post subject:

0x5, 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.
_________________
http://tanner.myserverathome.com
Back to top
SirCmpwn


Coding Knight


Joined: 06 Feb 2010
Posts: 1477
Location: Colorado Springs

Posted: 20 Feb 2010 08:48:46 pm    Post subject:

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

_________________
Drew "Sir Cmpwn" DeVault
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55763
Location: Earth, Sol, Milky Way

Posted: 20 Feb 2010 10:27:26 pm    Post subject:

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

_________________


Back to top
rthprog


Expert


Joined: 21 Sep 2007
Posts: 726
Location: Pittsburgh, PA

Posted: 21 Feb 2010 07:57:24 pm    Post subject:


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)
Back to top
nemo


Newbie


Joined: 17 Jun 2010
Posts: 27

Posted: 28 Jun 2010 02:22:33 pm    Post subject: 8X8 sprite to hex

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.
Back to top
rthprog


Expert


Joined: 21 Sep 2007
Posts: 726
Location: Pittsburgh, PA

Posted: 28 Jun 2010 02:25:50 pm    Post subject: Re: 8X8 sprite to hex

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?
Back to top
nemo


Newbie


Joined: 17 Jun 2010
Posts: 27

Posted: 28 Jun 2010 02:26:56 pm    Post subject:

B is the variable used by seq()
Back to top
rthprog


Expert


Joined: 21 Sep 2007
Posts: 726
Location: Pittsburgh, PA

Posted: 28 Jun 2010 02:27:20 pm    Post subject:

niemo wrote:
B is the variable used by seq()


Ooops, didn't catch that. Never mind then.
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55763
Location: Earth, Sol, Milky Way

Posted: 28 Jun 2010 02:40:34 pm    Post subject:

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
_________________


Back to top
nemo


Newbie


Joined: 17 Jun 2010
Posts: 27

Posted: 28 Jun 2010 02:49:38 pm    Post subject:

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


Last edited by nemo on 28 Jun 2010 03:20:28 pm; edited 1 time in total
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55763
Location: Earth, Sol, Milky Way

Posted: 28 Jun 2010 02:52:16 pm    Post subject:

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.
_________________


Back to top
nemo


Newbie


Joined: 17 Jun 2010
Posts: 27

Posted: 28 Jun 2010 03:00:35 pm    Post subject:

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.
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55763
Location: Earth, Sol, Milky Way

Posted: 28 Jun 2010 03:23:43 pm    Post subject:

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
_________________


Back to top
nemo


Newbie


Joined: 17 Jun 2010
Posts: 27

Posted: 28 Jun 2010 03:28:47 pm    Post subject:

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
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55763
Location: Earth, Sol, Milky Way

Posted: 15 Sep 2010 09:36:38 pm    Post subject:

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

_________________


Back to top
_player1537


Guru-in-Training


Joined: 25 Nov 2009
Posts: 2958

Posted: 22 Sep 2010 07:39:34 pm    Post subject:

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

_________________
http://tanner.myserverathome.com


Last edited by _player1537 on 22 Sep 2010 07:46:17 pm; edited 1 time in total
Back to top
MufinMcFlufin


Advanced Member


Joined: 29 Aug 2009
Posts: 252
Location: C:\Users\Admin\Desktop

Posted: 22 Sep 2010 07:43:02 pm    Post subject:

_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.
Back to top
Display posts from previous:   
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, 7, 8, 9, 10  Next
» View previous topic :: View next topic  
Page 5 of 10 » All times are GMT - 5 Hours

 
Jump to:  
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

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.045911 seconds.