Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. mega_evolve:
  2. push {r0-r7, lr}
  3.  
  4. @ Allocate space on the stack
  5. @ We're going to generate a dynamic battle script in the RAM
  6. mov r4, sp
  7. sub r4, #0xFF
  8. @ldr r4, =(0x020375D8)
  9.  
  10. @ Write the call byte
  11. mov r0, r4
  12. mov r1, #0x41
  13. strb r1, [r0]
  14.  
  15. @ Next, write the pointer of the target script
  16. adr r0, battle_script
  17. add r1, r4, #1
  18. bl unaligned_dword_write
  19.  
  20. @ Write goto byte after the call command
  21. mov r1, #0x28
  22. strb r1, [r4, #5]
  23.  
  24. @ Here we write the current battle script pointer. This makes it the target
  25. @ of the goto, so it will continue execution as normal after our little
  26. @ battle script...
  27. ldr r5, battle_script_insn_pointer
  28. ldr r0, [r5]
  29. add r1, r4, #6
  30. bl unaligned_dword_write
  31.  
  32. @ Now we execute our script
  33. str r4, [r5]
  34.  
  35. @ Change da species
  36. ldr r0, battle_participants
  37. ldr r1, battle_active
  38. ldrb r1, [r1]
  39. mov r2, #0x58
  40. mul r1, r2
  41. @add r0, r1
  42. mov r1, #3
  43. strh r1, [r0]
  44.  
  45. pop {r0-r7, pc}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement