Difference between revisions of "Slope Calculations"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Created page with " Calculate Z Mod Current Stack: 0x10 - Unit's X 0x12 - Unit's Y Previous Stack: 0x00 - Mount/Unit's X Mod 0x02 - Mount/Unit's Map Level 0x03 - 0x04 - Mount/Unit's Y M...")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Calculate Z Mod
+
=== Instructions and notes ===
  Current Stack:
+
  '''Parameters''' : r5 = Tile elevation
0x10 - Unit's X
+
              r4 = previous routine stack pointer
0x12 - Unit's Y
+
                    - 0x00 = X mod (X coord * 28 + preset value)
  Previous Stack:
+
                    - 0x02 = Elevation
  0x00 - Mount/Unit's X Mod
+
                    - 0x04 = Y mod (Y coord * 28 + preset value)
0x02 - Mount/Unit's Map Level
+
   
0x03 -  
+
  '''Returns''' : r2 holding Height data as negative value depending of slope type
0x04 - Mount/Unit's Y Mod
+
                  - (Height*12) if halves = 0 or unsupported slope type
 
+
                  - (Height*12) + (preset/28)*12*halves  (depending of slope [[#0007c80cNotes|see notes]])
0007c80c: 27bdffd8 addiu r29,r29,0xffd8 (routine has a really bad setup - could be MUCH better)
+
                  - (Height*12) + (1- preset/28)*12*halves (depending of slope [[#0007c80cNotes|see notes]])  
  0007c810: afb00018 sw r16,0x0018(r29)
+
                  NB : is preset is 14 , same result for all slope
0007c814: 00808021 addu r16,r4,r0 r16 = Stack Pointer
+
  -----------------------------------------------------------------------------------------
  0007c818: afb1001c sw r17,0x001c(r29)
+
   
0007c81c: 3c119249 lui r17,0x9249 r17 = -0.42857143 (-3 / 7)
+
  0007c80c: 27bdffd8 addiu r29,r29,-0x0028    |{{f/std|<nowiki>(routine has a extremly bad setup - could be MUCH better)</nowiki>}}
0007c820: afbf0020 sw r31,0x0020(r29) (is 4 / 7, but mult makes it negative)
+
  0007c810: afb00018 sw r16,0x0018(r29)      |
0007c824: 96020000 lhu r2,0x0000(r16) Load X Mod
+
  0007c814: 00808021 addu r16,r4,r0          |{{f/std|<nowiki>r16 = Stack Pointer</nowiki>}}
0007c828: 36312493 ori r17,r17,0x2493
+
  0007c818: afb1001c sw r17,0x001c(r29)      |
0007c82c: 00021400 sll r2,r2,0x10
+
  0007c81c: 3c119249 lui r17,0x9249          |
  0007c830: 00021c03 sra r3,r2,0x10 r3 = X Mod
+
  0007c820: afbf0020 sw r31,0x0020(r29)       |
  0007c834: 00710018 mult r3,r17 X Mod * -3 / 7
+
  0007c824: 96020000 lhu r2,0x0000(r16)       |{{f/load|<nowiki>r2 = Unit X*28 +14 (X mod) - halfword</nowiki>}}
  0007c838: 000217c3 sra r2,r2,0x1f (multu would do this without needing to
+
  0007c828: 36312493 ori r17,r17,0x2493      |{{f/std|<nowiki>r17 = 0x92492493 ( =-3/7 * 2^32)</nowiki>}}
  0007c83c: 00002010 mfhi r4 add the base back into it, afaik)
+
  0007c82c: 00021400 sll r2,r2,0x10           |{{f/std|<nowiki>r2 = unit X mod * 1024 (move the lower part of the register in upper part)</nowiki>}}
0007c840: 00832021 addu r4,r4,r3 X Mod * 4 / 7 (cancels the negative)
+
0007c830: 00021c03 sra r3,r2,0x10           |{{f/std|<nowiki>r3 = unit  X Mod (Uper part of register is cleaned)</nowiki>}}
  0007c844: 00042103 sra r4,r4,0x04 Unit's X = XMod / 28
+
  0007c834: 00710018 mult r3,r17             |{{f/std|<nowiki>X mod * -3/7 * 2^32</nowiki>}}
  0007c848: 00822023 subu r4,r4,r2
+
  0007c838: 000217c3 sra r2,r2,0x1f          |{{f/std|<nowiki>r2 = r2/2^31 (mostly 0x00, unlikely 0x01)</nowiki>}}
  0007c84c: a7a40010 sh r4,0x0010(r29) Store Unit's X
+
  0007c83c: 00002010 mfhi r4                 |{{f/std|<nowiki>r4 = unit X mod * -3/7</nowiki>}}
  0007c850: 96030004 lhu r3,0x0004(r16) Load Y Mod
+
  0007c840: 00832021 addu r4,r4,r3           |{{f/std|<nowiki>r4 = unit X Mod * 4 / 7 </nowiki>}}
  0007c854: 00000000 nop
+
  0007c844: 00042103 sra r4,r4,0x04           |{{f/std|<nowiki>r4 = Unit XMod / 28 (= unit X coord)</nowiki>}}
  0007c858: 00031c00 sll r3,r3,0x10
+
  0007c848: 00822023 subu r4,r4,r2           |{{f/std|<nowiki>rounding stuff</nowiki>}}
0007c85c: 00033403 sra r6,r3,0x10
+
  0007c84c: a7a40010 sh r4,0x0010(r29)       |{{f/store|<nowiki>Store Unit's X coord on stack 0x10</nowiki>}} {{f/std|<nowiki>(Unused in the routine)</nowiki>}}
  0007c860: 00d10018 mult r6,r17 Y Mod * -3 / 7
+
  0007c850: 96030004 lhu r3,0x0004(r16)      |{{f/load|<nowiki>r3 = Unit Y*28 +14 (Y mod) - halfword</nowiki>}}
  0007c864: 00042400 sll r4,r4,0x10
+
  0007c854: 00000000 nop                      |
  0007c868: 00042403 sra r4,r4,0x10
+
  0007c858: 00031c00 sll r3,r3,0x10           |{{f/std|<nowiki>r3 = unit Y mod * 1024 </nowiki>}}
  0007c86c: 00031fc3 sra r3,r3,0x1f
+
  0007c85c: 00033403 sra r6,r3,0x10          |{{f/std|<nowiki>r6 = unit  Y Mod (register cleanup)</nowiki>}}
0007c870: 00001010 mfhi r2
+
  0007c860: 00d10018 mult r6,r17              |{{f/std|<nowiki>Y mod * -3/7 * 2^32</nowiki>}}
0007c874: 00461021 addu r2,r2,r6 Y Mod * 4 / 7
+
  0007c864: 00042400 sll r4,r4,0x10          |{{f/std|<nowiki>r4 = unit X coord * 1024 </nowiki>}}
  0007c878: 00021103 sra r2,r2,0x04 Unit's Y = Y Mod / 28
+
  0007c868: 00042403 sra r4,r4,0x10          |r4 = Unit X coord (register cleanup)
  0007c87c: 00431023 subu r2,r2,r3
+
  0007c86c: 00031fc3 sra r3,r3,0x1f          |{{f/std|<nowiki>r3 = r3/2^31 = 0x00 (very unlikely 0x01)</nowiki>}}
  0007c880: a7a20012 sh r2,0x0012(r29) Store Unit's Y
+
  0007c870: 00001010 mfhi r2                  |{{f/std|<nowiki>r2 = Unit Y mod * -3/7</nowiki>}}
0007c884: 00021400 sll r2,r2,0x10
+
  0007c874: 00461021 addu r2,r2,r6            |{{f/std|<nowiki>r2 = Unit Y Mod * 4 / 7</nowiki>}}
  0007c888: 30a600ff andi r6,r5,0x00ff r6 = Unit's Map Level
+
  0007c878: 00021103 sra r2,r2,0x04          |{{f/std|<nowiki>r2 = Unit's Y Coord (Y mod / 28)</nowiki>}}
  0007c88c: 0c060fed jal 0x00183fb4 Get Tile's Data Pointer
+
  0007c87c: 00431023 subu r2,r2,r3            |{{f/std|<nowiki>rounding stuff</nowiki>}}
  0007c890: 00022c03 sra r5,r2,0x10 r5 = Unit's Y
+
  0007c880: a7a20012 sh r2,0x0012(r29)       |{{f/store|<nowiki>Store Unit's Y coord on stack 0x12</nowiki>}} {{f/std|<nowiki>(Unused in the routine)</nowiki>}}
  0007c894: 00402821 addu r5,r2,r0 r5 = Tile Data Pointer
+
  0007c884: 00021400 sll r2,r2,0x10          |{{f/std|<nowiki>r2 = unit Y coord * 1024 (move the lower part of the register in upper part)</nowiki>}}
  0007c898: 90a30002 lbu r3,0x0002(r5) Load Tile's Height
+
  0007c888: 30a600ff andi r6,r5,0x00ff        |r6 = Unit's Elevation
  0007c89c: 00000000 nop
+
  0007c88c: 0c060fed jal 0x00183fb4          |{{f/jal|Get_Tile_Data_Pointer|<nowiki>Get_Tile_Data_Pointer</nowiki>}} Return r2 = Unit tile data pointer
0007c8a0: 00031040 sll r2,r3,0x01 Height * 2
+
  0007c890: 00022c03 sra r5,r2,0x10          |r5 = Unit's Y (upper part of register cleared)
  0007c8a4: 00431021 addu r2,r2,r3 Height * 3
+
  0007c894: 00402821 addu r5,r2,r0           |{{f/std|<nowiki>r5 = Tile Data Pointer</nowiki>}}
  0007c8a8: 00021080 sll r2,r2,0x02 Height * 12
+
  0007c898: 90a30002 lbu r3,0x0002(r5)        |{{f/load|<nowiki>r3 = Tile's Height</nowiki>}}
  0007c8ac: 00025023 subu r10,r0,r2 Z Mod = -Height * 12
+
  0007c89c: 00000000 nop                      |
  0007c8b0: 90a20003 lbu r2,0x0003(r5) Load Halves + Depth
+
  0007c8a0: 00031040 sll r2,r3,0x01          |{{f/std|<nowiki>r2 = tile Height * 2</nowiki>}}
  0007c8b4: 00000000 nop
+
  0007c8a4: 00431021 addu r2,r2,r3            |{{f/std|<nowiki>r2 = Height * 3</nowiki>}}
0007c8b8: 3049001f andi r9,r2,0x001f r9 = Halves
+
  0007c8a8: 00021080 sll r2,r2,0x02          |{{f/std|<nowiki>r2 = Height * 12</nowiki>}}
  0007c8bc: 112001c6 beq r9,r0,0x0007cfd8 Branch if Halves = 0 (skips ALL of the slope checks)
+
  0007c8ac: 00025023 subu r10,r0,r2           |r10 = -(Height * 12)
  0007c8c0: 01402021 addu r4,r10,r0 r4 = Z Mod
+
  0007c8b0: 90a20003 lbu r2,0x0003(r5)        |{{f/load|<nowiki>r2 =  Tiles Halves + Depth</nowiki>}}
0007c8c4: 90a30004 lbu r3,0x0004(r5) Load Slope Type
+
  0007c8b4: 00000000 nop                      |
  0007c8c8: 34020052 ori r2,r0,0x0052
+
0007c8b8: 3049001f andi r9,r2,0x001f        |{{f/std|<nowiki>r9 = Tile  Halves</nowiki>}}
0007c8cc: 1062002f beq r3,r2,0x0007c98c Branch if Slope Type = 0x52
+
  0007c8bc: 112001c6 beq r9,r0,0x0007cfd8    {{f/Cond|<nowiki>If Halves <> 0x00</nowiki>}} {{f/Cond|<nowiki>Branch if Halves = 0 (skips ALL of the slope checks)</nowiki>}}
  0007c8d0: 28620053 slti r2,r3,0x0053
+
  0007c8c0: 01402021 addu r4,r10,r0          |{{f/std|<nowiki>r4 = Z Mod</nowiki>}}
  0007c8d4: 10400013 beq r2,r0,0x0007c924 Branch if Slope Type >= 0x53
+
  0007c8c4: 90a30004 lbu r3,0x0004(r5)            |{{f/load|<nowiki>r3 = Tile Slope Type</nowiki>}}
  0007c8d8: 34020025 ori r2,r0,0x0025
+
  0007c8c8: 34020052 ori r2,r0,0x0052              |{{f/std|<nowiki>r2 = 0x52</nowiki>}}
0007c8dc: 1062004f beq r3,r2,0x0007ca1c Branch if Slope Type = 0x25
+
  0007c8cc: 1062002f beq r3,r2,0x0007c98c          {{f/Cond|<nowiki>If Tile slope <> 0x52</nowiki>}} {{f/Cond|<nowiki>Else branch to Slope Type = 0x52 section</nowiki>}}
  0007c8e0: 00000000 nop
+
  0007c8d0: 28620053 slti r2,r3,0x0053                |{{f/std|<nowiki>r2 = 0x01 if slope < 0x53</nowiki>}}
0007c8e4: 28620026 slti r2,r3,0x0026
+
  0007c8d4: 10400013 beq r2,r0,0x0007c924              {{f/Cond|<nowiki>If slope < 0x52</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type >= 0x53</nowiki>}}
0007c8e8: 10400007 beq r2,r0,0x0007c908 Branch if Slope Type >= 0x26
+
  0007c8d8: 34020025 ori r2,r0,0x0025                      |{{f/std|<nowiki>r2 = 0x25</nowiki>}}
  0007c8ec: 34020011 ori r2,r0,0x0011
+
  0007c8dc: 1062004f beq r3,r2,0x0007ca1c                  {{f/Cond|<nowiki>If slope <> 0x25</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type = 0x25</nowiki>}}
0007c8f0: 10620084 beq r3,r2,0x0007cb04 Branch if Slope Type = 0x11
+
  0007c8e0: 00000000 nop                                       |{{f/std|<nowiki>  </nowiki>}}
  0007c8f4: 34020014 ori r2,r0,0x0014
+
  0007c8e4: 28620026 slti r2,r3,0x0026                        |{{f/std|<nowiki>r2 = 0x01 if slope < 0x26</nowiki>}}
  0007c8f8: 106200ac beq r3,r2,0x0007cbac Branch if Slope Type = 0x14
+
  0007c8e8: 10400007 beq r2,r0,0x0007c908                      {{f/Cond|<nowiki>If slope < 0x26</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type >= 0x26</nowiki>}}
  0007c8fc: 00041400 sll r2,r4,0x10
+
  0007c8ec: 34020011 ori r2,r0,0x0011                              |{{f/std|<nowiki>r2 = 0x11</nowiki>}}
  0007c900: 0801f3f7 j 0x0007cfdc
+
  0007c8f0: 10620084 beq r3,r2,0x0007cb04                          {{f/Cond|<nowiki>If slope <> 0x11</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type = 0x11</nowiki>}}
0007c904: 00000000 nop
+
  0007c8f4: 34020014 ori r2,r0,0x0014                                  |{{f/std|<nowiki>r2 = 0x14</nowiki>}}
0007c908: 34020041 ori r2,r0,0x0041
+
  0007c8f8: 106200ac beq r3,r2,0x0007cbac                              {{f/Cond|<nowiki>If slop <> 0x14</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type = 0x14</nowiki>}}
  0007c90c: 10620059 beq r3,r2,0x0007ca74 Branch if Slope Type = 0x41
+
  0007c8fc: 00041400 sll r2,r4,0x10                                        |{{f/std|<nowiki>r2 = r10 * 1024 (1st move for register clean up)</nowiki>}}
  0007c910: 34020044 ori r2,r0,0x0044
+
  0007c900: 0801f3f7 j 0x0007cfdc                                          {{f/jump|<nowiki>jump to end (slope type not supported/invalid)</nowiki>}}
  0007c914: 106200cd beq r3,r2,0x0007cc4c Branch if Slope Type = 0x44
+
0007c904: 00000000 nop                                                  |
  0007c918: 00041400 sll r2,r4,0x10
+
  0007c908: 34020041 ori r2,r0,0x0041                          {{f/Cond|<nowiki> Else (slope >= 0x26)</nowiki>}} {{f/std|<nowiki>r2 = 0x41</nowiki>}}
  0007c91c: 0801f3f7 j 0x0007cfdc
+
0007c90c: 10620059 beq r3,r2,0x0007ca74                      {{f/Cond|<nowiki>If slope <> 0x41</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type = 0x41</nowiki>}}
  0007c920: 00000000 nop
+
  0007c910: 34020044 ori r2,r0,0x0044                              |{{f/std|<nowiki>r2 = 0x44</nowiki>}}
  0007c924: 34020069 ori r2,r0,0x0069
+
  0007c914: 106200cd beq r3,r2,0x0007cc4c                          {{f/Cond|<nowiki>If slope <> 0x44</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type = 0x44</nowiki>}}
  0007c928: 1062013d beq r3,r2,0x0007ce20 Branch if Slope Type = 0x69
+
  0007c918: 00041400 sll r2,r4,0x10                                   |{{f/std|<nowiki>r2 = r10 * 1024 (1st move for register clean up)</nowiki>}}
  0007c92c: 2862006a slti r2,r3,0x006a
+
0007c91c: 0801f3f7 j 0x0007cfdc                                     {{f/jump|<nowiki>jump to end (slope type not supported/invalid)</nowiki>}}
  0007c930: 10400008 beq r2,r0,0x0007c954 Branch if Slope Type >= 0x6a
+
  0007c920: 00000000 nop                                               |
  0007c934: 34020058 ori r2,r0,0x0058
+
0007c924: 34020069 ori r2,r0,0x0069                  {{f/Cond|<nowiki>Else (Slope >= 0x53)</nowiki>}} {{f/std|<nowiki>r2 = 0x69</nowiki>}}
  0007c938: 10620025 beq r3,r2,0x0007c9d0 Branch if Slope Type = 0x58
+
0007c928: 1062013d beq r3,r2,0x0007ce20              {{f/Cond|<nowiki>If slope <> 0x69</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type = 0x69</nowiki>}}
  0007c93c: 00000000 nop
+
0007c92c: 2862006a slti r2,r3,0x006a                    |{{f/std|<nowiki>r2 = 1 if slope < 0x6a</nowiki>}}
  0007c940: 34020066 ori r2,r0,0x0066
+
0007c930: 10400008 beq r2,r0,0x0007c954                  {{f/Cond|<nowiki>If slope < 0x6a</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type >= 0x6a</nowiki>}}
  0007c944: 1062010c beq r3,r2,0x0007cd78 Branch if Slope Type = 0x66
+
0007c934: 34020058 ori r2,r0,0x0058                          |{{f/std|<nowiki>r2 = 0x58</nowiki>}}
  0007c948: 00041400 sll r2,r4,0x10
+
0007c938: 10620025 beq r3,r2,0x0007c9d0                      {{f/Cond|<nowiki>If slope <> 0x58</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type = 0x58</nowiki>}}
  0007c94c: 0801f3f7 j 0x0007cfdc
+
0007c93c: 00000000 nop                                          |{{f/std|<nowiki> </nowiki>}}
0007c950: 00000000 nop
+
0007c940: 34020066 ori r2,r0,0x0066                              |{{f/std|<nowiki>r2 = 0x66</nowiki>}}
  0007c954: 34020096 ori r2,r0,0x0096
+
0007c944: 1062010c beq r3,r2,0x0007cd78                          {{f/Cond|<nowiki>If slope <> 0x66</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type = 0x66</nowiki>}}
  0007c958: 106200e3 beq r3,r2,0x0007cce8 Branch if Slope Type = 0x96
+
0007c948: 00041400 sll r2,r4,0x10                                    |{{f/std|<nowiki>r2 = r10 * 1024 (1st move for register clean up)</nowiki>}}
  0007c95c: 28620097 slti r2,r3,0x0097
+
0007c94c: 0801f3f7 j 0x0007cfdc                                      {{f/jump|<nowiki>jump to end (slope type not supported/invalid)</nowiki>}}
  0007c960: 10400005 beq r2,r0,0x0007c978 Branch if Slope Type >= 0x97
+
0007c950: 00000000 nop                                              |
  0007c964: 34020085 ori r2,r0,0x0085
+
0007c954: 34020096 ori r2,r0,0x0096                      {{f/Cond|<nowiki>Else (slope >= 0x6a)</nowiki>}} {{f/std|<nowiki>r2 = 0x96</nowiki>}}
0007c968: 1062003f beq r3,r2,0x0007ca68 Branch if Slope Type = 0x85
+
0007c958: 106200e3 beq r3,r2,0x0007cce8                  {{f/Cond|<nowiki>If slope <> 0x96</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type = 0x96</nowiki>}}
  0007c96c: 00041400 sll r2,r4,0x10
+
0007c95c: 28620097 slti r2,r3,0x0097                        |{{f/std|<nowiki>r2 = 0x01 if slope < 0x97</nowiki>}}
  0007c970: 0801f3f7 j 0x0007cfdc
+
0007c960: 10400005 beq r2,r0,0x0007c978                      {{f/Cond|<nowiki>If slope < 0x97</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type >= 0x97</nowiki>}}
0007c974: 00000000 nop
+
0007c964: 34020085 ori r2,r0,0x0085                              |{{f/std|<nowiki>r2 = 0x85</nowiki>}}
0007c978: 34020099 ori r2,r0,0x0099
+
0007c968: 1062003f beq r3,r2,0x0007ca68                          {{f/Cond|<nowiki>If slope <> 0x85</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type = 0x85</nowiki>}}
0007c97c: 10620150 beq r3,r2,0x0007cec0 Branch if Slope Type = 0x99
+
0007c96c: 00041400 sll r2,r4,0x10                                    |{{f/std|<nowiki>r2 = r10 * 1024 (1st move for register clean up)</nowiki>}}
  0007c980: 00041400 sll r2,r4,0x10
+
0007c970: 0801f3f7 j 0x0007cfdc                                      {{f/jump|<nowiki>jump to end (slope type not supported/invalid)</nowiki>}}
0007c984: 0801f3f7 j 0x0007cfdc
+
0007c974: 00000000 nop                                              |
  0007c988: 00000000 nop
+
0007c978: 34020099 ori r2,r0,0x0099                          {{f/Cond|<nowiki>Else (slope > 0x97)</nowiki>}} {{f/std|<nowiki>r2 = 0x99</nowiki>}}
 +
0007c97c: 10620150 beq r3,r2,0x0007cec0                      {{f/Cond|<nowiki>if slope <> 0x99</nowiki>}} {{f/Cond|<nowiki>Branch if Slope Type = 0x99</nowiki>}}
 +
0007c980: 00041400 sll r2,r4,0x10                                |{{f/std|<nowiki>r2 = r10 * 1024 (1st move for register clean up)</nowiki>}}
 +
0007c984: 0801f3f7 j 0x0007cfdc                                  {{f/jump|<nowiki>jump to end (slope type not supported/invalid)</nowiki>}}
 +
0007c988: 00000000 nop                                          |
 +
 +
                                            {{f/com|<nowiki>--- Slope Type = 0x52  Section---</nowiki>}}
 +
0007c98c: 96030000 lhu r3,0x0000(r16)            |{{f/load|<nowiki>r3 =  X Mod (X coord*28 +14)</nowiki>}}
 +
0007c990: 00000000 nop                          |
 +
0007c994: 00031c00 sll r3,r3,0x10                |{{f/std|<nowiki>r3 = X mod * 1024 (move halfword in upper register part)</nowiki>}}
 +
0007c998: 00032403 sra r4,r3,0x10                |{{f/std|<nowiki>r4 = X mod *1024/1024 (move halfword in lower register part - upper part is 0x0000)</nowiki>}}
 +
0007c99c: 00910018 mult r4,r17                  |{{f/std|<nowiki>X Mod * (-3 / 7)*2^32</nowiki>}}
 +
0007c9a0: 00031fc3 sra r3,r3,0x1f                |{{f/std|<nowiki>r3 = 0x00 (or 0x01 if r3 is > 2^31 or r3 is a negative word - not possible X should be > 1169...)</nowiki>}}
 +
0007c9a4: 00001010 mfhi r2                      |{{f/std|<nowiki>r2 = X mod * -3/7</nowiki>}}
 +
0007c9a8: 00441021 addu r2,r2,r4                |{{f/std|<nowiki>r2 = X Mod * 4 / 7</nowiki>}}
 +
0007c9ac: 00021103 sra r2,r2,0x04                |{{f/std|<nowiki>r2 = X Coord (= X Mod / 28)</nowiki>}}
 +
0007c9b0: 00431023 subu r2,r2,r3                |{{f/std|<nowiki>(r2 = r2 - 0x00)</nowiki>}}
 +
0007c9b4: 000218c0 sll r3,r2,0x03                |{{f/std|<nowiki>r3 = X coord * 8</nowiki>}}
 +
0007c9b8: 00621823 subu r3,r3,r2                |{{f/std|<nowiki>r3 = X coord * 7</nowiki>}}
 +
0007c9bc: 00031880 sll r3,r3,0x02                |{{f/std|<nowiki>r3 = X coord * 28</nowiki>}}
 +
0007c9c0: 00832023 subu r4,r4,r3                |{{f/std|<nowiki>r4 = preset value  (X Coord*28 + 14 - X Coord*28 (=14)  depending of calling routine ?)</nowiki>}}
 +
0007c9c4: 00042400 sll r4,r4,0x10                |{{f/std|<nowiki>r4 = preset value *1024</nowiki>}}
 +
0007c9c8: 0801f3e8 j 0x0007cfa0                  {{f/jump|<nowiki>Jump to  [(Preset/28) * (12 * Halves)] section with X preset</nowiki>}} {{f/jump|<nowiki> </nowiki>}}
 +
0007c9cc: 00042403 sra r4,r4,0x10                |{{f/std|<nowiki>r4 = preset value with clean register</nowiki>}}
 +
 +
                                            {{f/com|<nowiki>--- Slope Type = 0x58  Section---</nowiki>}}
 +
0007c9d0: 96030000 lhu r3,0x0000(r16)            |{{f/load|<nowiki>Load X Mod</nowiki>}} {{f/std|<nowiki>(X coord*28 + 14)</nowiki>}}
 +
0007c9d4: 00000000 nop                          |
 +
0007c9d8: 00031c00 sll r3,r3,0x10                |{{f/std|<nowiki>r3 = X Mod * 1024</nowiki>}}
 +
0007c9dc: 00032403 sra r4,r3,0x10                |{{f/std|<nowiki>r4 = X Mod  (clear upper part of registery)</nowiki>}}
 +
0007c9e0: 00910018 mult r4,r17                  |{{f/std|<nowiki>X Mod *( -3 / 7)*2^32</nowiki>}}
 +
0007c9e4: 00031fc3 sra r3,r3,0x1f                |{{f/std|<nowiki>r3 = 0x00</nowiki>}}
 +
0007c9e8: 00001010 mfhi r2                      |{{f/std|<nowiki>r2 = X mod * (-3/7)</nowiki>}}
 +
0007c9ec: 00441021 addu r2,r2,r4                |{{f/std|<nowiki>r2 = X Mod * 4 / 7</nowiki>}}
 +
0007c9f0: 00021103 sra r2,r2,0x04                |{{f/std|<nowiki>r2 = X Mod / 28 (= X coord )</nowiki>}}
 +
0007c9f4: 00431023 subu r2,r2,r3                |{{f/std|<nowiki>r2 =  X coord -0x00</nowiki>}}
 +
0007c9f8: 000218c0 sll r3,r2,0x03                |{{f/std|<nowiki>r3 = X Coord * 8</nowiki>}}
 +
0007c9fc: 00621823 subu r3,r3,r2                |{{f/std|<nowiki>r3 = X Coord * 7</nowiki>}}
 +
0007ca00: 00031880 sll r3,r3,0x02                |{{f/std|<nowiki>r3 = X Coord * 28</nowiki>}}
 +
0007ca04: 00832023 subu r4,r4,r3                |{{f/std|<nowiki>r4 = 14 (X Coord * 28 + 14) - X coord*28  </nowiki>}} {{f/std|<nowiki>(depeding of calling routine ?)</nowiki>}}
 +
0007ca08: 00042400 sll r4,r4,0x10                |
 +
0007ca0c: 00042403 sra r4,r4,0x10                |{{f/std|<nowiki>r4 =14 (upper part of registery cleared)</nowiki>}}
 +
0007ca10: 00041040 sll r2,r4,0x01                |{{f/std|<nowiki>r2 = 28 (preset*2)</nowiki>}}
 +
0007ca14: 0801f3d7 j 0x0007cf5c                  {{f/jump|<nowiki>Jump to [(1-preset/28) * (12*Halves)] section with X preset</nowiki>}}
 +
0007ca18: 00441021 addu r2,r2,r4                |{{f/std|<nowiki>r2 = 42 (preset *3)</nowiki>}}
 +
 +
                                            {{f/com|<nowiki>--- Slope Type = 0x25  Section---</nowiki>}}
 +
0007ca1c: 96030004 lhu r3,0x0004(r16)            |{{f/load|<nowiki>r3 = Y Mod</nowiki>}} {{f/std|<nowiki>(Y coord*28 + 14)</nowiki>}}
 +
0007ca20: 00000000 nop                          |
 +
0007ca24: 00031c00 sll r3,r3,0x10                |{{f/std|<nowiki>r3 = r3*1024</nowiki>}}
 +
0007ca28: 00032403 sra r4,r3,0x10                |{{f/std|<nowiki>r3 = Y Mod (register cleared)</nowiki>}}
 +
0007ca2c: 00910018 mult r4,r17                  |{{f/std|<nowiki>r4 = Y Mod * -3 / 7 * 2^32</nowiki>}}
 +
0007ca30: 00031fc3 sra r3,r3,0x1f                |{{f/std|<nowiki>r3 = 0x00</nowiki>}}
 +
0007ca34: 00001010 mfhi r2                      |{{f/std|<nowiki>r2 = Y Mod * -3/7</nowiki>}}
 +
0007ca38: 00441021 addu r2,r2,r4                |{{f/std|<nowiki>r2 = Y Mod * 4/7</nowiki>}}
 +
0007ca3c: 00021103 sra r2,r2,0x04                |{{f/std|<nowiki>r2 = Y Coord</nowiki>}}
 +
0007ca40: 00431023 subu r2,r2,r3                |{{f/std|<nowiki>r2 = Y Coord</nowiki>}}
 +
0007ca44: 000218c0 sll r3,r2,0x03                |{{f/std|<nowiki>r2 = Y Coord * 8</nowiki>}}
 +
0007ca48: 00621823 subu r3,r3,r2                |{{f/std|<nowiki>r2 = Y Coord * 7</nowiki>}}
 +
0007ca4c: 00031880 sll r3,r3,0x02                |{{f/std|<nowiki>r2 = Y Coord * 28</nowiki>}}
 +
0007ca50: 00832023 subu r4,r4,r3                |{{f/std|<nowiki>r4 = Y preset value</nowiki>}}
 +
0007ca54: 00042400 sll r4,r4,0x10                |{{f/std|<nowiki>r4 = r4 * 1024</nowiki>}}
 +
0007ca58: 00042403 sra r4,r4,0x10                |{{f/std|<nowiki>r4 = Y preset value (register cleared)</nowiki>}}
 +
0007ca5c: 00041040 sll r2,r4,0x01                |{{f/std|<nowiki>r2 = Y preset value * 2</nowiki>}}
 +
0007ca60: 0801f3d7 j 0x0007cf5c                  {{f/jump|<nowiki>Jump to [(1-preset/28) * (12*Halves)] section with Y preset</nowiki>}}
 +
0007ca64: 00441021 addu r2,r2,r4                |{{f/std|<nowiki>r2 = Y preset value * 3</nowiki>}}
 +
 +
                                            {{f/com|<nowiki>--- Slope Type = 0x85  Section---</nowiki>}}
 +
0007ca68: 96030004 lhu r3,0x0004(r16)            |{{f/load|<nowiki>r3 = Y Mod</nowiki>}} {{f/std|<nowiki>(Y coord*28 + 14)</nowiki>}}
 +
0007ca6c: 0801f266 j 0x0007c998                  {{f/jump|<nowiki>Jump to 0x52 section with Y Mod </nowiki>}} {{f/std|<nowiki>will go to [(Preset/28) * (12 * Halves)] section with Y preset</nowiki>}}
 +
0007ca70: 00031c00 sll r3,r3,0x10                |{{f/std|<nowiki>r3 = r3 * 1024 (1st move of register cleanup)</nowiki>}}
 +
 +
                                            {{f/com|<nowiki>--- Slope Type = 0x41  Section---</nowiki>}}
 +
0007ca74: 96020000 lhu r2,0x0000(r16)            |{{f/load|<nowiki>r2 = X Mod (X Coord*28 + X Preset)</nowiki>}}
 +
0007ca78: 00000000 nop                          |
 +
0007ca7c: 00021400 sll r2,r2,0x10                |{{f/std|<nowiki>r2 = r2 * 1024</nowiki>}}
 +
0007ca80: 00022403 sra r4,r2,0x10                |{{f/std|<nowiki>r4 = X mod (upper register cleanup)</nowiki>}}
 +
0007ca84: 00910018 mult r4,r17                  |{{f/std|<nowiki>X mod * -3/7 * 2^32</nowiki>}}
 +
0007ca88: 96060004 lhu r6,0x0004(r16)            |{{f/load|<nowiki>r6 =  Y Mod (Y Coord * 28 + Y preset)</nowiki>}}
 +
0007ca8c: 00001810 mfhi r3                      |{{f/std|<nowiki>r3 = X mod * -3/7</nowiki>}}
 +
0007ca90: 00063400 sll r6,r6,0x10                |{{f/std|<nowiki>r6 = r6 *1024</nowiki>}}
 +
0007ca94: 00062c03 sra r5,r6,0x10                |{{f/std|<nowiki>r5 = Y mod (upper register cleanup)</nowiki>}}
 +
0007ca98: 00b10018 mult r5,r17                  |{{f/std|<nowiki>Y Mod * -3 / 7 * 2^32</nowiki>}}
 +
0007ca9c: 000217c3 sra r2,r2,0x1f                |{{f/std|<nowiki>r2 = 0x00</nowiki>}}
 +
0007caa0: 000637c3 sra r6,r6,0x1f                |{{f/std|<nowiki>r6 = 0x00</nowiki>}}
 +
0007caa4: 00641821 addu r3,r3,r4                |{{f/std|<nowiki>r3 = X Mod * 4 / 7</nowiki>}}
 +
0007caa8: 00031903 sra r3,r3,0x04                |{{f/std|<nowiki>r3 = X Mod / 28 = X coord</nowiki>}}
 +
0007caac: 00621823 subu r3,r3,r2                |{{f/std|<nowiki>r3 = X coord - 0x00</nowiki>}}
 +
0007cab0: 000310c0 sll r2,r3,0x03                |{{f/std|<nowiki>r2 = X Coord * 8</nowiki>}}
 +
0007cab4: 00431023 subu r2,r2,r3                |{{f/std|<nowiki>r2 = X Coord * 7</nowiki>}}
 +
0007cab8: 00021080 sll r2,r2,0x02                |{{f/std|<nowiki>r2 = X Coord * 28</nowiki>}}
 +
0007cabc: 00822023 subu r4,r4,r2                |{{f/std|<nowiki>r4 = X preset value</nowiki>}}
 +
0007cac0: 00042400 sll r4,r4,0x10                |{{f/std|<nowiki>r4 = r4 * 1024</nowiki>}}
 +
0007cac4: 00043c03 sra r7,r4,0x10                |r7 = X preset value (upper register cleanup)
 +
0007cac8: 00001010 mfhi r2                      |{{f/std|<nowiki>r2 = Y Mod * -3/7</nowiki>}}
 +
0007cacc: 00451021 addu r2,r2,r5                |{{f/std|<nowiki>r2 = Y Mod *4/7</nowiki>}}
 +
0007cad0: 00021103 sra r2,r2,0x04                |{{f/std|<nowiki>r2 = Y Mod / 28 = Y Coord</nowiki>}}
 +
0007cad4: 00461023 subu r2,r2,r6                |{{f/std|<nowiki>r2 = Y Coord  - 0x00</nowiki>}}
 +
0007cad8: 000218c0 sll r3,r2,0x03                |{{f/std|<nowiki>r3 = Y Coord * 8</nowiki>}}
 +
0007cadc: 00621823 subu r3,r3,r2                |{{f/std|<nowiki>r3 = Y Coord * 7</nowiki>}}
 +
0007cae0: 00031880 sll r3,r3,0x02                |{{f/std|<nowiki>r3 = Y Coord * 28</nowiki>}}
 +
0007cae4: 00a32823 subu r5,r5,r3                |{{f/std|<nowiki>r5 = Y preset</nowiki>}}
 +
0007cae8: 00052c00 sll r5,r5,0x10                |{{f/std|<nowiki>r5 = Y preset * 1024</nowiki>}}
 +
0007caec: 00052403 sra r4,r5,0x10                |r4 = Y preset (upper register cleanup)
 +
0007caf0: 00e4102a slt r2,r7,r4                  |{{f/std|<nowiki>r2 = 0x01 if X preset < Y preset / Else 0x00</nowiki>}}
 +
0007caf4: 1040012a beq r2,r0,0x0007cfa0          {{f/Cond|<nowiki>If X preset < Y preset</nowiki>}} / if X Preset >= Y Preset  branch to  [(Preset/28) * (12 * Halves)] section with Y preset
 +
0007caf8: 00071040 sll r2,r7,0x01                    |{{f/std|<nowiki>r2 = X preset * 2</nowiki>}}
 +
0007cafc: 0801f3ea j 0x0007cfa8                      {{f/jump|<nowiki>Jump to  [(Preset/28) * (12 * Halves)] section with X preset</nowiki>}}
 +
0007cb00: 00471021 addu r2,r2,r7                    |{{f/std|<nowiki>r2 = X preset * 3</nowiki>}}
 +
 +
                                            {{f/com|<nowiki>--- Slope Type = 0x11  Section---</nowiki>}}
 +
0007cb04: 96020000 lhu r2,0x0000(r16)            |{{f/load|<nowiki>r2 = X Mod (X Coord*28 + X Preset)</nowiki>}}
 +
0007cb08: 00000000 nop                          |
 +
0007cb0c: 00021400 sll r2,r2,0x10                |{{f/std|<nowiki>r2 = r2 * 1024</nowiki>}}
 +
0007cb10: 00022403 sra r4,r2,0x10                |{{f/std|<nowiki>r4 = X mod (upper register cleanup)</nowiki>}}
 +
0007cb14: 00910018 mult r4,r17                  |{{f/std|<nowiki>X mod * -3/7 * 2^32</nowiki>}} {{f/std|<nowiki>X Mod * -3 / 7</nowiki>}}
 +
0007cb18: 96060004 lhu r6,0x0004(r16)            |{{f/load|<nowiki>r6 =  Y Mod (Y Coord * 28 + Y preset)</nowiki>}}
 +
0007cb1c: 00001810 mfhi r3                      |{{f/std|<nowiki>r3 = X mod * -3/7</nowiki>}}
 +
0007cb20: 00063400 sll r6,r6,0x10                |{{f/std|<nowiki>r6 = r6 *1024</nowiki>}}
 +
0007cb24: 00062c03 sra r5,r6,0x10                |{{f/std|<nowiki>r5 = Y mod (upper register cleanup)</nowiki>}}
 +
0007cb28: 00b10018 mult r5,r17                  |{{f/std|<nowiki>Y Mod * -3 / 7 * 2^32</nowiki>}}
 +
0007cb2c: 000217c3 sra r2,r2,0x1f                |{{f/std|<nowiki>r2 = 0x00</nowiki>}}
 +
0007cb30: 000637c3 sra r6,r6,0x1f                |{{f/std|<nowiki>r6 = 0x00</nowiki>}}
 +
0007cb34: 00641821 addu r3,r3,r4                |{{f/std|<nowiki>r3 = X Mod * 4 / 7</nowiki>}}
 +
0007cb38: 00031903 sra r3,r3,0x04                |{{f/std|<nowiki>r3 = X Mod / 28 = X coord</nowiki>}}
 +
0007cb3c: 00621823 subu r3,r3,r2                |{{f/std|<nowiki>r3 = X coord - 0x00</nowiki>}}
 +
0007cb40: 000310c0 sll r2,r3,0x03                |{{f/std|<nowiki>r2 = X Coord * 8</nowiki>}}
 +
0007cb44: 00431023 subu r2,r2,r3                |{{f/std|<nowiki>r2 = X Coord * 7</nowiki>}}
 +
0007cb48: 00021080 sll r2,r2,0x02                |{{f/std|<nowiki>r2 = X Coord * 28</nowiki>}}
 +
0007cb4c: 00822023 subu r4,r4,r2                |{{f/std|<nowiki>r4 = X preset value</nowiki>}}
 +
0007cb50: 00042400 sll r4,r4,0x10                |{{f/std|<nowiki>r4 = r4 * 1024</nowiki>}}
 +
0007cb54: 00043c03 sra r7,r4,0x10                |r7 = X preset value (upper register cleanup)
 +
0007cb58: 00001010 mfhi r2                      |{{f/std|<nowiki>r2 = Y Mod * -3/7</nowiki>}}
 +
0007cb5c: 00451021 addu r2,r2,r5                |{{f/std|<nowiki>r2 = Y Mod *4/7</nowiki>}}
 +
0007cb60: 00021103 sra r2,r2,0x04                |{{f/std|<nowiki>r2 = Y Mod / 28 = Y Coord</nowiki>}}
 +
0007cb64: 00461023 subu r2,r2,r6                |{{f/std|<nowiki>r2 = Y Coord  - 0x00</nowiki>}}
 +
0007cb68: 000218c0 sll r3,r2,0x03                |{{f/std|<nowiki>r3 = Y Coord * 8</nowiki>}}
 +
0007cb6c: 00621823 subu r3,r3,r2                |{{f/std|<nowiki>r3 = Y Coord * 7</nowiki>}}
 +
0007cb70: 00031880 sll r3,r3,0x02                |{{f/std|<nowiki>r3 = Y Coord * 28</nowiki>}}
 +
0007cb74: 00a32823 subu r5,r5,r3                |{{f/std|<nowiki>r5 = Y preset</nowiki>}}
 +
0007cb78: 00052c00 sll r5,r5,0x10                |{{f/std|<nowiki>r5 = Y preset * 1024</nowiki>}}
 +
0007cb7c: 00052c03 sra r5,r5,0x10                |r5 = Y preset (upper registery clean up)
 +
0007cb80: 3402001c ori r2,r0,0x001c              |{{f/std|<nowiki>r2 = 28</nowiki>}}
 +
0007cb84: 00452023 subu r4,r2,r5                |{{f/std|<nowiki>28 - Y preset</nowiki>}}
 +
0007cb88: 00e4102a slt r2,r7,r4                  |{{f/std|<nowiki>r2 = 0x01 if X preset < 28-Y preset</nowiki>}}
 +
0007cb8c: 14400004 bne r2,r0,0x0007cba0          {{f/Cond|<nowiki>If X preset > (28 - Y preset)</nowiki>}}
 +
0007cb90: 00000000 nop                              |{{f/std|<nowiki> </nowiki>}}
 +
0007cb94: 00051040 sll r2,r5,0x01                    |{{f/std|<nowiki>r2 = Y preset * 2</nowiki>}}
 +
0007cb98: 0801f3d7 j 0x0007cf5c                      {{f/jump|<nowiki>Jump to [(1-preset/28) * (12*Halves)] section with Y preset</nowiki>}}
 +
0007cb9c: 00451021 addu r2,r2,r5                    |{{f/std|<nowiki>r2 = Y preset * 3</nowiki>}}
 +
0007cba0: 00071040 sll r2,r7,0x01                |{{f/std|<nowiki>r2 = X preset *2</nowiki>}}
 +
0007cba4: 0801f3ea j 0x0007cfa8                  {{f/jump|<nowiki>Jump to  [(Preset/28) * (12 * Halves)] section with X preset</nowiki>}}
 +
0007cba8: 00471021 addu r2,r2,r7                |{{f/std|<nowiki>r2 = X preset *3</nowiki>}}
 
   
 
   
*Slope Type = 0x52*
+
                                            {{f/com|<nowiki>--- Slope Type = 0x14  Section---</nowiki>}}
  0007c98c: 96030000 lhu r3,0x0000(r16) Load X Mod
+
  0007cbac: 96020000 lhu r2,0x0000(r16)           |{{f/load|<nowiki>r2 = X Mod (X Coord*28 + X Preset)</nowiki>}}
  0007c990: 00000000 nop
+
  0007cbb0: 00000000 nop                           |
  0007c994: 00031c00 sll r3,r3,0x10
+
  0007cbb4: 00021400 sll r2,r2,0x10               |{{f/std|<nowiki>r2 = r2 * 1024</nowiki>}}
  0007c998: 00032403 sra r4,r3,0x10
+
  0007cbb8: 00022403 sra r4,r2,0x10               |{{f/std|<nowiki>r4 = X mod (upper register cleanup)</nowiki>}}
  0007c99c: 00910018 mult r4,r17 X Mod * -3 / 7
+
  0007cbbc: 00910018 mult r4,r17                   |{{f/std|<nowiki>X mod * -3/7 * 2^32</nowiki>}} {{f/std|<nowiki>X Mod * -3 / 7</nowiki>}}
  0007c9a0: 00031fc3 sra r3,r3,0x1f
+
  0007cbc0: 96060004 lhu r6,0x0004(r16)            |{{f/load|<nowiki>r6 =  Y Mod (Y Coord * 28 + Y preset)</nowiki>}}
  0007c9a4: 00001010 mfhi r2
+
0007cbc4: 00000000 nop                          |
  0007c9a8: 00441021 addu r2,r2,r4 X Mod * 4 / 7
+
0007cbc8: 00063400 sll r6,r6,0x10                |{{f/std|<nowiki>r6 = r6 *1024</nowiki>}}
  0007c9ac: 00021103 sra r2,r2,0x04 X = X Mod / 28
+
0007cbcc: 00062c03 sra r5,r6,0x10                |{{f/std|<nowiki>r5 = Y mod (upper register cleanup)</nowiki>}}
  0007c9b0: 00431023 subu r2,r2,r3
+
0007cbd0: 00001810 mfhi r3                      |{{f/std|<nowiki>r3 = X mod * -3/7</nowiki>}}
  0007c9b4: 000218c0 sll r3,r2,0x03 X * 8
+
0007cbd4: 000217c3 sra r2,r2,0x1f                |{{f/std|<nowiki>r2 = 0x00</nowiki>}}
  0007c9b8: 00621823 subu r3,r3,r2 X * 7
+
0007cbd8: 000637c3 sra r6,r6,0x1f                |{{f/std|<nowiki>r6 = 0x00</nowiki>}}
  0007c9bc: 00031880 sll r3,r3,0x02 X * 28
+
0007cbdc: 00b10018 mult r5,r17                  |{{f/std|<nowiki>Y Mod * -3 / 7 * 2^32</nowiki>}}
  0007c9c0: 00832023 subu r4,r4,r3 X Slope = X Mod - X * 28
+
0007cbe0: 00641821 addu r3,r3,r4                |{{f/std|<nowiki>r3 = X Mod * 4 / 7</nowiki>}}
  0007c9c4: 00042400 sll r4,r4,0x10
+
0007cbe4: 00031903 sra r3,r3,0x04                |{{f/std|<nowiki>r3 = X Mod / 28 = X coord</nowiki>}}
  0007c9c8: 0801f3e8 j 0x0007cfa0 (Slope Mod = X Slope * 12 * Halves / 28)
+
0007cbe8: 00621823 subu r3,r3,r2                |{{f/std|<nowiki>r3 = X coord - 0x00</nowiki>}}
  0007c9cc: 00042403 sra r4,r4,0x10
+
0007cbec: 000310c0 sll r2,r3,0x03                |{{f/std|<nowiki>r2 = X Coord * 8</nowiki>}}
 +
0007cbf0: 00431023 subu r2,r2,r3                 |{{f/std|<nowiki>r2 = X Coord * 7</nowiki>}}
 +
0007cbf4: 00021080 sll r2,r2,0x02                |{{f/std|<nowiki>r2 = X Coord * 28</nowiki>}}
 +
0007cbf8: 00822023 subu r4,r4,r2                |{{f/std|<nowiki>r4 = X preset value</nowiki>}}
 +
0007cbfc: 00042400 sll r4,r4,0x10                |{{f/std|<nowiki>r4 = r4 * 1024</nowiki>}}
 +
0007cc00: 00044403 sra r8,r4,0x10                |r8 = X preset value (upper register cleanup)
 +
0007cc04: 3404001c ori r4,r0,0x001c              |{{f/std|<nowiki>r4 = 28</nowiki>}}
 +
0007cc08: 00883823 subu r7,r4,r8                |{{f/std|<nowiki>r7 = 28-X preset</nowiki>}}
 +
  0007cc0c: 00001010 mfhi r2                       |{{f/std|<nowiki>r2 = Y Mod * -3/7</nowiki>}}
 +
  0007cc10: 00451021 addu r2,r2,r5                |{{f/std|<nowiki>r2 = Y Mod *4/7</nowiki>}}
 +
  0007cc14: 00021103 sra r2,r2,0x04               |{{f/std|<nowiki>r2 = Y Mod / 28 = Y Coord</nowiki>}}
 +
  0007cc18: 00461023 subu r2,r2,r6                |{{f/std|<nowiki>r2 = Y Coord  - 0x00</nowiki>}}
 +
  0007cc1c: 000218c0 sll r3,r2,0x03               |{{f/std|<nowiki>r3 = Y Coord * 8</nowiki>}}
 +
  0007cc20: 00621823 subu r3,r3,r2                 |{{f/std|<nowiki>r3 = Y Coord * 7</nowiki>}}
 +
  0007cc24: 00031880 sll r3,r3,0x02               |{{f/std|<nowiki>r3 = Y Coord * 28</nowiki>}}
 +
  0007cc28: 00a32823 subu r5,r5,r3                |{{f/std|<nowiki>r5 = Y preset</nowiki>}}
 +
0007cc2c: 00052c00 sll r5,r5,0x10                |{{f/std|<nowiki>r5 = Y preset * 1024</nowiki>}}
 +
0007cc30: 00052c03 sra r5,r5,0x10                |r5 = Y preset (upper registery clean up)
 +
0007cc34: 00852023 subu r4,r4,r5                |{{f/std|<nowiki>r4 = 28 - Y Preset</nowiki>}}
 +
0007cc38: 00e4102a slt r2,r7,r4                  |{{f/std|<nowiki>r2 = 0x01 if (28-X preset)<(28-Y preset)</nowiki>}}
 +
0007cc3c: 144000c5 bne r2,r0,0x0007cf54          {{f/Cond|<nowiki>If (28-Y preset)<=(28-X preset)</nowiki>}} /Else Branch to [(1-preset/28) * (12*Halves)] section with X preset
 +
  0007cc40: 00051040 sll r2,r5,0x01                    |{{f/std|<nowiki>r2 = Y preset*2</nowiki>}}
 +
  0007cc44: 0801f3d7 j 0x0007cf5c                      {{f/jump|<nowiki>Jump to [(1-preset/28) * (12*Halves)] section with Y preset</nowiki>}}
 +
  0007cc48: 00451021 addu r2,r2,r5                    |{{f/std|<nowiki>r2 = Y preset*3</nowiki>}}
 
   
 
   
*Slope Type = 0x58*
+
                                            {{f/com|<nowiki>--- Slope Type = 0x44  Section---</nowiki>}}
  0007c9d0: 96030000 lhu r3,0x0000(r16) Load X Mod
+
  0007cc4c: 96020000 lhu r2,0x0000(r16)           |{{f/load|<nowiki>r2 = X Mod (X Coord*28 + X Preset)</nowiki>}}
  0007c9d4: 00000000 nop
+
  0007cc50: 00000000 nop                           |
  0007c9d8: 00031c00 sll r3,r3,0x10
+
  0007cc54: 00021400 sll r2,r2,0x10               |{{f/std|<nowiki>r2 = r2 * 1024</nowiki>}}
  0007c9dc: 00032403 sra r4,r3,0x10
+
  0007cc58: 00022403 sra r4,r2,0x10               |{{f/std|<nowiki>r4 = X mod (upper register cleanup)</nowiki>}}
  0007c9e0: 00910018 mult r4,r17 X Mod * -3 / 7
+
  0007cc5c: 00910018 mult r4,r17                   |{{f/std|<nowiki>X mod * -3/7 * 2^32</nowiki>}}
  0007c9e4: 00031fc3 sra r3,r3,0x1f
+
0007cc60: 96060004 lhu r6,0x0004(r16)            |{{f/load|<nowiki>r6 =  Y Mod (Y Coord * 28 + Y preset)</nowiki>}}
  0007c9e8: 00001010 mfhi r2
+
0007cc64: 00000000 nop                          |
  0007c9ec: 00441021 addu r2,r2,r4 X Mod * 4 / 7
+
0007cc68: 00063400 sll r6,r6,0x10                |{{f/std|<nowiki>r6 = r6 *1024</nowiki>}}
  0007c9f0: 00021103 sra r2,r2,0x04 X = X Mod / 28
+
0007cc6c: 00062c03 sra r5,r6,0x10                |{{f/std|<nowiki>r5 = Y mod (upper register cleanup)</nowiki>}}
  0007c9f4: 00431023 subu r2,r2,r3
+
0007cc70: 00001810 mfhi r3                      |{{f/std|<nowiki>r3 = X mod * -3/7</nowiki>}}
  0007c9f8: 000218c0 sll r3,r2,0x03 X * 8
+
0007cc74: 000217c3 sra r2,r2,0x1f                |{{f/std|<nowiki>r2 = 0x00</nowiki>}}
  0007c9fc: 00621823 subu r3,r3,r2 X * 7
+
0007cc78: 000637c3 sra r6,r6,0x1f                |{{f/std|<nowiki>r6 = 0x00</nowiki>}}
  0007ca00: 00031880 sll r3,r3,0x02 X * 28
+
0007cc7c: 00b10018 mult r5,r17                  |{{f/std|<nowiki>Y Mod * -3 / 7 * 2^32</nowiki>}}
  0007ca04: 00832023 subu r4,r4,r3 X Slope = X Mod - X * 28
+
0007cc80: 00641821 addu r3,r3,r4                |{{f/std|<nowiki>r3 = X Mod * 4 / 7</nowiki>}}
  0007ca08: 00042400 sll r4,r4,0x10
+
  0007cc84: 00031903 sra r3,r3,0x04                |{{f/std|<nowiki>r3 = X Mod / 28 = X coord</nowiki>}}
  0007ca0c: 00042403 sra r4,r4,0x10
+
0007cc88: 00621823 subu r3,r3,r2                |{{f/std|<nowiki>r3 = X coord - 0x00</nowiki>}}
  0007ca10: 00041040 sll r2,r4,0x01 X Slope * 2
+
0007cc8c: 000310c0 sll r2,r3,0x03                |{{f/std|<nowiki>r2 = X Coord * 8</nowiki>}}
  0007ca14: 0801f3d7 j 0x0007cf5c (Slope Mod = Halves * 12 - (X Slope * 12 * Halves / 28))
+
0007cc90: 00431023 subu r2,r2,r3                |{{f/std|<nowiki>r2 = X Coord * 7</nowiki>}}
  0007ca18: 00441021 addu r2,r2,r4 X Slope * 3
+
0007cc94: 00021080 sll r2,r2,0x02                |{{f/std|<nowiki>r2 = X Coord * 28</nowiki>}}
 +
0007cc98: 00822023 subu r4,r4,r2                |{{f/std|<nowiki>r4 = X preset value</nowiki>}}
 +
0007cc9c: 00042400 sll r4,r4,0x10                |{{f/std|<nowiki>r4 = r4 * 1024</nowiki>}}
 +
0007cca0: 00044403 sra r8,r4,0x10                |r8 = X preset value (upper register cleanup)
 +
0007cca4: 3402001c ori r2,r0,0x001c              |{{f/std|<nowiki>r2 = 28</nowiki>}}
 +
0007cca8: 00483823 subu r7,r2,r8                |{{f/std|<nowiki>r7 = 28-X preset</nowiki>}}
 +
  0007ccac: 00001010 mfhi r2                       |{{f/std|<nowiki>r2 = Y Mod * -3/7</nowiki>}}
 +
  0007ccb0: 00451021 addu r2,r2,r5                |{{f/std|<nowiki>r2 = Y Mod *4/7</nowiki>}}
 +
  0007ccb4: 00021103 sra r2,r2,0x04               |{{f/std|<nowiki>r2 = Y Mod / 28 = Y Coord</nowiki>}}
 +
  0007ccb8: 00461023 subu r2,r2,r6                |{{f/std|<nowiki>r2 = Y Coord  - 0x00</nowiki>}}
 +
  0007ccbc: 000218c0 sll r3,r2,0x03               |{{f/std|<nowiki>r3 = Y Coord * 8</nowiki>}}
 +
  0007ccc0: 00621823 subu r3,r3,r2                 |{{f/std|<nowiki>r3 = Y Coord * 7</nowiki>}}
 +
  0007ccc4: 00031880 sll r3,r3,0x02               |{{f/std|<nowiki>r3 = Y Coord * 28</nowiki>}}
 +
  0007ccc8: 00a32823 subu r5,r5,r3                 |{{f/std|<nowiki>r5 = Y preset</nowiki>}}
 +
  0007cccc: 00052c00 sll r5,r5,0x10               |{{f/std|<nowiki>r5 = Y preset * 1024</nowiki>}}
 +
  0007ccd0: 00052403 sra r4,r5,0x10                |r4 = Y preset (upper registery clean up)
 +
0007ccd4: 00e4102a slt r2,r7,r4                 |{{f/std|<nowiki>r2 = 0x01 if (28-X preset) < Y preset</nowiki>}}
 +
0007ccd8: 104000b2 beq r2,r0,0x0007cfa4          {{f/Cond|<nowiki>If  28-X preset < Y preset</nowiki>}} / Else branch to  '''[(Preset/28) * (12 * Halves)] section with Y preset'''
 +
  0007ccdc: 00041040 sll r2,r4,0x01               |{{f/std|<nowiki>r2 = Y preset*2</nowiki>}}
 +
  0007cce0: 0801f3d6 j 0x0007cf58                      {{f/jump|<nowiki>Jump to [(1-preset/28) * (12*Halves)] section with X preset</nowiki>}}
 +
  0007cce4: 00081040 sll r2,r8,0x01                    |{{f/std|<nowiki>r2 = X preset*2</nowiki>}}
 
   
 
   
*Slope Type = 0x25*
+
                                            {{f/com|<nowiki>--- Slope Type = 0x96  Section---</nowiki>}}
  0007ca1c: 96030004 lhu r3,0x0004(r16) Load Y Mod
+
  0007cce8: 96020000 lhu r2,0x0000(r16)           |{{f/load|<nowiki>r2 = X Mod (X Coord*28 + X Preset)</nowiki>}}
  0007ca20: 00000000 nop
+
  0007ccec: 00000000 nop                           |
  0007ca24: 00031c00 sll r3,r3,0x10
+
  0007ccf0: 00021400 sll r2,r2,0x10               |{{f/std|<nowiki>r2 = r2 * 1024</nowiki>}}
  0007ca28: 00032403 sra r4,r3,0x10
+
  0007ccf4: 00022403 sra r4,r2,0x10               |{{f/std|<nowiki>r4 = X mod (upper register cleanup)</nowiki>}}
  0007ca2c: 00910018 mult r4,r17 Y Mod * -3 / 7
+
  0007ccf8: 00910018 mult r4,r17                   |{{f/std|<nowiki>X mod * -3/7 * 2^32</nowiki>}}
  0007ca30: 00031fc3 sra r3,r3,0x1f
+
0007ccfc: 96060004 lhu r6,0x0004(r16)            |{{f/load|<nowiki>r6 =  Y Mod (Y Coord * 28 + Y preset)</nowiki>}}
  0007ca34: 00001010 mfhi r2
+
0007cd00: 00001810 mfhi r3                      |{{f/std|<nowiki>r3 = X mod * -3/7</nowiki>}}
  0007ca38: 00441021 addu r2,r2,r4 Y Mod * 4 / 7
+
  0007cd04: 00063400 sll r6,r6,0x10                |{{f/std|<nowiki>r6 = r6 *1024</nowiki>}}
  0007ca3c: 00021103 sra r2,r2,0x04 Y = Y Mod / 28
+
0007cd08: 00062c03 sra r5,r6,0x10                |{{f/std|<nowiki>r5 = Y mod (upper register cleanup)</nowiki>}}
  0007ca40: 00431023 subu r2,r2,r3
+
0007cd0c: 00b10018 mult r5,r17                  |{{f/std|<nowiki>Y Mod * -3 / 7 * 2^32</nowiki>}}
  0007ca44: 000218c0 sll r3,r2,0x03 Y * 8
+
0007cd10: 000217c3 sra r2,r2,0x1f                |{{f/std|<nowiki>r2 = 0x00</nowiki>}}
  0007ca48: 00621823 subu r3,r3,r2 Y * 7
+
0007cd14: 000637c3 sra r6,r6,0x1f                |{{f/std|<nowiki>r6 = 0x00</nowiki>}}
  0007ca4c: 00031880 sll r3,r3,0x02 Y * 28
+
0007cd18: 00641821 addu r3,r3,r4                |{{f/std|<nowiki>r3 = X Mod * 4 / 7</nowiki>}}
  0007ca50: 00832023 subu r4,r4,r3 Y Slope = Y Mod - Y * 28
+
0007cd1c: 00031903 sra r3,r3,0x04                |{{f/std|<nowiki>r3 = X Mod / 28 = X coord</nowiki>}}
  0007ca54: 00042400 sll r4,r4,0x10
+
0007cd20: 00621823 subu r3,r3,r2                |{{f/std|<nowiki>r3 = X coord - 0x00</nowiki>}}
  0007ca58: 00042403 sra r4,r4,0x10
+
0007cd24: 000310c0 sll r2,r3,0x03                |{{f/std|<nowiki>r2 = X Coord * 8</nowiki>}}
  0007ca5c: 00041040 sll r2,r4,0x01 Y Slope * 2
+
0007cd28: 00431023 subu r2,r2,r3                |{{f/std|<nowiki>r2 = X Coord * 7</nowiki>}}
  0007ca60: 0801f3d7 j 0x0007cf5c (Slope Mod = Halves * 12 - (Y Slope * 12 * Halves / 28))
+
0007cd2c: 00021080 sll r2,r2,0x02                |{{f/std|<nowiki>r2 = X Coord * 28</nowiki>}}
  0007ca64: 00441021 addu r2,r2,r4 Y Slope * 3
+
0007cd30: 00822023 subu r4,r4,r2                |{{f/std|<nowiki>r4 = X preset value</nowiki>}}
 +
0007cd34: 00042400 sll r4,r4,0x10                |{{f/std|<nowiki>r4 = r4 * 1024</nowiki>}}
 +
0007cd38: 00043c03 sra r7,r4,0x10                |r7 = X preset value (upper register cleanup)
 +
  0007cd3c: 00001010 mfhi r2                       |{{f/std|<nowiki>r2 = Y Mod * -3/7</nowiki>}}
 +
  0007cd40: 00451021 addu r2,r2,r5                |{{f/std|<nowiki>r2 = Y Mod *4/7</nowiki>}}
 +
  0007cd44: 00021103 sra r2,r2,0x04               |{{f/std|<nowiki>r2 = Y Mod / 28 = Y Coord</nowiki>}}
 +
  0007cd48: 00461023 subu r2,r2,r6                |{{f/std|<nowiki>r2 = Y Coord  - 0x00</nowiki>}}
 +
  0007cd4c: 000218c0 sll r3,r2,0x03               |{{f/std|<nowiki>r3 = Y Coord * 8</nowiki>}}
 +
  0007cd50: 00621823 subu r3,r3,r2                 |{{f/std|<nowiki>r3 = Y Coord * 7</nowiki>}}
 +
  0007cd54: 00031880 sll r3,r3,0x02               |{{f/std|<nowiki>r3 = Y Coord * 28</nowiki>}}
 +
  0007cd58: 00a32823 subu r5,r5,r3                 |{{f/std|<nowiki>r5 = Y preset</nowiki>}}
 +
0007cd5c: 00052c00 sll r5,r5,0x10                |{{f/std|<nowiki>r5 = Y preset * 1024</nowiki>}}
 +
  0007cd60: 00052403 sra r4,r5,0x10               |r4 = Y preset (upper registery clean up)
 +
  0007cd64: 00e4102a slt r2,r7,r4                 |{{f/std|<nowiki>r2 = 0x01 if X preset < Y preset</nowiki>}}
 +
0007cd68: 1440008d bne r2,r0,0x0007cfa0          {{f/Cond|<nowiki>If X preset > Y preset</nowiki>}} / Else branch to  '''[(Preset/28) * (12 * Halves)] section with Y preset'''
 +
  0007cd6c: 00071040 sll r2,r7,0x01                   |{{f/std|<nowiki>r2 = X preset * 2</nowiki>}}
 +
  0007cd70: 0801f3ea j 0x0007cfa8                      {{f/jump|<nowiki>Jump to  [(Preset/28) * (12 * Halves)] section with X preset</nowiki>}}
 +
  0007cd74: 00471021 addu r2,r2,r7                    |{{f/std|<nowiki>r2 = X preset * 3</nowiki>}}
 
   
 
   
*Slope Type = 0x85*
+
                                            {{f/com|<nowiki>--- Slope Type = 0x66  Section---</nowiki>}}
  0007ca68: 96030004 lhu r3,0x0004(r16) Load Y Mod
+
0007cd78: 96020000 lhu r2,0x0000(r16)            |{{f/load|<nowiki>r2 = X Mod (X Coord*28 + X Preset)</nowiki>}}
  0007ca6c: 0801f266 j 0x0007c998 (Y Slope = Y Mod - Y * 28)
+
0007cd7c: 00000000 nop                          |
  0007ca70: 00031c00 sll r3,r3,0x10 (Slope Mod = Y Slope * 12 * Halves / 28)
+
0007cd80: 00021400 sll r2,r2,0x10                |{{f/std|<nowiki>r2 = r2 * 1024</nowiki>}}
 +
  0007cd84: 00022403 sra r4,r2,0x10                |{{f/std|<nowiki>r4 = X mod (upper register cleanup)</nowiki>}}
 +
0007cd88: 00910018 mult r4,r17                  |{{f/std|<nowiki>X mod * -3/7 * 2^32</nowiki>}}
 +
0007cd8c: 96060004 lhu r6,0x0004(r16)           |{{f/load|<nowiki>r6 =  Y Mod (Y Coord * 28 + Y preset)</nowiki>}}
 +
  0007cd90: 00001810 mfhi r3                      |{{f/std|<nowiki>r3 = X mod * -3/7</nowiki>}}
 +
0007cd94: 00063400 sll r6,r6,0x10                |{{f/std|<nowiki>r6 = r6 *1024</nowiki>}}
 +
0007cd98: 00062c03 sra r5,r6,0x10                |{{f/std|<nowiki>r5 = Y mod (upper register cleanup)</nowiki>}}
 +
0007cd9c: 00b10018 mult r5,r17                  |{{f/std|<nowiki>Y Mod * -3 / 7 * 2^32</nowiki>}}
 +
0007cda0: 000217c3 sra r2,r2,0x1f                |{{f/std|<nowiki>r2 = 0x00</nowiki>}}
 +
0007cda4: 000637c3 sra r6,r6,0x1f                |{{f/std|<nowiki>r6 = 0x00</nowiki>}}
 +
0007cda8: 00641821 addu r3,r3,r4                |{{f/std|<nowiki>r3 = X Mod * 4 / 7</nowiki>}}
 +
0007cdac: 00031903 sra r3,r3,0x04                |{{f/std|<nowiki>r3 = X Mod / 28 = X coord</nowiki>}}
 +
0007cdb0: 00621823 subu r3,r3,r2                |{{f/std|<nowiki>r3 = X coord - 0x00</nowiki>}}
 +
0007cdb4: 000310c0 sll r2,r3,0x03                |{{f/std|<nowiki>r2 = X Coord * 8</nowiki>}}
 +
0007cdb8: 00431023 subu r2,r2,r3                |{{f/std|<nowiki>r2 = X Coord * 7</nowiki>}}
 +
0007cdbc: 00021080 sll r2,r2,0x02                |{{f/std|<nowiki>r2 = X Coord * 28</nowiki>}}
 +
0007cdc0: 00822023 subu r4,r4,r2                |{{f/std|<nowiki>r4 = X preset value</nowiki>}}
 +
0007cdc4: 00042400 sll r4,r4,0x10                |{{f/std|<nowiki>r4 = r4 * 1024</nowiki>}}
 +
0007cdc8: 00043c03 sra r7,r4,0x10                |r7 = X preset value (upper register cleanup)
 +
0007cdcc: 00001010 mfhi r2                      |{{f/std|<nowiki>r2 = Y Mod * -3/7</nowiki>}}
 +
0007cdd0: 00451021 addu r2,r2,r5                |{{f/std|<nowiki>r2 = Y Mod *4/7</nowiki>}}
 +
0007cdd4: 00021103 sra r2,r2,0x04                |{{f/std|<nowiki>r2 = Y Mod / 28 = Y Coord</nowiki>}}
 +
0007cdd8: 00461023 subu r2,r2,r6                |{{f/std|<nowiki>r2 = Y Coord  - 0x00</nowiki>}}
 +
0007cddc: 000218c0 sll r3,r2,0x03                |{{f/std|<nowiki>r3 = Y Coord * 8</nowiki>}}
 +
0007cde0: 00621823 subu r3,r3,r2                |{{f/std|<nowiki>r3 = Y Coord * 7</nowiki>}}
 +
  0007cde4: 00031880 sll r3,r3,0x02                |{{f/std|<nowiki>r3 = Y Coord * 28</nowiki>}}
 +
0007cde8: 00a32823 subu r5,r5,r3                |{{f/std|<nowiki>r5 = Y preset</nowiki>}}
 +
0007cdec: 00052c00 sll r5,r5,0x10                |{{f/std|<nowiki>r5 = Y preset * 1024</nowiki>}}
 +
0007cdf0: 00052c03 sra r5,r5,0x10               |r5 = Y preset (upper registery clean up)
 +
0007cdf4: 3402001c ori r2,r0,0x001c              |{{f/std|<nowiki>r2 = 28</nowiki>}}
 +
0007cdf8: 00452023 subu r4,r2,r5                |{{f/std|<nowiki>r4 = 28 - Y preset</nowiki>}}
 +
0007cdfc: 00e4102a slt r2,r7,r4                  |{{f/std|<nowiki>r2 = 0x01 if X preset < (28-Y preset)</nowiki>}}
 +
0007ce00: 14400004 bne r2,r0,0x0007ce14          {{f/Cond|<nowiki>If  X preset >= (28-Y preset)</nowiki>}}
 +
0007ce04: 00000000 nop                              |{{f/std|<nowiki> </nowiki>}}
 +
0007ce08: 00071040 sll r2,r7,0x01                    |{{f/std|<nowiki>r2 = X preset * 2</nowiki>}}
 +
0007ce0c: 0801f3ea j 0x0007cfa8                      {{f/jump|<nowiki>Jump to  [(Preset/28) * (12 * Halves)] section with X preset</nowiki>}}
 +
0007ce10: 00471021 addu r2,r2,r7                    |{{f/std|<nowiki>r2 = X preset * 3</nowiki>}}
 +
0007ce14: 00051040 sll r2,r5,0x01                |{{f/std|<nowiki>r2 = Y preset*2</nowiki>}}
 +
0007ce18: 0801f3d7 j 0x0007cf5c                  {{f/jump|<nowiki>Jump to [(1-preset/28) * (12*Halves)] section with  Y preset</nowiki>}}
 +
0007ce1c: 00451021 addu r2,r2,r5                |{{f/std|<nowiki>r2 = Y preset*3</nowiki>}}
 
   
 
   
*Slope Type = 0x41*
+
                                            {{f/com|<nowiki>--- Slope Type = 0x69  Section---</nowiki>}}
  0007ca74: 96020000 lhu r2,0x0000(r16) Load X Mod
+
  0007ce20: 96020000 lhu r2,0x0000(r16)           |{{f/load|<nowiki>r2 = X Mod (X Coord*28 + X Preset)</nowiki>}}
  0007ca78: 00000000 nop
+
  0007ce24: 00000000 nop                           |
  0007ca7c: 00021400 sll r2,r2,0x10
+
  0007ce28: 00021400 sll r2,r2,0x10               |{{f/std|<nowiki>r2 = r2 * 1024</nowiki>}}
  0007ca80: 00022403 sra r4,r2,0x10
+
  0007ce2c: 00022403 sra r4,r2,0x10               |{{f/std|<nowiki>r4 = X mod (upper register cleanup)</nowiki>}}
  0007ca84: 00910018 mult r4,r17 X Mod * -3 / 7
+
  0007ce30: 00910018 mult r4,r17                   |{{f/std|<nowiki>X mod * -3/7 * 2^32</nowiki>}}
  0007ca88: 96060004 lhu r6,0x0004(r16) Load Y Mod
+
  0007ce34: 96060004 lhu r6,0x0004(r16)           |{{f/load|<nowiki>r6 =  Y Mod (Y Coord * 28 + Y preset)</nowiki>}}
  0007ca8c: 00001810 mfhi r3
+
  0007ce38: 00000000 nop                          |
  0007ca90: 00063400 sll r6,r6,0x10
+
  0007ce3c: 00063400 sll r6,r6,0x10               |{{f/std|<nowiki>r6 = r6 *1024</nowiki>}}
  0007ca94: 00062c03 sra r5,r6,0x10
+
  0007ce40: 00062c03 sra r5,r6,0x10               |{{f/std|<nowiki>r5 = Y mod (upper register cleanup)</nowiki>}}
  0007ca98: 00b10018 mult r5,r17 Y Mod * -3 / 7
+
  0007ce44: 00001810 mfhi r3                      |{{f/std|<nowiki>r3 = X mod * -3/7</nowiki>}}
  0007ca9c: 000217c3 sra r2,r2,0x1f
+
  0007ce48: 000217c3 sra r2,r2,0x1f               |{{f/std|<nowiki>r2 = 0x00</nowiki>}}
  0007caa0: 000637c3 sra r6,r6,0x1f
+
  0007ce4c: 000637c3 sra r6,r6,0x1f               |{{f/std|<nowiki>r6 = 0x00</nowiki>}}
  0007caa4: 00641821 addu r3,r3,r4 X Mod * 4 / 7
+
  0007ce50: 00b10018 mult r5,r17                  |{{f/std|<nowiki>Y Mod * -3 / 7 * 2^32</nowiki>}}
  0007caa8: 00031903 sra r3,r3,0x04 X = X Mod / 28
+
0007ce54: 00641821 addu r3,r3,r4                 |{{f/std|<nowiki>r3 = X Mod * 4 / 7</nowiki>}}
  0007caac: 00621823 subu r3,r3,r2
+
  0007ce58: 00031903 sra r3,r3,0x04               |{{f/std|<nowiki>r3 = X Mod / 28 = X coord</nowiki>}}
  0007cab0: 000310c0 sll r2,r3,0x03 X * 8
+
  0007ce5c: 00621823 subu r3,r3,r2                 |{{f/std|<nowiki>r3 = X coord - 0x00</nowiki>}}
  0007cab4: 00431023 subu r2,r2,r3 X * 7
+
  0007ce60: 000310c0 sll r2,r3,0x03               |{{f/std|<nowiki>r2 = X Coord * 8</nowiki>}}
  0007cab8: 00021080 sll r2,r2,0x02 X * 28
+
  0007ce64: 00431023 subu r2,r2,r3                 |{{f/std|<nowiki>r2 = X Coord * 7</nowiki>}}
  0007cabc: 00822023 subu r4,r4,r2 X Slope = X Mod - X * 28
+
  0007ce68: 00021080 sll r2,r2,0x02               |{{f/std|<nowiki>r2 = X Coord * 28</nowiki>}}
  0007cac0: 00042400 sll r4,r4,0x10
+
  0007ce6c: 00822023 subu r4,r4,r2                 |{{f/std|<nowiki>r4 = X preset value</nowiki>}}
  0007cac4: 00043c03 sra r7,r4,0x10
+
  0007ce70: 00042400 sll r4,r4,0x10               |{{f/std|<nowiki>r4 = r4 * 1024</nowiki>}}
  0007cac8: 00001010 mfhi r2
+
  0007ce74: 00044403 sra r8,r4,0x10                |r8 = X preset value (upper register cleanup)
  0007cacc: 00451021 addu r2,r2,r5 Y Mod * 4 / 7
+
0007ce78: 3404001c ori r4,r0,0x001c              |{{f/std|<nowiki>r4 = 28</nowiki>}}
  0007cad0: 00021103 sra r2,r2,0x04 Y = Y Mod / 28
+
0007ce7c: 00883823 subu r7,r4,r8                |{{f/std|<nowiki>r7 = 28 - X preset</nowiki>}}
  0007cad4: 00461023 subu r2,r2,r6
+
  0007ce80: 00001010 mfhi r2                       |{{f/std|<nowiki>r2 = Y Mod * -3/7</nowiki>}}
  0007cad8: 000218c0 sll r3,r2,0x03 Y * 8
+
  0007ce84: 00451021 addu r2,r2,r5                 |{{f/std|<nowiki>r2 = Y Mod *4/7</nowiki>}}
  0007cadc: 00621823 subu r3,r3,r2 Y * 7
+
  0007ce88: 00021103 sra r2,r2,0x04               |{{f/std|<nowiki>r2 = Y Mod / 28 = Y Coord</nowiki>}}
  0007cae0: 00031880 sll r3,r3,0x02 Y * 28
+
  0007ce8c: 00461023 subu r2,r2,r6                 |{{f/std|<nowiki>r2 = Y Coord  - 0x00</nowiki>}}
  0007cae4: 00a32823 subu r5,r5,r3 Y Slope = Y Mod - Y * 28
+
  0007ce90: 000218c0 sll r3,r2,0x03               |{{f/std|<nowiki>r3 = Y Coord * 8</nowiki>}}
  0007cae8: 00052c00 sll r5,r5,0x10
+
  0007ce94: 00621823 subu r3,r3,r2                 |{{f/std|<nowiki>r3 = Y Coord * 7</nowiki>}}
  0007caec: 00052403 sra r4,r5,0x10 (Favors lowest Slope)
+
  0007ce98: 00031880 sll r3,r3,0x02               |{{f/std|<nowiki>r3 = Y Coord * 28</nowiki>}}
  0007caf0: 00e4102a slt r2,r7,r4 (Branch -> Slope Mod = Y Slope * 12 * Halves / 28)
+
  0007ce9c: 00a32823 subu r5,r5,r3                 |{{f/std|<nowiki>r5 = Y preset</nowiki>}}
  0007caf4: 1040012a beq r2,r0,0x0007cfa0 Branch if X Slope >= Y Slope
+
  0007cea0: 00052c00 sll r5,r5,0x10               |{{f/std|<nowiki>r5 = Y preset * 1024</nowiki>}} {{f/std|<nowiki>r2 = 28</nowiki>}}
  0007caf8: 00071040 sll r2,r7,0x01 (X Mod - X * 28) * 2
+
  0007cea4: 00052c03 sra r5,r5,0x10               |r5 = Y preset (upper registery clean up)
  0007cafc: 0801f3ea j 0x0007cfa8 (Else -> Slope Mod = X Slope * 12 * Halves / 28)
+
0007cea8: 00852023 subu r4,r4,r5                |{{f/std|<nowiki>r4 = 28 - Y preset</nowiki>}} {{f/std|<nowiki>r2 = 0x01 if X preset < (28-Y preset)</nowiki>}}
  0007cb00: 00471021 addu r2,r2,r7 (X Mod - X * 28) * 3
+
  0007ceac: 00e4102a slt r2,r7,r4                 |{{f/std|<nowiki>r2 = 0x01 if (28-X preset) <  (28-Y preset)</nowiki>}}
 +
  0007ceb0: 10400028 beq r2,r0,0x0007cf54          {{f/Cond|<nowiki>If (28-Y preset) > (28-X preset)</nowiki>}} /Else branch to '''[(1-preset/28) * (12*Halves)] section with  X preset'''
 +
  0007ceb4: 00051040 sll r2,r5,0x01                   |{{f/std|<nowiki>r2 = Y preset * 2</nowiki>}}
 +
  0007ceb8: 0801f3d7 j 0x0007cf5c                      {{f/jump|<nowiki>Jump to [(1-preset/28) * (12*Halves)] section with  Y preset</nowiki>}}
 +
  0007cebc: 00451021 addu r2,r2,r5                    |{{f/std|<nowiki>r2 = Y preset * 3</nowiki>}}
 
   
 
   
*Slope Type = 0x11*
+
                                            {{f/com|<nowiki>--- Slope Type = 0x99  Section---</nowiki>}}
  0007cb04: 96020000 lhu r2,0x0000(r16) Load X Mod
+
  0007cec0: 96020000 lhu r2,0x0000(r16)           |{{f/load|<nowiki>r2 = X Mod (X Coord*28 + X Preset)</nowiki>}}
  0007cb08: 00000000 nop
+
  0007cec4: 00000000 nop                           |
  0007cb0c: 00021400 sll r2,r2,0x10
+
  0007cec8: 00021400 sll r2,r2,0x10               |{{f/std|<nowiki>r2 = r2 * 1024</nowiki>}}
  0007cb10: 00022403 sra r4,r2,0x10
+
  0007cecc: 00022403 sra r4,r2,0x10               |{{f/std|<nowiki>r4 = X mod (upper register cleanup)</nowiki>}}
  0007cb14: 00910018 mult r4,r17 X Mod * -3 / 7
+
  0007ced0: 00910018 mult r4,r17                   |{{f/std|<nowiki>X mod * -3/7 * 2^32</nowiki>}}
  0007cb18: 96060004 lhu r6,0x0004(r16) Load Y Mod
+
  0007ced4: 96060004 lhu r6,0x0004(r16)           |{{f/load|<nowiki>r6 =  Y Mod (Y Coord * 28 + Y preset)</nowiki>}}
  0007cb1c: 00001810 mfhi r3
+
  0007ced8: 00000000 nop                          |
  0007cb20: 00063400 sll r6,r6,0x10
+
  0007cedc: 00063400 sll r6,r6,0x10               |{{f/std|<nowiki>r6 = r6 *1024</nowiki>}}
  0007cb24: 00062c03 sra r5,r6,0x10
+
  0007cee0: 00062c03 sra r5,r6,0x10               |{{f/std|<nowiki>r5 = Y mod (upper register cleanup)</nowiki>}}
  0007cb28: 00b10018 mult r5,r17 Y Mod * -3 / 7
+
  0007cee4: 00001810 mfhi r3                      |{{f/std|<nowiki>r3 = X mod * -3/7</nowiki>}}
  0007cb2c: 000217c3 sra r2,r2,0x1f
+
  0007cee8: 000217c3 sra r2,r2,0x1f               |{{f/std|<nowiki>r2 = 0x00</nowiki>}}
  0007cb30: 000637c3 sra r6,r6,0x1f
+
  0007ceec: 000637c3 sra r6,r6,0x1f               |{{f/std|<nowiki>r6 = 0x00</nowiki>}}
  0007cb34: 00641821 addu r3,r3,r4 X Mod * 4 / 7
+
0007cef0: 00b10018 mult r5,r17                  |{{f/std|<nowiki>Y Mod * -3 / 7 * 2^32</nowiki>}}
  0007cb38: 00031903 sra r3,r3,0x04 X = X Mod / 28
+
  0007cef4: 00641821 addu r3,r3,r4                 |{{f/std|<nowiki>r3 = X Mod * 4 / 7</nowiki>}}
  0007cb3c: 00621823 subu r3,r3,r2
+
  0007cef8: 00031903 sra r3,r3,0x04               |{{f/std|<nowiki>r3 = X Mod / 28 = X coord</nowiki>}}
  0007cb40: 000310c0 sll r2,r3,0x03 X * 8
+
  0007cefc: 00621823 subu r3,r3,r2                 |{{f/std|<nowiki>r3 = X coord - 0x00</nowiki>}}
  0007cb44: 00431023 subu r2,r2,r3 X * 7
+
  0007cf00: 000310c0 sll r2,r3,0x03               |{{f/std|<nowiki>r2 = X Coord * 8</nowiki>}}
  0007cb48: 00021080 sll r2,r2,0x02 X * 28
+
  0007cf04: 00431023 subu r2,r2,r3                 |{{f/std|<nowiki>r2 = X Coord * 7</nowiki>}}
  0007cb4c: 00822023 subu r4,r4,r2 X Slope = X Mod - X * 28
+
  0007cf08: 00021080 sll r2,r2,0x02               |{{f/std|<nowiki>r2 = X Coord * 28</nowiki>}}
  0007cb50: 00042400 sll r4,r4,0x10
+
  0007cf0c: 00822023 subu r4,r4,r2                 |{{f/std|<nowiki>r4 = X preset value</nowiki>}}
  0007cb54: 00043c03 sra r7,r4,0x10
+
  0007cf10: 00042400 sll r4,r4,0x10               |{{f/std|<nowiki>r4 = r4 * 1024</nowiki>}}
  0007cb58: 00001010 mfhi r2
+
  0007cf14: 00044403 sra r8,r4,0x10               |r8 = X preset value (upper register cleanup)
  0007cb5c: 00451021 addu r2,r2,r5 Y Mod * 4 / 7
+
0007cf18: 3402001c ori r2,r0,0x001c              |{{f/std|<nowiki>r2 = 28</nowiki>}}
  0007cb60: 00021103 sra r2,r2,0x04 Y = Y Mod / 28
+
0007cf1c: 00483823 subu r7,r2,r8                |{{f/std|<nowiki>r7 = 28 - X preset</nowiki>}}
  0007cb64: 00461023 subu r2,r2,r6
+
  0007cf20: 00001010 mfhi r2                       |{{f/std|<nowiki>r2 = Y Mod * -3/7</nowiki>}}
  0007cb68: 000218c0 sll r3,r2,0x03 Y * 8
+
  0007cf24: 00451021 addu r2,r2,r5                 |{{f/std|<nowiki>r2 = Y Mod *4/7</nowiki>}}
  0007cb6c: 00621823 subu r3,r3,r2 Y * 7
+
  0007cf28: 00021103 sra r2,r2,0x04               |{{f/std|<nowiki>r2 = Y Mod / 28 = Y Coord</nowiki>}}
  0007cb70: 00031880 sll r3,r3,0x02 Y * 28
+
  0007cf2c: 00461023 subu r2,r2,r6                 |{{f/std|<nowiki>r2 = Y Coord  - 0x00</nowiki>}}
  0007cb74: 00a32823 subu r5,r5,r3 Y Slope = Y Mod - Y * 28
+
  0007cf30: 000218c0 sll r3,r2,0x03               |{{f/std|<nowiki>r3 = Y Coord * 8</nowiki>}}
  0007cb78: 00052c00 sll r5,r5,0x10
+
  0007cf34: 00621823 subu r3,r3,r2                 |{{f/std|<nowiki>r3 = Y Coord * 7</nowiki>}}
  0007cb7c: 00052c03 sra r5,r5,0x10
+
  0007cf38: 00031880 sll r3,r3,0x02               |{{f/std|<nowiki>r3 = Y Coord * 28</nowiki>}}
0007cb80: 3402001c ori r2,r0,0x001c r2 = 28
+
  0007cf3c: 00a32823 subu r5,r5,r3                 |{{f/std|<nowiki>r5 = Y preset</nowiki>}}
0007cb84: 00452023 subu r4,r2,r5 28 - Y Slope
+
  0007cf40: 00052c00 sll r5,r5,0x10               |{{f/std|<nowiki>r5 = Y preset * 1024</nowiki>}}
  0007cb88: 00e4102a slt r2,r7,r4 (Favors higher Y Slope)
+
  0007cf44: 00052403 sra r4,r5,0x10               |r4 = Y preset (upper registery clean up)
  0007cb8c: 14400004 bne r2,r0,0x0007cba0 Branch if X Slope < (28 - Y Slope)
+
  0007cf48: 00e4102a slt r2,r7,r4                 |{{f/std|<nowiki>r2 = 0x01 if  (28-X preset)<Y preset</nowiki>}}
0007cb90: 00000000 nop
+
  0007cf4c: 14400015 bne r2,r0,0x0007cfa4          {{f/Cond|<nowiki>If (28-X preset) >= Y preset</nowiki>}}
  0007cb94: 00051040 sll r2,r5,0x01 Y Slope * 2
+
  0007cf50: 00041040 sll r2,r4,0x01               |{{f/std|<nowiki>r2 = Y preset * 2</nowiki>}}
0007cb98: 0801f3d7 j 0x0007cf5c (Slope Mod = Halves * 12 - (Y Slope * 12 * Halves / 28))
 
0007cb9c: 00451021 addu r2,r2,r5 Y Slope * 3
 
0007cba0: 00071040 sll r2,r7,0x01 X Slope * 2
 
0007cba4: 0801f3ea j 0x0007cfa8 (Slope Mod = X Slope * 12 * Halves / 28)
 
0007cba8: 00471021 addu r2,r2,r7 X Slope * 3
 
 
   
 
   
*Slope Type = 0x14*
+
                                            {{f/com|<nowiki>---- [(1-preset/28) * (12*Halves)] section ----</nowiki>}}
0007cbac: 96020000 lhu r2,0x0000(r16) Load X Mod
+
  0007cf54: 00081040 sll r2,r8,0x01                    |{{f/std|<nowiki>r2 = Preset * 2</nowiki>}} {{f/std|<nowiki>(could be X or Y - depending of jumping location)</nowiki>}}
  0007cbb0: 00000000 nop
+
  0007cf58: 00481021 addu r2,r2,r8                    |{{f/std|<nowiki>r2 = Preset * 3</nowiki>}}
0007cbb4: 00021400 sll r2,r2,0x10
+
  0007cf5c: 00021080 sll r2,r2,0x02                   |{{f/std|<nowiki>r2 = Preset * 12</nowiki>}}
0007cbb8: 00022403 sra r4,r2,0x10
+
  0007cf60: 00490018 mult r2,r9                        |{{f/std|<nowiki>Preset * 12 * Halves</nowiki>}}
0007cbbc: 00910018 mult r4,r17 X Mod * -3 / 7
+
  0007cf64: 00002012 mflo r4                          |{{f/std|<nowiki>r4 = Preset*12*Halves</nowiki>}}
0007cbc0: 96060004 lhu r6,0x0004(r16) Load Y Mod
+
  0007cf68: 00000000 nop                              |
0007cbc4: 00000000 nop
+
  0007cf6c: 00000000 nop                               |
0007cbc8: 00063400 sll r6,r6,0x10
+
  0007cf70: 00910018 mult r4,r17                       |{{f/std|<nowiki>r4 = Preset*12*Halves * -3/7 * 2^32</nowiki>}}
0007cbcc: 00062c03 sra r5,r6,0x10
+
  0007cf74: 00091840 sll r3,r9,0x01                    |{{f/std|<nowiki>r3 = Halves * 2</nowiki>}}
0007cbd0: 00001810 mfhi r3
+
  0007cf78: 00691821 addu r3,r3,r9                    |{{f/std|<nowiki>r3 = Halves * 3</nowiki>}}
0007cbd4: 000217c3 sra r2,r2,0x1f
+
  0007cf7c: 00031880 sll r3,r3,0x02                    |{{f/std|<nowiki>r3 = Halves * 12</nowiki>}}
0007cbd8: 000637c3 sra r6,r6,0x1f
+
  0007cf80: 00001010 mfhi r2                           |{{f/std|<nowiki>r2 = Preset * 12 * Halves * -3/7</nowiki>}}
0007cbdc: 00b10018 mult r5,r17 Y Mod * -3 / 7
+
  0007cf84: 00441021 addu r2,r2,r4                    |{{f/std|<nowiki>r2 = Preset * 12 * Halves * 4/7</nowiki>}}
  0007cbe0: 00641821 addu r3,r3,r4 X Mod * 4 / 7
+
  0007cf88: 00021103 sra r2,r2,0x04                    |{{f/std|<nowiki>r2 = Preset * 12 * Halves /28</nowiki>}}
0007cbe4: 00031903 sra r3,r3,0x04 X = X Mod / 28
+
  0007cf8c: 000427c3 sra r4,r4,0x1f                    |{{f/std|<nowiki>r4 = 0x00</nowiki>}}
0007cbe8: 00621823 subu r3,r3,r2
+
  0007cf90: 00441023 subu r2,r2,r4                    |{{f/std|<nowiki>r2 = Preset * 12 * Halves /28</nowiki>}} {{f/std|<nowiki>= halve*6</nowiki>}}
0007cbec: 000310c0 sll r2,r3,0x03 X * 8
+
  0007cf94: 00621823 subu r3,r3,r2                     |{{f/std|<nowiki>r3 = (Halves * 12)- (Halve*12*preset)/28 = (1-preset/28)*12*Halves</nowiki>}}
0007cbf0: 00431023 subu r2,r2,r3 X * 7
+
  0007cf98: 0801f3f6 j 0x0007cfd8                      {{f/jump|<nowiki>Jump to almost end (clear return register)</nowiki>}}
  0007cbf4: 00021080 sll r2,r2,0x02 X * 28
+
  0007cf9c: 01432023 subu r4,r10,r3                    |{{f/std|<nowiki>r4 = Final Height = -(height*12 + (1-preset/28)*12*Halves)</nowiki>}}
0007cbf8: 00822023 subu r4,r4,r2 X Slope = X Mod - X * 28
 
0007cbfc: 00042400 sll r4,r4,0x10
 
0007cc00: 00044403 sra r8,r4,0x10
 
0007cc04: 3404001c ori r4,r0,0x001c r4 = 28
 
0007cc08: 00883823 subu r7,r4,r8 28 - X Slope
 
0007cc0c: 00001010 mfhi r2
 
0007cc10: 00451021 addu r2,r2,r5 Y Mod * 4 / 7
 
  0007cc14: 00021103 sra r2,r2,0x04 Y = Y Mod / 28
 
0007cc18: 00461023 subu r2,r2,r6
 
0007cc1c: 000218c0 sll r3,r2,0x03 Y * 8
 
0007cc20: 00621823 subu r3,r3,r2 Y * 7
 
0007cc24: 00031880 sll r3,r3,0x02 Y * 28
 
0007cc28: 00a32823 subu r5,r5,r3 Y Slope = Y Mod - Y * 28
 
0007cc2c: 00052c00 sll r5,r5,0x10
 
0007cc30: 00052c03 sra r5,r5,0x10 (Favors highest Slope)
 
0007cc34: 00852023 subu r4,r4,r5 28 - Y Slope
 
0007cc38: 00e4102a slt r2,r7,r4 (Branch -> Slope Mod = Halves * 12 - (X Slope * 12 * Halves / 28))
 
  0007cc3c: 144000c5 bne r2,r0,0x0007cf54 Branch if (28 - X Slope) < (28 - Y Slope)
 
0007cc40: 00051040 sll r2,r5,0x01 Y Slope * 2
 
0007cc44: 0801f3d7 j 0x0007cf5c (Else -> Slope Mod = Halves * 12 - (Y Slope * 12 * Halves / 28))
 
  0007cc48: 00451021 addu r2,r2,r5 Y Slope * 3
 
 
 
*Slope Type = 0x44*
 
0007cc4c: 96020000 lhu r2,0x0000(r16) Load X Mod
 
  0007cc50: 00000000 nop
 
  0007cc54: 00021400 sll r2,r2,0x10
 
0007cc58: 00022403 sra r4,r2,0x10
 
0007cc5c: 00910018 mult r4,r17 X Mod * -3 / 7
 
  0007cc60: 96060004 lhu r6,0x0004(r16) Load Y Mod
 
0007cc64: 00000000 nop
 
0007cc68: 00063400 sll r6,r6,0x10
 
0007cc6c: 00062c03 sra r5,r6,0x10
 
0007cc70: 00001810 mfhi r3
 
0007cc74: 000217c3 sra r2,r2,0x1f
 
0007cc78: 000637c3 sra r6,r6,0x1f
 
0007cc7c: 00b10018 mult r5,r17 Y Mod * -3 / 7
 
  0007cc80: 00641821 addu r3,r3,r4 X Mod * 4 / 7
 
  0007cc84: 00031903 sra r3,r3,0x04 X = X Mod / 28
 
  0007cc88: 00621823 subu r3,r3,r2
 
0007cc8c: 000310c0 sll r2,r3,0x03 X * 8
 
  0007cc90: 00431023 subu r2,r2,r3 X * 7
 
  0007cc94: 00021080 sll r2,r2,0x02 X * 28
 
0007cc98: 00822023 subu r4,r4,r2 X Slope = X Mod - X * 28
 
  0007cc9c: 00042400 sll r4,r4,0x10
 
0007cca0: 00044403 sra r8,r4,0x10
 
0007cca4: 3402001c ori r2,r0,0x001c r2 = 28
 
  0007cca8: 00483823 subu r7,r2,r8 28 - X Slope
 
0007ccac: 00001010 mfhi r2
 
0007ccb0: 00451021 addu r2,r2,r5 Y Mod * 4 / 7
 
0007ccb4: 00021103 sra r2,r2,0x04 Y = Y Mod / 28
 
0007ccb8: 00461023 subu r2,r2,r6
 
0007ccbc: 000218c0 sll r3,r2,0x03 Y * 8
 
  0007ccc0: 00621823 subu r3,r3,r2 Y * 7
 
0007ccc4: 00031880 sll r3,r3,0x02 Y * 28
 
0007ccc8: 00a32823 subu r5,r5,r3 Y Slope = Y Mod - Y * 28
 
0007cccc: 00052c00 sll r5,r5,0x10
 
0007ccd0: 00052403 sra r4,r5,0x10 (Favors higher X Result)
 
0007ccd4: 00e4102a slt r2,r7,r4 (Branch -> Slope Mod = Y Slope * 12 * Halves / 28)
 
  0007ccd8: 104000b2 beq r2,r0,0x0007cfa4 Branch if (28 - X Slope) >= Y Slope
 
  0007ccdc: 00041040 sll r2,r4,0x01 Y Slope * 2
 
0007cce0: 0801f3d6 j 0x0007cf58 (Else -> Slope Mod = Halves * 12 - (X Slope * 12 * Halves / 28))
 
0007cce4: 00081040 sll r2,r8,0x01 X Slope * 2
 
 
   
 
   
*Slope Type = 0x96*
+
                                            {{f/com|<nowiki>---- [(preset/28) * (12*Halves)] section ----</nowiki>}}
  0007cce8: 96020000 lhu r2,0x0000(r16) Load X Mod
+
  0007cfa0: 00041040 sll r2,r4,0x01                |{{f/std|<nowiki>r2 = preset * 2</nowiki>}}
  0007ccec: 00000000 nop
+
  0007cfa4: 00441021 addu r2,r2,r4                |{{f/std|<nowiki>r2 = preset * 3</nowiki>}}
0007ccf0: 00021400 sll r2,r2,0x10
+
  0007cfa8: 00021080 sll r2,r2,0x02                |{{f/std|<nowiki>r2 = preset * 12</nowiki>}}
  0007ccf4: 00022403 sra r4,r2,0x10
+
  0007cfac: 00490018 mult r2,r9                    |{{f/std|<nowiki>preset * 12 * Halves</nowiki>}}
  0007ccf8: 00910018 mult r4,r17 X Mod * -3 / 7
+
  0007cfb0: 00001812 mflo r3                      |{{f/std|<nowiki>r3 = preset * 12 * Halves</nowiki>}}
  0007ccfc: 96060004 lhu r6,0x0004(r16) Load Y Mod
+
  0007cfb4: 00000000 nop                          |
0007cd00: 00001810 mfhi r3
+
  0007cfb8: 00000000 nop                          |
  0007cd04: 00063400 sll r6,r6,0x10
+
  0007cfbc: 00710018 mult r3,r17                   |{{f/std|<nowiki>(Slope mod* 12 * Halves) * (-3 / 7)*2^32</nowiki>}}
  0007cd08: 00062c03 sra r5,r6,0x10
+
  0007cfc0: 00001010 mfhi r2                       |{{f/std|<nowiki>r2 = (preset* 12 * Halves) * -3/7</nowiki>}}
  0007cd0c: 00b10018 mult r5,r17 Y Mod * -3 / 7
+
  0007cfc4: 00431021 addu r2,r2,r3                 |{{f/std|<nowiki>r2 = (Preset* 12 * Halves) * -3/7</nowiki>}}
  0007cd10: 000217c3 sra r2,r2,0x1f
+
  0007cfc8: 00021103 sra r2,r2,0x04               |{{f/std|<nowiki>r2 = (Preset* 12 * Halves) /28</nowiki>}}
  0007cd14: 000637c3 sra r6,r6,0x1f
+
  0007cfcc: 00031fc3 sra r3,r3,0x1f                |{{f/std|<nowiki>r3 = 0x00</nowiki>}}
0007cd18: 00641821 addu r3,r3,r4 X Mod * 4 / 7
+
  0007cfd0: 00431023 subu r2,r2,r3                 |{{f/std|<nowiki>r2 = Halves * 12 * Preset/28</nowiki>}} {{f/std|<nowiki>= Halves*6 when preset = 14</nowiki>}}
  0007cd1c: 00031903 sra r3,r3,0x04 X = X Mod / 28
+
  0007cfd4: 01422023 subu r4,r10,r2               |{{f/std|<nowiki>r4 = final height = -(height*12 + halves*12*preset/28) </nowiki>}}
  0007cd20: 00621823 subu r3,r3,r2
+
  0007cfd8: 00041400 sll r2,r4,0x10               |
0007cd24: 000310c0 sll r2,r3,0x03 X * 8
+
  0007cfdc: 00021403 sra r2,r2,0x10               |{{f/std|<nowiki>r2 = final height with clean register</nowiki>}}
  0007cd28: 00431023 subu r2,r2,r3 X * 7
+
  0007cfe0: 8fbf0020 lw r31,0x0020(r29)            |
0007cd2c: 00021080 sll r2,r2,0x02 X * 28
+
  0007cfe4: 8fb1001c lw r17,0x001c(r29)            |
  0007cd30: 00822023 subu r4,r4,r2 X Slope = X Mod - X * 28
+
  0007cfe8: 8fb00018 lw r16,0x0018(r29)            |
  0007cd34: 00042400 sll r4,r4,0x10
+
  0007cfec: 27bd0028 addiu r29,r29,0x0028          |
  0007cd38: 00043c03 sra r7,r4,0x10
+
  0007cff0: 03e00008 jr r31                  '''END'''
0007cd3c: 00001010 mfhi r2
+
  0007cff4: 00000000 nop
  0007cd40: 00451021 addu r2,r2,r5 Y Mod * 4 / 7
+
=== Notes ===
  0007cd44: 00021103 sra r2,r2,0x04 Y = Y Mod / 28
+
  <span ID = "0007c80cNotes"></span>
  0007cd48: 00461023 subu r2,r2,r6
+
  For notes below, (preset X)/28 will be refered as X and (preset Y/28) as Y. (1-preset/28) will be refered as anti-preset
  0007cd4c: 000218c0 sll r3,r2,0x03 Y * 8
+
  So X, Y, Anti-X, Anti-Y (...)
  0007cd50: 00621823 subu r3,r3,r2 Y * 7
 
  0007cd54: 00031880 sll r3,r3,0x02 Y * 28
 
0007cd58: 00a32823 subu r5,r5,r3 Y Slope = Y Mod - Y * 28
 
  0007cd5c: 00052c00 sll r5,r5,0x10
 
  0007cd60: 00052403 sra r4,r5,0x10 (Favors highest Slope)
 
0007cd64: 00e4102a slt r2,r7,r4 (Branch -> Slope Mod = Y Slope * 12 * Halves / 28)
 
0007cd68: 1440008d bne r2,r0,0x0007cfa0 Branch if X Slope < Y Slope
 
0007cd6c: 00071040 sll r2,r7,0x01 X Slope * 2
 
0007cd70: 0801f3ea j 0x0007cfa8 (Else -> Slope Mod = X Slope * 12 * Halves / 28)
 
  0007cd74: 00471021 addu r2,r2,r7 X Slope * 3
 
 
   
 
   
*Slope Type = 0x66*
+
Here is the details per slope type
0007cd78: 96020000 lhu r2,0x0000(r16) Load X Mod
+
  0x11 : X or Anti-Y (smallest value)
0007cd7c: 00000000 nop
+
  0x14 : Anti-X or Anti-Y (smallest value)
0007cd80: 00021400 sll r2,r2,0x10
+
  0x25 : Anti-Y (always)
0007cd84: 00022403 sra r4,r2,0x10
+
  0x41 : X or Y (smallest value)
0007cd88: 00910018 mult r4,r17 X Mod * -3 / 7
+
  0x44 : Anti-X or Y (smallest value)
0007cd8c: 96060004 lhu r6,0x0004(r16) Load Y Mod
+
  0x52 : X (always)
0007cd90: 00001810 mfhi r3
+
  0x58 : Anti-X (always)
0007cd94: 00063400 sll r6,r6,0x10
+
  0x66 : X or Anti-Y (greatest value)
0007cd98: 00062c03 sra r5,r6,0x10
+
  0x69 : Anti-X or Anti-Y (greatest value)
0007cd9c: 00b10018 mult r5,r17 Load Y * -3 / 7
+
  0x85 : Y (always)
0007cda0: 000217c3 sra r2,r2,0x1f
+
  0x96 : X or Y (greatest value)
0007cda4: 000637c3 sra r6,r6,0x1f
+
  0x99 : Anti-X or Y (greatest value)
0007cda8: 00641821 addu r3,r3,r4 X Mod * 4 / 7
 
0007cdac: 00031903 sra r3,r3,0x04 X = X Mod / 28
 
0007cdb0: 00621823 subu r3,r3,r2
 
0007cdb4: 000310c0 sll r2,r3,0x03 X * 8
 
0007cdb8: 00431023 subu r2,r2,r3 X * 7
 
0007cdbc: 00021080 sll r2,r2,0x02 X * 28
 
0007cdc0: 00822023 subu r4,r4,r2 X Slope = X Mod - X * 28
 
0007cdc4: 00042400 sll r4,r4,0x10
 
0007cdc8: 00043c03 sra r7,r4,0x10
 
0007cdcc: 00001010 mfhi r2
 
0007cdd0: 00451021 addu r2,r2,r5 Y Mod * 4 / 7
 
0007cdd4: 00021103 sra r2,r2,0x04 Y = Y Mod / 28
 
0007cdd8: 00461023 subu r2,r2,r6
 
0007cddc: 000218c0 sll r3,r2,0x03 Y * 8
 
0007cde0: 00621823 subu r3,r3,r2 Y * 7
 
0007cde4: 00031880 sll r3,r3,0x02 Y * 28
 
0007cde8: 00a32823 subu r5,r5,r3 Y Slope = Y Mod - Y * 28
 
0007cdec: 00052c00 sll r5,r5,0x10
 
0007cdf0: 00052c03 sra r5,r5,0x10
 
0007cdf4: 3402001c ori r2,r0,0x001c r2 = 28
 
0007cdf8: 00452023 subu r4,r2,r5 28 - Y Slope
 
0007cdfc: 00e4102a slt r2,r7,r4 (Favors lower X Slope)
 
0007ce00: 14400004 bne r2,r0,0x0007ce14 Branch if X Slope < (28 - Y Slope)
 
0007ce04: 00000000 nop
 
0007ce08: 00071040 sll r2,r7,0x01 X Slope * 2
 
0007ce0c: 0801f3ea j 0x0007cfa8 (Slope Mod = X Slope * 12 * Halves / 28)
 
0007ce10: 00471021 addu r2,r2,r7 X Slope * 3
 
0007ce14: 00051040 sll r2,r5,0x01 Y Slope * 2
 
0007ce18: 0801f3d7 j 0x0007cf5c (Slope Mod = Halves * 12 - (Y Slope * 12 * Halves / 28))
 
0007ce1c: 00451021 addu r2,r2,r5 Y Slope * 3
 
  
*Slope Type = 0x69*
+
=== Return locations ===
0007ce20: 96020000 lhu r2,0x0000(r16) Load X Mod
+
  '''Battle.bin'''
0007ce24: 00000000 nop
+
  0007d150: [[Complex_Height_Data_from_unit_misc_data_and_coordinates]] - When call by [[0007d51c_-_0007d5cc]] X preset = Y preset = 14
0007ce28: 00021400 sll r2,r2,0x10
+
  0007d988: [[0007d5d0_-_0007db18]]
0007ce2c: 00022403 sra r4,r2,0x10
+
  00089144: [[000890b8_-_00089248]]
0007ce30: 00910018 mult r4,r17 X Mod * -3 / 7
+
  00089a90: [[000898a0_-_00089b9c]]
0007ce34: 96060004 lhu r6,0x0004(r16) Load Y Mod
+
  00089c9c: [[00089ba0_-_00089d9c]]
0007ce38: 00000000 nop
+
  0008a03c: [[00089f24_-_0008a114]]
0007ce3c: 00063400 sll r6,r6,0x10
+
  0008cb40: [[0008ca7c_-_0008cbb0]]
0007ce40: 00062c03 sra r5,r6,0x10
 
0007ce44: 00001810 mfhi r3
 
0007ce48: 000217c3 sra r2,r2,0x1f
 
0007ce4c: 000637c3 sra r6,r6,0x1f
 
0007ce50: 00b10018 mult r5,r17 Y Mod * -3 / 7
 
0007ce54: 00641821 addu r3,r3,r4 X Mod * 4 / 7
 
0007ce58: 00031903 sra r3,r3,0x04 X = X Mod / 28
 
0007ce5c: 00621823 subu r3,r3,r2
 
0007ce60: 000310c0 sll r2,r3,0x03 X * 8
 
0007ce64: 00431023 subu r2,r2,r3 X * 7
 
0007ce68: 00021080 sll r2,r2,0x02 X * 28
 
0007ce6c: 00822023 subu r4,r4,r2 X Slope = X Mod - X * 28
 
0007ce70: 00042400 sll r4,r4,0x10
 
0007ce74: 00044403 sra r8,r4,0x10
 
0007ce78: 3404001c ori r4,r0,0x001c r4 = 28
 
0007ce7c: 00883823 subu r7,r4,r8 28 - X Slope
 
0007ce80: 00001010 mfhi r2
 
0007ce84: 00451021 addu r2,r2,r5 Y Mod * 4 / 7
 
0007ce88: 00021103 sra r2,r2,0x04 Y = Y Mod / 28
 
0007ce8c: 00461023 subu r2,r2,r6
 
0007ce90: 000218c0 sll r3,r2,0x03 Y * 8
 
0007ce94: 00621823 subu r3,r3,r2 Y * 7
 
0007ce98: 00031880 sll r3,r3,0x02 Y * 28
 
0007ce9c: 00a32823 subu r5,r5,r3 Y Slope = Y Mod - Y * 28
 
0007cea0: 00052c00 sll r5,r5,0x10
 
0007cea4: 00052c03 sra r5,r5,0x10 (Favors lowest Slope)
 
0007cea8: 00852023 subu r4,r4,r5 28 - Y Slope
 
0007ceac: 00e4102a slt r2,r7,r4 (Branch -> Slope Mod = Halves * 12 - (X Slope * 12 * Halves / 28))
 
0007ceb0: 10400028 beq r2,r0,0x0007cf54 Branch if (28 - X Slope) >= (28 - Y Slope)
 
0007ceb4: 00051040 sll r2,r5,0x01 Y Slope * 2
 
0007ceb8: 0801f3d7 j 0x0007cf5c (Else -> Slope Mod = Halves * 12 - (Y Slope * 12 * Halves / 28))
 
0007cebc: 00451021 addu r2,r2,r5 Y Slope * 3
 
 
 
*Slope Type = 0x99*
 
0007cec0: 96020000 lhu r2,0x0000(r16) Load X Mod
 
0007cec4: 00000000 nop
 
0007cec8: 00021400 sll r2,r2,0x10
 
0007cecc: 00022403 sra r4,r2,0x10
 
0007ced0: 00910018 mult r4,r17 X Mod * -3 / 7
 
0007ced4: 96060004 lhu r6,0x0004(r16) Load Y Mod
 
0007ced8: 00000000 nop
 
0007cedc: 00063400 sll r6,r6,0x10
 
0007cee0: 00062c03 sra r5,r6,0x10
 
0007cee4: 00001810 mfhi r3
 
0007cee8: 000217c3 sra r2,r2,0x1f
 
0007ceec: 000637c3 sra r6,r6,0x1f
 
0007cef0: 00b10018 mult r5,r17 Y Mod * -3 / 7
 
0007cef4: 00641821 addu r3,r3,r4 X Mod * 4 / 7
 
0007cef8: 00031903 sra r3,r3,0x04 X = X Mod / 28
 
  0007cefc: 00621823 subu r3,r3,r2
 
  0007cf00: 000310c0 sll r2,r3,0x03 X * 8
 
0007cf04: 00431023 subu r2,r2,r3 X * 7
 
0007cf08: 00021080 sll r2,r2,0x02 X * 28
 
0007cf0c: 00822023 subu r4,r4,r2 X Slope = X Mod - X * 28
 
0007cf10: 00042400 sll r4,r4,0x10
 
0007cf14: 00044403 sra r8,r4,0x10
 
0007cf18: 3402001c ori r2,r0,0x001c r2 = 28
 
0007cf1c: 00483823 subu r7,r2,r8 28 - X Slope
 
0007cf20: 00001010 mfhi r2
 
0007cf24: 00451021 addu r2,r2,r5 Y Mod * 4 / 7
 
0007cf28: 00021103 sra r2,r2,0x04 Y = Y Mod / 28
 
0007cf2c: 00461023 subu r2,r2,r6
 
0007cf30: 000218c0 sll r3,r2,0x03 Y * 8
 
0007cf34: 00621823 subu r3,r3,r2 Y * 7
 
0007cf38: 00031880 sll r3,r3,0x02 Y * 28
 
0007cf3c: 00a32823 subu r5,r5,r3 Y Slope = Y Mod - Y * 28
 
0007cf40: 00052c00 sll r5,r5,0x10
 
0007cf44: 00052403 sra r4,r5,0x10 (Favors lower Y Slope)
 
0007cf48: 00e4102a slt r2,r7,r4 (Branch -> Slope Mod = Y Slope * 12 * Halves / 28)
 
  0007cf4c: 14400015 bne r2,r0,0x0007cfa4 Branch if (28 - X Slope) < Y Slope
 
0007cf50: 00041040 sll r2,r4,0x01 Y Slope * 2
 
0007cf54: 00081040 sll r2,r8,0x01 X Slope * 2
 
0007cf58: 00481021 addu r2,r2,r8 X Slope * 3
 
0007cf5c: 00021080 sll r2,r2,0x02 X Slope * 12
 
0007cf60: 00490018 mult r2,r9 X Slope * 12 * Halves
 
0007cf64: 00002012 mflo r4
 
0007cf68: 00000000 nop
 
  0007cf6c: 00000000 nop
 
0007cf70: 00910018 mult r4,r17 X Slope * 12 * Halves * -3 / 7
 
0007cf74: 00091840 sll r3,r9,0x01 Halves * 2
 
0007cf78: 00691821 addu r3,r3,r9 Halves * 3
 
0007cf7c: 00031880 sll r3,r3,0x02 Halves * 12
 
0007cf80: 00001010 mfhi r2
 
0007cf84: 00441021 addu r2,r2,r4 X Slope * 12 * Halves * 4 / 7
 
0007cf88: 00021103 sra r2,r2,0x04 X Slope * 12 * Halves / 28
 
0007cf8c: 000427c3 sra r4,r4,0x1f
 
  0007cf90: 00441023 subu r2,r2,r4
 
0007cf94: 00621823 subu r3,r3,r2 Slope Mod = Halves * 12 - X Slope * 12 * Halves / 28
 
0007cf98: 0801f3f6 j 0x0007cfd8
 
  0007cf9c: 01432023 subu r4,r10,r3 Z Mod - Slope Mod
 
0007cfa0: 00041040 sll r2,r4,0x01 Y Slope * 2
 
0007cfa4: 00441021 addu r2,r2,r4 Y Slope * 3
 
0007cfa8: 00021080 sll r2,r2,0x02 Y Slope * 12
 
0007cfac: 00490018 mult r2,r9 Y Slope * 12 * Halves
 
0007cfb0: 00001812 mflo r3
 
0007cfb4: 00000000 nop
 
0007cfb8: 00000000 nop
 
  0007cfbc: 00710018 mult r3,r17 Y Slope * 12 * Halves * -3 / 7
 
0007cfc0: 00001010 mfhi r2
 
0007cfc4: 00431021 addu r2,r2,r3 Y Slope * 12 * Halves * 4 / 7
 
0007cfc8: 00021103 sra r2,r2,0x04 Slope Mod = Y Slope * 12 * Halves / 28
 
0007cfcc: 00031fc3 sra r3,r3,0x1f
 
0007cfd0: 00431023 subu r2,r2,r3
 
  0007cfd4: 01422023 subu r4,r10,r2 Z Mod -= Slope Mod
 
0007cfd8: 00041400 sll r2,r4,0x10
 
0007cfdc: 00021403 sra r2,r2,0x10 r2 = Z Mod
 
0007cfe0: 8fbf0020 lw r31,0x0020(r29)
 
0007cfe4: 8fb1001c lw r17,0x001c(r29)
 
0007cfe8: 8fb00018 lw r16,0x0018(r29)
 
0007cfec: 27bd0028 addiu r29,r29,0x0028
 
0007cff0: 03e00008 jr r31
 
0007cff4: 00000000 nop
 

Latest revision as of 19:15, 18 December 2021

Instructions and notes

Parameters : r5 = Tile elevation
             r4 = previous routine stack pointer
                    - 0x00 = X mod (X coord * 28 + preset value)
                    - 0x02 = Elevation					 
                    - 0x04 = Y mod (Y coord * 28 + preset value)

Returns : r2 holding Height data as negative value depending of slope type
                  - (Height*12) if halves = 0 or unsupported slope type
                  - (Height*12) + (preset/28)*12*halves   (depending of slope see notes)
                  - (Height*12) + (1- preset/28)*12*halves  (depending of slope see notes)   
                  NB : is preset is 14 , same result for all slope
-----------------------------------------------------------------------------------------

0007c80c: 27bdffd8 addiu r29,r29,-0x0028    |(routine has a extremly bad setup - could be MUCH better)
0007c810: afb00018 sw r16,0x0018(r29)       |
0007c814: 00808021 addu r16,r4,r0           |r16 = Stack Pointer
0007c818: afb1001c sw r17,0x001c(r29)       |
0007c81c: 3c119249 lui r17,0x9249           |
0007c820: afbf0020 sw r31,0x0020(r29)       |
0007c824: 96020000 lhu r2,0x0000(r16)       |r2 = Unit X*28 +14 (X mod) - halfword
0007c828: 36312493 ori r17,r17,0x2493       |r17 = 0x92492493 ( =-3/7 * 2^32)
0007c82c: 00021400 sll r2,r2,0x10           |r2 = unit X mod * 1024 (move the lower part of the register in upper part)
0007c830: 00021c03 sra r3,r2,0x10           |r3 = unit  X Mod (Uper part of register is cleaned)
0007c834: 00710018 mult r3,r17              |X mod * -3/7 * 2^32
0007c838: 000217c3 sra r2,r2,0x1f           |r2 = r2/2^31 (mostly 0x00, unlikely 0x01)
0007c83c: 00002010 mfhi r4                  |r4 = unit X mod * -3/7
0007c840: 00832021 addu r4,r4,r3            |r4 = unit X Mod * 4 / 7 
0007c844: 00042103 sra r4,r4,0x04           |r4 = Unit XMod / 28 (= unit X coord)
0007c848: 00822023 subu r4,r4,r2            |rounding stuff
0007c84c: a7a40010 sh r4,0x0010(r29)        |Store Unit's X coord on stack 0x10 (Unused in the routine)
0007c850: 96030004 lhu r3,0x0004(r16)       |r3 = Unit Y*28 +14 (Y mod) - halfword
0007c854: 00000000 nop                      |
0007c858: 00031c00 sll r3,r3,0x10           |r3 = unit Y mod * 1024 
0007c85c: 00033403 sra r6,r3,0x10           |r6 = unit  Y Mod (register cleanup)
0007c860: 00d10018 mult r6,r17              |Y mod * -3/7 * 2^32
0007c864: 00042400 sll r4,r4,0x10           |r4 = unit X coord * 1024 
0007c868: 00042403 sra r4,r4,0x10           |r4 = Unit X coord (register cleanup)
0007c86c: 00031fc3 sra r3,r3,0x1f           |r3 = r3/2^31 = 0x00 (very unlikely 0x01)
0007c870: 00001010 mfhi r2                  |r2 = Unit Y mod * -3/7
0007c874: 00461021 addu r2,r2,r6            |r2 = Unit Y Mod * 4 / 7
0007c878: 00021103 sra r2,r2,0x04           |r2 = Unit's Y Coord (Y mod / 28)
0007c87c: 00431023 subu r2,r2,r3            |rounding stuff
0007c880: a7a20012 sh r2,0x0012(r29)        |Store Unit's Y coord on stack 0x12 (Unused in the routine)
0007c884: 00021400 sll r2,r2,0x10           |r2 = unit Y coord * 1024 (move the lower part of the register in upper part)
0007c888: 30a600ff andi r6,r5,0x00ff        |r6 = Unit's Elevation
0007c88c: 0c060fed jal 0x00183fb4           |-->Get_Tile_Data_Pointer Return r2 = Unit tile data pointer
0007c890: 00022c03 sra r5,r2,0x10           |r5 = Unit's Y (upper part of register cleared)
0007c894: 00402821 addu r5,r2,r0            |r5 = Tile Data Pointer
0007c898: 90a30002 lbu r3,0x0002(r5)        |r3 = Tile's Height
0007c89c: 00000000 nop                      |
0007c8a0: 00031040 sll r2,r3,0x01           |r2 = tile Height * 2
0007c8a4: 00431021 addu r2,r2,r3            |r2 = Height * 3
0007c8a8: 00021080 sll r2,r2,0x02           |r2 = Height * 12
0007c8ac: 00025023 subu r10,r0,r2           |r10 = -(Height * 12)
0007c8b0: 90a20003 lbu r2,0x0003(r5)        |r2 =  Tiles Halves + Depth
0007c8b4: 00000000 nop                      |
0007c8b8: 3049001f andi r9,r2,0x001f        |r9 = Tile  Halves
0007c8bc: 112001c6 beq r9,r0,0x0007cfd8     #If Halves <> 0x00 #Branch if Halves = 0 (skips ALL of the slope checks)
0007c8c0: 01402021 addu r4,r10,r0           |r4 = Z Mod
0007c8c4: 90a30004 lbu r3,0x0004(r5)             |r3 = Tile Slope Type
0007c8c8: 34020052 ori r2,r0,0x0052              |r2 = 0x52
0007c8cc: 1062002f beq r3,r2,0x0007c98c          #If Tile slope <> 0x52 #Else branch to Slope Type = 0x52 section
0007c8d0: 28620053 slti r2,r3,0x0053                 |r2 = 0x01 if slope < 0x53
0007c8d4: 10400013 beq r2,r0,0x0007c924              #If slope < 0x52 #Branch if Slope Type >= 0x53
0007c8d8: 34020025 ori r2,r0,0x0025                      |r2 = 0x25
0007c8dc: 1062004f beq r3,r2,0x0007ca1c                  #If slope <> 0x25 #Branch if Slope Type = 0x25
0007c8e0: 00000000 nop                                       |   
0007c8e4: 28620026 slti r2,r3,0x0026                         |r2 = 0x01 if slope < 0x26
0007c8e8: 10400007 beq r2,r0,0x0007c908                      #If slope < 0x26 #Branch if Slope Type >= 0x26
0007c8ec: 34020011 ori r2,r0,0x0011                              |r2 = 0x11
0007c8f0: 10620084 beq r3,r2,0x0007cb04                          #If slope <> 0x11 #Branch if Slope Type = 0x11
0007c8f4: 34020014 ori r2,r0,0x0014                                  |r2 = 0x14
0007c8f8: 106200ac beq r3,r2,0x0007cbac                              #If slop <> 0x14 #Branch if Slope Type = 0x14
0007c8fc: 00041400 sll r2,r4,0x10                                        |r2 = r10 * 1024 (1st move for register clean up)
0007c900: 0801f3f7 j 0x0007cfdc                                          >>jump to end (slope type not supported/invalid)
0007c904: 00000000 nop                                                   |
0007c908: 34020041 ori r2,r0,0x0041                          # Else (slope >= 0x26) r2 = 0x41
0007c90c: 10620059 beq r3,r2,0x0007ca74                      #If slope <> 0x41 #Branch if Slope Type = 0x41
0007c910: 34020044 ori r2,r0,0x0044                              |r2 = 0x44
0007c914: 106200cd beq r3,r2,0x0007cc4c                          #If slope <> 0x44 #Branch if Slope Type = 0x44
0007c918: 00041400 sll r2,r4,0x10                                    |r2 = r10 * 1024 (1st move for register clean up)
0007c91c: 0801f3f7 j 0x0007cfdc                                      >>jump to end (slope type not supported/invalid)
0007c920: 00000000 nop                                               |
0007c924: 34020069 ori r2,r0,0x0069                  #Else (Slope >= 0x53) r2 = 0x69
0007c928: 1062013d beq r3,r2,0x0007ce20              #If slope <> 0x69 #Branch if Slope Type = 0x69
0007c92c: 2862006a slti r2,r3,0x006a                     |r2 = 1 if slope < 0x6a
0007c930: 10400008 beq r2,r0,0x0007c954                  #If slope < 0x6a #Branch if Slope Type >= 0x6a
0007c934: 34020058 ori r2,r0,0x0058                          |r2 = 0x58
0007c938: 10620025 beq r3,r2,0x0007c9d0                      #If slope <> 0x58 #Branch if Slope Type = 0x58
0007c93c: 00000000 nop                                           | 
0007c940: 34020066 ori r2,r0,0x0066                              |r2 = 0x66
0007c944: 1062010c beq r3,r2,0x0007cd78                          #If slope <> 0x66 #Branch if Slope Type = 0x66
0007c948: 00041400 sll r2,r4,0x10                                    |r2 = r10 * 1024 (1st move for register clean up)
0007c94c: 0801f3f7 j 0x0007cfdc                                      >>jump to end (slope type not supported/invalid)
0007c950: 00000000 nop                                               |
0007c954: 34020096 ori r2,r0,0x0096                      #Else (slope >= 0x6a) r2 = 0x96
0007c958: 106200e3 beq r3,r2,0x0007cce8                  #If slope <> 0x96 #Branch if Slope Type = 0x96
0007c95c: 28620097 slti r2,r3,0x0097                         |r2 = 0x01 if slope < 0x97
0007c960: 10400005 beq r2,r0,0x0007c978                      #If slope < 0x97 #Branch if Slope Type >= 0x97
0007c964: 34020085 ori r2,r0,0x0085                              |r2 = 0x85
0007c968: 1062003f beq r3,r2,0x0007ca68                          #If slope <> 0x85 #Branch if Slope Type = 0x85
0007c96c: 00041400 sll r2,r4,0x10                                    |r2 = r10 * 1024 (1st move for register clean up)
0007c970: 0801f3f7 j 0x0007cfdc                                      >>jump to end (slope type not supported/invalid)
0007c974: 00000000 nop                                               |
0007c978: 34020099 ori r2,r0,0x0099                          #Else (slope > 0x97) r2 = 0x99
0007c97c: 10620150 beq r3,r2,0x0007cec0                      #if slope <> 0x99 #Branch if Slope Type = 0x99
0007c980: 00041400 sll r2,r4,0x10                                |r2 = r10 * 1024 (1st move for register clean up)
0007c984: 0801f3f7 j 0x0007cfdc                                  >>jump to end (slope type not supported/invalid)
0007c988: 00000000 nop                                           |

                                            --- Slope Type = 0x52  Section---
0007c98c: 96030000 lhu r3,0x0000(r16)            |r3 =  X Mod (X coord*28 +14)
0007c990: 00000000 nop                           |
0007c994: 00031c00 sll r3,r3,0x10                |r3 = X mod * 1024 (move halfword in upper register part)
0007c998: 00032403 sra r4,r3,0x10                |r4 = X mod *1024/1024 (move halfword in lower register part - upper part is 0x0000)
0007c99c: 00910018 mult r4,r17                   |X Mod * (-3 / 7)*2^32
0007c9a0: 00031fc3 sra r3,r3,0x1f                |r3 = 0x00 (or 0x01 if r3 is > 2^31 or r3 is a negative word - not possible X should be > 1169...)
0007c9a4: 00001010 mfhi r2                       |r2 = X mod * -3/7
0007c9a8: 00441021 addu r2,r2,r4                 |r2 = X Mod * 4 / 7
0007c9ac: 00021103 sra r2,r2,0x04                |r2 = X Coord (= X Mod / 28)
0007c9b0: 00431023 subu r2,r2,r3                 |(r2 = r2 - 0x00)
0007c9b4: 000218c0 sll r3,r2,0x03                |r3 = X coord * 8
0007c9b8: 00621823 subu r3,r3,r2                 |r3 = X coord * 7
0007c9bc: 00031880 sll r3,r3,0x02                |r3 = X coord * 28
0007c9c0: 00832023 subu r4,r4,r3                 |r4 = preset value   (X Coord*28 + 14 - X Coord*28 (=14)  depending of calling routine ?)
0007c9c4: 00042400 sll r4,r4,0x10                |r4 = preset value *1024
0007c9c8: 0801f3e8 j 0x0007cfa0                  >>Jump to  [(Preset/28) * (12 * Halves)] section with X preset >> 
0007c9cc: 00042403 sra r4,r4,0x10                |r4 = preset value with clean register

                                            --- Slope Type = 0x58  Section---
0007c9d0: 96030000 lhu r3,0x0000(r16)            |Load X Mod (X coord*28 + 14)
0007c9d4: 00000000 nop                           |
0007c9d8: 00031c00 sll r3,r3,0x10                |r3 = X Mod * 1024
0007c9dc: 00032403 sra r4,r3,0x10                |r4 = X Mod  (clear upper part of registery)
0007c9e0: 00910018 mult r4,r17                   |X Mod *( -3 / 7)*2^32
0007c9e4: 00031fc3 sra r3,r3,0x1f                |r3 = 0x00
0007c9e8: 00001010 mfhi r2                       |r2 = X mod * (-3/7)
0007c9ec: 00441021 addu r2,r2,r4                 |r2 = X Mod * 4 / 7
0007c9f0: 00021103 sra r2,r2,0x04                |r2 = X Mod / 28 (= X coord )
0007c9f4: 00431023 subu r2,r2,r3                 |r2 =  X coord -0x00
0007c9f8: 000218c0 sll r3,r2,0x03                |r3 = X Coord * 8
0007c9fc: 00621823 subu r3,r3,r2                 |r3 = X Coord * 7
0007ca00: 00031880 sll r3,r3,0x02                |r3 = X Coord * 28
0007ca04: 00832023 subu r4,r4,r3                 |r4 = 14 (X Coord * 28 + 14) - X coord*28   (depeding of calling routine ?)
0007ca08: 00042400 sll r4,r4,0x10                |
0007ca0c: 00042403 sra r4,r4,0x10                |r4 =14 (upper part of registery cleared)
0007ca10: 00041040 sll r2,r4,0x01                |r2 = 28 (preset*2)
0007ca14: 0801f3d7 j 0x0007cf5c                  >>Jump to [(1-preset/28) * (12*Halves)] section with X preset
0007ca18: 00441021 addu r2,r2,r4                 |r2 = 42 (preset *3)

                                            --- Slope Type = 0x25  Section---
0007ca1c: 96030004 lhu r3,0x0004(r16)            |r3 = Y Mod (Y coord*28 + 14)
0007ca20: 00000000 nop                           |
0007ca24: 00031c00 sll r3,r3,0x10                |r3 = r3*1024
0007ca28: 00032403 sra r4,r3,0x10                |r3 = Y Mod (register cleared)
0007ca2c: 00910018 mult r4,r17                   |r4 = Y Mod * -3 / 7 * 2^32
0007ca30: 00031fc3 sra r3,r3,0x1f                |r3 = 0x00
0007ca34: 00001010 mfhi r2                       |r2 = Y Mod * -3/7
0007ca38: 00441021 addu r2,r2,r4                 |r2 = Y Mod * 4/7
0007ca3c: 00021103 sra r2,r2,0x04                |r2 = Y Coord
0007ca40: 00431023 subu r2,r2,r3                 |r2 = Y Coord
0007ca44: 000218c0 sll r3,r2,0x03                |r2 = Y Coord * 8
0007ca48: 00621823 subu r3,r3,r2                 |r2 = Y Coord * 7
0007ca4c: 00031880 sll r3,r3,0x02                |r2 = Y Coord * 28
0007ca50: 00832023 subu r4,r4,r3                 |r4 = Y preset value
0007ca54: 00042400 sll r4,r4,0x10                |r4 = r4 * 1024
0007ca58: 00042403 sra r4,r4,0x10                |r4 = Y preset value (register cleared)
0007ca5c: 00041040 sll r2,r4,0x01                |r2 = Y preset value * 2
0007ca60: 0801f3d7 j 0x0007cf5c                  >>Jump to [(1-preset/28) * (12*Halves)] section with Y preset
0007ca64: 00441021 addu r2,r2,r4                 |r2 = Y preset value * 3

                                            --- Slope Type = 0x85  Section---
0007ca68: 96030004 lhu r3,0x0004(r16)            |r3 = Y Mod (Y coord*28 + 14)
0007ca6c: 0801f266 j 0x0007c998                  >>Jump to 0x52 section with Y Mod  will go to [(Preset/28) * (12 * Halves)] section with Y preset
0007ca70: 00031c00 sll r3,r3,0x10                |r3 = r3 * 1024 (1st move of register cleanup)

                                            --- Slope Type = 0x41   Section---
0007ca74: 96020000 lhu r2,0x0000(r16)            |r2 = X Mod (X Coord*28 + X Preset)
0007ca78: 00000000 nop                           |
0007ca7c: 00021400 sll r2,r2,0x10                |r2 = r2 * 1024
0007ca80: 00022403 sra r4,r2,0x10                |r4 = X mod (upper register cleanup)
0007ca84: 00910018 mult r4,r17                   |X mod * -3/7 * 2^32
0007ca88: 96060004 lhu r6,0x0004(r16)            |r6 =  Y Mod (Y Coord * 28 + Y preset)
0007ca8c: 00001810 mfhi r3                       |r3 = X mod * -3/7
0007ca90: 00063400 sll r6,r6,0x10                |r6 = r6 *1024
0007ca94: 00062c03 sra r5,r6,0x10                |r5 = Y mod (upper register cleanup)
0007ca98: 00b10018 mult r5,r17                   |Y Mod * -3 / 7 * 2^32
0007ca9c: 000217c3 sra r2,r2,0x1f                |r2 = 0x00
0007caa0: 000637c3 sra r6,r6,0x1f                |r6 = 0x00
0007caa4: 00641821 addu r3,r3,r4                 |r3 = X Mod * 4 / 7
0007caa8: 00031903 sra r3,r3,0x04                |r3 = X Mod / 28 = X coord
0007caac: 00621823 subu r3,r3,r2                 |r3 = X coord - 0x00
0007cab0: 000310c0 sll r2,r3,0x03                |r2 = X Coord * 8
0007cab4: 00431023 subu r2,r2,r3                 |r2 = X Coord * 7
0007cab8: 00021080 sll r2,r2,0x02                |r2 = X Coord * 28
0007cabc: 00822023 subu r4,r4,r2                 |r4 = X preset value
0007cac0: 00042400 sll r4,r4,0x10                |r4 = r4 * 1024
0007cac4: 00043c03 sra r7,r4,0x10                |r7 = X preset value (upper register cleanup)
0007cac8: 00001010 mfhi r2                       |r2 = Y Mod * -3/7
0007cacc: 00451021 addu r2,r2,r5                 |r2 = Y Mod *4/7
0007cad0: 00021103 sra r2,r2,0x04                |r2 = Y Mod / 28 = Y Coord
0007cad4: 00461023 subu r2,r2,r6                 |r2 = Y Coord  - 0x00
0007cad8: 000218c0 sll r3,r2,0x03                |r3 = Y Coord * 8
0007cadc: 00621823 subu r3,r3,r2                 |r3 = Y Coord * 7
0007cae0: 00031880 sll r3,r3,0x02                |r3 = Y Coord * 28
0007cae4: 00a32823 subu r5,r5,r3                 |r5 = Y preset
0007cae8: 00052c00 sll r5,r5,0x10                |r5 = Y preset * 1024
0007caec: 00052403 sra r4,r5,0x10                |r4 = Y preset (upper register cleanup)
0007caf0: 00e4102a slt r2,r7,r4                  |r2 = 0x01 if X preset < Y preset / Else 0x00
0007caf4: 1040012a beq r2,r0,0x0007cfa0          #If X preset < Y preset / if X Preset >= Y Preset  branch to  [(Preset/28) * (12 * Halves)] section with Y preset
0007caf8: 00071040 sll r2,r7,0x01                    |r2 = X preset * 2
0007cafc: 0801f3ea j 0x0007cfa8                      >>Jump to  [(Preset/28) * (12 * Halves)] section with X preset
0007cb00: 00471021 addu r2,r2,r7                     |r2 = X preset * 3

                                            --- Slope Type = 0x11   Section---
0007cb04: 96020000 lhu r2,0x0000(r16)            |r2 = X Mod (X Coord*28 + X Preset)
0007cb08: 00000000 nop                           |
0007cb0c: 00021400 sll r2,r2,0x10                |r2 = r2 * 1024
0007cb10: 00022403 sra r4,r2,0x10                |r4 = X mod (upper register cleanup)
0007cb14: 00910018 mult r4,r17                   |X mod * -3/7 * 2^32 X Mod * -3 / 7
0007cb18: 96060004 lhu r6,0x0004(r16)            |r6 =  Y Mod (Y Coord * 28 + Y preset)
0007cb1c: 00001810 mfhi r3                       |r3 = X mod * -3/7
0007cb20: 00063400 sll r6,r6,0x10                |r6 = r6 *1024
0007cb24: 00062c03 sra r5,r6,0x10                |r5 = Y mod (upper register cleanup)
0007cb28: 00b10018 mult r5,r17                   |Y Mod * -3 / 7 * 2^32
0007cb2c: 000217c3 sra r2,r2,0x1f                |r2 = 0x00
0007cb30: 000637c3 sra r6,r6,0x1f                |r6 = 0x00
0007cb34: 00641821 addu r3,r3,r4                 |r3 = X Mod * 4 / 7
0007cb38: 00031903 sra r3,r3,0x04                |r3 = X Mod / 28 = X coord
0007cb3c: 00621823 subu r3,r3,r2                 |r3 = X coord - 0x00
0007cb40: 000310c0 sll r2,r3,0x03                |r2 = X Coord * 8
0007cb44: 00431023 subu r2,r2,r3                 |r2 = X Coord * 7
0007cb48: 00021080 sll r2,r2,0x02                |r2 = X Coord * 28
0007cb4c: 00822023 subu r4,r4,r2                 |r4 = X preset value
0007cb50: 00042400 sll r4,r4,0x10                |r4 = r4 * 1024
0007cb54: 00043c03 sra r7,r4,0x10                |r7 = X preset value (upper register cleanup)
0007cb58: 00001010 mfhi r2                       |r2 = Y Mod * -3/7
0007cb5c: 00451021 addu r2,r2,r5                 |r2 = Y Mod *4/7
0007cb60: 00021103 sra r2,r2,0x04                |r2 = Y Mod / 28 = Y Coord
0007cb64: 00461023 subu r2,r2,r6                 |r2 = Y Coord  - 0x00
0007cb68: 000218c0 sll r3,r2,0x03                |r3 = Y Coord * 8
0007cb6c: 00621823 subu r3,r3,r2                 |r3 = Y Coord * 7
0007cb70: 00031880 sll r3,r3,0x02                |r3 = Y Coord * 28
0007cb74: 00a32823 subu r5,r5,r3                 |r5 = Y preset
0007cb78: 00052c00 sll r5,r5,0x10                |r5 = Y preset * 1024
0007cb7c: 00052c03 sra r5,r5,0x10                |r5 = Y preset (upper registery clean up)
0007cb80: 3402001c ori r2,r0,0x001c              |r2 = 28
0007cb84: 00452023 subu r4,r2,r5                 |28 - Y preset
0007cb88: 00e4102a slt r2,r7,r4                  |r2 = 0x01 if X preset < 28-Y preset
0007cb8c: 14400004 bne r2,r0,0x0007cba0          #If X preset > (28 - Y preset)
0007cb90: 00000000 nop                               | 
0007cb94: 00051040 sll r2,r5,0x01                    |r2 = Y preset * 2
0007cb98: 0801f3d7 j 0x0007cf5c                      >>Jump to [(1-preset/28) * (12*Halves)] section with Y preset
0007cb9c: 00451021 addu r2,r2,r5                     |r2 = Y preset * 3
0007cba0: 00071040 sll r2,r7,0x01                |r2 = X preset *2
0007cba4: 0801f3ea j 0x0007cfa8                  >>Jump to  [(Preset/28) * (12 * Halves)] section with X preset
0007cba8: 00471021 addu r2,r2,r7                 |r2 = X preset *3

                                            --- Slope Type = 0x14   Section---
0007cbac: 96020000 lhu r2,0x0000(r16)            |r2 = X Mod (X Coord*28 + X Preset)
0007cbb0: 00000000 nop                           |
0007cbb4: 00021400 sll r2,r2,0x10                |r2 = r2 * 1024
0007cbb8: 00022403 sra r4,r2,0x10                |r4 = X mod (upper register cleanup)
0007cbbc: 00910018 mult r4,r17                   |X mod * -3/7 * 2^32 X Mod * -3 / 7
0007cbc0: 96060004 lhu r6,0x0004(r16)            |r6 =  Y Mod (Y Coord * 28 + Y preset)
0007cbc4: 00000000 nop                           |
0007cbc8: 00063400 sll r6,r6,0x10                |r6 = r6 *1024
0007cbcc: 00062c03 sra r5,r6,0x10                |r5 = Y mod (upper register cleanup)
0007cbd0: 00001810 mfhi r3                       |r3 = X mod * -3/7
0007cbd4: 000217c3 sra r2,r2,0x1f                |r2 = 0x00
0007cbd8: 000637c3 sra r6,r6,0x1f                |r6 = 0x00
0007cbdc: 00b10018 mult r5,r17                   |Y Mod * -3 / 7 * 2^32
0007cbe0: 00641821 addu r3,r3,r4                 |r3 = X Mod * 4 / 7
0007cbe4: 00031903 sra r3,r3,0x04                |r3 = X Mod / 28 = X coord
0007cbe8: 00621823 subu r3,r3,r2                 |r3 = X coord - 0x00
0007cbec: 000310c0 sll r2,r3,0x03                |r2 = X Coord * 8
0007cbf0: 00431023 subu r2,r2,r3                 |r2 = X Coord * 7
0007cbf4: 00021080 sll r2,r2,0x02                |r2 = X Coord * 28
0007cbf8: 00822023 subu r4,r4,r2                 |r4 = X preset value
0007cbfc: 00042400 sll r4,r4,0x10                |r4 = r4 * 1024
0007cc00: 00044403 sra r8,r4,0x10                |r8 = X preset value (upper register cleanup)
0007cc04: 3404001c ori r4,r0,0x001c              |r4 = 28
0007cc08: 00883823 subu r7,r4,r8                 |r7 = 28-X preset
0007cc0c: 00001010 mfhi r2                       |r2 = Y Mod * -3/7
0007cc10: 00451021 addu r2,r2,r5                 |r2 = Y Mod *4/7
0007cc14: 00021103 sra r2,r2,0x04                |r2 = Y Mod / 28 = Y Coord
0007cc18: 00461023 subu r2,r2,r6                 |r2 = Y Coord  - 0x00
0007cc1c: 000218c0 sll r3,r2,0x03                |r3 = Y Coord * 8
0007cc20: 00621823 subu r3,r3,r2                 |r3 = Y Coord * 7
0007cc24: 00031880 sll r3,r3,0x02                |r3 = Y Coord * 28
0007cc28: 00a32823 subu r5,r5,r3                 |r5 = Y preset
0007cc2c: 00052c00 sll r5,r5,0x10                |r5 = Y preset * 1024
0007cc30: 00052c03 sra r5,r5,0x10                |r5 = Y preset (upper registery clean up)
0007cc34: 00852023 subu r4,r4,r5                 |r4 = 28 - Y Preset
0007cc38: 00e4102a slt r2,r7,r4                  |r2 = 0x01 if (28-X preset)<(28-Y preset)
0007cc3c: 144000c5 bne r2,r0,0x0007cf54          #If (28-Y preset)<=(28-X preset) /Else Branch to [(1-preset/28) * (12*Halves)] section with X preset
0007cc40: 00051040 sll r2,r5,0x01                    |r2 = Y preset*2
0007cc44: 0801f3d7 j 0x0007cf5c                      >>Jump to [(1-preset/28) * (12*Halves)] section with Y preset
0007cc48: 00451021 addu r2,r2,r5                     |r2 = Y preset*3

                                            --- Slope Type = 0x44   Section---
0007cc4c: 96020000 lhu r2,0x0000(r16)            |r2 = X Mod (X Coord*28 + X Preset)
0007cc50: 00000000 nop                           |
0007cc54: 00021400 sll r2,r2,0x10                |r2 = r2 * 1024
0007cc58: 00022403 sra r4,r2,0x10                |r4 = X mod (upper register cleanup)
0007cc5c: 00910018 mult r4,r17                   |X mod * -3/7 * 2^32
0007cc60: 96060004 lhu r6,0x0004(r16)            |r6 =  Y Mod (Y Coord * 28 + Y preset)
0007cc64: 00000000 nop                           |
0007cc68: 00063400 sll r6,r6,0x10                |r6 = r6 *1024
0007cc6c: 00062c03 sra r5,r6,0x10                |r5 = Y mod (upper register cleanup)
0007cc70: 00001810 mfhi r3                       |r3 = X mod * -3/7
0007cc74: 000217c3 sra r2,r2,0x1f                |r2 = 0x00
0007cc78: 000637c3 sra r6,r6,0x1f                |r6 = 0x00
0007cc7c: 00b10018 mult r5,r17                   |Y Mod * -3 / 7 * 2^32
0007cc80: 00641821 addu r3,r3,r4                 |r3 = X Mod * 4 / 7
0007cc84: 00031903 sra r3,r3,0x04                |r3 = X Mod / 28 = X coord
0007cc88: 00621823 subu r3,r3,r2                 |r3 = X coord - 0x00
0007cc8c: 000310c0 sll r2,r3,0x03                |r2 = X Coord * 8
0007cc90: 00431023 subu r2,r2,r3                 |r2 = X Coord * 7
0007cc94: 00021080 sll r2,r2,0x02                |r2 = X Coord * 28
0007cc98: 00822023 subu r4,r4,r2                 |r4 = X preset value
0007cc9c: 00042400 sll r4,r4,0x10                |r4 = r4 * 1024
0007cca0: 00044403 sra r8,r4,0x10                |r8 = X preset value (upper register cleanup)
0007cca4: 3402001c ori r2,r0,0x001c              |r2 = 28
0007cca8: 00483823 subu r7,r2,r8                 |r7 = 28-X preset
0007ccac: 00001010 mfhi r2                       |r2 = Y Mod * -3/7
0007ccb0: 00451021 addu r2,r2,r5                 |r2 = Y Mod *4/7
0007ccb4: 00021103 sra r2,r2,0x04                |r2 = Y Mod / 28 = Y Coord
0007ccb8: 00461023 subu r2,r2,r6                 |r2 = Y Coord  - 0x00
0007ccbc: 000218c0 sll r3,r2,0x03                |r3 = Y Coord * 8
0007ccc0: 00621823 subu r3,r3,r2                 |r3 = Y Coord * 7
0007ccc4: 00031880 sll r3,r3,0x02                |r3 = Y Coord * 28
0007ccc8: 00a32823 subu r5,r5,r3                 |r5 = Y preset
0007cccc: 00052c00 sll r5,r5,0x10                |r5 = Y preset * 1024
0007ccd0: 00052403 sra r4,r5,0x10                |r4 = Y preset (upper registery clean up)
0007ccd4: 00e4102a slt r2,r7,r4                  |r2 = 0x01 if (28-X preset) < Y preset
0007ccd8: 104000b2 beq r2,r0,0x0007cfa4          #If  28-X preset < Y preset / Else branch to  [(Preset/28) * (12 * Halves)] section with Y preset
0007ccdc: 00041040 sll r2,r4,0x01                |r2 = Y preset*2
0007cce0: 0801f3d6 j 0x0007cf58                      >>Jump to [(1-preset/28) * (12*Halves)] section with X preset
0007cce4: 00081040 sll r2,r8,0x01                    |r2 = X preset*2

                                            --- Slope Type = 0x96   Section---
0007cce8: 96020000 lhu r2,0x0000(r16)            |r2 = X Mod (X Coord*28 + X Preset)
0007ccec: 00000000 nop                           |
0007ccf0: 00021400 sll r2,r2,0x10                |r2 = r2 * 1024
0007ccf4: 00022403 sra r4,r2,0x10                |r4 = X mod (upper register cleanup)
0007ccf8: 00910018 mult r4,r17                   |X mod * -3/7 * 2^32
0007ccfc: 96060004 lhu r6,0x0004(r16)            |r6 =  Y Mod (Y Coord * 28 + Y preset)
0007cd00: 00001810 mfhi r3                       |r3 = X mod * -3/7
0007cd04: 00063400 sll r6,r6,0x10                |r6 = r6 *1024
0007cd08: 00062c03 sra r5,r6,0x10                |r5 = Y mod (upper register cleanup)
0007cd0c: 00b10018 mult r5,r17                   |Y Mod * -3 / 7 * 2^32
0007cd10: 000217c3 sra r2,r2,0x1f                |r2 = 0x00
0007cd14: 000637c3 sra r6,r6,0x1f                |r6 = 0x00
0007cd18: 00641821 addu r3,r3,r4                 |r3 = X Mod * 4 / 7
0007cd1c: 00031903 sra r3,r3,0x04                |r3 = X Mod / 28 = X coord
0007cd20: 00621823 subu r3,r3,r2                 |r3 = X coord - 0x00
0007cd24: 000310c0 sll r2,r3,0x03                |r2 = X Coord * 8
0007cd28: 00431023 subu r2,r2,r3                 |r2 = X Coord * 7
0007cd2c: 00021080 sll r2,r2,0x02                |r2 = X Coord * 28
0007cd30: 00822023 subu r4,r4,r2                 |r4 = X preset value
0007cd34: 00042400 sll r4,r4,0x10                |r4 = r4 * 1024
0007cd38: 00043c03 sra r7,r4,0x10                |r7 = X preset value (upper register cleanup)
0007cd3c: 00001010 mfhi r2                       |r2 = Y Mod * -3/7
0007cd40: 00451021 addu r2,r2,r5                 |r2 = Y Mod *4/7
0007cd44: 00021103 sra r2,r2,0x04                |r2 = Y Mod / 28 = Y Coord
0007cd48: 00461023 subu r2,r2,r6                 |r2 = Y Coord  - 0x00
0007cd4c: 000218c0 sll r3,r2,0x03                |r3 = Y Coord * 8
0007cd50: 00621823 subu r3,r3,r2                 |r3 = Y Coord * 7
0007cd54: 00031880 sll r3,r3,0x02                |r3 = Y Coord * 28
0007cd58: 00a32823 subu r5,r5,r3                 |r5 = Y preset
0007cd5c: 00052c00 sll r5,r5,0x10                |r5 = Y preset * 1024
0007cd60: 00052403 sra r4,r5,0x10                |r4 = Y preset (upper registery clean up)
0007cd64: 00e4102a slt r2,r7,r4                  |r2 = 0x01 if X preset < Y preset
0007cd68: 1440008d bne r2,r0,0x0007cfa0          #If X preset > Y preset / Else branch to  [(Preset/28) * (12 * Halves)] section with Y preset
0007cd6c: 00071040 sll r2,r7,0x01                    |r2 = X preset * 2
0007cd70: 0801f3ea j 0x0007cfa8                      >>Jump to  [(Preset/28) * (12 * Halves)] section with X preset
0007cd74: 00471021 addu r2,r2,r7                     |r2 = X preset * 3

                                            --- Slope Type = 0x66   Section---
0007cd78: 96020000 lhu r2,0x0000(r16)            |r2 = X Mod (X Coord*28 + X Preset)
0007cd7c: 00000000 nop                           |
0007cd80: 00021400 sll r2,r2,0x10                |r2 = r2 * 1024
0007cd84: 00022403 sra r4,r2,0x10                |r4 = X mod (upper register cleanup)
0007cd88: 00910018 mult r4,r17                   |X mod * -3/7 * 2^32
0007cd8c: 96060004 lhu r6,0x0004(r16)            |r6 =  Y Mod (Y Coord * 28 + Y preset)
0007cd90: 00001810 mfhi r3                       |r3 = X mod * -3/7
0007cd94: 00063400 sll r6,r6,0x10                |r6 = r6 *1024
0007cd98: 00062c03 sra r5,r6,0x10                |r5 = Y mod (upper register cleanup)
0007cd9c: 00b10018 mult r5,r17                   |Y Mod * -3 / 7 * 2^32
0007cda0: 000217c3 sra r2,r2,0x1f                |r2 = 0x00
0007cda4: 000637c3 sra r6,r6,0x1f                |r6 = 0x00
0007cda8: 00641821 addu r3,r3,r4                 |r3 = X Mod * 4 / 7
0007cdac: 00031903 sra r3,r3,0x04                |r3 = X Mod / 28 = X coord
0007cdb0: 00621823 subu r3,r3,r2                 |r3 = X coord - 0x00
0007cdb4: 000310c0 sll r2,r3,0x03                |r2 = X Coord * 8
0007cdb8: 00431023 subu r2,r2,r3                 |r2 = X Coord * 7
0007cdbc: 00021080 sll r2,r2,0x02                |r2 = X Coord * 28
0007cdc0: 00822023 subu r4,r4,r2                 |r4 = X preset value
0007cdc4: 00042400 sll r4,r4,0x10                |r4 = r4 * 1024
0007cdc8: 00043c03 sra r7,r4,0x10                |r7 = X preset value (upper register cleanup)
0007cdcc: 00001010 mfhi r2                       |r2 = Y Mod * -3/7
0007cdd0: 00451021 addu r2,r2,r5                 |r2 = Y Mod *4/7
0007cdd4: 00021103 sra r2,r2,0x04                |r2 = Y Mod / 28 = Y Coord
0007cdd8: 00461023 subu r2,r2,r6                 |r2 = Y Coord  - 0x00
0007cddc: 000218c0 sll r3,r2,0x03                |r3 = Y Coord * 8
0007cde0: 00621823 subu r3,r3,r2                 |r3 = Y Coord * 7
0007cde4: 00031880 sll r3,r3,0x02                |r3 = Y Coord * 28
0007cde8: 00a32823 subu r5,r5,r3                 |r5 = Y preset
0007cdec: 00052c00 sll r5,r5,0x10                |r5 = Y preset * 1024
0007cdf0: 00052c03 sra r5,r5,0x10                |r5 = Y preset (upper registery clean up)
0007cdf4: 3402001c ori r2,r0,0x001c              |r2 = 28
0007cdf8: 00452023 subu r4,r2,r5                 |r4 = 28 - Y preset
0007cdfc: 00e4102a slt r2,r7,r4                  |r2 = 0x01 if X preset < (28-Y preset)
0007ce00: 14400004 bne r2,r0,0x0007ce14          #If  X preset >= (28-Y preset)
0007ce04: 00000000 nop                               | 
0007ce08: 00071040 sll r2,r7,0x01                    |r2 = X preset * 2
0007ce0c: 0801f3ea j 0x0007cfa8                      >>Jump to  [(Preset/28) * (12 * Halves)] section with X preset
0007ce10: 00471021 addu r2,r2,r7                     |r2 = X preset * 3
0007ce14: 00051040 sll r2,r5,0x01                |r2 = Y preset*2
0007ce18: 0801f3d7 j 0x0007cf5c                  >>Jump to [(1-preset/28) * (12*Halves)] section with  Y preset
0007ce1c: 00451021 addu r2,r2,r5                 |r2 = Y preset*3

                                            --- Slope Type = 0x69   Section---
0007ce20: 96020000 lhu r2,0x0000(r16)            |r2 = X Mod (X Coord*28 + X Preset)
0007ce24: 00000000 nop                           |
0007ce28: 00021400 sll r2,r2,0x10                |r2 = r2 * 1024
0007ce2c: 00022403 sra r4,r2,0x10                |r4 = X mod (upper register cleanup)
0007ce30: 00910018 mult r4,r17                   |X mod * -3/7 * 2^32
0007ce34: 96060004 lhu r6,0x0004(r16)            |r6 =  Y Mod (Y Coord * 28 + Y preset)
0007ce38: 00000000 nop                           |
0007ce3c: 00063400 sll r6,r6,0x10                |r6 = r6 *1024
0007ce40: 00062c03 sra r5,r6,0x10                |r5 = Y mod (upper register cleanup)
0007ce44: 00001810 mfhi r3                       |r3 = X mod * -3/7
0007ce48: 000217c3 sra r2,r2,0x1f                |r2 = 0x00
0007ce4c: 000637c3 sra r6,r6,0x1f                |r6 = 0x00
0007ce50: 00b10018 mult r5,r17                   |Y Mod * -3 / 7 * 2^32
0007ce54: 00641821 addu r3,r3,r4                 |r3 = X Mod * 4 / 7
0007ce58: 00031903 sra r3,r3,0x04                |r3 = X Mod / 28 = X coord
0007ce5c: 00621823 subu r3,r3,r2                 |r3 = X coord - 0x00
0007ce60: 000310c0 sll r2,r3,0x03                |r2 = X Coord * 8
0007ce64: 00431023 subu r2,r2,r3                 |r2 = X Coord * 7
0007ce68: 00021080 sll r2,r2,0x02                |r2 = X Coord * 28
0007ce6c: 00822023 subu r4,r4,r2                 |r4 = X preset value
0007ce70: 00042400 sll r4,r4,0x10                |r4 = r4 * 1024
0007ce74: 00044403 sra r8,r4,0x10                |r8 = X preset value (upper register cleanup)
0007ce78: 3404001c ori r4,r0,0x001c              |r4 = 28
0007ce7c: 00883823 subu r7,r4,r8                 |r7 = 28 - X preset
0007ce80: 00001010 mfhi r2                       |r2 = Y Mod * -3/7
0007ce84: 00451021 addu r2,r2,r5                 |r2 = Y Mod *4/7
0007ce88: 00021103 sra r2,r2,0x04                |r2 = Y Mod / 28 = Y Coord
0007ce8c: 00461023 subu r2,r2,r6                 |r2 = Y Coord  - 0x00
0007ce90: 000218c0 sll r3,r2,0x03                |r3 = Y Coord * 8
0007ce94: 00621823 subu r3,r3,r2                 |r3 = Y Coord * 7
0007ce98: 00031880 sll r3,r3,0x02                |r3 = Y Coord * 28
0007ce9c: 00a32823 subu r5,r5,r3                 |r5 = Y preset
0007cea0: 00052c00 sll r5,r5,0x10                |r5 = Y preset * 1024 r2 = 28
0007cea4: 00052c03 sra r5,r5,0x10                |r5 = Y preset (upper registery clean up)
0007cea8: 00852023 subu r4,r4,r5                 |r4 = 28 - Y preset r2 = 0x01 if X preset < (28-Y preset)
0007ceac: 00e4102a slt r2,r7,r4                  |r2 = 0x01 if (28-X preset) <  (28-Y preset)
0007ceb0: 10400028 beq r2,r0,0x0007cf54          #If (28-Y preset) > (28-X preset) /Else branch to [(1-preset/28) * (12*Halves)] section with  X preset
0007ceb4: 00051040 sll r2,r5,0x01                    |r2 = Y preset * 2
0007ceb8: 0801f3d7 j 0x0007cf5c                      >>Jump to [(1-preset/28) * (12*Halves)] section with  Y preset
0007cebc: 00451021 addu r2,r2,r5                     |r2 = Y preset * 3

                                            --- Slope Type = 0x99   Section---
0007cec0: 96020000 lhu r2,0x0000(r16)            |r2 = X Mod (X Coord*28 + X Preset)
0007cec4: 00000000 nop                           |
0007cec8: 00021400 sll r2,r2,0x10                |r2 = r2 * 1024
0007cecc: 00022403 sra r4,r2,0x10                |r4 = X mod (upper register cleanup)
0007ced0: 00910018 mult r4,r17                   |X mod * -3/7 * 2^32
0007ced4: 96060004 lhu r6,0x0004(r16)            |r6 =  Y Mod (Y Coord * 28 + Y preset)
0007ced8: 00000000 nop                           |
0007cedc: 00063400 sll r6,r6,0x10                |r6 = r6 *1024
0007cee0: 00062c03 sra r5,r6,0x10                |r5 = Y mod (upper register cleanup)
0007cee4: 00001810 mfhi r3                       |r3 = X mod * -3/7
0007cee8: 000217c3 sra r2,r2,0x1f                |r2 = 0x00
0007ceec: 000637c3 sra r6,r6,0x1f                |r6 = 0x00
0007cef0: 00b10018 mult r5,r17                   |Y Mod * -3 / 7 * 2^32
0007cef4: 00641821 addu r3,r3,r4                 |r3 = X Mod * 4 / 7
0007cef8: 00031903 sra r3,r3,0x04                |r3 = X Mod / 28 = X coord
0007cefc: 00621823 subu r3,r3,r2                 |r3 = X coord - 0x00
0007cf00: 000310c0 sll r2,r3,0x03                |r2 = X Coord * 8
0007cf04: 00431023 subu r2,r2,r3                 |r2 = X Coord * 7
0007cf08: 00021080 sll r2,r2,0x02                |r2 = X Coord * 28
0007cf0c: 00822023 subu r4,r4,r2                 |r4 = X preset value
0007cf10: 00042400 sll r4,r4,0x10                |r4 = r4 * 1024
0007cf14: 00044403 sra r8,r4,0x10                |r8 = X preset value (upper register cleanup)
0007cf18: 3402001c ori r2,r0,0x001c              |r2 = 28
0007cf1c: 00483823 subu r7,r2,r8                 |r7 = 28 - X preset
0007cf20: 00001010 mfhi r2                       |r2 = Y Mod * -3/7
0007cf24: 00451021 addu r2,r2,r5                 |r2 = Y Mod *4/7
0007cf28: 00021103 sra r2,r2,0x04                |r2 = Y Mod / 28 = Y Coord
0007cf2c: 00461023 subu r2,r2,r6                 |r2 = Y Coord  - 0x00
0007cf30: 000218c0 sll r3,r2,0x03                |r3 = Y Coord * 8
0007cf34: 00621823 subu r3,r3,r2                 |r3 = Y Coord * 7
0007cf38: 00031880 sll r3,r3,0x02                |r3 = Y Coord * 28
0007cf3c: 00a32823 subu r5,r5,r3                 |r5 = Y preset
0007cf40: 00052c00 sll r5,r5,0x10                |r5 = Y preset * 1024
0007cf44: 00052403 sra r4,r5,0x10                |r4 = Y preset (upper registery clean up)
0007cf48: 00e4102a slt r2,r7,r4                  |r2 = 0x01 if  (28-X preset)<Y preset
0007cf4c: 14400015 bne r2,r0,0x0007cfa4          #If (28-X preset) >= Y preset
0007cf50: 00041040 sll r2,r4,0x01                |r2 = Y preset * 2

                                            ---- [(1-preset/28) * (12*Halves)] section ----
0007cf54: 00081040 sll r2,r8,0x01                    |r2 = Preset * 2 (could be X or Y - depending of jumping location)
0007cf58: 00481021 addu r2,r2,r8                     |r2 = Preset * 3
0007cf5c: 00021080 sll r2,r2,0x02                    |r2 = Preset * 12
0007cf60: 00490018 mult r2,r9                        |Preset * 12 * Halves
0007cf64: 00002012 mflo r4                           |r4 = Preset*12*Halves
0007cf68: 00000000 nop                               |
0007cf6c: 00000000 nop                               |
0007cf70: 00910018 mult r4,r17                       |r4 = Preset*12*Halves * -3/7 * 2^32
0007cf74: 00091840 sll r3,r9,0x01                    |r3 = Halves * 2
0007cf78: 00691821 addu r3,r3,r9                     |r3 = Halves * 3
0007cf7c: 00031880 sll r3,r3,0x02                    |r3 = Halves * 12
0007cf80: 00001010 mfhi r2                           |r2 = Preset * 12 * Halves * -3/7
0007cf84: 00441021 addu r2,r2,r4                     |r2 = Preset * 12 * Halves * 4/7
0007cf88: 00021103 sra r2,r2,0x04                    |r2 = Preset * 12 * Halves /28
0007cf8c: 000427c3 sra r4,r4,0x1f                    |r4 = 0x00
0007cf90: 00441023 subu r2,r2,r4                     |r2 = Preset * 12 * Halves /28 = halve*6
0007cf94: 00621823 subu r3,r3,r2                     |r3 = (Halves * 12)- (Halve*12*preset)/28 = (1-preset/28)*12*Halves
0007cf98: 0801f3f6 j 0x0007cfd8                      >>Jump to almost end (clear return register)
0007cf9c: 01432023 subu r4,r10,r3                    |r4 = Final Height = -(height*12 + (1-preset/28)*12*Halves)

                                            ---- [(preset/28) * (12*Halves)] section ----
0007cfa0: 00041040 sll r2,r4,0x01                |r2 = preset * 2
0007cfa4: 00441021 addu r2,r2,r4                 |r2 = preset * 3
0007cfa8: 00021080 sll r2,r2,0x02                |r2 = preset * 12
0007cfac: 00490018 mult r2,r9                    |preset * 12 * Halves
0007cfb0: 00001812 mflo r3                       |r3 = preset * 12 * Halves
0007cfb4: 00000000 nop                           |
0007cfb8: 00000000 nop                           |
0007cfbc: 00710018 mult r3,r17                   |(Slope mod* 12 * Halves) * (-3 / 7)*2^32
0007cfc0: 00001010 mfhi r2                       |r2 = (preset* 12 * Halves) * -3/7
0007cfc4: 00431021 addu r2,r2,r3                 |r2 = (Preset* 12 * Halves) * -3/7
0007cfc8: 00021103 sra r2,r2,0x04                |r2 = (Preset* 12 * Halves) /28
0007cfcc: 00031fc3 sra r3,r3,0x1f                |r3 = 0x00
0007cfd0: 00431023 subu r2,r2,r3                 |r2 = Halves * 12 * Preset/28 = Halves*6 when preset = 14
0007cfd4: 01422023 subu r4,r10,r2                |r4 = final height = -(height*12 + halves*12*preset/28) 
0007cfd8: 00041400 sll r2,r4,0x10                |
0007cfdc: 00021403 sra r2,r2,0x10                |r2 = final height with clean register
0007cfe0: 8fbf0020 lw r31,0x0020(r29)            |
0007cfe4: 8fb1001c lw r17,0x001c(r29)            |
0007cfe8: 8fb00018 lw r16,0x0018(r29)            |
0007cfec: 27bd0028 addiu r29,r29,0x0028          |
0007cff0: 03e00008 jr r31                   END
0007cff4: 00000000 nop

Notes


For notes below, (preset X)/28 will be refered as X and (preset Y/28) as Y. (1-preset/28) will be refered as anti-preset
So X, Y, Anti-X, Anti-Y (...)

Here is the details per slope type
 0x11 : X or Anti-Y (smallest value)
 0x14 : Anti-X or Anti-Y (smallest value)
 0x25 : Anti-Y (always)
 0x41 : X or Y (smallest value)
 0x44 : Anti-X or Y (smallest value)
 0x52 : X (always)
 0x58 : Anti-X (always)
 0x66 : X or Anti-Y (greatest value)
 0x69 : Anti-X or Anti-Y (greatest value)
 0x85 : Y (always)
 0x96 : X or Y (greatest value)
 0x99 : Anti-X or Y (greatest value)

Return locations

Battle.bin
0007d150: Complex_Height_Data_from_unit_misc_data_and_coordinates - When call by 0007d51c_-_0007d5cc X preset = Y preset = 14
0007d988: 0007d5d0_-_0007db18
00089144: 000890b8_-_00089248
00089a90: 000898a0_-_00089b9c
00089c9c: 00089ba0_-_00089d9c
0008a03c: 00089f24_-_0008a114
0008cb40: 0008ca7c_-_0008cbb0