Author Topic: TI-Nspire emulator  (Read 329358 times)

0 Members and 3 Guests are viewing this topic.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: TI-Nspire emulator
« Reply #330 on: November 13, 2014, 01:06:54 pm »
I know, I tried to execute "r" and other commands but nothing happened. I'll try again with other CX flash images. It's strange that it seems to freeze with the CX boot1 while it just runs into an error with the classic boot1.
I'm pretty sure the flash images are correct (unless I should create them with another version of the emu on the pc side. I'm using the one from the latest prebuilt ndless sdk).
I have android 4.4.2 on my phone. It has a normal armv7 processor and much more RAM than needed.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: TI-Nspire emulator
« Reply #331 on: November 13, 2014, 03:16:07 pm »
I believe I found the issue:
In nspire_emu theres an array called addr_cache, which holds two values (read and write) for each 400 bytes of memory.
Each entry (For example, if you want to read at 18000020, its entry is addr_cache[(0x18000020 >> 10) << 1]) contains the following information:
-Pointer: If you add the address you want to access to the entry, bit 31 is clear and you can dereference the result directly
-Special entry: If you add the address you want to access to the entry, bit 31 is set
-MMIO: A special entry which (the entry itself, not the result of the addition) has bit 22 set
-Invalid entry: A special entry which has bit 22 clear.

The issue is, if the allocated memory is beyond 0x7CFFFFFF, you lose information and it crashes.
I expanded the entry format to 64 bits (but kept the bit positions!) and it works, except for rare occasions when the address itself has bit 31 already set!
So now I have to either:
-Fix the algorithm for computations
-Make a new format

This issue is also present on 32bit machines, but nspire_emu invoked VirtualAlloc with some parameter magic so it's always below 2GiB.
This "trick" also works on linux,  but not on mac.

I went for the latter, but it's slower, for now. I encode the 3 various kinds of entries in the lowest 2 bits.
Do you have a better suggestion?

I recompiled the App and it may work now, although I don't consider this as fixed.
I also solved the bug that you can't exit if the emulation thread enters an infinite loop (that's what happens if addr_cache overflows, what probably happened in your case).

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: TI-Nspire emulator
« Reply #332 on: November 13, 2014, 04:19:30 pm »
I can't think of a better solution that works in all cases...
Sounds like that was probably the problem with both errors for me, yes.
The directory is /sdcard/ on my phone instead of the /sdcard1/ in the current build, so I couldn't test if it's fixed.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: TI-Nspire emulator
« Reply #333 on: November 13, 2014, 04:49:10 pm »
Ok, I changed that: download

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: TI-Nspire emulator
« Reply #334 on: November 13, 2014, 05:51:22 pm »
Great! It really fixed everything, I could load a CX and a classic OS without any problems. Booting took about 2-3 minutes :)
The only thing that doesn't seem to work is the "Reset" menu entry, but that's a minor problem (actually not important at all as long as there's no input :P).
Oh, and the progress percentages are displayed after each other on a very long line instead of overwriting the old percentage as on the PC.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: TI-Nspire emulator
« Reply #335 on: November 13, 2014, 05:58:27 pm »
Quote
Great! It really fixed everything, I could load a CX and a classic OS without any problems. Booting took about 2-3 minutes
Same here. How much RAM do you have? Large or small NAND?

Quote
The only thing that doesn't seem to work is the "Reset" menu entry, but that's a minor problem (actually not important at all as long as there's no input ).
Not surprising, it's not implemented yet, like the file transfer and settings tabs.

Quote
Oh, and the progress percentages are displayed after each other on a very long line instead of overwriting the old percentage as on the PC.
That's a known bug, it's just appending the serial data to the QPlainTextEdit, '\b' and '\r' are ignored, like other ANSI escape sequences for colors.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: TI-Nspire emulator
« Reply #336 on: November 14, 2014, 03:00:00 pm »
Same here. How much RAM do you have? Large or small NAND?
3GB RAM. Large or small NAND didn't make a big difference I think (didn't measure the time exactly).

Quote
That's a known bug, it's just appending the serial data to the QPlainTextEdit, '\b' and '\r' are ignored, like other ANSI escape sequences for colors.
Ah ok. Well, it's not important anyway.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: TI-Nspire emulator
« Reply #337 on: November 14, 2014, 03:06:05 pm »
Same here. How much RAM do you have? Large or small NAND?
3GB RAM. Large or small NAND didn't make a big difference I think (didn't measure the time exactly).
I've got less than a tenth.. Not a surprise that it works with 132MiB NAND for you...

Quote
Quote
That's a known bug, it's just appending the serial data to the QPlainTextEdit, '\b' and '\r' are ignored, like other ANSI escape sequences for colors.
Ah ok. Well, it's not important anyway.
It's already fixed :P

Offline Legimet

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +29/-0
    • View Profile
Re: TI-Nspire emulator
« Reply #338 on: November 14, 2014, 09:23:36 pm »
Strange, I get an ICE trying to compile it with GCC 4.8.
Code: [Select]
../emu.c:206:8: internal compiler error: in update_ssa_across_abnormal_edges, at tree-inline.c:1853
  memset(rom, -1, 0x80000);
        ^

I'll check with the newer version of GCC on my Debian Jessie system and if it doesn't work, I'll report it.

EDIT: Also, you should add armcode_bin.h to .gitignore.
« Last Edit: November 14, 2014, 09:37:21 pm by Legimet »

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: TI-Nspire emulator
« Reply #339 on: November 15, 2014, 12:47:09 am »
Works for me with gcc 4.9, though it crashed clang now ("internal backend error" on linking emu.o)
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: TI-Nspire emulator
« Reply #340 on: November 15, 2014, 06:28:45 am »
Strange, I get an ICE trying to compile it with GCC 4.8.
Code: [Select]
../emu.c:206:8: internal compiler error: in update_ssa_across_abnormal_edges, at tree-inline.c:1853
  memset(rom, -1, 0x80000);
        ^

I'll check with the newer version of GCC on my Debian Jessie system and if it doesn't work, I'll report it.[/quote]
I compile on my openSUSE 13.2 64-bit system with
Code: [Select]
gcc version 4.8.3 20140627 [gcc-4_8-branch revision 212064] (SUSE Linux)and
Code: [Select]
clang version 3.5.0 (tags/RELEASE_350/final 216961)just fine.
I use
Code: [Select]
gcc version 4.9 20140827 (prerelease) (GCC)to compile for android and it works well.

Quote
EDIT: Also, you should add armcode_bin.h to .gitignore.
I kept it in the repo as it's a PITA on some platforms to make the header. On windows there are some $PATH issues and xxd not available and on Mac it's not possible to create a 32bit mach file from a binary.

Quote
Works for me with gcc 4.9, though it crashed clang now ("internal backend error" on linking emu.o)
Report that, I assume you use lld?
« Last Edit: November 15, 2014, 06:52:38 am by Vogtinator »

Offline Legimet

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +29/-0
    • View Profile
Re: TI-Nspire emulator
« Reply #341 on: November 16, 2014, 12:22:07 pm »
OK, it works fine with the GCC 4.9.something in Debian jessie.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: TI-Nspire emulator
« Reply #342 on: November 16, 2014, 02:30:28 pm »
Does it work? Any bugs?

Currently I'm trying to implement some touchpad input. Clicking works already (right mouse button on LCD), but the nspire's cursor does not appear somehow if you try to move it by holding the left mouse button while moving the mouse above the LCD, nothing happens. The velocity and contact values are correctly set like it's described in the wiki, but that doesn't seem to be enough. Does anyone have a clue?

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: TI-Nspire emulator
« Reply #343 on: November 16, 2014, 02:32:34 pm »
I haven't tried yet because I have no idea how to grab the ROM from my Nspire... TiLP doens't work :\
I'm not a nerd but I pretend:

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: TI-Nspire emulator
« Reply #344 on: November 16, 2014, 02:33:41 pm »
You can also download every ROM you'd ever want from tiplanet.org