User | Post |
HabsoluteFate
Posts: 133/179 |
Originally posted by HyperHacker
Originally posted by HabsoluteFate $00/FEA8 22 EC F7 0F JSR $0FF7EC ; Jump to new fireball Sub Routine
Erm, how are you doing that? You JSR to a different bank. And of course, there doesn't seem to be one free byte in bank 0. Way to waste space, Nintendo!
Op Code 22 can be interpretted as either JSL or JSR as far as what i have read... "The JSL instruction is an alias for JSR long." |
HyperLamer
Posts: 3960/8210 |
Originally posted by HabsoluteFate $00/FEA8 22 EC F7 0F JSR $0FF7EC ; Jump to new fireball Sub Routine
Erm, how are you doing that? You JSR to a different bank. And of course, there doesn't seem to be one free byte in bank 0. Way to waste space, Nintendo! |
HabsoluteFate
Posts: 128/179 |
Originally posted by HyperHacker Well, I found the game's fireball subroutine - $FEA8 (called from $D0AA when you shoot), but there's a bit of a problem. You have to JSR to it, which isn't exactly possible outside of bank 00. Anyone know how I can use it? Hopefully I can stick a small chunk of code in the bank to handle it, but maybe someone knows a better way...
Also anyone know how to move the sprite layer? I've got a level set up where Mario stays still and layer 2 moves; problem is, the sprites don't move with it because Mario's technically still in the same place.
[edit] Could you do 'JSR $1234' to jump to whatever address $1234 points to? I know some other instructions can do it... Also is it necessary to use JSL when calling code in RAM from bank 0?
The fireball sub routine is currently used by both Fire Mario and Yoshi. they jump into the sub routine at different locations. Here are some notes of mine when i was working on my new power up...i totally changed the design midway so the following code is rough notes:
$00/FEA8 22 EC F7 0F JSR $0FF7EC ; Jump to new fireball Sub Routine $00/FEAC C9 00 CMP #$00 ; Compare Fireball are we done flag with 0 $00/FEAE D0 05 BNE $FEB5 $00/FEA0 60 RTS $00/FEB1 EA NOP $00/FEB2 EA NOP $00/FEB3 EA NOP $00/FEB4 EA NOP
$0F/F7EC A5 19 LDA $19 $0F/F7EE C9 03 CMP #$03 $0F/F7F0 D0 12 BNE $CapeFireMario FireMario: $0F/F7F2 A2 09 LDX #$09 Redo: $0F/F7F4 BD 0B 17 LDA $170B,x $0F/F7F7 F0 08 BEQ ExitMario $0F/F7F9 CA DEX $0F/F7FA E0 07 CPX #$07 $0F/F7FC D0 F6 BNE $F7F4 (Redo) $0F/F7FE A9 00 LDA #$00 ; Flag that we are done $0F/F800 6B RTL ExitMario: $0F/F801 A9 01 LDA #$01 ; Flag that we are not done $0F/F803 6B RTL CapeFireMario: $0F/F804 A9 00 LDA #$00 ; Flag that we are done $0F/F806 EA NOP ; Replace these 4 EAs with a Jump Long to Yoshi SubRoutine later on $0F/F807 EA NOP $0F/F808 EA NOP $0F/F809 EA NOP $0F/F80A 6B RTL ; Return
Makes "ThrowYoshiFireballs" $02/A1A7 22 0B F8 0F JSR $0FF80B $02/A1AB EA NOP $0F/F80B BD 47 17 LDA $1747,x $0F/F80E 29 80 AND #$80 $0F/F811 6B RTL
Seems to be Start of Sub Routine For Collision between thong/fireballs with enemies $02/A0B3 DA PHX A:9F00 X:0005 Y:0000 P:envMXdiZc Without this Yoshi's facial animation stops after shooting fireballs $01/EFEE A9 2A LDA #$2A A:0003 X:0008 Y:00D0 P:envMXdiZC This code seems to increase the fireball size: $02/9F71 A5 14 LDA $14 [$00:0014] A:9F00 X:0007 Y:002B P:envMXdizc This is the code that actually throws the fireballs $02/A1A4 BC 53 A1 LDY $A153,x[$02:A15A] A:9F03 X:0007 Y:0000 P:envMXdizc
warning: This code probably does not work and probably isnt very efficient
Edit: I'm going to introduce a program soon that will allow moving of entire sub routines from one location to another..which should make things easier...i needed something like that anyways for my power up stuff. the program will also allow import/export of ASM code that way you can export a block of code, make edits, and import that block of code (although since odds are it wouldnt fit in the original location you will have to move that code somewhere else)...i'll keep you guys posted once its completed and tested |
HyperLamer
Posts: 3959/8210 |
Well, I found the game's fireball subroutine - $FEA8 (called from $D0AA when you shoot), but there's a bit of a problem. You have to JSR to it, which isn't exactly possible outside of bank 00. Anyone know how I can use it? Hopefully I can stick a small chunk of code in the bank to handle it, but maybe someone knows a better way...
Also anyone know how to move the sprite layer? I've got a level set up where Mario stays still and layer 2 moves; problem is, the sprites don't move with it because Mario's technically still in the same place.
[edit] Could you do 'JSR $1234' to jump to whatever address $1234 points to? I know some other instructions can do it... Also is it necessary to use JSL when calling code in RAM from bank 0? |
Kario
Posts: 1601/2082 |
You flippin took my word.
Good find btw. |
HyperLamer
Posts: 3953/8210 |
Spawning fireballs. How do you do it? All this is doing is setting X to one and playing fireball sounds:
LDX #1 LDA $1714 ;Check fireball 1 BEQ fireball DEX LDA $1713 ;Check 2 BNE end
fireball: LDY #$20 STY $C100 ;Unused LDA #5 STA $1713,X ;Enable fireball LDA $96 STA $171D,X ;Y pos (low) LDA $97 ;CLC ;ADC $C100 STA $1731,X ;Y pos (high) LDA $94 STA $173B,X ;X pos (low) LDA $95 STA $1727,X ;X pos (high) STZ $1745,X ;Y speed LDA #6 STA $174F,X ;X speed ;LDA #6 STA $1DFC ;Sound |