private List <UInt32> writeSubroutineMakeNoneMapIconsInvisible(AddressMapper addressMapper, VAVAddr entryAddr, VAVAddr returnContinueAddr, VAVAddr returnMakeInvisibleAddr) { var Scene_Layout_Obj_SetVisible = addressMapper.toVersionAgnosticAddress((BSVAddr)0x8006f854); // precondition: r31 MapIconButton* // r5 is unused // postcondition: r0 is map icon type // r5 is 0 var asm = new List <UInt32>(); asm.Add(PowerPcAsm.lwz(5, 0x188, 31)); // get current map id into r5 asm.Add(PowerPcAsm.cmpwi(5, -1)); // map id == -1 ? asm.Add(PowerPcAsm.bne(8)); // { asm.Add(PowerPcAsm.lwz(3, 0x28, 31)); // \ asm.Add(PowerPcAsm.li(5, 0)); // | asm.Add(PowerPcAsm.lwz(4, -0x6600, 13)); // | make "NEW" text invisible asm.Add(PowerPcAsm.bl(entryAddr, asm.Count, Scene_Layout_Obj_SetVisible)); // / asm.Add(PowerPcAsm.lwz(3, 0x28, 31)); // \ asm.Add(PowerPcAsm.li(5, 0)); // / make Locked Map Icon "(?)" invisible asm.Add(PowerPcAsm.b(entryAddr, asm.Count, returnMakeInvisibleAddr)); // returnMakeInvisibleAddr // } else { asm.Add(PowerPcAsm.lwz(0, 0x184, 3)); // get map icon type (replaced opcode) asm.Add(PowerPcAsm.b(entryAddr, asm.Count, returnContinueAddr)); // returnContinueAddr // } return(asm); }
private List <UInt32> writeSubroutineGetMapsInZone(AddressMapper addressMapper, List <MapDescriptor> mapDescriptors, VAVAddr mapSetZoneOrderTable, VAVAddr entryAddr, VAVAddr returnAddr) { PowerPcAsm.Pair16Bit v = PowerPcAsm.make16bitValuePair((UInt32)mapSetZoneOrderTable); // precondition: r5 MapSet // r29 _ZONE_TYPE // r30 int* array containing map ids // r3,r4,r6,r7,r31 unused // postcondition: r3 num maps (must be same as in SubroutineGetNumMapsInZone) var asm = new List <UInt32>(); var asm_l2 = new List <UInt32>(); var asm_l3 = new List <UInt32>(); asm.Add(PowerPcAsm.li(3, 0)); var mapSets = (from m in mapDescriptors where m.MapSet != -1 orderby m.MapSet select m.MapSet).Distinct(); foreach (var mapSet in mapSets) { asm.Add(PowerPcAsm.cmpwi(5, mapSet)); var zones = (from m in mapDescriptors where m.MapSet == mapSet && m.Zone != -1 orderby m.Zone select m.Zone).Distinct(); asm_l2.Clear(); foreach (var zone in zones) { asm_l2.Add(PowerPcAsm.cmpwi(29, zone)); IOrderedEnumerable <MapDescriptor> maps; if (zone == 0) { maps = from m in mapDescriptors where m.MapSet == mapSet && m.Zone == 1 orderby m.Order select m; } else if (zone == 1) { maps = from m in mapDescriptors where m.MapSet == mapSet && m.Zone == 0 orderby m.Order select m; } else { maps = from m in mapDescriptors where m.MapSet == mapSet && m.Zone == zone orderby m.Order select m; } short i = 0; asm_l3.Clear(); asm_l3.Add(PowerPcAsm.li(3, (short)maps.Count())); foreach (var map in maps) { short mapId = (short)mapDescriptors.IndexOf(map); var mapDescriptor = mapDescriptors[i]; asm_l3.Add(PowerPcAsm.li(4, mapId)); asm_l3.Add(PowerPcAsm.stw(4, i, 30)); i += 4; } asm_l2.Add(PowerPcAsm.bne(asm_l3.Count + 1)); asm_l2.AddRange(asm_l3); } asm.Add(PowerPcAsm.bne(asm_l2.Count + 1)); asm.AddRange(asm_l2); } asm.Add(PowerPcAsm.b(entryAddr, asm.Count, returnAddr)); return(asm); }
private List <UInt32> writeSubroutineGetNumMapsInZone(List <MapDescriptor> mapDescriptors) { // precondition: r3 _ZONE_TYPE // postcondition: r3 num maps var asm = new List <UInt32>(); for (short i = 0; i < 6; i++) { asm.Add(PowerPcAsm.cmpwi(3, i)); asm.Add(PowerPcAsm.bne(3)); asm.Add(PowerPcAsm.li(3, (short)(from m in mapDescriptors where m.Zone == i && m.MapSet == 0 select m).Count())); asm.Add(PowerPcAsm.blr()); } asm.Add(PowerPcAsm.blr()); return(asm); }
private List <UInt32> writeGetDescriptionForCustomSquareRoutine(AddressMapper addressMapper, VAVAddr routineStartAddress) { var asm = new List <UInt32>(); var gameUiTextGetString = addressMapper.toVersionAgnosticAddress((BSVAddr)0x800f78dc); var gameUiTextGetCardMsg = addressMapper.toVersionAgnosticAddress((BSVAddr)0x800f837c); var gameBoard = PowerPcAsm.make16bitValuePair((UInt32)addressMapper.toVersionAgnosticAddress((BSVAddr)0x8054d018)); asm.Add(PowerPcAsm.lis(7, gameBoard.upper16Bit)); // asm.Add(PowerPcAsm.addi(7, 7, gameBoard.lower16Bit)); // r7 <- start of gameboard table containing all squares asm.Add(PowerPcAsm.mulli(8, 24, 0x54)); // r8 <- squareId * 0x54 (the size of each square) asm.Add(PowerPcAsm.add(6, 7, 8)); // r6 <- the current square asm.Add(PowerPcAsm.lbz(8, 0x4d, 6)); // r8 <- square.squareType asm.Add(PowerPcAsm.cmpwi(8, 0x2e)); // if(square.squareType == 0x2e) asm.Add(PowerPcAsm.bne(3)); // { asm.Add(PowerPcAsm.lbz(4, 0x18, 6)); // r4 <- square.district_color asm.Add(PowerPcAsm.b(routineStartAddress, asm.Count, gameUiTextGetCardMsg)); // goto Game::uitext::get_card_message(r4) // } asm.Add(PowerPcAsm.li(6, 0x0)); // \ asm.Add(PowerPcAsm.li(7, 0x0)); // | No message arguments asm.Add(PowerPcAsm.li(8, 0x0)); // / asm.Add(PowerPcAsm.b(routineStartAddress, asm.Count, gameUiTextGetString)); // goto Game::uitext::get_string(r4, 0, 0, 0) return(asm); }