Mgamerz

Untitled

Dec 16th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. rngaddress EQU 0200F440h
  2.  
  3. ;Flashman Chips
  4. flashmanchipcount EQU 4h
  5. flashmanchipreturnaddr EQU 0xb672ah
  6. teamfamily EQU 26h
  7. areafamily EQU 0h
  8. stagefamily EQU 4h
  9. trumpyfamily EQU 3Fh
  10.  
  11.  
  12. input equ whitevanilla.gba ; Put the name of your ROM here
  13. fspace equ 0x10 ; Put the ROM free space offset here
  14.  
  15. .gba
  16. .open input,output.gba,8000000h
  17.  
  18. .org fspace+8000000h
  19. .align 2
  20.  
  21. rngRoutine:
  22. ldr r0, [rngaddress]
  23. blt return
  24.  
  25.  
  26. loadRandomChip:
  27. push {r14}
  28. bl rngRoutine ;GET RNG result AND PUT INTO r0
  29. pop {r15}
  30. mov r1, flashmanchipcount ;number of chips in selection list
  31. swi 6; Divide
  32. ldr r0,=@@chipLookupTable ;Load address of chip lookup table (defined below)
  33. mov r2,0x03 ; Load r2 with 3
  34. mul r1,r2 ;Multiple the modulo result by the size of the structs (3 bytes) - this will provide an offset into the chip lookup table
  35. add r0,r0,r1 ;calculate the address using the offset, store in r0
  36. ldrb r3, [r0,0x02] ;load byte from *r0 (offset 2 forward) into r3 (dmg)
  37. ldrb r1, [r0,0x01] ;load byte from *r0 (offset 1 forward) into r1 (sublevel)
  38. ldrb r0, [r0,0x00] ;load byte from *r0 (direct addr) into r0 (family)
  39. ldrb r2,[r5,16h] ; ...this is actually the object's alliance enemy/allied
  40.  
  41. b flashmanchipreturnaddr ;return to chip usage code (flashman)
  42. .pool
  43. @@chipLookupTable:
  44. .byte teamfamily, 0h, 0h
  45. .byte areafamily, 0h, 10h
  46. .byte stagefamily, 4h, 0h
  47. .byte trumpyfamily, 1h, 0h
  48.  
  49. .close
  50. ; eof
Advertisement
Add Comment
Please, Sign In to add comment