Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
About
Team
Rules
Stats
Status
Sitemap
Chat
Downloads
Forum
News
Our Projects
Major Community Projects
Recent Posts
Unread Posts
Replies
Tools
SourceCoder3
Other Things...
Omnimaga Radio
TI-83 Plus ASM File Unsquisher
Z80 Conversion Tools
IES TI File Editor
Free RAM areas
Comprehensive Getkeyr table
URL Shortener
Online Axe Tilemap Editor
Help
Contact Us
Change Request
Report Issue/Bug
Team
Articles
Members
View the memberlist
Search For Members
Buddies
Login
Register
Omnimaga
»
Forum
»
Calculator Community
»
TI Calculators
»
Calculator C
»
[TIGCC] C strange 16x16 sprite error?
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [TIGCC] C strange 16x16 sprite error? (Read 8009 times)
0 Members and 1 Guest are viewing this topic.
bfr
LV8
Addict (Next: 1000)
Posts: 819
Rating: +4/-0
[TIGCC] C strange 16x16 sprite error?
«
on:
March 20, 2006, 12:25:00 pm »
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
bfr's website -
http://bfr.tifreakware.net
Ranman
LV10
31337 u53r (Next: 2000)
Posts: 1354
Rating: +83/-0
[TIGCC] C strange 16x16 sprite error?
«
Reply #1 on:
March 20, 2006, 02:23:00 pm »
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 at
Ticalc
.
bfr
LV8
Addict (Next: 1000)
Posts: 819
Rating: +4/-0
[TIGCC] C strange 16x16 sprite error?
«
Reply #2 on:
March 20, 2006, 02:38:00 pm »
Thanks. =)
I'm always making mistakes like these...:dang:
Logged
bfr's website -
http://bfr.tifreakware.net
Liazon
Guest
[TIGCC] C strange 16x16 sprite error?
«
Reply #3 on:
March 20, 2006, 04:10:00 pm »
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)
Posts: 1354
Rating: +83/-0
[TIGCC] C strange 16x16 sprite error?
«
Reply #4 on:
March 20, 2006, 05:45:00 pm »
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 at
Ticalc
.
Liazon
Guest
[TIGCC] C strange 16x16 sprite error?
«
Reply #5 on:
March 21, 2006, 10:31:00 am »
I forget how you typecast, but what's the point of typecasting data?
Logged
MathStuf
Guest
[TIGCC] C strange 16x16 sprite error?
«
Reply #6 on:
March 21, 2006, 11:51:00 am »
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)
Posts: 1354
Rating: +83/-0
[TIGCC] C strange 16x16 sprite error?
«
Reply #7 on:
March 21, 2006, 03:45:00 pm »
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 at
Ticalc
.
saubue
Guest
[TIGCC] C strange 16x16 sprite error?
«
Reply #8 on:
March 22, 2006, 03:14:00 am »
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
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)
Posts: 1354
Rating: +83/-0
[TIGCC] C strange 16x16 sprite error?
«
Reply #9 on:
March 22, 2006, 03:58:00 am »
Thanks for that example Saubue!
I did not know that. :oops:
You're never too old to learn something new.
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 at
Ticalc
.
Liazon
Guest
[TIGCC] C strange 16x16 sprite error?
«
Reply #10 on:
March 22, 2006, 10:12:00 am »
O_O
*
Liazon
Logged
bfr
LV8
Addict (Next: 1000)
Posts: 819
Rating: +4/-0
[TIGCC] C strange 16x16 sprite error?
«
Reply #11 on:
March 22, 2006, 10:48:00 am »
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
bfr's website -
http://bfr.tifreakware.net
Ranman
LV10
31337 u53r (Next: 2000)
Posts: 1354
Rating: +83/-0
[TIGCC] C strange 16x16 sprite error?
«
Reply #12 on:
March 23, 2006, 03:44:00 am »
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 at
Ticalc
.
Print
Pages: [
1
]
Go Up
« previous
next »
Omnimaga
»
Forum
»
Calculator Community
»
TI Calculators
»
Calculator C
»
[TIGCC] C strange 16x16 sprite error?