Need some ASM help

Go down

Need some ASM help Empty Need some ASM help

Post by Charmander106 Sat 23 Apr 2016 - 0:30

I was just wanting to have it so you can switch your current held items by using the L and R buttons but my code messes up link's collision and pressing either the L/R buttons crashes the game.

Anyone willing to take a look at the code? Confused

Code:
lorom

;////////////////////NOTES/////////////////////////
;$7E:0202[0x01] -   currently selected item (Euclid)

;$0D/DEC7 8D 02 02    STA $0202  [$0D:0202]   A:DF0A X:0001 Y:0031 P:envMXdizC
;$0D/DED5 8D 02 02    STA $0202  [$0D:0202]   A:0902 X:0001 Y:0012 P:eNvMXdizc

;$0DDEBD Start of Code Selected Item (Up/Down?)
;$0DDECB Start of Code Selected Item (Left/Right?)

;$07E3F4 - Step Counter Code, possible hijack?
;$07F8A0 - Our Custom Code.

;$F2[0x01] - Unfiltered Joypad 1 Register: Same as $F6,
;            except it preserves buttons that were being pressed in the previous frame.
; L = 20 R = 10



org $07E3F4

 JSR $F8A0

org $07F8A0

 LDA $F2
 CMP #$10
 BNE PressLeft
 JSL $0DDECB
 LDA $20
 RTS

PressLeft:
 CMP #$20
 BNE END
 JSL $0DDECB
 LDA $20

END:
 RTS


Charmander106
Charmander106

Need some ASM help Image213

Since : 2014-04-01

Back to top Go down

Need some ASM help Empty Re: Need some ASM help

Post by Conn Sat 23 Apr 2016 - 5:58

your project is not as easy as it seems.
I fixed your code as far as it won't break anymore, but:
- the L-R press is on autofire
- the code doesn't work, there are further ram addresses involved (selected item is not only $0202 which works with this code, there is also a further ram involved that sets it to equipped, so that you can use this item and it shows also up in your Y-box). You must run another subroutine which is executed when you exit the menu.

Basically, the problem with your code was that you made a JSL where a JSR is needed, so I moved your code to the end of bank 06/ffd0. Unfortunately, here I found only little space at the end of the bank, so you cannot write much more code here Sad

Code:

lorom

;////////////////////NOTES/////////////////////////
;$7E:0202[0x01] -  currently selected item (Euclid)

;$0D/DEC7 8D 02 02    STA $0202  [$0D:0202]  A:DF0A X:0001 Y:0031 P:envMXdizC
;$0D/DED5 8D 02 02    STA $0202  [$0D:0202]  A:0902 X:0001 Y:0012 P:eNvMXdizc

;$0DDEBD Start of Code Selected Item (Up/Down?)
;$0DDECB Start of Code Selected Item (Left/Right?)

;$07E3F4 - Step Counter Code, possible hijack?
;$07F8A0 - Our Custom Code.

;$F2[0x01] - Unfiltered Joypad 1 Register: Same as $F6,
;            except it preserves buttons that were being pressed in the previous frame.
; L = 20 R = 10



org $07E3F2

JSL $0dffd0
NOP

org $0dffd0
 SEP #$20
 LDA $F2
 CMP #$10
 BNE PressLeft
 JSR $DEcb
 BRA END

PressLeft:
 CMP #$20
 BNE END
 JSr $DEcb


END:
LDA $20
SEC
 RTL

Conn
Conn

Need some ASM help Image212

Since : 2013-06-30

Back to top Go down

Need some ASM help Empty Re: Need some ASM help

Post by Charmander106 Sat 23 Apr 2016 - 10:27

Well I was just bored and thought I could give ASM a shot, but I just don't understand it, even though I really want to...

sigh... Sad
Charmander106
Charmander106

Need some ASM help Image213

Since : 2014-04-01

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum