Четверг, 10.10.2024, 06:14
Вы вошли как Гость | Группа "Гости" | RSS

.
 
 
Главная Регистрация Вход
[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Модератор форума: Nemesis_c  
6-button routine
Nemesis_cДата: Четверг, 01.09.2011, 08:35 | Сообщение # 1


 
Сообщений: 1148
Статус: Offline
 

HardWareMan's 6-button routine:

*Buttons map     
     JoyUp           equ    $0001     
     JoyDown         equ    $0002     
     JoyUpDown       equ    $0003     
     JoyLeft         equ    $0004     
     JoyRight        equ    $0008     
     JoyLeftRight    equ    $000C     
     JoyCursor       equ    $000F     
     JoyB            equ    $0010     
     JoyC            equ    $0020     
     JoyA            equ    $0040     
     JoyABC          equ    $0070     
     JoyStart        equ    $0080     
     JoyABCS         equ    $00F0     
     JoyZ            equ    $0100     
     JoyY            equ    $0200     
     JoyX            equ    $0400     
     JoyMode         equ    $0800     
     JoyMS           equ    $0880     
     JoyXYZM         equ    $0F00     
     JoyAnyButton    equ    $0FF0     
     JoyAnyKey       equ    $0FFF     

     *Joypad polling     
        clr.l   d0         *Clear d0     
        clr.l   d1         *Clear d1     
        move.b   #$40,$A10003      *SYN = 1     
        nop            *Delay     
        nop            *Delay     
        move.b   $A10003,d1      *Reading first 6 buttons     
        andi.b   #$3F,d1         *Mask it     
        move.b   #$00,$A10003      *SYN = 0     
        nop            *Delay     
        nop            *Delay     
        move.b   $A10003,d0      *Read second 2 buttons     
        and.b   #$30,d0         *Mask it     
        rol.b   #2,d0         *Shift by 2 bits     
        or.b   d0,d1         *Combine basic 8 buttons and store it to d1     
        move.b   #$40,$A10003      *SYN = 1     
        nop            *Delay     
        nop            *Delay     
        move.b   #$00,$A10003      *SYN = 0     
        nop            *Delay     
        nop            *Delay     
        move.b   #$40,$A10003      *SYN = 1     
        nop            *Delay     
        nop            *Delay     
        move.b   #$00,$A10003      *SYN = 0     
        nop            *Delay     
        nop            *Delay     
        move.b   #$40,$A10003      *SYN = 1     
        nop            *Delay     
        nop            *All this for unlock extra buttons (XYZM)     
        move.b   $A10003,d0      *Read extra buttons     
        andi.b   #$0F,d0         *Mask it     
        eor.b   #$0F,d0         *Invert it     
        rol.l   #8,d0         *Shift it by 8 bits     
        or.w   d1,d0         *Combine it with basic buttons     
        not.b   d0         *Invert basic buttons     
        move.b   #$40,$A10003      *SYN = 1     
        move.w   d0,KeyState         *Save joystick state

Chilly Willy's 6-button routine:

| 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
 
  • Страница 1 из 1
  • 1
Поиск:


Select language:
English
French
German
Portuguese
Chinese
Nemesis_c, r57shell, Smoke, Lipetsk, GoodBye (aka vfiuchcikicshuusrch) & Segaman © 2024
Хостинг от uCoz