コード例 #1
0
        private List <UInt32> writeSubroutineForceFetchFakeVentureCard(VAVAddr fakeVentureCard)
        {
            PowerPcAsm.Pair16Bit v = PowerPcAsm.make16bitValuePair((UInt32)fakeVentureCard);

            // precondition: r3 is ChanceCardUI *
            // ChanceCardUI->field_0x34 is ChanceBoard *
            // ChanceBoard->field_0x158 is current venture card id

            var asm = new List <UInt32>();

            asm.Add(PowerPcAsm.lis(6, v.upper16Bit));      // \
            asm.Add(PowerPcAsm.addi(6, 6, v.lower16Bit));  // / r6 <- forceVentureCardVariable
            asm.Add(PowerPcAsm.lwz(4, 0x0, 6));            // | r4 <- forceVentureCard
            asm.Add(PowerPcAsm.cmpwi(4, 0x0));             // | if(forceVentureCard != 0)
            asm.Add(PowerPcAsm.beq(7));                    // | {
            asm.Add(PowerPcAsm.lwz(5, 0x34, 3));           // |   r5 <- ChanceCardUI.ChanceBoard
            asm.Add(PowerPcAsm.stw(4, 0x158, 5));          // |   ChanceBoard.currentVentureCardId <- r4
            asm.Add(PowerPcAsm.li(5, 0));                  // |\  forceVentureCard <- 0
            asm.Add(PowerPcAsm.stw(5, 0x0, 6));            // |/
            asm.Add(PowerPcAsm.li(8, 0x0));                // |   r8 <- 0 (the venture card is initialized)
            asm.Add(PowerPcAsm.blr());                     // |   return r4 and r8
                                                           // | }
            asm.Add(PowerPcAsm.li(4, -0x1));               // | r4 <- -1
            asm.Add(PowerPcAsm.li(8, 0x3));                // | r8 <- 3 (the venture card is continued to be executed)
            asm.Add(PowerPcAsm.blr());                     // | return r4 and r8


            return(asm);
        }
コード例 #2
0
        private List <UInt32> writeSubroutineSkipMapUnlockCheck(AddressMapper addressMapper, VAVAddr entryAddr, VAVAddr returnContinueAddr, VAVAddr returnSkipMapUnlockedCheck)
        {
            // precondition:  r26  is mapid
            //                 r3  is unused
            // postcondition:  r3  is mapid
            var asm = new List <UInt32>();

            asm.Add(PowerPcAsm.or(3, 26, 26));                                         // r3 <- mapid
            asm.Add(PowerPcAsm.cmpwi(3, -1));                                          // mapid == -1 ?
            asm.Add(PowerPcAsm.beq(entryAddr, asm.Count, returnSkipMapUnlockedCheck)); //   goto skipMapUnlockedCheck
            asm.Add(PowerPcAsm.b(entryAddr, asm.Count, returnContinueAddr));           // else goto returnContinueAddr
            return(asm);
        }
コード例 #3
0
        private List <UInt32> writeGetTextureForCustomSquareRoutine(byte register_textureType, byte register_squareType)
        {
            var asm = new List <UInt32>();

            asm.Add(PowerPcAsm.li(register_textureType, 0x1));    // textureType = 1
            asm.Add(PowerPcAsm.cmpwi(register_squareType, 0x2e)); // if(squareType == 0x2e)
            asm.Add(PowerPcAsm.beq(2));                           // {
            asm.Add(PowerPcAsm.blr());                            //   return textureType;
                                                                  // } else {
            asm.Add(PowerPcAsm.li(register_textureType, 0x5));    //   textureType = 5
            asm.Add(PowerPcAsm.blr());                            //   return textureType;
                                                                  // }
            return(asm);
        }
コード例 #4
0
        private List <UInt32> writeUploadSimulatedButtonPress(AddressMapper addressMapper, VAVAddr routineStartAddress, VAVAddr returnAddr)
        {
            var asm = new List <UInt32>();
            // 0x804363b4 (4 bytes): force simulated button press
            var forceSimulatedButtonPress = PowerPcAsm.make16bitValuePair((UInt32)addressMapper.toVersionAgnosticAddress((BSVAddr)0x804363b4));
            var pressedButtonsBitArray    = PowerPcAsm.make16bitValuePair((UInt32)addressMapper.toVersionAgnosticAddress((BSVAddr)0x8078C880));

            asm.Add(PowerPcAsm.lis(6, forceSimulatedButtonPress.upper16Bit));                // \
            asm.Add(PowerPcAsm.addi(6, 6, forceSimulatedButtonPress.lower16Bit));            // / r6 <- &forceSimulatedButtonPress
            asm.Add(PowerPcAsm.lis(7, pressedButtonsBitArray.upper16Bit));                   // \
            asm.Add(PowerPcAsm.addi(7, 7, pressedButtonsBitArray.lower16Bit));               // / r7 <- &pressedButtonsBitArray
            asm.Add(PowerPcAsm.lwz(0, 0x0, 6));                                              // r0 <- forceSimulatedButtonPress
            asm.Add(PowerPcAsm.cmpwi(0, 0x0));                                               // if (forceSimulatedButtonPress != 0)
            asm.Add(PowerPcAsm.beq(4));                                                      // {
            asm.Add(PowerPcAsm.stw(0, 0x0, 7));                                              //   pressedButtonsBitArray <- forceSimulatedButtonPress
            asm.Add(PowerPcAsm.li(0, 0x0));                                                  //   \ 
            asm.Add(PowerPcAsm.stw(0, 0x0, 6));                                              //   / forceSimulatedButtonPress <- 0
                                                                                             // }
            asm.Add(PowerPcAsm.lwz(0, 0x4, 3));                                              // *replaced opcode*
            asm.Add(PowerPcAsm.b(routineStartAddress, asm.Count, returnAddr));               // return

            return(asm);
        }