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 - Jim Bauwens

Pages: 1 ... 8 9 [10] 11 12 ... 125
136
Lua / Re: Ti-Nspire: Changing menu items dynamically?
« on: July 22, 2013, 10:06:18 am »
Just re-register the menu.

For example:
Code: [Select]
function swap()
    menu[1], menu[2] = menu[2], menu[1]
    toolpalette.register(menu)
end

menu = {
 
    {"Analysis",                 
       {"Decimal", print},         
       {"Hexadecimal", print},
       {"Octal", print},
       {"Binary", print},
       {"Signed", print},
       {"Unsigned", print},
    },
    {"Boolean",
       {"And", print},
       {"Or", print},
       {"XOr", print},
       {"Not", print},
    },
    {"Toggle",
       {"Swap menu", swap}     
    }
 
}

function on.construction()
    toolpalette.register(menu)
end

When clicking on swap, the first two menus will always be swapped. Silly example, but it shows that you dynamically can change the menu items.

137
General Calculator Help / Re: Help Needed with NSpire CM and nLaunch
« on: July 19, 2013, 05:38:25 am »
Judging the latest news, it seems they have made a port of nLaunch to the CM, and unbricked his calculator. However, he managed to brick it even more now; the boot1 refuses to boot. This means that the only solution would be to use JTAG..

138
News / Re: Release of FormulaPro for the Nspire
« on: July 18, 2013, 04:39:27 am »
Use the link http://education.bwns.be/FormulaPro/eepro.html and then manually remove the units you don't want. I don't have the time to do this for you. Maybe in the future EEPro will support the ability to select your units.

139
Lua / Re: iNote 2E
« on: July 01, 2013, 08:58:53 am »
Hello imath! First of all I'm really happy you decided to join the site here :) I've seen your work before and most of it looks really very good.
iNote 2E is also looking very impressive and I'll definitely check it out soon.

140
Calculator C / Re: We MUST port that to Ndless
« on: June 26, 2013, 09:21:42 am »
Would you be able to describe precisely how it works ?

I suppose, but if you stare long enough at the code you will see that it isn't so complex.

Alright, for those who are interested here is my Lua code
Code: [Select]
local reg  = {}
local wormImg
local width, height

local wormTexture = {
0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,
0x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F53,0x3F53,0x3F53,0x7fab,
0x7fab,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x3F53,0x7fab,
0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab,0x7fab
}


function on.construction()
  width = 338/2
  height = 212/2
  wormImg = {}
 
  local tsize = 15
  local width, height = width, height
  local wormImg = wormImg

  local SPOKES = 1200
  local spokeCalc = {}
  local spokeCosCalc = {}
  local spokeSinCalc = {}

  local x,y,z
  local divCalcX,divCalcY = 0,0
  local sin, cos, log, floor = math.sin, math.cos, math.log, math.floor

  local XCENTER = floor(width/2)
  local YCENTER = floor(height/2 - height/4)
  local DIVS = SPOKES/2

  for i=1, SPOKES do
    local n = 2*math.pi*i/SPOKES
    spokeCalc[i] = n
    spokeCosCalc[i] = cos(n)
    spokeSinCalc[i] = sin(n)
  end
 
  local incW = width/DIVS
  local incH = height/DIVS
 
  for j=1, SPOKES, 2 do
    z = log(j/DIVS)*25-25
    divCalcX = divCalcX + incW
    divCalcY = divCalcY + incH
    for i=1, SPOKES do
      x = floor(divCalcX*spokeCosCalc[i]) + XCENTER
      y = floor(divCalcY*spokeSinCalc[i]  - z ) + YCENTER

      if x>=0 and x<=width and y>=0 and y<=height then
        if not wormImg[y] then wormImg[y] = {} end
        wormImg[y][x] = 1 + floor(i/8)%tsize + tsize*(floor(j/12)%tsize)
      end
    end
  end
 
  timer.start(0.05)
end

local function shiftup()
    local wormTexture = wormTexture
    local reg=reg
   
    for k=1, 15 do
      reg[k]=wormTexture[k]
    end
    for k=16, 15*15  do
      wormTexture[k-15]=wormTexture[k] -- +1 for C to Lua
    end
    for k=1,15 do
      wormTexture[k+210]=reg[k]
    end
end

local function shiftright()
    local wormTexture = wormTexture
    local last
   
    for k=0, 14 do
      last=wormTexture[15*k+15]
      for i=15, 2, -1 do
        wormTexture[15*k+i]=wormTexture[15*k+(i-1)]
      end
      wormTexture[15*k + 1]=last
    end
end

--count=0
function on.paint(gc)
  local wormTexture = wormTexture
  local wormImg = wormImg
  local height, width= height-1, width-1
  local pos=0
  for y=0, height do
    local yy=wormImg[y]
    for x=0, width do
        pos=pos+1
        gc:setColorRGB(wormTexture[yy[x]])
        gc:fillRect(x*2, y*2, 2, 2)
        --gc:fillRect(x, y, 1, 1)
    end
  end
  --count=count+1
  --gc:setColorRGB(0xFF00FF)
  --gc:drawString(""..count, 100, 100, "top")
end

function on.timer()
  shiftup()
  shiftright()
 
  platform.window:invalidate()
end

I halved the resolution and amount of spokes so that it actually can run on your handheld. Of course speed will not be awesome, but it does run. Keep in mind that launching takes some time (as it then generates the swirl 'lookup' image).

Also, I changed and removed parts that aren't necessary for it to run. For example I completely removed wormTexture2 as that's only need for smooth transition to another texture and wormEffect because there is no reason in storing it.

Now, if TI only would give us some proper way to have a graphics buffer, this could run at a very decent speed :P

141
Calculator C / Re: We MUST port that to Ndless
« on: June 25, 2013, 06:36:20 pm »
You already ported it? O.O

But why is there the border at the top of the screen? ??? Is it in Lua instead of C++? How fast does it run btw?

Also if someone made a vid of calc demos, the following song would fit really well :P


As I mentioned, I ported it to Lua ^^
I havent tested it on a handheld, but I presume very slow.

142
Calculator C / Re: We MUST port that to Ndless
« on: June 25, 2013, 06:11:56 pm »
Look here how cute :P



Now I just need to see if I can speed it up so it works decent on calc (since it's Lua) ^^

143
Calculator C / Re: We MUST port that to Ndless
« on: June 25, 2013, 05:37:43 pm »
I've ported most of the code the Lua and it seems to be working almost properly in the student software. (It probably will be very very slow on calc ;P). However, the code (of the original) it very unoptimized and the person porting it to the Nspire C should really rewrite some of it :) I'm already changing a lot in my Lua port ^^

Btw, it uses 15x15 textures.

144
Actually, Lua is an interpreted language. If the script isn't already bytecode, it will 'compile' it to Lua bytecode, to then be interpreted by the Lua VM. On the Nspire you can't have scripts that are already bytecode so the conversion happens at launch. That means launch time might slow down, but for the rest of the run time it will be running Lua bytecode (unless you use loadstring).

145
TI-Nspire / Re: [Ndless C] nRayC, a raycasting library for TI-Nspire
« on: June 22, 2013, 05:13:50 pm »
Take a look here: http://www.codeproject.com/Articles/570700/SquareplusRootplusalgorithmplusforplusC

It's more complex, but I think it will be faster (better algorithm).

146
News / C++ on the TI-Nspire
« on: June 16, 2013, 04:34:09 pm »
ExtendeD is still working on Ndless, and has just solved technical issues that prevented C++ support from being implemented in Ndless.
Here you go for a brand new version of Ndless :)

The first C++ programs for Nspire have been coded by tangrs a while ago, but the issue was that elf2flt was not handling some relocations with recent GCC versions for ARM. This caused issues with hoffa's nSDL, and was reducing the number of programs you could port for the Nspire.

Now that the issue has been identified, ExtendeD patched elf2flt and published :


Here's a preview of the new features of a direct port (with small changes to adapt to the platform itself, like keyboard, resolution...) showing what c++ with nSDL can provide, with a quick  port of Advanced Tetris by GDO, by Extended :


Have fun with Ndless, even if TI tries to prevent us from opening the Nspire - they have more to lose than we do :)




Source and downloads: http://ndlessly.wordpress.com/2013/06/15/cpp-for-the-ti-nspire/ & ExtendeD for tip

Cross posted from TI-Planet

147
TI-BASIC / Re: Can StorePic damage Flash ROM? (84+CSE)
« on: June 02, 2013, 12:32:29 pm »
An ASM lib to StorePic to extra RAM would definitively be nice, even if just a few pics. In my case, I was wondering, because in Zelda I would like to speed up map display by storing the generic map stuff into a pic for future display, but I would have to recall the pic everytime Link moves to a new room.

Recalling the pic shouldn't wear out the Flash ROM as far as I know. It's the writing that would be the problem. So if you don't have to constantly store the screen there shouldn't be a problem.

148
Lua / Re: [Library] Compress
« on: June 01, 2013, 04:40:45 pm »
Very interesting!

I've creating a little RLE algorithm for TI.Image some time ago, but I never really used it because it was too slow to my likings. I'll definitely check this out (and look if I can help with optimizations) when I get some time after my exams ^^

Many thanks :)

149
TI-BASIC / Re: My z80 basic palprime algorithm
« on: May 14, 2013, 03:04:25 pm »
So I tested yours and I got 21 seconds for the 42nd prime palindrome.
Strange, I just tried it again and I get 16s on my TI-84 Plus. (not sure what OS version actually). I've attached my program to this post, could you time that (in case something is different in tokens)?



Compared to mine, yours is 53 bytes less, too. You have a bunch of places that can be optimised for speed, though, so I tried a few things and here is what I have:
First, here are the main optimisations I made:
Code: [Select]
:If prod(Ans-{1,3,7,9
     Goes to:
:If 1<gcd(10,Ans           ;I actually used 'not equal', but this works, too

:If fPart(F/3
     Goes to:
:If remainder(F,3

:While Ans{^2}≤F and fPart(F/Ans) and fPart(F/(Ans+2
     Goes to:
:While Ans{^2}≤F and min(remainder(F,{Ans,Ans+2
There are a few more, too, but here is what I ended up with:
Code: [Select]
:DelVar EAns-5→N
:While 1
:E+1→E
:1+int(log(E→B
:If 1<gcd(10,int(E10^(1-Ans
:End
:10E→F
:E→D
:While iPart(D
:.1iPart(D→D
:10(F+fPart(Ans→F
:End
:For(H,0,9
:If remainder(F,3
:Then
:√(F→D
:7
:While Ans≤D and min(remainder(F,{Ans,Ans+4
:Ans+6
:End
:N-(Ans>D→N
:If not(Ans
:Return
:End
:End
:F+10^(B→F
:End
:End
Now it takes about 17 seconds to compute the 42nd prime palindrome and it is 24 bytes smaller :)
Hah, nice optimisations!  It's always fun when you still can make such a big difference by little code changes :)

Quote
I have been trying to tweak it to get it even faster and I know that there must be a few optimisations that I am not seeing. It is 77 bytes smaller than mine and almost as fast, so that is really awesome.

...

After adjusting the prime checker thing even more, I made it much faster, and it is now faster than mine, at the cost of some bytes (still 59 bytes smaller than mine). For comparison, the version above takes 17 seconds to find palprime 42 and 86 seconds for palprime 100. This version takes 13 and 52 seconds, respectively.
Code: [Select]
:DelVar EAns-5→N
:While 1
:E+1→E
:1+int(log(E→B
:If 1<gcd(10,int(E10^(1-Ans
:End
:10E→F
:E→D
:While iPart(D
:.1iPart(D→D
:10(F+fPart(Ans→F
:End
:For(H,0,9
:If min(remainder(F,{3,7,11
:Then
:√(F→D
:13
:While Ans≤D and min(remainder(F,Ans+{0,4,6,10,16,18,24,28
:Ans+30
:End
:N-(Ans>D→N
:If not(Ans
:Return
:End
:End
:F+10^(B→F
:End
:End
Hopefully everything is typed properly.
EDIT: Made it even faster. Now 12 and 49 seconds respectively, using the same prime checking routine as my program.

Hah, cool! I actually changed my Nspire version to use 30 but reverted the change because it became slower for larger numbers (although faster for smaller numbers). But didn't try it in my z80 version.

Anyway thanks Xeda for looking into my code!

150
TI-BASIC / My z80 basic palprime algorithm
« on: May 13, 2013, 03:46:54 pm »
While I only participated in the TI-Nspire section for the palprime contest, I made a z80 basic version too (which I did not enter). It's my first basic program for z80 based calculators.
It finds the 42nd palprime in 16 seconds (TI-84 Plus)

Here is the code
Code: [Select]
:Ans→N    --- find the AnsTh palprime
:5→A
:0→E
:While 1
:E+1→E
:1+int(log(Ans→B
:int(E10^(1-Ans
:If prod(Ans-{1,3,7,9
:End
:E10^(B+1→F
:E
:For(G,B,1,{-}1
:.1Ans→D
:F+fPart(Ans)10^(G→F
:int(D
:End
:10^(B→P
:For(H,0,9
:If fPart(F/3:Then
:5
:While Ans{^2}≤F and fPart(F/Ans) and fPart(F/(Ans+2
:Ans+6
:End
:If Ans{^2}>F
:Then
:A+1→A
:If A=N:Stop
:End
:End
:F+P→F
:End
:End
The result will be stored in F.

Beware I'm using some end tokens to quickly jump again to the start of the loop, so there is start/end of block 'mismatching' ;P.
While I'm not really going to continue this I'd like to know if I still can optimise it more (the code, not the algorithm)^^

Edit: I forgot, it can not find the first 5 palprimes, not implemented because I was first focusing on the algorithm

Pages: 1 ... 8 9 [10] 11 12 ... 125