Author Topic: [Nspire C] Zombie Chase  (Read 14981 times)

0 Members and 1 Guest are viewing this topic.

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
[Nspire C] Zombie Chase
« on: May 20, 2013, 12:40:51 am »
This is a port of my Prizm game Zombie Chase.

Here is some screenies:




The problem is, is that it reboots the calc every time you exit.
This is the code it does when the while loop breaks:
Code: [Select]
free(screen);
return 0;

The screen variable is:
Code: [Select]
screen = (char*)malloc(SCREEN_BYTES_SIZE * sizeof(char));
I hope you can help so that I can get this uploaded for you to enjoy(or dislike :P).
« Last Edit: May 20, 2013, 12:41:09 am by Spenceboy98 »
I like milk.

Offline excale

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 103
  • Rating: +19/-1
    • View Profile
Re: [Nspire C] Zombie Chase
« Reply #1 on: May 20, 2013, 05:29:50 am »
I think it reboots after the return, possibly because you wrote data out of the malloc-ed memory somewhere earlier in the program, thus overwriting some informations needed by the OS.
« Last Edit: May 20, 2013, 05:30:06 am by excale »

Offline ajorians

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 105
  • Rating: +47/-0
    • View Profile
Re: [Nspire C] Zombie Chase
« Reply #2 on: May 20, 2013, 08:09:47 am »
Hi Spenceboy98,

A couple of tips I've learned that may be able to help:
1. After free; you can set your pointer to NULL:
free(screen);
screen = NULL;
return 0;
And so I suggest for every free to set the pointer to NULL.  Because should you call free again on the same pointer, free(NULL) won't crash!  See the C standard 7.20.3.2: http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1124.pdf
But that may be an indication that you are freeing the same memory twice.

2. Are you using an emulator or only transferring to your calculator?  I only say because if you use an emulator; besides being faster you can add printf (amongst other things) to see the values of variables:
printf("Screen pointer is at address %p\n", screen);

3. Are you using anything for the graphics?  That is entirely your choice; but nRGBLib (http://ourl.ca/14731) is really helpful!  In there is a macro:
#define GetNewScreenBuffer() malloc(SCREEN_BYTES_SIZE)
(https://bitbucket.org/totorigolo/nrgblib/src/9a736d6ff9e432e7e1df2122c03d8b39c05d6dd2/src/include/nCOMMON.h?at=default)
And I am thinking you could use that instead of writing it yourself.

If you post your source code I'll take a look to see why the calculator reboots on exit.  I've chased down a few of these now! :)

Have a great day!

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: [Nspire C] Zombie Chase
« Reply #3 on: May 20, 2013, 05:12:48 pm »
Hi Spenceboy98,

A couple of tips I've learned that may be able to help:
1. After free; you can set your pointer to NULL:
free(screen);
screen = NULL;
return 0;
And so I suggest for every free to set the pointer to NULL.  Because should you call free again on the same pointer, free(NULL) won't crash!  See the C standard 7.20.3.2: http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1124.pdf
But that may be an indication that you are freeing the same memory twice.

2. Are you using an emulator or only transferring to your calculator?  I only say because if you use an emulator; besides being faster you can add printf (amongst other things) to see the values of variables:
printf("Screen pointer is at address %p\n", screen);

3. Are you using anything for the graphics?  That is entirely your choice; but nRGBLib (http://ourl.ca/14731) is really helpful!  In there is a macro:
#define GetNewScreenBuffer() malloc(SCREEN_BYTES_SIZE)
(https://bitbucket.org/totorigolo/nrgblib/src/9a736d6ff9e432e7e1df2122c03d8b39c05d6dd2/src/include/nCOMMON.h?at=default)
And I am thinking you could use that instead of writing it yourself.

If you post your source code I'll take a look to see why the calculator reboots on exit.  I've chased down a few of these now! :)

Have a great day!


I've tested it on both emulator and calc. I don't really want to post my source, but I'll pm you it, so that you can help.
I like milk.

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: [Nspire C] Zombie Chase
« Reply #4 on: May 21, 2013, 11:11:23 pm »
*BUMP*

Working version thanks to ajorians(I had the background filling routine filling too much :P).

Screenies:




Could someone test this on a CX and post some screenshots of those?

Download is attached.
I like milk.

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: [Nspire C] Zombie Chase
« Reply #5 on: May 22, 2013, 05:58:07 pm »
*BUMP*

Could someone please test this on a CX? I'd like to see what it looks like. :P

Also, opinions are appreciated. :)
I like milk.

Offline ajorians

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 105
  • Rating: +47/-0
    • View Profile
Re: [Nspire C] Zombie Chase
« Reply #6 on: May 24, 2013, 01:29:08 pm »
Hi Spenceboy98,

I just tested your program and I hit troubles with my CX :(

The first 2 screenshots are what it looked like to me.

Which is strange because I compiled your code and it looked fine (3rd screenshot).  I still have the code and can send it.  I am thinking that when I compiled and ran your code compared to this version it seems like the filesize increased a lot (4th screenshot; the version I got working is the smaller filesize).

Hope that helps.  Holler if I can be of any more help.  And have a great day!

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: [Nspire C] Zombie Chase
« Reply #7 on: May 24, 2013, 03:06:42 pm »
You need either to use lcd_ingray or lcd_incolor according to is_cx :
http://hackspire.unsads.com/wiki/index.php/Libndls#Screen
« Last Edit: May 24, 2013, 03:07:11 pm 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 Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: [Nspire C] Zombie Chase
« Reply #8 on: May 24, 2013, 04:45:06 pm »
How about now(attached)?

The reason it is bigger than what I showed is because I made it have the color FAIL, which made it a lot bigger. :P
I like milk.

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: [Nspire C] Zombie Chase
« Reply #9 on: May 25, 2013, 03:44:51 pm »
*BUMP*

I needs some CX testers please. ;) :P
I like milk.

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: [Nspire C] Zombie Chase
« Reply #10 on: May 25, 2013, 03:57:38 pm »
I've tipped people at TI-Planet about it ( http://tiplanet.org/forum/viewtopic.php?f=17&t=11982 ), hopefully this will provide more beta-testers :)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: [Nspire C] Zombie Chase
« Reply #11 on: May 25, 2013, 05:48:07 pm »
I've tipped people at TI-Planet about it ( http://tiplanet.org/forum/viewtopic.php?f=17&t=11982 ), hopefully this will provide more beta-testers :)


Thanks. I hope it will. :)
I like milk.

Offline AlexisVieira

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 100
  • Rating: +1/-1
    • View Profile
Re: [Nspire C] Zombie Chase
« Reply #12 on: May 27, 2013, 09:58:22 am »
well, it works good on my nspire touchpad but the "points" of the "zombies" are too small
I'm Portuguese, sorry bad English

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [Nspire C] Zombie Chase
« Reply #13 on: May 27, 2013, 01:31:52 pm »
Looks nice, is it like Scipi/HOMER-16's computer zombie game? And yeah maybe the points could be a bit larger and there should be a bit of color.

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: [Nspire C] Zombie Chase
« Reply #14 on: May 27, 2013, 04:14:33 pm »
Looks nice, is it like Scipi/HOMER-16's computer zombie game? And yeah maybe the points could be a bit larger and there should be a bit of color.

It should work on a CX, but no one has tested my most recent upload.

About the points, do you mean the amount taken off of the health when you get touched by a zombie?
I like milk.