Page 34 of 57
Posted: Thu Sep 20, 2012 4:35 pm
by Chilly Willy
KanedaFr wrote:little bug on the joy support :
readJoypad return joy state and type
unfortunatly type is also used when it calls joyEventCB
so change is not 0 when released but type << 12 ...
I would prefer to keep the initial mode : 0 for release, button for press
The "backwards compatibility" has its limits... for controllers, there is now a mask you should use for just the buttons - use (val & BUTTON_ALL) instead of plain old (val). If you force the support for pads to three button pad mode (for example, JOY_setSupport(PORT_1, JOY_SUPPORT_3BTN); ), then you'll have complete backwards compatibility since the TYPE for 3 button pads is 0.
Posted: Thu Sep 20, 2012 8:16 pm
by Stef
Well that is not a big deal anyway, i separated type and state because i think it is less confusing this way too
Now we have :
which return type for the specified joypad and the readJoypadState(..) does not return anymore joypad type in high nibble.
Posted: Thu Sep 20, 2012 9:58 pm
by Chilly Willy
I assume you changed the example, too, right?

Posted: Thu Sep 20, 2012 10:01 pm
by Stef
yep

Posted: Sat Sep 22, 2012 4:28 pm
by djcouchycouch
I'm seeing what looks like to be a bug with fastMemsetU16.
Code: Select all
#define MAX_COINS_IN_LEVEL 256
u16 coinMap[MAX_COINS_IN_LEVEL];
fastMemsetU16((u16*)coinMap, 1, MAX_COINS_IN_LEVEL);
PrintNumber(coinMap[0]); // helper printing function
PrintNumber(coinMap[1]);
PrintNumber(coinMap[2]);
Output (values are in hexidecimal):
Code: Select all
Message : 00000001
Message : 00000101
Message : 00000101
switching to memsetU16 gives the correct output:
Code: Select all
Message : 00000001
Message : 00000001
Message : 00000001
I kept wondering why my coins were all screwed up
DJCC
Posted: Sat Sep 22, 2012 5:00 pm
by Chilly Willy
Change line 347 of memory.c from
to
Code: Select all
asm("move.w %0,%1\n\t"
"swap %1\n\t"
"move.w %0,%1\n"
: "=d" (value), "=d" (value32) : : "cc" );
Posted: Sat Sep 22, 2012 5:06 pm
by djcouchycouch
Tried it out and now it's giving me:
Code: Select all
Message : 00000001
Message : 00000000
Message : 00000000
Posted: Sat Sep 22, 2012 7:18 pm
by Chilly Willy
A first word can be written by itself for odd word addresses, then it tries writing longs. So it seems like the asm isn't working... okay, try this:
Code: Select all
asm("move.w %1,%0\n\t"
"swap %0\n\t"
"move.w %1,%0\n"
: "=d" (value32) : "=d" (value) : "cc" );
Had value as an output register, which was probably the problem.
Posted: Sat Sep 22, 2012 7:22 pm
by djcouchycouch
That doesn't compile.
/sgdk092/src/memory.c:356: error: input operand constraint contains `='
Posted: Sat Sep 22, 2012 10:05 pm
by Chilly Willy
djcouchycouch wrote:That doesn't compile.
/sgdk092/src/memory.c:356: error: input operand constraint contains `='
Get rid of the second =... just use "d" (value). The = is for indicating write access, if I remember correctly.
Posted: Sat Sep 22, 2012 10:17 pm
by djcouchycouch
That seems to work. Thanks!
Posted: Sun Sep 23, 2012 12:20 am
by Chilly Willy
djcouchycouch wrote:That seems to work. Thanks!
No problem. Glad it finally worked out. Pulling inline assembly off the top of my head is fun, but takes a little debugging. I always forget which field is inputs and which are the outputs... things like that.

Posted: Sun Sep 23, 2012 3:08 pm
by Stef
Very stupid bug, to keep all C you just need to change the
by
but asm part is faster as you can use the swap instruction.
Posted: Sun Sep 23, 2012 6:53 pm
by Chilly Willy
Stef wrote:Very stupid bug, to keep all C you just need to change the
by
but asm part is faster as you can use the swap instruction.
I was fairly certain << 16 wasn't going to use swap, which is why I recommended the asm. If it didn't use swap, it wouldn't be "fast" at that point, and it was supposed to be the fast version of the routine.
Posted: Sun Sep 23, 2012 7:22 pm
by Stef
Chilly Willy wrote:
I was fairly certain << 16 wasn't going to use swap, which is why I recommended the asm. If it didn't use swap, it wouldn't be "fast" at that point, and it was supposed to be the fast version of the routine.
Hehe is was sure that it wouldn't too but in fact it does use the swap instruction ! But the rest of the code is really not the best we can do so i finally rewrote all these methods in pure asm.
I made fastxxx deprecated as now the normal memset and memcpy methods use fast asm code now
