#39074 - Mitch GBA - Mon Apr 04, 2005 8:21 am
Hello..
I'm working on a game, and I have an animated character that I want to put in the data thing. I got this far, and working:
memcpy( (u16 *)0x06014000, &frame1Data, sizeof(frame1Data) );
memcpy( (u16 *)0x06014200, &frame2Data, sizeof(frame2Data) );
memcpy( (u16 *)0x06014400, &frame3Data, sizeof(frame3Data) );
memcpy( (u16 *)0x06014600, &frame4Data, sizeof(frame4Data) );
memcpy( (u16 *)0x06014800, &frame5Data, sizeof(frame5Data) );
memcpy( (u16 *)0x06014a00, &frame6Data, sizeof(frame6Data) );
but after the 'a00' part, what do I do? I tried, 'b' and 'c', and that didn't work..
#39100 - Steve++ - Mon Apr 04, 2005 3:11 pm
That would be c then e. Do you know hexadecimal?
Your frame data should be in an array. That is, instead of frame1Data, frame2Data, etc. you could use frameData[n]. Then you could do something like the following:
Code: |
for (i=0; i<FRAME_COUNT; ++i)
{
memcpy((u16*)0x06014000+0x200*i, &frameData[i], sizeof(frame1Data[i]));
}
|
#39138 - tepples - Tue Apr 05, 2005 2:47 am
Steve++ wrote: |
Your frame data should be in an array. That is, instead of frame1Data, frame2Data, etc. you could use frameData[n]. |
But do the common data conversion programs (.png to asm/C or binary tile data to asm/C) support this?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#39163 - Mitch GBA - Tue Apr 05, 2005 12:05 pm
Why cant I use 'g' and 'i'??
#39164 - LOst? - Tue Apr 05, 2005 12:29 pm
Mitch GBA wrote: |
Why cant I use 'g' and 'i'?? |
Because 'g' would be 16 and 'i' would be 17 and since hexadecimal means base 16 so will there be a carry digit to the left after every mod 16.
Look at this table and judge for yourself:
0x0 = 0
0x1 = 1
0x2 = 2
0x3 = 3
0x4 = 4
0x5 = 5
0x6 = 6
0x7 = 7
0x8 = 8
0x9 = 9
0xa = 10
0xb = 11
0xc = 12
0xd = 13
0xe = 14
0xf = 15
0x10 = 16
0x11 = 17
0x12 = 18
0x13 = 19
0x14 = 20
0x15 = 21
0x16 = 22
...
0x1e = 30
0x1f = 31
0x20 = 32
0x21 = 33
...
0x2e = 46
0x2f = 47
0x30 = 48
0x31 = 49
... etc
#39166 - Mitch GBA - Tue Apr 05, 2005 2:19 pm
ok, but how do I put that in here???
memcpy( (u16 *)0x06014000, &frame6Data, sizeof(frame6Data) );
#39171 - tepples - Tue Apr 05, 2005 3:05 pm
Counting by 0x0200 in hex:
4000, 4200, 4400, 4600, 4800, 4a00, 4c00, 4e00, 5000, 5200, 5400...
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#39173 - Mitch GBA - Tue Apr 05, 2005 3:10 pm
Ah, thanks.. I'll try that :)
#39181 - Steve++ - Tue Apr 05, 2005 6:14 pm
I really want you to be able to understand hexadecimal. Think of it this way: We each have ten fingers, so in our number system we have ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Suppose we had sixteen fingers instead. This would probably have caused us to use a number system with sixteen digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f. That is the only difference between the two numbering systems - decimal has ten digits and hexadecimal has sixteen digits. All the rules are the same. You just need to learn to think of numbers in a sixteen digit system.
Why does this numbering system exist? There was a need for a numbering system where one digit represents a certain number of bits. We have binary, where one digit represents one bit, so there are only two digits, 0 and 1. Someone also came up with octal, where one digit represents three bits, and there are eight digits, 0, 1, 2, 3, 4, 5, 6, 7. Of course, three is a bit of a strange number considering we put bits together in groups of eight (bytes). In hexadecimal, one digit represents four bits, therefore two digits represent one byte. The more you program a system like the gba, the more you'll appreciate this relationship between bits and digits.
#39182 - Mitch GBA - Tue Apr 05, 2005 6:30 pm
I think I understand, thanks... Got it working too :) This is my first GBA game, and first time c++, so all the data storage, and pointers etc still are quite new to me..