6 button
Moderator: BigEvilCorporation
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Except that you forgot the input again...
or
The comments in the assembly tell you which bits stand for which button, and the bit is set when the button is pressed. If you like the bit clear for when the button is pressed, you would need to remove the eor from the end of the function.
Code: Select all
pad1 = get_pad (0);
Code: Select all
pad2 = get_pad (1);
When I write
The screen starts to flicker. What buttons are read out.
Code: Select all
pad1 = get_pad (0);
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
SighMixail wrote:When I writeThe screen starts to flicker. What buttons are read out.Code: Select all
pad1 = get_pad (0);
From the code I pasted in the previos page
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)
The C defines I use in main.c are
Code: Select all
#define SEGA_CTRL_BUTTONS 0x0FFF
#define SEGA_CTRL_UP 0x0001
#define SEGA_CTRL_DOWN 0x0002
#define SEGA_CTRL_LEFT 0x0004
#define SEGA_CTRL_RIGHT 0x0008
#define SEGA_CTRL_B 0x0010
#define SEGA_CTRL_C 0x0020
#define SEGA_CTRL_A 0x0040
#define SEGA_CTRL_START 0x0080
#define SEGA_CTRL_Z 0x0100
#define SEGA_CTRL_Y 0x0200
#define SEGA_CTRL_X 0x0400
#define SEGA_CTRL_MODE 0x0800
#define SEGA_CTRL_TYPE 0xF000
#define SEGA_CTRL_THREE 0x0000
#define SEGA_CTRL_SIX 0x1000
#define SEGA_CTRL_NONE 0xF000
main
asm
Why it blinks?
Code: Select all
#include <genesis.h>
extern unsigned short int get_pad(int pad);
int main() {
u32 pad1;
VDP_init();
VDP_drawText(APLAN, "----------------------------------------", 0, 0, 25);
for (;;) {
pad1 = get_pad (0);
if (pad1 & 0x0100){//button Z
VDP_drawText(APLAN, "-----------------ZZZ--------------------", 0, 0, 14);
}
VDP_waitVSync();
}
return 0;
}
Code: Select all
.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
which one ?
Genesis Dev 06b (and now 06c) at viewtopic.php?p=12146#12146
Fusion : google
KMod:
http://gendev.spritesmind.net/page-gensK.html
Regen:
viewforum.php?f=15
Genesis Dev 06b (and now 06c) at viewtopic.php?p=12146#12146
Fusion : google
KMod:
http://gendev.spritesmind.net/page-gensK.html
Regen:
viewforum.php?f=15
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
I prefer using Gens/GS: http://segaretro.org/Gens/GS
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
The source is right here: viewtopic.php?p=12154#12154
You aren't paying much attention to what we are saying in the thread. It's hard to help if you don't listen.
You aren't paying much attention to what we are saying in the thread. It's hard to help if you don't listen.