NESDev and Strangulation Records messageboards
Forum Index | FAQ | New User | Login | Search

Previous ThreadView All ThreadsNext ThreadShow in Flat Mode*


SubjectRe: Shift Ops and Input (?)  
Posted bymcmartin
Posted on1/19/03 06:18 AM
From IP128.12.190.38  



If all you had pressed was LEFT, current would be #$02. The procedure repeatedly reads 4016, shoves the value bit into carry (the LSR command), then rotates it into current. Since 8 reads occur, current contains an entirely new value when it is completed. Since LEFT is the seventh item read, it is the seventh bit shifted in, and since it's shifting in from right to left (ROL), it ends up in the #$02 place.

The routine I quoted actually is designed to work with a battery of other routines and constants, which allow you to check if a direction or button is down, up, has just been pressed, or has just been released. (That's what the 'last' variable is for - for comparisons to detect falling and rising edges.) Also, it defines bitmasks so you can check to see if DOWN and A are active, say, by the code:

    ldx #$00   ; Controller 1
lda #input'dir'down | input'btn'a
jsr input'down
bne _not'pressed
; Code for dealing with DOWN+A here
_not'pressed:
; Code continues


This is the "input.p65" file included in the Galaxy Patrol source. It's overkill for Galaxy Patrol by itself, but I plan on making good use of it later.

--Michael



-
Entire Thread
Subject  Posted byPosted On
*Shift Ops and Input (?)   deschenes201/18/03 05:21 AM
.*Re: Shift Ops and Input (?)   mcmartin1/18/03 05:36 AM
..*Re: Shift Ops and Input (?)   deschenes201/18/03 05:47 AM
....Re: Shift Ops and Input (?)   mcmartin1/19/03 06:18 AM
....*Re: Shift Ops and Input (?)   zero soul1/21/03 01:09 AM
.....*Re: Shift Ops and Input (?)   quietust1/21/03 04:47 AM
......*Re: Shift Ops and Input (?)   zero soul1/21/03 8:36 PM
.......*(and an addendum)  zero soul1/21/03 8:39 PM
........*Re: (and an addendum)  gesis_l1/21/03 10:36 PM
.........*Re: (and an addendum)  zero soul1/22/03 00:14 AM
.......*(correction)  zero soul1/21/03 8:37 PM
Jump to

Memblers' homepage             Contact Me

Forums powered by WWWThreads Demo