Author Topic: nCraft (3D minecraft-like game for the nspire)  (Read 115953 times)

0 Members and 1 Guest are viewing this topic.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: Some 3D with Ndless...
« Reply #75 on: April 28, 2012, 07:15:53 pm »
Hello everybody !

I have problems with color support, and I would need your help...
I have to change my buffer from uint8_t* to void*.

But in a function to change a pixel, I have to cast a void* value to an uint8_t if the screen is in 4 bpp mode.
So I tried :
Code: [Select]
function setPixel(void *buffer,int x,int y,int color)
{
    //...
    uint8_t px=*((uint8_t *)buffer[pos])     //pos is an int
    //...
}
But gcc does not like that... What should I do instead?

A function doesn't have a "function" in front of its name, although I'm not sure you wrote it in your code like that.

For the cast, try this:
Code: [Select]
uint8_t px=(((uint8_t *)buffer)[pos]);
If you write a * in front of it and a [] at the end, you're dereferencing the pointer twice, the * is wrong here.
I'm not sure if you need the parentheses around "(uint8_t*)buffer", but they certainly don't do any harm.

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: Some 3D with Ndless...
« Reply #76 on: April 29, 2012, 05:01:30 am »
Oh yeah, small confusion with  Lua :)
(Obviously, I did not write that in my code)

But this doesn't work either...
GCC says :
buffer.c:19:35: warning : dereferencing ‘void *’ pointer [enabled by default]
buffer.c:19:5: error : invalid use of void expression

EDIT : Anyway, I found another way to do this (I just copied the setPixel function in particles, the ndless sample)
« Last Edit: April 29, 2012, 05:18:50 am by Chockosta »

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: Some 3D with Ndless...
« Reply #77 on: April 29, 2012, 07:26:03 am »
I tested it with an older x86 gcc and it worked...
But I'm glad you found another solution :)

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: Some 3D with Ndless...
« Reply #78 on: April 29, 2012, 08:23:33 am »
So, CX compatibility should be okay, but for random reasons it keep crashing when I open it with the emulator...
I really do not understand.

The CX emulator works fine, I can run other programs that I compiled.
But it doesn't seem that the error comes from the code, since it runs perfectly on non-CX emulator.
I have no clue...

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Some 3D with Ndless...
« Reply #79 on: April 29, 2012, 11:07:56 am »
So, CX compatibility should be okay, but for random reasons it keep crashing when I open it with the emulator...
I really do not understand.

The CX emulator works fine, I can run other programs that I compiled.
But it doesn't seem that the error comes from the code, since it runs perfectly on non-CX emulator.
I have no clue...

When it crashes, does it say something, like bad write word at 0x..... or it just Resets ?
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: Some 3D with Ndless...
« Reply #80 on: April 29, 2012, 11:14:41 am »
When I enter "c" in the bebugger, I get :
"Warning at PC=114DA7EC: Bad read_word: 900d000c"...
Maybe a malloc failed ?

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Some 3D with Ndless...
« Reply #81 on: April 29, 2012, 11:21:32 am »
No, this is normal. On emulator I haven't been able to edit (write) neither timer 1, timer 2 nor RTC.
It appears that, for the RTC, it is synchronized with the real time of the computer and you can't edit it. I don't know for the timer 1 and timer 2, maybe the same story.
« Last Edit: April 29, 2012, 11:22:31 am by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Some 3D with Ndless...
« Reply #82 on: April 29, 2012, 11:42:42 am »
The timers work, but they are a different module on the Nspire CX than on the original Nspire. The list of registers is here, and as you can see, Base+0x0C is a write-only register.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Some 3D with Ndless...
« Reply #83 on: April 29, 2012, 02:11:44 pm »
Does it work perfectly on calc, though? Sometimes emulators do not emulate stuff 100% accurately.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Some 3D with Ndless...
« Reply #84 on: April 29, 2012, 02:36:18 pm »
It wouldn't work oncalc either because it has been programmed using only the classic Nspire timers. The CX timers have to be programmed differently.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: Some 3D with Ndless...
« Reply #85 on: April 29, 2012, 02:38:47 pm »
I never tested any of my ndless programs on calc...
Actually, I don't have ndless on my calc. (Or else I would be too tempted to play in class :) )

So I hope that it will work like in nspire_emu...
« Last Edit: April 29, 2012, 02:42:05 pm by Chockosta »

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: Some 3D with Ndless...
« Reply #86 on: April 30, 2012, 01:32:17 pm »
Thanks for your link, calc84maniac, but I still have problems.
According to this, the timer value address should be 0x900D0004, right ?

But the value at 0x900D0004 is 0 and doesn't change...

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: Some 3D with Ndless...
« Reply #87 on: May 01, 2012, 01:08:42 pm »
(Sorry for the triple post...)

By the way, even if I can't use the timers, the color display works great.
Here is some eye-candy...
(In the first picture, you can see iron, gold and diamond, and in the second one, there is pretty much every block I added :) )

Offline AzNg0d1030

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 522
  • Rating: +45/-4
  • Hardcore anime watcher.
    • View Profile
Re: Some 3D with Ndless...
« Reply #88 on: May 01, 2012, 05:42:13 pm »
Ohohoho, the triple post is fine when you need to make us see THESE BEAUTIFUL PICTURES! :D
Try to not triple in such a short time though :P
You just lost the game.



Offline annoyingcalc

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1953
  • Rating: +140/-72
  • Found in Eclipse.exe
    • View Profile
Re: Some 3D with Ndless...
« Reply #89 on: May 03, 2012, 06:56:50 pm »
(Sorry for the triple post...)

By the way, even if I can't use the timers, the color display works great.
Here is some eye-candy...
(In the first picture, you can see iron, gold and diamond, and in the second one, there is pretty much every block I added :) )
WOW! I cant wait for more updates
This used to contain a signature.