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.


Topics - NecroBumpist

Pages: [1]
1
TI-Nspire / [Lua] Speedcubing Timer
« on: December 20, 2011, 10:33:43 pm »
Hey guys, it's been a while since I've contributed anything here, but over the last week I had some free time.
Last week I took 8 different finals, and in the time after the tests I spent crafting a tool to help me with a new passion of mine.

Speed cubing, or the process of competitively solving a Rubik's cube.

At first I included a simple timer, that was originally measured in milliseconds, but after further work I formatted the time into a 00:00.00 format and added a list of previous times, automagic saving, and statistic keeping (best, total average, average of 10, soon to be median 3 of 5 and 10 of 12)

So, the controls:
Enter: Start/stop the timer
"Y"/"N": After stopping the timer you have the option whether or not to add it to the list of times, the options should be obvious
"D": Clears the current list of times
"S"/"R": Saves/Recalls one saved list of times

Since I wrote this on calc, and not with the assistance of an emulator, I have no screenshots for you, but here's the code (hopefully it works after transcribing it from my calc)

I'll probably add new features here as I make them.
Note: You can just compile this with luna or something and run it on calc.

So if any of you guys are cubers, maybe you'll use this to practice when you can't access a computer  :)

Code: (lua) [Select]
tn, msg = 0, "";
t, n, aa, a10, b = 0, 0, 0, 0, 0
save = false
times = {};

function a()
local min, avg10, avga = 2^32, 0, 0
for i = 1, tn do
local v = times[i]
if v < min then
min = v
end
if i <= 10 then
avg10 = avg10 + v
end
avga = avga + v
end
b = min
aa = math.floor(avga/tn)
a10 = math.floor(avg10 / math.min(tn, 10))
end

function f(t)
return ("%02d:%02d.%02d"):format(t/60000, t/1000%60, t/10%100)
end

function on.paint(g)
if c then
t = (timer.getMilliSecCounter() - n)
end
g:drawString("time: " .. f(t), 0, 0, "top");
g:drawString(msg, 0, 20, "top");
g:drawString("best:              " .. f(b), 150, 0, "top");
g:drawString("average (10): " .. f(a10), 150, 20, "top");
g:drawString("average (all): " .. f(aa), 150, 40, "top");
for i = 1, 8 do
local v = times[i];
if not v then break end
g:drawString(i .. ")      " .. f(v), 0, 20+i*20, "top")
end
timer.start(0.01);
end

function on.timer()
timer.stop()
platform.window:invalidate()
end

function on.charIn(c)
if save then
save = false
msg = ""
if c == "y" then
table.insert(times, 1, t)
tn = tn + 1
a()
on.charIn("s")
end
end
if c == "d" then
t = 0
times = {};
tn = 0;
msg = "";
a();
elseif c == "s" then
local s = "" .. tn
msg = "saved"
for i = 1, tn do
s = s .. " " .. times[i]
end
var.store("cube_times", s .. " ");
elseif c == "r" then
local s, b , n = var.recall("cube_times") or "0 ", {}, 0;
msg = "loaded";
for w in s:gmatch("%d+%s") do
n = n + 1;
b[n] = tonumber(w);
end
tn = table.remove(b, 1);
times = b;
a();
end
end

function on.enterKey()
 if save then
 save = false
msg = ""
return
end
if c then
save = true;
msg = "save? (y/n)";
c = nil;
else
c = true;
msg = "";
n = timer.getMilliSecCounter();
end
end

on.charIn("r")


2
Other Calc-Related Projects and Ideas / The Necrotorium
« on: October 11, 2011, 11:58:21 pm »
This my 100th post here on Omnimaga, so I might as well make it significant. Not much to show for it except goals, but I want to be able to post again already.

The Necrotorium will be a repository of all of my calculator related projects, jumbled up into one thread.
Because I like the version control integration my IDE has with Github, I will distribute all of my files from there, instead of attaching them to new posts like the Axe Parser project. However, I will make a new posts for worthy updates listing important information to keep everyone informed.

So, what will the Necrotorium include ?
Well I'll quote the README from the Github located here

Quote from: Github README
Projects In The Works:
- nGfx (NSpire Graphics)
    I hope to create a whole new level of abstraction for creating games on the TI-Nspire.
    This will be facilitated by designing a simple language that compiles to Lua, hopefully
    taking away all of the complexities of getting a good UI in order.
- Lua IDE
    I'm working on a simple IDE that will allow you to code in Lua on calc, easily run it,
    save / load code, and remap the keypad to allow easy access to some symbols.
    I might attempt syntax highlighting in the future, though I am without a CX, so this is
    not an immediate priority.
- Bitmap2Img
    A script that when completed, will convert uncompressed bitmap images to the
    ti.image format.

These are the main projects I've taken interest to recently.
Particularly nGfx. I have the sudden urge to take another stab at writing a compiler, so I'd like to try that here.

Now that I've gotten this out of the way, I will begin writing portions of nGfx, and will soon have code examples (which will be open to drastic changes).

I would love to see collaboration in the future when I've outlined a much more solid direction for these projects to head towards.

Spoiler For Title:
The title is derived from my name "NecroBumpist" and the word "Repositorium"

3
Computer Programming / The Best Linkers
« on: October 09, 2011, 04:43:14 pm »
I am using assembly, but this question about linking in general, so this section seems the most low-level and appropriate.

I've dabbled with assembly a few times before, but one problem that always bugged me is the linker I used.
I already had MinGW installed, so I just used GCC to link my object files, however this always created huge, bloated files.
I suspect this is from including crap I don't need, but I have no idea how to disable this.

So, what suggestions would you guys make for a Win7 x86/x64 Linker, that is either non bloaty like GCC, or it is easy to disable all this bloat.

Tips for disabling GCC's bloat are accepted as well.

Note: I'm using NASM as my assembler.

4
Lua / Oh Nspire-Lua, you so crazy!
« on: October 08, 2011, 05:41:25 pm »
I was trying to make a Lua IDE when i came across this bug with text rendering.
Keep in mind this happens much faster in real time.

Spoiler For probable cause:
The negative symbol is what I'm typing, and it is likely a two byte character, however, when I backspace, I only remove one byte at a time, and this causes it to read whatever comes after the string in RAM I'm assuming.

5
Miscellaneous / Weetabix Cereal Is One Hell of a Drug
« on: September 30, 2011, 09:47:38 pm »


What are your opinions of this commercial ;) ?
I'm personally rather surprised by hearing Dubstep in a commercial.

6
General Calculator Help / TI-NSpire Testing Woes
« on: September 30, 2011, 08:12:01 pm »
I'm trying to start development for a TI-Nspire (Touch pad) game, but I need to be able to test things!

Okay, my trial license for TI-Student software expired a few days ago, and I can't find any thing in what remaining portions of the original packaging I have (I can't even recall if there was a license included).

I have also spent hours trying to get TiLP to work, but to no avail.

My last hope is nspire_emu (not sure how I'd get files to this though)
Where can I find the imagedump.exe required to decompress the boot2 image as mentioned by Hackspire

EDIT:
I got a copy of imagedump.exe, but now I need help getting OS 3.0.2 or 3.1.0 working.
I've read around, but I still don't quite understand patching an OS >3.0.2

Could someone please help me out with step-by-step instructions please :) ?

DOUBLE EDIT:
Finally got OS 3.0.1 working.
Here's the instructions for anyone else struggling to get OS 3 working on nspire_emu
Spoiler For Spoiler:
  • Download nspire_emu 053 here
  • Download imgdump.exe here
  • Download OS 2.0.1 here (CAS)
  • Download OS 3.0.1 here (CAS, CX, CX CAS) (I don't think nspire_emu works with CX, but I've included links anyway)
  • Download TNOC here
  • Unzip TNOC and use it to remove the boot2 image from OS 3.0.1 (go ahead and remove the examples if you want to free up more space)
  • Use WinRAR / 7zip to open the OS 2.0.1 file as an archive, and copy the boot2.img file outside of the archive
  • Open command prompt, navigate to the directory where you saved everything, and then type the following commands
    • imgdump.exe boot2.img (this will create a boot2.img.raw file)
    • nspire_emu.exe /N /F=flash.bin /PO=<OS Name> (substitute your OS 3.0.1 name here (don't forget the file extension) & Add the flag "/C" if you're using CAS)
    • nspire_emu.exe /B=boot2.img.raw /F=flash.bin (This will start the emulator. Add the "/C" flag if you're using CAS, and any other parameters, like keyboard type)
Have fun :)

7
Miscellaneous / Taylor Mali - God Tier Poet
« on: August 28, 2011, 01:35:01 am »
So, I somehow was linked to one of Taylor Mali's poetry videos on youtube, and I was absolutely hooked.
I think he's amazing, but I want to hear what you guys think :)

here's a list of some of his videos I've watched on youtube:

Spoiler For Spoiler:












8
Computer Projects and Ideas / LuaSrcDiet
« on: August 21, 2011, 12:51:13 pm »
NOTE: I did not make this, but since the NSpire does not have gigabytes of memory, I though I would share it with you guys

LuaSrcDiet

I found this project a while back (It's made by the author of ANoFrillsIntroToLua51VMInstructions.pdf), and I think it could be of use for NSpire Lua developers.

Basically, what it does is it removes as much unnecessary information as possible.
This means removing whitespace, comments, and renaming/reusing variables whenever possible.

I just used it again on a script of mine that was 38,513 bytes long.
It outputted a file 21,899 bytes long.
That's a 41% reduction

Everything should run the same. (Though if you have an error it might be harder to figure out which variable it was really from)

So if you're looking to save space in large projects of yours, you might want to give this a try :)

9
Welp, I am in need of more posts before I can join the IRC apparently, so I will introduce you all to a project I'm working on :)

Since Lua is currently the fastest programming language for up-to-date NSpire calculators, I thought I would share this relevant project.
This really is for those who want to get the absolute most out of Lua. It's very impractical to write an entire program from Lua assembly, since the compiler does a decent job for most non-time-critical functions.

Lua is actually a semi-compiled language (at least that's what I'm going to call it).
It is compiled to bytecode, and than interpreted dynamically on a virtual machine.

You can execute Lua bytecode directly in Lua with the loadstring() function.

Code: (Example 1) [Select]
loadstring("\27\76\117\97\81\0\1\4\4\4\8\0\56\0\0\0\64\67\58\47\85\115\101\114\115\47\74\97\115\111\110\47\68\111\99\117\109\101\110\116\115\47\80\114\111\103\114\97\109\109\105\110\103\47\76\117\97\47\77\79\68\83\47\116\101\115\116\46\108\117\97\0\13\0\0\0\13\0\0\0\0\0\0\2\1\0\0\0\30\0\128\0\0\0\0\0\0\0\0\0\1\0\0\0\13\0\0\0\0\0\0\0\0\0\0\0")();

Now I'd go over the bytecode format, but you can learn all of that here
This document also includes all of the information on all of the instructions to the Lua VM.

Now, onto the project.
(In retrospect, the name I chose was rather silly, but meh, it applies)

Basically, it includes the following:
  • An assembler for a custom syntax of my own design (feature ridden)
  • Something I would call a Linker, that takes a table of all the relevant information, and compiles it into Lua bytecode
  • Soon to be a disassembler, which will turn a normal Lua function into Lua assembly.

You can find the repository here: https://github.com/NecroBumpist/MODS

So, time for "Hello World!" in Lua assembly
Code: [Select]
local mods = require("MODS.Current.main");
local bytecode = mods.Assemble(
[[
; Hello_World.lasm
.options 0, 0, 0, 2        ; a directive, which sets some properties, the '2' meaning MaxStackSize

getglobal    0,    <'print'>        ; <> denotes a constant, i've yet to bother with a directive for doing constants
loadk        1,    <'Hello World!'> ; The LuaVM is register based, we put the function in one register, then arguments above it
call         0,    2,    1          ; now we call register 0, with (2-1) parameters, accepting (1-1) values back
return       0,    0                ; and now we return
]]);

loadstring(bytecode)() -- turns the bytecode into a function, then we call that function

>Hello World!


So,  I'd like to hear what some of you Lua users who are looking for speed improvements think :)
I plan on updating the repository soon to include:
  • Write some proper documentation
  • Updates to the assembler to include NASM like Macros (debugging right now)

In ten or twenty minutes the repository should be much cleaner ;)

Comments, questions, or concerns ? Or Lua Assembly general thread.

10
Introduce Yourself! / Greetings Omnimaga!
« on: August 18, 2011, 05:02:17 pm »
Hello everyone!

I'm so excited to finally join this forum.
I've always been crazy for Lua, and when I read that TI now allows Lua on the NSpire I knew I just had to join!
I'm a total optimization freak, so in other games I would even go so far as to program time critical subroutines in Lua assembly, something I'm eager to test on the NSpire.

I can't wait to see what great things come of Omnimaga :)

(P.S. How is omnimaga pronounced?)

Pages: [1]