Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
26 May, 2013, 01:32:23 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: [TIGCC] C strange 16x16 sprite error? -  (Read 443 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
bfr
LV8 Addict (Next: 1000)
********
Offline Offline

Last Login: 13 December, 2012, 02:20:32
Date Registered: 29 August, 2008, 04:06:24
Location: United States
Posts: 944

Total Post Ratings: +4

View Profile WWW
« on: 20 March, 2006, 19:25:00 »
0

For some reason, I get the following error only when I do something for a 16x16 sprite - it doesn't happen with 8x8 or 32x32.

Incompatible type for argument 4 for 'Sprite16'.

Here's the code:

sprite16.c

c1-->
CODE
ec1
#include
#include "spinit.h"

unsigned short int sprite;

void _main(int x, int y, int height, char* variable, char* plane, char* method){
   if(variable=="a16"){
 
Logged

Ranman
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Last Login: 23 April, 2013, 23:37:04
Date Registered: 16 October, 2008, 23:25:59
Posts: 1390


Total Post Ratings: +78

View Profile
« Reply #1 on: 20 March, 2006, 21:23:00 »
0

The function prototype for Sprite16 is:

c1-->
CODE
ec1void Sprite16 (short x, short y, short height, unsigned short *sprite, void *vm_addr, short mode); c2
ec2

The 4th parameter is an "unsigned short *" not an "unsigned short". It is expecting you to pass in a pointer to an unsigned short. This pointer is the address of the sprite data.


Another thing to remember:

Both Sprite16 and Sprite32 expect the sprite data to begin on an even memory address. If you attempt to pass in an odd address to them, you will get a memory violation.
Logged

Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator.  Download available here.
bfr
LV8 Addict (Next: 1000)
********
Offline Offline

Last Login: 13 December, 2012, 02:20:32
Date Registered: 29 August, 2008, 04:06:24
Location: United States
Posts: 944

Total Post Ratings: +4

View Profile WWW
« Reply #2 on: 20 March, 2006, 21:38:00 »
0

Thanks.  =)

I'm always making mistakes like these...:dang:banghead.gif
Logged

Liazon
Guest
« Reply #3 on: 20 March, 2006, 23:10:00 »
0

QuoteBegin-Ranman+-->
QUOTE (Ranman)

Both Sprite16 and Sprite32 expect the sprite data to begin on an even memory address. If you attempt to pass in an odd address to them, you will get a memory violation.


how is this possible?  how would you know if the address was odd/even?
Logged
Ranman
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Last Login: 23 April, 2013, 23:37:04
Date Registered: 16 October, 2008, 23:25:59
Posts: 1390


Total Post Ratings: +78

View Profile
« Reply #4 on: 21 March, 2006, 00:45:00 »
0

QuoteBegin-Liazon+Mar 20 2006, 22:1-->
QUOTE (Liazon @ Mar 20 2006, 22:10)
how is this possible?
Logged

Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator.  Download available here.
Liazon
Guest
« Reply #5 on: 21 March, 2006, 17:31:00 »
0

I forget how you typecast, but what's the point of typecasting data?
Logged
MathStuf
Guest
« Reply #6 on: 21 March, 2006, 18:51:00 »
0

I see a problem... You are not testing whether the strings are the same correctly. The right way is:
c1-->
CODE
ec1if(!strcmp(string_1, string_2))
{
// strings are the same
}
else
{
// strings are different
}c2
ec2
That should help some. Turning on Grayscale would too.

In addition, you can't do arguments that way in C for the calcs. You need argv/argc and stuff like that (I'm not quite sure how to use them).
Logged
Ranman
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Last Login: 23 April, 2013, 23:37:04
Date Registered: 16 October, 2008, 23:25:59
Posts: 1390


Total Post Ratings: +78

View Profile
« Reply #7 on: 21 March, 2006, 22:45:00 »
0

QuoteBegin-MathStuf+Mar 21 2006, 17:51-->
QUOTE (MathStuf @ Mar 21 2006, 17:51)
In addition, you can't do arguments that way in C for the calcs. You need argv/argc and stuff like that (I'm not quite sure how to use them).

Good catch MathStuf!

I thought the main entry point always had to have the following signature (or prototype):

c1
-->
CODE
ec1void _main(void)c2
ec2

Can you pass parameters into _main? Do you have to do something special with the TIGCC startup code to actually pass the parameter into _main?

The standard main entry point for most computer based applications looks something like this:

c1
-->
CODE
ec1main(int argc, char *argv[ ])c2
ec2

 - argc : this is the number of strings that the argv array contains.
 - argv : this is an array of strings.
Logged

Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator.  Download available here.
saubue
Guest
« Reply #8 on: 22 March, 2006, 10:14:00 »
0

QuoteBegin-Ranman+-->
QUOTE (Ranman)
Can you pass parameters into _main? Do you have to do something special with the TIGCC startup code to actually pass the parameter into _main?


Of course you can Smileysmile.gif
The functions neccessary to do this kind of stuff can be found in the header http://tigcc.ticalc.org/doc/args.html

TIGCC also offers an example program:
c1
-->
CODE
ec1// An example of passing arguments to C program
// Try this program calling argtest(arg1,arg2,...)

#define USE_TI89
#define USE_TI92PLUS
#define USE_V200

#define MIN_AMS 100

#include
#include
#include
#include

void _main(void)
{
 
Logged
Ranman
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Last Login: 23 April, 2013, 23:37:04
Date Registered: 16 October, 2008, 23:25:59
Posts: 1390


Total Post Ratings: +78

View Profile
« Reply #9 on: 22 March, 2006, 10:58:00 »
0

Thanks for that example Saubue! Cheesybiggrin.gif I did not know that. :oops:embarassed.gif

You're never too old to learn something new.  Winkwink.gif

However, the example does show that you don't pass the data directly into _main via parameters; rather that _main must go get the data from some location maintained by the AMS through the use of specialized functions.

Logged

Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator.  Download available here.
Liazon
Guest
« Reply #10 on: 22 March, 2006, 17:12:00 »
0

O_Oshocked2.gif *Liazon
Logged
bfr
LV8 Addict (Next: 1000)
********
Offline Offline

Last Login: 13 December, 2012, 02:20:32
Date Registered: 29 August, 2008, 04:06:24
Location: United States
Posts: 944

Total Post Ratings: +4

View Profile WWW
« Reply #11 on: 22 March, 2006, 17:48:00 »
0

QuoteBegin-MathStuf+Mar 21 2006, 17:51-->
QUOTE (MathStuf @ Mar 21 2006, 17:51)
Turning on Grayscale would too.

I didn't turn on grayscale for a reason.  I'm trying some stuff out.

I was doing unsigned short mySprite[16]; before, but I kept getting strange error, and only with 16x16 sprites.  It worked with unsigned long mySprite[32]; and unsigned char mySprite[8];.  

Thanks everybody.  I've done stuff with C and TIGCC before, but I'm not very experienced with sprites in C.  I've basically only used unmasked simple 8x8 sprites before, and have also never used paramaters in my programs before.
Logged

Ranman
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Last Login: 23 April, 2013, 23:37:04
Date Registered: 16 October, 2008, 23:25:59
Posts: 1390


Total Post Ratings: +78

View Profile
« Reply #12 on: 23 March, 2006, 10:44:00 »
0

QuoteBegin-Liazon+Mar 21 2006, 16:31-->
QUOTE (Liazon @ Mar 21 2006, 16:31)
I forget how you typecast, but what's the point of typecasting data?

Typecasting is usually discouraged. You should only do it when it is really necessary. A good example when typecasting is needed is when you use a function call (API) that you do not have control over. This applies to data as well.

Here is an example:

You declare the following 3 variables:

c1
-->
CODE
ec1int myInt1;
Logged

Ranman
Bringing Randy Glover's Jumpman to the TI-89 calculator.  Download available here.
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.31 seconds with 30 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.