6 button

For anything related to IO (joypad, serial, XE...)

Moderator: BigEvilCorporation

Mixail
Very interested
Posts: 100
Joined: Thu Nov 18, 2010 4:47 pm

6 button

Post by Mixail » Thu Nov 18, 2010 4:51 pm

How to include 6 button joy stick? (X, Y, Z)

Code: Select all

#include <genesis.h>
#include <joy.h>


volatile u16 joy;


int main() {
JOY_setSupport(0, JOY_SUPPORT_6BTN);
JOY_setSupport(1, JOY_SUPPORT_6BTN);

	VDP_drawText(APLAN, "----------------------------------------", 0, 0, 25);
   while (1) {joy = JOY_readJoypad(JOY_1);

		
if (joy & BUTTON_Z){
		
VDP_drawText(APLAN, "-----------------ZZZ--------------------", 0, 0, 14);}

      
				


    }
}

User avatar
Stef
Very interested
Posts: 2773
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Thu Nov 18, 2010 7:52 pm

I know that suck but 6 buttons joysticks aren't yet supported by the library even if definitions are there :-/
I plan to add them in future version though.

Chilly Willy
Very interested
Posts: 2586
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Nov 18, 2010 9:02 pm

I'm sure there is a thread around here that shows how to read 6-button pads as well as mice. It's just not part of Stef's mini-devkit... yet.

Mixail
Very interested
Posts: 100
Joined: Thu Nov 18, 2010 4:47 pm

Post by Mixail » Fri Nov 19, 2010 12:20 pm

Chilly Willy wrote:I'm sure there is a thread around here that shows how to read 6-button pads as well as mice. It's just not part of Stef's mini-devkit... yet.
Where it can be seen?

User avatar
KanedaFr
Administrateur
Posts: 1116
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Fri Nov 19, 2010 12:31 pm

Hi,

you could find it using the search function or on this post

I used Chilly Willy's code with success in my last hack.

Stef, how could I contribute to GenDevKit ? I'm working on 6 buttons, multiplayer and, perhaps, Justifier support right now
(yeah, back in business, thanks to the RGC)

User avatar
Stef
Very interested
Posts: 2773
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Nov 19, 2010 12:49 pm

KanedaFr wrote:Hi,

you could find it using the search function or on this post

I used Chilly Willy's code with success in my last hack.

Stef, how could I contribute to GenDevKit ? I'm working on 6 buttons, multiplayer and, perhaps, Justifier support right now
(yeah, back in business, thanks to the RGC)
Hey :)

Actually everyone can contribute to it =)
Of course you have to respect a bit the actual "nomenclature and logic" but i'm open to any refactoring if it worth ;)

For now almost all stuff is on my HD and the current available online version is quite outdated. If some people as you are interested in contributing i will open a project on google code or something like that to centralize development.
I'll do it quite soon but i can send you the last WIP package while it's done...

User avatar
KanedaFr
Administrateur
Posts: 1116
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Fri Nov 19, 2010 1:19 pm

@Mixail

you'll need to refactor a little the asm code if you use GenDevKit
1- add .global get_pad as first line
2- replace | comment by *
3- replace ax by %ax and dx by %dx
4- replace bsr.x by bsr
5- replace addi by add and cmpi by cmp (to confirm by Stef)
6- on your C code, declare get_pad with
extern u32 get_pad( );
7- get pad value with
u32 pad1 = get_pad( 0xA10003 );


@Stef
no problem with respect of nomenclature and logic, of course.

on what parts did you make some update ? there is no point for me to work on 6B support if you added it ;)

else, you can look at my tutorial on Eclipse to see how I miss a shell and rm ;)

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.

waiting for WIP or google code link ;)

Thanks

Mixail
Very interested
Posts: 100
Joined: Thu Nov 18, 2010 4:47 pm

Post by Mixail » Fri Nov 19, 2010 1:33 pm

To me to use this ASM code?

Code: Select all

| get current pad value
| entry: a0 = pad control port
| exit:  d2 = 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)
get_pad:
        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 */
        rts

no_pad:
        move.w  #0xF000,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 

User avatar
KanedaFr
Administrateur
Posts: 1116
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Fri Nov 19, 2010 2:02 pm

yes, but you'll need to update it like I said

User avatar
Stef
Very interested
Posts: 2773
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Nov 19, 2010 2:39 pm

KanedaFr wrote: no problem with respect of nomenclature and logic, of course.

on what parts did you make some update ? there is no point for me to work on 6B support if you added it ;)
As far i remember i didn't worked on joystick code since last version, the main stuff i worked on is some bitmap stuff which I almost entirely rewrote (and still not satisfied with...), anyway bitmap is definitely not something megadrive is designed for so i'll concentrate my efforts on others parts now =)
else, you can look at my tutorial on Eclipse to see how I miss a shell and rm ;)

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.
Where is your Eclipse integration tutorial by the way ? i can't find it anymore :?
I added rm in dev kit and there are some others improvements as a real library build in makefile, though i need to udpate/improve some stuff i can pick here and there (mainly in the dedicated topic, i missed a lot of interesting post). About the shell, on windows i stay with cmd as bsh isn't always available, the idea for me is to have a minimalist solution and avoid cygwin and/or mingw complete installation.


About the IDE i'm still using Code::Blocks but with a simple makefile project compilation so it's really easy to configure it now :) Also the makefile handle some data file as raw sound and graphics and convert them to C or S files.

I'm using Eclipse but only for Java development, it's a very nice IDE but a bit heavy sometime, anyway i should be able to provide some simple tutorials to integrate the devkit in common IDE.
Last edited by Stef on Fri Nov 19, 2010 2:42 pm, edited 1 time in total.

Mixail
Very interested
Posts: 100
Joined: Thu Nov 18, 2010 4:47 pm

Post by Mixail » Fri Nov 19, 2010 2:40 pm

So it is correct?

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       
        andi.w  #0x0F00, %d0     
        cmp.w  #0x0F00, %d0
        beq.b   common          
        move.w  #0x010F, %d2      
.globl common 
common:
        lsl.b   #4, %d2           
        lsl.w   #4, %d2           
        andi.w  #0x303F, %d1      
        move.b  %d1, %d2           
        lsr.w   #6, %d1           
        or.w    %d1, %d2           
        eori.w  #0x1FFF, %d2      
        rts

.globl no_pad
no_pad:
        move.w  #0xF000, %d2
        rts

.globl get_input
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 

User avatar
KanedaFr
Administrateur
Posts: 1116
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Fri Nov 19, 2010 3:21 pm

Mixail wrote:So it is correct?
change addi by add
and only the first .global is needed

User avatar
KanedaFr
Administrateur
Posts: 1116
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Fri Nov 19, 2010 3:28 pm

Stef wrote:
else, you can look at my tutorial on Eclipse to see how I miss a shell and rm ;)

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.
Where is your Eclipse integration tutorial by the way ? i can't find it anymore :?
http://gendev.spritesmind.net/page-eclipse.html
The good news is, since I resintalled the SDK last week, I was able to update my tut as a pure newbie.
It's so working with the last version and the links are valid.
I added rm in dev kit and there are some others improvements as a real library build in makefile, though i need to udpate/improve some stuff i can pick here and there (mainly in the dedicated topic, i missed a lot of interesting post). About the shell, on windows i stay with cmd as bsh isn't always available, the idea for me is to have a minimalist solution and avoid cygwin and/or mingw complete installation.
cmd isn't working on some cass.
for example on Windows7 the ">" doesn't work as expected, which broke my debug feature.

you'll find all you need, or a basis, on the tut.
I really fought to find a working shell !


About the IDE i'm still using Code::Blocks but with a simple makefile project compilation so it's really easy to configure it now :) Also the makefile handle some data file as raw sound and graphics and convert them to C or S files.

I'm using Eclipse but only for Java development, it's a very nice IDE but a bit heavy sometime, anyway i should be able to provide some simple tutorials to integrate the devkit in common IDE.
Using Eclipse CDT is a pleasure with makefile!

Chilly Willy
Very interested
Posts: 2586
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Fri Nov 19, 2010 7:58 pm

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.
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.

User avatar
Stef
Very interested
Posts: 2773
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Nov 19, 2010 9:40 pm

Chilly Willy wrote:
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.
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.
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 :p

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest