Reading jagpad A from GFABASIC

From Atari Wiki
Revision as of 12:21, 13 October 2011 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
'
' Jagpad routine in GFABASIC
' by Simon Sunnyboy / Paradize
'
DO
  jag%=FN jagpad_a
  EXIT IF jag% AND 128            ! exit if button
  IF jag% AND 1
    PRINT "UP ";
  ENDIF
  IF jag% AND 2
    PRINT "DOWN ";
  ENDIF
  IF jag% AND 4
    PRINT "LEFT ";
  ENDIF
  IF jag% AND 8
    PRINT "RIGHT ";
  ENDIF
  IF jag% AND 16
    PRINT "OPTIONS ";
  ENDIF
  IF jag% AND 32
    PRINT "BUTC ";
  ENDIF
  IF jag% AND 64
    PRINT "BUTB ";
  ENDIF
LOOP
EDIT
'
FUNCTION jagpad_a
  LOCAL vec%,pad%
  '
  '  returns the state of Jagpad A as a vector
  ' Bits 0-3  standard joystick directions (compatible with IKBD)
  ' Bit 4  Options button
  ' Bit 5  Button C
  ' Bit 6  Button B
  ' Bit 7  Button A
  ' directions
  vec%=0
  SDPOKE &HFF9202,&HFFFE
  pad%=NOT (DPEEK(&HFF9202) AND &HF00)
  IF pad% AND 2048           ! right
    vec%=vec% OR 8
  ENDIF
  IF pad% AND 1024           ! left
    vec%=vec% OR 4
  ENDIF
  IF pad% AND 512           ! down
    vec%=vec% OR 2
  ENDIF
  IF pad% AND 256           ! up
    vec%=vec% OR 1
  ENDIF
  '
  SDPOKE &HFF9202,&HFFFE
  pad%=NOT (DPEEK(&HFF9200) AND &HF)
  IF pad% AND 2
    vec%=vec% OR 128            ! button A
  ENDIF
  SDPOKE &HFF9202,&HFFFD
  pad%=NOT (DPEEK(&HFF9200) AND &HF)
  IF pad% AND 2
    vec%=vec% OR 64            ! button B
  ENDIF
  SDPOKE &HFF9202,&HFFFB
  pad%=NOT (DPEEK(&HFF9200) AND &HF)
  IF pad% AND 2
    vec%=vec% OR 32            ! button C
  ENDIF
  '
  SDPOKE &HFF9202,&HFFF7
  pad%=NOT (DPEEK(&HFF9200) AND &HF)
  IF pad% AND 2
    vec%=vec% OR 16            ! Options
  ENDIF
  '
  RETURN vec%
ENDFUNC

Back to Game_&_Demo_programming_techniques