Posted: Sun Nov 28, 2010 7:00 pm
KanedaFr It is possible more in detail about it?
Sega Megadrive/Genesis development
https://gendev.spritesmind.net/forum/
https://gendev.spritesmind.net/forum/viewtopic.php?f=23&t=823
Code: Select all
pad1 = get_pad (0);
Code: Select all
pad2 = get_pad (1);
Code: Select all
pad1 = get_pad (0);
SighMixail wrote:When I writeThe screen starts to flicker. What buttons are read out.Code: Select all
pad1 = get_pad (0);
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)
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
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
Where do you test your code ?Mixail wrote:Why it blinks?
Where it to download?KanedaFr wrote:well...
no blink using GenesisDev06b
Fusion 3.6 / Kmod 0.7c / Regen 0.97D