6 button
Moderator: BigEvilCorporation
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
I quickly set up a project on google code : http://code.google.com/p/sgdk/
For now it contains nothing except the dev kit archive.
I'll complete it with time, adding docs, tutorials etc...
As you'll see Kaneda i used and included some of your nice tools in the devkit
Some stuff changed since the v4 and i guess you'll experience some troubles to compile your projects, don't hesitate to request some help !
The logo is now activable / desactivable from the config.h file (i need to remove the "flemteam" stuff :p)
For now it contains nothing except the dev kit archive.
I'll complete it with time, adding docs, tutorials etc...
As you'll see Kaneda i used and included some of your nice tools in the devkit
Some stuff changed since the v4 and i guess you'll experience some troubles to compile your projects, don't hesitate to request some help !
The logo is now activable / desactivable from the config.h file (i need to remove the "flemteam" stuff :p)
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Oh, so I guess KanedaFr wasn't using your gcc either. 3.4.6 isn't too bad. Maybe include a newer version in addition as some older stuff doesn't like the 4.x without some changes, and vice versa.Stef wrote:Devkit uses GCC 3.4.6 but i've version 4.1.1 sitting somewhere, i never encountered this bug with 3.4.6 though... need to test more asm :pChilly Willy wrote:That says to me the version of gcc in the devkit needs to be updated. You shouldn't work around bugs like that when newer versions without the bugs are available.KanedaFr wrote: The only bug I found is about gas... it seems it handles wrongly the xxxi instructions :
Chilly willy's code for ex, doesn't work as is since he used andi, cmpi
I had to use cmp and not cmpi because %d0 was overwritten (?!)
perhaps I did something wrong (but I doubt since cmp worked) but it would be great if you could check this.
I used gcc coming with GDK0.4Chilly Willy wrote: Oh, so I guess KanedaFr wasn't using your gcc either. 3.4.6 isn't too bad. Maybe include a newer version in addition as some older stuff doesn't like the 4.x without some changes, and vice versa.
Very easy to test : use ChillyWilly joy6 code, you'll see it doesn't work with cmp.i and add.i
great!Stef wrote:I quickly set up a project on google code : http://code.google.com/p/sgdk/
For now it contains nothing except the dev kit archive.
I'll complete it with time, adding docs, tutorials etc...
As you'll see Kaneda i used and included some of your nice tools in the devkit
Some stuff changed since the v4 and i guess you'll experience some troubles to compile your projects, don't hesitate to request some help !
The logo is now activable / desactivable from the config.h file (i need to remove the "flemteam" stuff :p)
I will test it this week !
So it is correct?
change eori by eor?
Code: Select all
.globl get_pad
get_pad:
bsr get_input
move.w %d0, %d1
andi.w #0x0C00, %d0
bne.b no_pad
bsr get_input
bsr get_input
move.w %d0, %d2
bsr get_input
and.w #0x0F00, %d0
cmp.w #0x0F00, %d0
beq.b common
move.w #0x010F, %d2
common:
lsl.b #4, %d2
lsl.w #4, %d2
and.w #0x303F, %d1
move.b %d1, %d2
lsr.w #6, %d1
or.w %d1, %d2
eori.w #0x1FFF, %d2
rts
no_pad:
move.w #0xF000, %d2
rts
get_input:
move.b #0x00,(%a0)
nop
nop
move.b (%a0),%d0
move.b #0x40,(%a0)
lsl.w #8, %d0
move.b (%a0), %d0
rts
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
You missed the first andi and an eori toward the end.
Also, if you wish to also support Master System pads with the same routine, change the no_pad code to this:
If you use that with that old compiler, be sure to change the imm opcodes in it too.
Also, if you wish to also support Master System pads with the same routine, change the no_pad code to this:
Code: Select all
| no pad found, so we're going to ASSUME an SMS (compatible) pad
no_pad:
lea 0xA10003,a0
move.b (a0),d0 /* - 1 c b r l d u */
andi.w #0x003F,d0 /* 0 0 0 0 0 0 0 0 0 0 c b r l d u */
eori.w #0x003F,d0 /* 0 0 0 0 0 0 0 0 0 0 C B R L D U */
move.l (sp)+,d2
rts
This error
My code:
ASM
C code:
What to do?
My code:
ASM
Code: Select all
.globl get_pad
get_pad:
bsr get_input
move.w %d0, %d1
and.w #0x0C00, %d0
bne.b no_pad
bsr get_input
bsr get_input
move.w %d0, %d2
bsr get_input
and.w #0x0F00, %d0
cmp.w #0x0F00, %d0
beq.b common
move.w #0x010F, %d2
common:
lsl.b #4, %d2
lsl.w #4, %d2
and.w #0x303F, %d1
move.b %d1, %d2
lsr.w #6, %d1
or.w %d1, %d2
eor.w #0x1FFF, %d2
rts
no_pad:
lea 0xA10003,a0
move.b (a0),d0
and.w #0x003F,d0
eor.w #0x003F,d0
move.l (sp)+,d2
rts
get_input:
move.b #0x00,(%a0)
nop
nop
move.b (%a0),%d0
move.b #0x40,(%a0)
lsl.w #8, %d0
move.b (%a0), %d0
rts
Code: Select all
#include <genesis.h>
extern u32 get_pad ();
int main() {
u32 pad1 = get_pad (0xA10003);
VDP_init();
VDP_drawText(APLAN, "----------------------------------------", 0, 0, 25);
for (;;) {
if (pad1 & BUTTON_Z){
VDP_drawText(APLAN, "-----------------ZZZ--------------------", 0, 0, 14);}
//VDP_waitVSync();
}
return 0;
}
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
The line in main.c should be
The error is because wherever get_pad() is, it's not in the linker line (or not in the correct place in the line - the object file containing get_pad() needs to be after main.o).
Code: Select all
extern unsigned short int get_pad(int pad);
http://zalil.ru/30033285
Why it doesn't work? Deduces the black screen.
Why it doesn't work? Deduces the black screen.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
First, pad is the pad number, not an address... valid values are 0 and 1.
Second, you then don't fetch the pad number from the stack, nor save a register that needs saving.
Here's get_pad() written to be called from C
Second, you then don't fetch the pad number from the stack, nor save a register that needs saving.
Here's get_pad() written to be called from C
Code: Select all
| buttons = get_pad(pad)
| entry: arg = pad control port
| exit: d0 = pad value (0 0 0 1 M X Y Z S A C B R L D U) or (0 0 0 0 0 0 0 0 S A C B R L D U)
.global get_pad
get_pad:
move.l d2,-(sp)
move.l 8(sp),d0 /* first arg is pad number */
cmpi.w #1,d0
bhi no_pad
add.w d0,d0
addi.l #0xA10003,d0 /* pad control register */
movea.l d0,a0
bsr.b get_input /* - 0 s a 0 0 d u - 1 c b r l d u */
move.w d0,d1
andi.w #0x0C00,d0
bne.b no_pad
bsr.b get_input /* - 0 s a 0 0 d u - 1 c b r l d u */
bsr.b get_input /* - 0 s a 0 0 0 0 - 1 c b m x y z */
move.w d0,d2
bsr.b get_input /* - 0 s a 1 1 1 1 - 1 c b r l d u */
andi.w #0x0F00,d0 /* 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 */
cmpi.w #0x0F00,d0
beq.b common /* six button pad */
move.w #0x010F,d2 /* three button pad */
common:
lsl.b #4,d2 /* - 0 s a 0 0 0 0 m x y z 0 0 0 0 */
lsl.w #4,d2 /* 0 0 0 0 m x y z 0 0 0 0 0 0 0 0 */
andi.w #0x303F,d1 /* 0 0 s a 0 0 0 0 0 0 c b r l d u */
move.b d1,d2 /* 0 0 0 0 m x y z 0 0 c b r l d u */
lsr.w #6,d1 /* 0 0 0 0 0 0 0 0 s a 0 0 0 0 0 0 */
or.w d1,d2 /* 0 0 0 0 m x y z s a c b r l d u */
eori.w #0x1FFF,d2 /* 0 0 0 1 M X Y Z S A C B R L D U */
move.w d2,d0
move.l (sp)+,d2
rts
| no pad found, so we're going to ASSUME an SMS (compatible) pad
no_pad:
lea 0xA10003,a0
move.b (a0),d0 /* - 1 c b r l d u */
andi.w #0x003F,d0 /* 0 0 0 0 0 0 0 0 0 0 c b r l d u */
eori.w #0x003F,d0 /* 0 0 0 0 0 0 0 0 0 0 C B R L D U */
move.l (sp)+,d2
rts
| read single phase from controller
get_input:
move.b #0x00,(a0)
nop
nop
move.b (a0),d0
move.b #0x40,(a0)
lsl.w #8,d0
move.b (a0),d0
rts
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Code: Select all
#include <genesis.h>
extern unsigned short int get_pad(int pad);
int main() {
u32 pad1 = get_pad (0xA10003);
VDP_init();
VDP_drawText(APLAN, "----------------------------------------", 0, 0, 25);
for (;;) {
if (pad1 & 0x0400){//button Z
VDP_drawText(APLAN, "-----------------ZZZ--------------------", 0, 0, 14);
//VDP_waitVSync();
}
return 0;
}
I think you misunderstood one thing : get_pad doesn't return a pointer to a pad but the pad's buttons status.
So, you need to call get_pad on your for loop and keep the wait_vsync!
even better, I suggest you to call this on a vblank handler
So, you need to call get_pad on your for loop and keep the wait_vsync!
Code: Select all
int main() {
u32 pad1;
VDP_init();
VDP_drawText(APLAN, "----------------------------------------", 0, 0, 25);
for (;;) {
pad1 = get_pad (0xA10003);
if (pad1 & 0x0400){//button Z
VDP_drawText(APLAN, "-----------------ZZZ--------------------", 0, 0, 14);
}
VDP_waitVSync();
}
return 0;
}