Display Simple Selection Menu

From Final Fantasy Hacktics Wiki
Revision as of 04:45, 24 April 2024 by Talcall (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#   ROUTINE: DISPLAY SIMPLE SELECTION MENU
#   This routine displays the simple selection menu that contains only one column per row and shows "Menu" in the top left.
#   No parameters.

80138ed8: 27bdfec8 addiu r29,r29,-0x0138
80138edc: afbf0130 sw r31,0x0130(r29)
80138ee0: afb5012c sw r21,0x012c(r29)
80138ee4: afb40128 sw r20,0x0128(r29)
80138ee8: afb30124 sw r19,0x0124(r29)
80138eec: afb20120 sw r18,0x0120(r29)
80138ef0: afb1011c sw r17,0x011c(r29)
80138ef4: 0c0532f0 jal 0x8014cbc0               #   result1 = Get First Thread Parameter ();
80138ef8: afb00118 sw r16,0x0118(r29)
80138efc: 00408821 addu r17,r2,r0               #   result1
80138f00: 27b00018 addiu r16,r29,0x0018         #   stack.0x18
80138f04: 86230038 lh r3,0x0038(r17)            #   Selected row index (result1.0x38)
80138f08: 2402ffff addiu r2,r0,-0x0001          #   -1
80138f0c: 14620002 bne r3,r2,0x80138f18        
80138f10: afa30110 sw r3,0x0110(r29)            #   stack.0x110 = Selected row index
                                                #   if (Selected row index == -1)
80138f14: afa00110 sw r0,0x0110(r29)            #       stack.0x110 = 0 
80138f18: 27a40010 addiu r4,r29,0x0010          #   stack.0x10    
80138f1c: 02202821 addu r5,r17,r0               #   result1 (display info?)
80138f20: 0c04e05d jal 0x80138174               #   ? 0x138174 (stack.0x10, result1, stack.0x18);               // Calls image loading setup routine (0x14a834) multiple times... 
                                                #                                                                   //     maybe shows the menu background?
80138f24: 02003021 addu r6,r16,r0               #   stack.0x18
80138f28: 27a40094 addiu r4,r29,0x0094          #   stack.0x94
80138f2c: 02002821 addu r5,r16,r0               #   stack.0x18
80138f30: 0c052fd5 jal 0x8014bf54               #   ? 0x14bf54 (stack.0x94, stack.0x18, 0x7c);
80138f34: 3406007c ori r6,r0,0x007c             #   0x7c
80138f38: 27a60010 addiu r6,r29,0x0010          #   stack.0x10
80138f3c: 34070001 ori r7,r0,0x0001             #   1
80138f40: 00009021 addu r18,r0,r0               #   count = 0
80138f44: 0200a821 addu r21,r16,r0              #   stack.0x18
80138f48: 86240004 lh r4,0x0004(r17)            #   Inner window width (result1.0x4)
80138f4c: 86250006 lh r5,0x0006(r17)            #   Inner window height (result1.0x6)
80138f50: 0c05312a jal 0x8014c4a8               #   result2 = ? 0x14c4a8 (Inner window width, Inner window height, stack.0x10, 1);
80138f54: 34140002 ori r20,r0,0x0002            #   2
80138f58: 34040008 ori r4,r0,0x0008             #   8
80138f5c: 34050009 ori r5,r0,0x0009             #   9
80138f60: 3c108016 lui r16,0x8016
80138f64: 26105fa8 addiu r16,r16,0x5fa8         #   0x80165fa8
80138f68: 86230004 lh r3,0x0004(r17)            #   Inner window width
80138f6c: 00409821 addu r19,r2,r0               #   result2 (behvaior info?)
80138f70: 0c0529b3 jal 0x8014a6cc               #   ? 0x14a6cc (8, 9); <-- sets inner window buffer size
80138f74: ae030000 sw r3,0x0000(r16)            #   *0x80165fa8 = Inner window width
80138f78: 02602821 addu r5,r19,r0               #   result2
80138f7c: 8624001c lh r4,0x001c(r17)            #   Menu text entry to display for entire menu text (result1.0x1c)
80138f80: 3c018016 lui r1,0x8016
80138f84: ac205f8c sw r0,0x5f8c(r1)             #   *0x80165f8c
80138f88: 0c052cbc jal 0x8014b2f0               #   Display Menu Text Entry (Menu text entry, result2, 0x80165fa0);
80138f8c: 2606fff8 addiu r6,r16,-0x0008         #   0x80165fa0
80138f90: 27a40010 addiu r4,r29,0x0010          #   stack.0x10
80138f94: 0c00923f jal 0x800248fc               #   SYS LoadImage (RECT *Recp, ulong *p); transfer image data
80138f98: 02602821 addu r5,r19,r0               #   result2
                                                #   // This loop continues iterating as long as the menu is open, and exits when an option is selected or the menu is closed.
                                                #   while (true) { 
80138f9c: 0c0532a0 jal 0x8014ca80               #       Switch To Next Thread ();               // Bringing up menu causes hard lock if removed
80138fa0: 00000000 nop
80138fa4: 16400004 bne r18,r0,0x80138fb8        
80138fa8: 32420001 andi r2,r18,0x0001           #       count % 2
                                                #       if (count == 0) {
80138fac: 0c04bc13 jal 0x8012f04c               #           ? 0x12f04c (result2);       // Select button soft locks if removed - dims menu, but nothing happens
80138fb0: 02602021 addu r4,r19,r0               #           result2
80138fb4: 32420001 andi r2,r18,0x0001           #           count % 2
                                                #       }
80138fb8: 00021940 sll r3,r2,0x05               #       (count % 2) * 32
80138fbc: 00621823 subu r3,r3,r2                #       (count % 2) * 31
80138fc0: 00031880 sll r3,r3,0x02               #       (count % 2) * 124
80138fc4: 02a38021 addu r16,r21,r3              #       stack.0x18 + ((count % 2) * 124)    // Palette related?
80138fc8: 97a20110 lhu r2,0x0110(r29)           #       stack.0x110
80138fcc: 02002021 addu r4,r16,r0               #       stack.0x18 + ((count % 2) * 124)
80138fd0: 0c04e118 jal 0x80138460               #       ? 0x138460 (stack.0x18 + ((count % 2) * 124));                                  // Menu colors messed up if removed
80138fd4: a6220038 sh r2,0x0038(r17)            #       result1.0x38 = stack.0x110
80138fd8: 02202021 addu r4,r17,r0               #       result1
80138fdc: 02002821 addu r5,r16,r0               #       stack.0x18 + ((count % 2) * 124)
80138fe0: 8fa70110 lw r7,0x0110(r29)            #       stack.0x110
80138fe4: 0c04e15c jal 0x80138570               #       ? 0x138570 (result1, stack.0x18 + ((count % 2) * 124), count, stack.0x110);     // Cursor doesn't display if removed
80138fe8: 02403021 addu r6,r18,r0               #       count
80138fec: 8fa30090 lw r3,0x0090(r29)            #       stack.0x90
80138ff0: 00000000 nop
80138ff4: 14600005 bne r3,r0,0x8013900c         #       if ((
80138ff8: 00000000 nop                          #               (stack.0x90 == 0)
80138ffc: 8fa2010c lw r2,0x010c(r29)            #               stack.0x10c
80139000: 00000000 nop
80139004: 10540007 beq r2,r20,0x80139024        #               AND (stack.0x10c == 2))
80139008: 00000000 nop
8013900c: 14740007 bne r3,r20,0x8013902c        #           OR ((stack.0x90 == 2)
80139010: 00000000 nop
80139014: 8fa2010c lw r2,0x010c(r29)            #               stack.0x10c
80139018: 00000000 nop
8013901c: 14400003 bne r2,r0,0x8013902c         #               AND (stack.0x10c == 0))) {
80139020: 00000000 nop
80139024: afa00090 sw r0,0x0090(r29)            #                   stack.0x90 = 0
80139028: afa0010c sw r0,0x010c(r29)            #                   stack.0x10c = 0
                                                #               }
8013902c: 3c048017 lui r4,0x8017
80139030: 248497d0 addiu r4,r4,-0x6830          #       0x801697d0
80139034: 0c04e025 jal 0x80138094               #       result = ? 0x138094 (0x801697d0);                       // Checks if menu was closed? Either by selecting an option that closes 
                                                #                                                                   //     the window, or menu was cancelled
80139038: 00000000 nop
8013903c: 1440000d bne r2,r0,0x80139074         #       if (result != 0), break                                     // Exits the loop if so...
80139040: 02202021 addu r4,r17,r0               #       result1
80139044: 8fa50110 lw r5,0x0110(r29)            #       stack.0x110
80139048: 0c04df04 jal 0x80137c10               #       Handle Menu Action (result1, stack.0x110);              // Circle button action doesn't work if removed
8013904c: 26520001 addiu r18,r18,0x0001         #       count = count + 1
80139050: 02202021 addu r4,r17,r0               #       result1
80139054: 0c04dfb5 jal 0x80137ed4               #       ? 0x137ed4 (result1, stack.0x110);                      // Can't change selection if removed (Up and Down buttons don't do anything)
80139058: 27a50110 addiu r5,r29,0x0110          #       stack.0x110
8013905c: 0c04dfe1 jal 0x80137f84               #       ? 0x137f84 (result1);                                   // Can't cancel out of menu if removed (X button doesn't work)
80139060: 02202021 addu r4,r17,r0               #       result1
80139064: 0c04e2c4 jal 0x80138b10               #       ? 0x138b10 (stack.0x18 + ((count % 2) * 124));          // Menu doesn't display if removed, but is still functional
80139068: 02002021 addu r4,r16,r0               #       stack.0x18 + ((count % 2) * 124)    
8013906c: 0804e3e7 j 0x80138f9c                 #   }
80139070: 00000000 nop

80139074: 0c0532a0 jal 0x8014ca80               #   Switch To Next Thread ();
80139078: 00000000 nop
8013907c: 0c0532fd jal 0x8014cbf4               #   result = Get Second Thread Parameter ();
80139080: 00000000 nop
80139084: 14400003 bne r2,r0,0x80139094         #   if (result == 0) {
80139088: 00000000 nop
8013908c: 0c053256 jal 0x8014c958               #       Stop Current Thread ();
80139090: 00000000 nop                          #   }
80139094: 8fbf0130 lw r31,0x0130(r29)
80139098: 8fb5012c lw r21,0x012c(r29)
8013909c: 8fb40128 lw r20,0x0128(r29)
801390a0: 8fb30124 lw r19,0x0124(r29)
801390a4: 8fb20120 lw r18,0x0120(r29)
801390a8: 8fb1011c lw r17,0x011c(r29)
801390ac: 8fb00118 lw r16,0x0118(r29)
801390b0: 27bd0138 addiu r29,r29,0x0138
801390b4: 03e00008 jr r31
801390b8: 00000000 nop