EmilyBrooks

how to handle switch statements (for n64 decomp)

Sep 25th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. so you're going to get this "jump table" in the assembly file
  2.  
  3. for example, func_80A6F358.s
  4.  
  5. glabel jtbl_80A6F500
  6. .word L80A6F390
  7. .word L80A6F3BC
  8. .word L80A6F3C8
  9. .word L80A6F384
  10. .word L80A6F384
  11. .word 0x00000000, 0x00000000, 0x00000000
  12.  
  13. it will list the targets to where the code will jump to, and they correspond with blocks of code
  14.  
  15. in the assembly, each one goes in order of lowest to highest, so L80A6F384, then L80A6F390, then L80A6F3BC, then L80A6F3C8. you need to recreate these "blocks of code" inside your switch statement in this order
  16.  
  17. HOWEVER, the order of the cases is not this order. refer back to the jtbl for this. so in this example, the first entry in the table is L80A6F390, so you should put `case 0` on that block, even though it is the second block in your switch statement. that's just how morons make their switch statements don't ask me. then case 1 would be second in the table, which is L80A6F3BC (the third block of code)
  18.  
  19. the final switch statement should be
  20.  
  21. switch (temp_t6) {
  22. case 3:
  23. case 4:
  24. <L80A6F384 block>
  25. case 0:
  26. <L80A6F390 block>
  27. case 1:
  28. <L80A6F3BC block>
  29. case 2:
  30. <L80A6F384 block>
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment