Jump to content
IGNORED

Help with joystick movement (5200)


Recommended Posts

I'm guessing those are fake labels.. imagine that those will jump to places in your code for what to do when the joytick is moved in the specified direction.

 

Example:

.

.

.

cmp #c_STICK_PULLED_UP

bmi JoystickMoveUp

 

cmp #c_STICK_PULLED_DOWN

bpl JoystickMoveDown

rts

.

.

. other code here, etc

.

.

JoystickMoveUp:

; here is where you put your routines for

; what to do if the joystick was moved in

; the up direction

.

.

.

.

 

HTH,

calamari

 

[ 11-26-2001: Message edited by: calamari ]

Link to comment
Share on other sites

Oh. I think I misunderstood what part of the code you were confused about! Don't mind me, I'm old and swiss-cheese for brains.

 

Yeah, here is literally what I have in my routine:

 

code:


horizmove

 

lda SPOT0

; Check the value of POT0 to see if the joystick is centered. The

; documentation states that the POT range is 0-228.

;added on 10/27/01 per debro:

lsr ;divide by 2 to prevent overflow

cmp #$1A ; stick pulled left

bmi mvleft

cmp #$50 ; stick pulled right

bpl mvright

;end of added new code on 10/27/01

 

rts

horizmove1

 

clc

sbc #$78 ; Subtract 120 from the POT0 value

 

bmi mvleft ; If this value is negative then the

; user is pushing to the left

mvright

cpx #$CA ; If the player is at the right most (used to be $B0)

; side of the playfield then don't

bne mvright1 ; move right

rts

mvright1

lda leftright

sta PrevDir ; save off previous direction faced, for middle animation

lda #$01 ; this code means draw right-facing helicoper

sta leftright

inx ; Move 1 pixels to the right

rts

 

mvleft

cpx #$30 ; If the player is at the left most (used to be $40)

; side of the playfield then don't

bne mvleft1 ; move left.

rts

mvleft1

lda leftright

sta PrevDir ; save off previous direction faced, for middle animation

lda #$00 ; this code means draw right-facing helicoper

sta leftright

dex ; Move 1 pixels to the left

 

rts

 


 

[ 11-26-2001: Message edited by: Cafeman ]

Link to comment
Share on other sites

Still having problems, here is my movement code:

 

;************ Horizontal move ****************************************

 

horizmove

 

lda SPOT0

lsr ; Divide by 2 to prevent overflow...

 

cmp #$1A ; stick pulled left

bmi mvleft

cmp #$50 ; stick pulled right

bpl mvright

ldy #$00 ; clear hmove flag

sty hmFlag

rts

horizmove1

ldy #$01

sty hmFlag ; set hmove flag

clc

sbc #$78 ; Subtract 100 from the POT0 value

 

bmi mvleft ; If this value is negative then the

; user is pushing to the left

;

; FALL THROUGH

;

 

mvright

cpx #$C8 ; If the player is at the right most

bne mvright1 ; side of the playfield then don't move right

 

ldy #$01 ;right

jsr changeroom

rts

mvright1

 

inx ; Move 1 pixels to the right

 

lda bFrame ; If animation is already in the direction

cmp #

beq mvrs

lda #

sta pFrame

sta bFrame

lda #

sta mFrame

lda #

sta sFrame

mvrs rts

 

mvleft

cpx #$30 ; If the player is at the left most

bne mvleft1 ; side of the playfield then don't move left

 

ldy #$00 ;left

jsr changeroom

rts

mvleft1

 

dex ; Move 1 pixels to the left

 

lda bFrame ; If animation is already in this direction

cmp #

beq mvls

lda #

sta pFrame

sta bFrame

lda #

sta mFrame

lda #

sta sFrame

mvls rts

 

 

;************ Vertical move ****************************************

 

vertmove

 

lda SPOT1

cmp #$1A ; stick pulled up

bmi vertmove1

 

cmp #$50 ; stick pulled down

bne vertmove1

ldy #$00

sty vmFlag ; clear vmove Flag

rts

vertmove1

 

ldy #$01

sty vmFlag ; set vmove Flag

clc

sbc #$78 ; Subtract 100 from the POT1 value

 

bmi mvup ; If this value is negative then the

; user is pushing to the left

;

; FALL THROUGH

;

 

mvdown

lda pmbase0

cmp lowbound

bne mvdown1

 

ldy #$03 ;down

jsr changeroom

rts

mvdown1

inc pmbase0

rts

 

mvup

lda pmbase0

cmp topbound

bne mvup1

 

ldy #$02 ;up

jsr changeroom

rts

mvup1

dec pmbase0

rts

 

any suggestions??

Link to comment
Share on other sites

What are your results with this routine?

 

Also I'm assuming you are using the low and high byte notation with the &gt and &lt in your code. If you post that here you must use "& + lt" for a less than sign and "& + gt" for a greater than sign.

 

Try it with those combinations because right now the code is hard to read without them.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...