Code:
47060C <>ShopScene (2k3: 492C98)
47084C <>CreateBuyWindow (lists items for purchase) (2k3: 492EE4)
47084C = width
470851 = height
470856 = slide open (0|1 = no|yes)
470858 = y-Pos [B1 ..] saves 3 bytes
47085D = x-Pos Default = 0 //set manually: [BA .. .. .. ..] needed
47085F call sub_493C30 call CreateWindow
470868 <>OpenBuyWindow (2k3: 492F00)
47086F call sub_4946DC call CreateCursor
47087F call sub_41EB70 get more items into the list(?)
470889 call sub_493D80 call RefreshWindow (clear Window's contents)
470890 <>LoadShownItems (for BuyWindow) (2k3: 492F28)
4708A6 mov get current ListPosition
4708B7 mov edi,[ebx+64] get Ptr on ItemList
4708BA cmp esi,[edi+8] Is the ListPosition still within the ItemList's size?
4708BD jge jump if all Items were listed
4708C3 mov edx,esi get current ListPosition
4708C5 mov eax,edi get Ptr on ItemList
4708C7 call sub_40F72C call LoadFromList(?)
4708CC mov esi,eax memorize Item_ID
4708CE (49AA34 = ItemParamPtr)
4708D5 mov edx,esi get Item_ID
4708D7 call sub_4631D0 call GetItemParam
4708DC mov eax,[eax+14] get ItemPrice
** (ItemData)
04 = Item_ID
08 = Item_Name
0C = Explanation (0 if non-existent)
10 = Item_Type (0 = CommonItem | 1 = Weapon | 2 = Shield | ...)
14 = Item_Price
18 = No. of uses (0 = infinite)
1C = Atk
20 = Def
24 = Int
28 = Agi
2C = hands used (0|1 = one|two)
30 = MP Cost
34 = Hit%
38 = Crit%
3C = BattleAnimation_ID
40 = Weapon Options (flags can be combined)
.. .. .. 01 = 1st Attack
.. .. 01 .. = 2x Attack
.. 01 .. .. = Attack All
01 .. .. .. = Ignore Evasion
44 = Armor Options (flags can be combined)
.. .. .. 01 = Prevent Crit
.. .. 01 .. = Increase Evasion
.. 01 .. .. = 1/2 MP Cost
01 .. .. .. = No Terrain DMG
48 = Target Range (0|1 = Ally|Party)
4C = HP Recovery(%)
50 = HP Recovery(Units)
54 = MP Recovery(%)
58 = MP Recovery(Units)
5C = Usability Options (flags can be combined)
.. .. .. 01 = use in menu only
.. .. 01 .. = use on dead heroes only
60 = HP+
64 = MP+
68 = Str+
6C = Def+
70 = Int+
74 = Agi+
78 = SkillScroll's Message (0|1 = ItemName|Skill)
7C = SkillBook's / SkillScroll's (2k3: invoked) Skill_ID
80 = Switch_ID
84 = Usability (flags can be combined)
.. .. .. 01 = on field
.. .. 01 .. = in battle
88 = HeroAmount(?)
8C ?
90 = highest checked/cured Condition_ID
94 = Ptr on Condition_Array
98 = highest checked Attribute_ID
9C = Ptr on Attribute_Array
A0 = Condition Hit%
A4 ?
A8 ?
(2k3)
AC = InvokeSkill_flag
B0 ?
B4 ? Ptr on ???
B8 = ItemCursed_flag
BC = ConditionInfliction_flag
4708EF jl jump if not enough money(?)
4708F8 mov edx,esi get Item_ID
4708FA call sub_47D2A0 GetItemAmount
4708FF cmp eax, 63 Is ItemAmount above/same 99?
470902 jge jump if true (color gray)
470919 mov edx,esi get Item_ID
47091B call sub_4631D0 call GetItemParam
470920 mov eax, [eax+8] get ItemName
470961 add edx, 84h set x-Pos to write the ItemPrice
47099C 3 set 0 no ItemPrice is shown
4709A4 <>AssignItemData (2k3: 49303C)
4709C8 <>CreateSellWindow (2k3: 493060)
4709C8 mov [eax+4], 2 set to 2 columns of Items
4709CF = width
4709D4 = height
4709D9 = slide open (0|1 = no|yes)
4709DB = y-Pos [B1 ..] saves 3 bytes
4709E0 = x-Pos Default = 0 //set manually: [BA .. .. .. ..] needed
4709E2 call sub_493C30 call CreateWindow
4709E8 <>OpenSellWindow (2k3: 493080)
4709EF call sub_4946DC call CreateCursor
470A15 call sub_493D80 call RefreshWindow (clear Window's contents)
470A1C <>LoadItems (SELL Window) (2k3: 4930B4)
470A4D jge jump -> don't print ItemName
470A5C call sub_47D030 get Item
470A61 mov edi,eax memorize Item_ID
470A6C call sub_47D044 get ItemAmount(?)
470A7B mov edx,edi get Item_ID
470A7D call sub_4631D0 call GetItemParam
470A82 cmp [eax+14], 0 is the ItemPrice = 0 ?
470A86 jle jump if ItemPrice = 0 -> set color index to 3
470A98 mov edx,edi get Item_ID
470A9A call sub_4631D0 call GetItemParam
470A9F mov eax, [eax+8] get ItemName
470ADA add edx, 78h set x-Pos of ":No." for ItemQuantity //44h for 3 columns
470B14 5 set 0 no ":No." is shown
470B20 <>ItemOnDesicionKey (2k3: 4931B8)
470B2C jle jump when Item can't be sold
470B3A sub_47D030 get Item(?)
470B44 <>CreateVendingWindow ("How many?") (2k3: 4931DC)
470B47 = width
470B4C = height
470B51 = slide open (0|1 = no|yes)
470B53 = y-Pos [B1 ..] saves 3 bytes
470B58 = x-Pos Deafault = 0 //set manually: [BA .. .. .. ..] needed
470B65 call sub_493C30 call CreateWindow
470B6D = Cursor_x-Pos
470B74 = Cursor_y-Pos
470B7B = Cursor_Width
470B82 = Cursor_ChoicesAmount
470B88 <>VendingWindow (2k3: 493220)
470BA6 call sub_493D80 call RefreshWindow (clear Window's contents)
470BAF jle [E9]jmp -> no Text printed //NOP -> "invalid Item"
470BBB call sub_493F78 call UpdateCursor
470BC7 mov edx,[ebx+64] get Item_ID
470BCA call sub_4631D0 call GetItemParam
470BCF mov eax,[eax+8] get Item_Name
470BD3 = Item_Color
470BD5 = show item (0|1 = no|yes)
470BD7 = y-Pos (item)
470BDC = x-Pos (item)
470BE5 call print ItemName?
470BE8 set " X " in front of chosen quantity
470BED = color of " X "
470BEF = show " X " (0|1 = no|yes)
470BF1 = y-Pos ( X )
470BF6 = x-Pos ( X )
470BFF call print " X "? NOP -> game crashes
470C06 show chosen quantity
470C1A call sub_408AD0 print ItemQuantity(?)
470C23 = ItemAmount_Color
470C25 = show ItemAmount (0|1 = no|yes)
470C27 = y-Pos (ItemAmount)
470C2C = x-Pos (ItemAmount)
470C3C jz [EB]jmp -> jump to BuyPrice calculation(display)
470C3E+ SellPrice calculation(display)
470C49 mov edx,[ebx+64] get Item_ID
470C4C call sub_4631D0 call GetItemParam
470C51 mov eax, [eax+14h] get ItemPrice
470C54 sar eax, 1 halves the price //calculate shown price
470C5B imul multiply [Quantity]x[Price]
470C78 = Money_Color (selling)
470C7A = show money (0|1 = no|yes)
470C7C (49ABDC VocabStringPtr)
470C89 call sub_403D4C get StringLength (to correct x-Pos of the GoldAmount)
470C93 = x-Pos (money)
470C9A sub edx, eax [x-Pos] - [GoldVocab_Length]
470C9D = y-Pos (money)
470CAB+ BuyPrice calculation/display
470CB6 mov edx,[ebx+64] get Item_ID
470CB9 call sub_4631D0 call GetItemParam
470CC1 imul multiply [Quantity]x[Price]
470CDE = Money_Color (buying)
470CE0 = show money (0|1 = no|yes)
470CEF call sub_403D4C get StringLength
470CF9 = Gold x-Pos (money)
470D03 = Gold y-Pos (money)
470D16 get GoldVocab
470D1D = GoldVocab_Color
470D1F = show GoldVocab (0|1 = no|yes)
470D28 get GoldVocab
470D2E call sub_403D4C get StringLength for GoldVocab
470D38 = x-Pos (GoldVocab)
470D3F = y-Pos (GoldVocab)
470D48 call print GoldVocab(?)
470D80 2 set 0 "x " isn't shown behind the ItemAmount
470D84 [78] = "x"
470D8C 3 set 0 doesn't show ItemAmount
470D98 3 set 0 doesn't show total value of the items
470DA0 <>ItemAmountNavigation (Vending) (2k3: 49343C)
470DA6 call sub_494340 call SlideOpenWindow
470DAE (49AA04 = KeyPtr)
470DB5 test Is [right] pressed?
470DBE inc ebx amount +1
470DC6 test Is [left] pressed?
470DCF dec ebx amount -1
470DD7 test Is [up] pressed?
470DE0 add ebx, 0A amount +10
470DEA test Is [down] pressed?
470DF3 sub ebx, 0A amount -10
470DFB call sub_41EB0C ??
470E05 call sub_41EB70 ??
470E18 call sub_46A3B8 get CursorSound
470E26 call sub_46A0A8 call PlaySound
470E32 call print new ItemAmount
470E38 <>VocabStringPool(?) (2k3: 4934D8)
470F04 <>?? (2k3: 4935A4)
470F7C <>?? (2k3: 49361C)
470FD4 <>DrawShopWindows (2k3: 493674)
470FEC (49AA48 = ScreenPtr)
470FF6 call sub_4524F4 ??
470FFB = Seperator_Width
471000 = Seperator_Height
471005 = hide (0|1 = no|yes)
471007 = y-Pos [B1 ..] saves 3 bytes
47100C = x-Pos Default = 0 //set manually: [BA .. .. .. ..] needed
47100E mov eax,[ebx+**] get Ptr on Window (**10 = SeperatorWindow)
471011 call sub_493C30 call CreateWindow
471016 -> 471029 ??ShopMBox(?)
471026 mov eax,[ebx+**] get Ptr on Window (**14 = ShopMenuWindow)
471029 call sub_493C30 call CreateWindow
47102E = InfoWindow_Width
471033 = InfoWindow_Height
471035 = hide (0|1 = no|yes)
471037 = y-Pos Default = 0 //set manually: [B1 ..]
471039 = x-Pos Default = 0 //set manually: [BA .. .. .. ..] needed
47103B mov eax,[ebx+**] get Ptr on Window (**18 = InfoWindow)
47103E call sub_493C30 call CreateWindow
471043 mov eax,[ebx+**] get Ptr on Window (**1C = BuyWindow)
47104C call sub_47084C initialize BuyWindow
471051 mov eax,[ebx+**] get Ptr on Window (**20 = SellWindow)
471054 call sub_4709C8 initialize SellWindow
471059 mov eax,[ebx+**] get Ptr on Window (**24 = VendingWindow)
47105C call sub_470B44 initialize VendingWindow
471061 = PartyWindow_Width
471066 = PartyWindow_Height
471068 = hide (0|1 = no|yes)
47106A = y-Pos
47106F = x-Pos
471074 mov eax,[ebx+**] get Ptr on Window (**28 = PartyWindow)
471077 call sub_493C30 call CreateWindow
47107C = OwnedEquippedWindow_Width
471081 = OwnedEquippedWindow_Height
471083 = hide (0|1 = no|yes)
471085 = y-Pos
47108A = x-Pos
47108F mov eax,[ebx+**] get Ptr on Window (2C = OwnedEquippedWindow)
471092 call sub_493C30 call CreateWindow
471097 = GoldWindow_Width
47109C = GoldWindow_Height
47109E = hide (0|1 = no|yes)
4710A0 = y-Pos
4710A5 = x-Pos
4710AA mov eax,[ebx+**] get Ptr on Window (**30 = GoldWindow)
4710AD call sub_493C30 call CreateWindow
4710B2 = ShopMenu_Width (MBox)
4710B7 = ShopMenu_Height
4710B9 = slide open (0|1 = no|yes)
4710BC = y-Pos
4710C0 = x-Pos Default = 0 //set manually: [B1 ..]
4710C2 mov eax,[ebx+**] get Ptr on Window (**14 = ShopMenuWindow)
4710C5 call sub_493C30 call CreateWindow
4710D1 call sub_469CE8 get FaceGraphic_Flag
4710D8 jz jump if no FaceGraphic (don't move the text right)
4710E1 cmp Is FacePosition = left ?
4710E5 jnz jump if Face Position = right( don't move the text right)
4710EF call sub_469CE8 get FaceGraphic_Flag(?)
471103 test Is a FaceGraphic used at all?
471105 jz jump if not used (set character limit to 50)
471107+ if FaceGraphic is used (set character limit to 38)
47111B mov eax,[ebx+34] get ShopType(?) (Normal / BuyOnly / SellOnly)
47112E call sub_471200 Show MessageBox(ShopMenu)
471133 jmp NOP -> call BuyWindow when entering the Shop
471140 call sub_471CD0 call SellWindow
4711C0 <>CloseShop (2k3: 493860)
4711CC call sub_46B538 call FadeOutScreen
4711DB call sub_4524F4 ??
4711E7 call sub_455E70 call EraseScreen(?)
4711F0 call ??NOP -> black screen when opening the shop a second time
4711FC mov [eax+4], 0 go to Scene 0 (Map_Scene) when closing the shop
471200 <>ShopMenu (MBox) (2k3: 4938A0)
471230 call sub_45D404 get VocabString Ptr(?)
471237 mov [ebx+C], 0 initialize navigation(?) in the ShopMenu
471240 call sub_495BA4 call UpdateInfoWindow
47124D cmp Is it the 1st or 2nd time choosing [Buy|Sell|Leave]?
471251 jz jump if it's the 2nd time
47125A mov edx, 1 set VocabString's beginning(?)
47125F mov eax, [esi+4] get VocabString for "1st viewing message"
471262 call sub_403F54 call LoadString(?)
47126B = color ("1st viewing message")
47126D = show (0|1 = no|yes)
47126F = y-Pos
471274 = x-Pos considers FaceGraphic_Flag //set manually: [B2 .. 90]
471277 mov eax,[ebx+**] get Ptr on Window** to write the string into
47127C call PrintString(?)
471288 mov edx, 1 set VocabString's beginning(?)
47128D mov eax, [esi+8] get VocabString for "2nd viewing message"
471290 call sub_403F54 call LoadString(?)
471299 = color ("2nd viewing message")
47129B = show (0|1 = no|yes)
47129D = y-Pos
4712A2 = x-Pos considers FaceGraphic_Flag //set manually: [B2 .. 90]
4712A5 mov eax,[ebx+**] get Ptr on Window** to write the string into
4712AA call PrintString(?) LoadIntoMem(?)
**ShopScene Window_IDs:
10 = SeperatorWindow
14 = ShopMenuWindow (MBox)
18 = InfoWindow (topmost window)
1C = BuyWindow
20 = SellWindow
24 = VendingWindow
28 = PartyWindow
2C = EquippedOwnedWindow
30 = GoldWindow
higher IDs are shown above Windows with lower IDs
4712B4 mov ecx,[esi+C] get VocabString for [Buy]Option
4712B7 moves the text to the right
4712BC call sub_403D98 load Vocab into memory(?)
4712C7 mov edx, 1 moves the text to the left
4712CC call sub_403F54 call LoadString(?)
4712D5 = [Buy]_Color
4712D9 = y-Pos (text)
4712DE = x-Pos (text) dynamically assigned //set manually: [B2 .. 90]
4712E1 mov eax,[ebx+14] get Ptr on Window to write String into
4712E6 call PrintString(?) LoadIntoMem(?)
4712F0 mov ecx,[esi+10] get VocabString for [Sell]
4712F3 moves the text to the right
4712F8 call sub_403D98 load Vocab into memory(?)
471303 mov edx, 1 moves the text to the left
471308 call sub_403F54 call LoadString(?)
471311 = [Sell]_Color
471315 = y-Pos (text)
47131A = x-Pos dynamically assigned //set manually: [B2 .. 90]
47131D mov eax,[ebx+14] get Ptr on Window to write String into
471322 call PrintString(?) LoadIntoMemory(?)
47132C mov ecx,[esi+14] get VocabString for [Leave]
47132F moves the text to the right
471334 call sub_403D98 load Vocab into memory(?)
47133F mov edx, 1 moves the text to the left
471344 call sub_403F54 call LoadString(?)
47134D = [Leave]_Color
471351 = y-Pos (text)
471356 = x-Pos dynamically assigned //set manually: [B2 .. 90]
471359 mov eax,[ebx+14] get Ptr on Window to write String into
47135E call ??PrintAllStrings(?)
471361 ??load Cursor(?)
471364 moves the cursor to the right
471367 Cursor-Pos-Correction when FaceGraphic is used(?)
47136A correct Cursor-Pos(?)
471374 call sub_469CE8 GetFaceGraphic_Flag
47137B jz jump if no FaceGraphic is used (doesn't shorten the cursor)
47137D get CursorLength Ptr(?)
471380 mov [eax+38], DC set shortened Cursor_Length
471389 get CursorLength Ptr(?)
47138C mov [eax+38],124 set Cursor_Length (normal)
471393 mov eax,[ebx+14] get Ptr on Window to put the Cursor into
471396 mov edx,[eax+3C] get y-Pos(?)
471399 add edx, 8 correct y-Pos (Pos_0 is on [Buy])
47139C mov [eax+34],edx assign corrected y-Pos to Pos_0(?)
47139F mov [eax+40], 3 amount of available Cursor_Positions
4713A6 mov DL, 1 allow cursor navigation (0|1 = false|true)
4713A8 call sub_4946DC call InitializeCursor(?)
4713E0 2x space for moving [Buy/Sell/Leave] to the right
4713E4 <>OwnedEquippedWindow (2k3: 493A84)
471304 test Is there any Item in the List?
471306 jnz jump if there are Items to buy (else: show zeros in OwnedEquippedWindow)
!! do NOT erase !! (2k3: 493AAC)
47140C jmp loc_4715C4
4714D6 PatchContainer-End
!! do NOT erase !! (2k3: 493B77)
4714DE mov edx,esi get Item_ID
4714E0 call sub_4631D0 call GetItemParam
4714EB call sub_495BA4 call UpdateInfoWindow
4714F0 mov eax,[ebx+2C] get Ptr on Window to clear prevoiusly printed values
4714F5 call clear previously printed number(?)
4714F8 off_49ABDC = VocabStringPtr
4714FF mov eax,[eax+AC] get VocabString for "Owned Items"
471506 = color
471508 = show (0|1 = no|yes)
47150A = y-Pos
47150F = x-Pos
471514 mov eax,[ebx+2C] get Ptr on Window to put "Owned Items" into
471519 call load String into memory(?)
471523 mov eax,[eax+B0] get VocabString for "Equipped Items"
47152A = color
47152C = show (0|1 = no|yes)
47152E = y-Pos
471533 = x-Pos
471538 mov eax,[ebx+2C] get Ptr on Window to put "Equipped Items" into
47153D call load String into memory(?)
47154D call sub_47D2A0 get OwnedItems_Amount (into EAX)
471552 ??load the amount (in EAX) into var_C(?)
471563 call sub_408AD0 print ItemAmount(?)
47156C = color (OwnedAmount)
47156E = show (0|1 = no|yes)
471570 = y-Pos
471575 = x-Pos
47157A mov eax,[ebx+2C] get Ptr on Window to put OwnedItems_Amount into
47157F call load String into memory(?)
47158F call sub_47D2CC get EqippedItems_Amount (into EAX)
471594 ??load the amount (in EAX) into var_C(?)
4715A5 call sub_408AD0 print ItemAmount(?)
4715AE = color (EquippedAmount)
4715B0 = show (0|1 = no|yes)
4715B2 = y-Pos
4715B7 = x-Pos
4715BC mov eax,[ebx+2C] get Ptr on Window to put EquippedItems_Amount into
4715C1 call load String into memory(?)
471604 <>PartyWindow (2k3: 493CA4)
471630 off_49AA9C = InventoryDataPtr
471637 mov eax,[eax+4] get PartySize
47163A test ??
471658 call sub_47CE60 ??
471685 call sub_483200 ??
471697 call sub_465C14 ??
4716A0 call sub_48325C ??
4716AD call sub_47EAAC ??
...
47174A call sub_47CE60 ??
471758 get Item_ID
47175B call sub_4631D0 call GetItemParam
471763 call sub_463054 get CanHeroUseItem_flag
471768 test Is CanHeroUseItem_Flag = true?
47176A jz jump if Hero can't use the Item
471773 get Item_ID
471776 call sub_4631D0 call GetItemParam
47179A mov ecx,C WalkAnimationSpeed (higher = slower)
loc_4717B1 <>ReColor
4717B8 call sub_47EAAC ??has sth. to do with the re-coloring of the HeroCharSets
4717BD mov [eax+18], 0 0 = normal color
loc_4717C3 <>GrayColor
4717D3 call sub_47EAAC ??
4717D8 mov [eax+18],1 1 = Gray_Flag
...
471820 call sub_465F64 ??
47182D call sub_450F8C ??
471832 = y-Pos (all Heroes)
471837 call sub_483238 LoadCharSet(?)
47183D = FaceDirection 0= up | 1= right | 2= down | 3= left
471840 = Transparency 0=none| 1= 12px | 2= 16px | 3= 32px | 4=don't show Chars
471849 call sub_47EAAC ??
471854 = x-Pos (1st Char)
47185A = x-Correction
471868 call sub_465C20 ??ShowCharSets(?)
47186D cmp Is there a Hero in the PartySlot?
471871 jz jump if there isn't
47187E get Item_ID
471881 call sub_4631D0 call GetItemParam
471886 mov AL, [eax+10] get Item_Type
47188C jnb jump if the Item_Type is not Weapon/Equipment
471892 mov [ebp+var_10] set EquipRatingSymbol: 0=[^] 1=[.] 2=[v] 3=[E]
471899 get Item_ID
47189E call sub_48393C get Equipped_Flag(?) //[.] is always set as default
4718A3 test Is Equipped_Flag = true?
4718A5 jz jump if Equipped_Flag = false (= don't set to [E])
4718A7 mov [ebp+var_10] set EquipRatingSymbol: [E]
4718AE xor esi, esi initialize EquipSlotPtr
__________GetEquipmentLoop__________
4718B3 ->mov edx, esi EDX: 0=Slot#1 | 1=Slot#2 | ...
4718B5 | mov eax, ebx get Hero_ID(?)
4718B7 | c.sub_483870 call GetEquippedItem (Slot_ID in EDX)
4718BC | mov [edi],eax memorize Item_ID into EDI's address
4718BE | inc esi EquipSlotPtr +1
4718BF | add edi, 4 EDI = EDI + 4 (EquipSlotPtr onto next memory position)
4718C2 | cmp esi, 5 Is ESI = 5?
4718C5 --jnz jump if ESI is not 5
_____________________________________
4718C9 call sub_4836EC get total amount of StatPoints
4718CE mov memorize TotalStatPoints
4718D8 get Item_ID
4718DB call sub_4631D0 call GetItemParam
4718E0 call sub_463118 get EquipmentType (0=Weapon | 1=Shield | ...)
4718E7 get Item_ID
4718EA mov eax,ebx get Ptr on ActorData
4718EC call sub_483964 call UnequipTwoHanded
4718F1 mov eax,ebx get Ptr on ActorData
4718F3 call sub_4836EC get total amount of StatPoints
4718F8 cmp Is the new Item better? (on the BuyableItem)
4718FB jle jump if stats are below/same
4718FB mov [ebp+var_10] set EquipRatingSymbol: [^]
471904 call sub_4836EC get total amount of StatPoints
471909 cmp Is the new Item worse? (on the BuyableItem)
47190C jge jump if stats are above/same
47190E mov [ebp+var_10] set EquipRatingSymbol: [v]
471915 xor esi, esi initialize EquipSlotPtr
__________UnequipTwoHandedLoop__________
47191A ->mov ecx, [edi] get Item_ID
47191C | mov edx, esi get EquipSlot (0 = EquipSlot#1 | 1 = EquipSlot#2 | ...)
47191E | mov eax, ebx get Ptr on ActorData
471920 | c.sub_483964 call UnequipTwoHanded
471925 | inc esi EquipSlot +1
471926 | add edi, 4 next Item_ID(?)
471929 | cmp esi, 5 Were all EquipSlots tested?
47192C --jnz
________________________________________
471935 get Item_ID
471938 call sub_4631D0 call GetItemParam
47193D cmp Is the Item_Type = Weapon?
471943 mov eax,ebx get Ptr on ActorData
471945 call sub_484498 call GetTwoWeaponStyleFlag
47194A test al,al Is the TwoWeaponStyle_flag = true?
47194C jz jump if not
47194E get Item_ID
471958 call sub_483964 call UnequipTwoHanded
471964 cmp Is EquippedItem worse than the BuyableItem? (?)
471967 jle jump if below/same
47196B mov [ebp+var_10] set EquipRatingSymbol: [^]
471973+ unequip two-handed weapons
471987 get [ebp+var_10] into EAX (get EquipRatingSymbol)
4719AC mov edx get x-Pos of each EquipRatingSymbol
4719AF shl edx, 5 distance between the EquipRatingSymbols(?)
4719B2 add edx, BC x-Pos of the EquipRatingSymbols (relative to the screen)
4719B8 add edx, 14 x-Pos-Correction
4719C2 get SystemGraphic
4719C5 mov ecx, 3C y-Pos of the EquipRatingSymbols
4719CA call sub_467EC4 print EquipRatingSymbols(?)
4719D5 jnz jump to 471740 = do all this stuff for the other Heroes(?)
4718E2 call sub_47EAAC ??
471A14 <>BuyWindow (2k3: 4940FC)
471A2B mov [ebx+C], 1 choosing [Buy] redirects navigation to the BuyWindow
471A2F mov eax,[ebx+14] get Ptr on Window (Shop MBox)
471A34 call clear contents of the Window
471A3E get VocabString for "Buy which item?"
471A41 call sub_45D404 GetVocabStringPtr
471A57 call sub_403F54 ??call LoadString(?)
471A60 = color
471A64 = y-Pos
471A69 = x-Pos considers FaceGraphic //set manually: [B2 .. 90]
471A6C mov eax,[ebx+14] get Ptr on Window to print the VocabString into
471A71 call print VocabString(?)
471A74 ??has sth. to do with cursor placement + navigation
471A79 call ??load BuyWindow's contents(?)
471A7F call sub_4709A4 load ItemData
471A88 call sub_4713E4 update OwnedEquippedWindow
471AB0 <>VendingWindow(Buy) (2k3: 494198)
471AC8 mov [ebx+C], 2 choosing an Item redirects to VendingWindow (+ Buy_Flag)
471ACC mov eax,[ebx+14 get Ptr on Window (ShopMenu)
471AD1 call clear contents of the Window
471ADB /get(set?) VocabString for "Buy how many?"
471ADE call sub_45D404 GetVocabStringPtr
471AF4 call sub_403F54 ??call LoadString(?)
471AFD = color
471B01 = y-Pos
471B06 = x-Pos considers FaceGraphic //set manually: [B2 .. 90]
471B09 mov eax,[ebx+14] get Ptr on Window to print the VocabString into
471B0E call print VocabString(?)
471B14 mov [eax+70], 0 clear Sell_Flag (0|1 = false|true) //to SHOW halved price
471B18 mov eax,[ebx+1C] get Item_ID from the selected Item
471B1B call sub_4709A4 load ItemData
471B26 mov [esi+68], 1 set initial ItemAmount to 1
471B30 call sub_4709A4 load ItemData
471B35 get Item_ID
471B37 off_49AA34 = ItemParamPtr
471B3E call sub_4631D0 call GetItemParam
471B43 cmp [eax+14], 0 Is the Item_Price = 0 ?
471B47 jle jump if Item_Price = 0
471B49+ divides your gold by Item_Price -> max.Amount you can afford
471B4C call sub_4709A4 load ItemData
471B51 get Item_ID
471B5A call sub_4631D0 call GetItemParam
471B5F push [eax+14] memorize Item_Price
471B62 off_49AA9C = InventoryDataPtr
471B69 mov eax,[eax+1C] get current GoldAmount
471B6C pop edx get memorized Item_Price into EDX
471B6D mov ecx, edx get Item_Price into ECX
471B70 idiv ecx divide EAX (current gold) by ECX (Item_Price)
471B72 mov esi, eax get max.Amount you can buy (of the selected Item) into ESI***
471B76 mov esi, 63h set max.Amount to 99 (if Item_Price = 0)
471B7E call sub_4709A4 load ItemData
471B8C call sub_47D2A0 get "Owned Items"Amount (into EAX)
471B91 mov edi, 63h EDI = 99
471B96 sub edi, eax EDI = EDI - EAX (~ 99 - ItemAmount) = room for items
471B98 mov edx, edi get ItemAmount (that you still have room for) into EDX
471B9A mov eax, esi get AffordableItemAmount from ESI*** into EAX
471B9C call sub_41EB0C cmp edx, eax | if EDX < EAX then set EAX = EDX (reduces the amount of items you can buy to the amount of items until they hit 99 units)
471BA4 set max.ItemAmount(?)
471BAC call print Strings(?) refresh VendingWindow(?)
471BD4 <>VendingTransaction(Buy) (2k3: 4942C0)
471BEF mov esi,[edi+68] get ItemAmount into ESI
471BF2 mov edx,[edi+64] get Item_ID into EDX
471BFC call sub_4631D0 call GetItemParam (by Item_ID from EDX)
471C01 mov edx,[eax+14] get Item_Price into EDX
471C04 imul edx, esi EDX = EDX*ESI //multiplay Item_Price with ItemAmount
471C0E call sub_47D518 call DecreaseGold
471C16 mov edx,[eax+64] get Item_ID
471C20 mov ecx,esi get ItemAmount
471C22 call sub_47D058 call AddItem
471C27 mov [ebx+C], 3 buying Items redirects to BuyWindow
471C2B mov eax,[ebx+14] get Ptr on Window (ShopMenu)
471C30 call clear contents of the Window
471C3A get(set?) VocabString for "Purchase Complete"
471C3D call sub_45D404 GetVocabStringPtr
471C53 call sub_403F54 ??call LoadString(?)
471C5C = color
471C60 = y-Pos
471C65 = x-Pos considers FaceGraphic //set manually: [B2 .. 90]
471C68 mov eax,[ebx+14] get Ptr on Window to print the VocabString into
471C6D call print VocabString(?)
471C70 mov eax,[ebx+30] get Ptr on Window (GoldWindow)
471C75 call update GoldWindow
471C7B mov edx,[edi+64] get Item_ID into EDX(?)
471C80 call sub_4713E4 update OwnedEquippedWindow
471C85 mov eax,[ebx+1C] get Ptr on Window (BuyWindow)
471C8A call ??update BuyWindow
471C9C mov [eax+64],edx Set new Item_ID = 0
471CA1 call update VendingWindow (clear because Item_ID = 0)
471CA4 mov [ebx+44],1E delay after purchase //default: [1E] = 30 Frames(?)
471CD0 <>SellWindow (2k3: 4943BC)
471CE7 mov [ebx+C], 4 choosing [Sell] redirects navigation to the SellWindow
471CEB mov eax,[ebx+14] get Ptr on Window (ShopMenu)
471CF0 call clear contents of the Window
471CFA get(set?) VocabString for "Sell which item?"
471CFD call sub_45D404 GetVocabStringPtr
471D13 call sub_403F54 ??call LoadString(?)
471D1C = color
471D20 = y-Pos
471D25 = x-Pos considers FaceGraphic //set manually: [B2 .. 90]
471D28 mov eax,[ebx+14] get Ptr on Window to print the VocabString into
471D2D call print VocabString(?)
471D35 call ??show SellWindowContents(?)
471D3B call sub_470B20 call ItemOnDesicionKey
471D44 call sub_4713E4 call OwnedEquippedWindow
471D6C <>VendingWindow(Sell) (2k3: 494458)
471D83 mov [ebx+C], 5 choosing an Item redirects to the VendingWindow (Sell_Flag)
471D87 mov eax,[ebx+14] get Ptr on Window (Shop MBox)
471D8C call clear contents of the Window
471D96 get(set?) VocabString for "Sell how many?"
471D99 call sub_45D404 GetVocabStringPtr
471DAF call sub_403F54 ??call LoadString(?)
471DB8 = color
471DBC = y-Pos
471DC1 = x-Pos considers FaceGraphic //set manually: [B2 .. 90]
471DC4 mov eax,[ebx+14] get Ptr on Window to print the VocabString into
471DC9 call print VocabString(?)
471DCF mov [eax+70], 1 set Sell_Flag (0|1 = false|true) //to SHOW halved price
471DD6 call sub_470B20 call ItemOnDesicionKey
471DE1 mov [esi+68], 1 set initial ItemAmount to 1
471DEB call sub_470B20 call ItemOnDesicionKey //NOP -> no [^|<|v|>]Navigation
471DF9 call sub_47D2A0 get "Owned Items"Amount (into EAX)
471E01 mov [esi+6C],eax memorize "Owned Items"Amount
471E04 mov eax, esi get Item_ID(Ptr) into ESI(?)
471E06 mov edx, [eax] get Item_ID into EDX(?)
471E08 call load(?) correct contents into the VendingWindow
471E0E call sub_470B20 call ItemOnDesicionKey //process the selected Item
471E38 <>VendingTransaction(Sell) (2k3: 49452C)
471E53 mov esi,[edi+68] get ItemAmount into ESI
471E56 mov edx,[edi+64] get Item_ID into EDX
471E60 call sub_4631D0 call GetItemParam (by Item_ID from EDX)
471E65 mov edx,[eax+14] get Item_Price into EDX
471E68 sar edx, 1 halves Item_Price
471E6F imul edx, esi EDX = EDX*ESI (= Item_Price*ItemAmount)
471E79 call sub_47D4FC call IncreaseGold
471E81 mov edx,[eax+64] get ItemAmount into EDX
471E8D call sub_47D154 remove Items (in inventory, amount in EDX)
471E92 mov [ebx+C], 6 selling Items redirects to SellWindow
471E96 mov eax,[ebx+14] get Ptr on Window (Shop MBox)
471E9B call clear contents of the Window
471EA5 get(set?) VocabString for "Sale complete"
471EA8 call sub_45D404 GetVocabStringPtr
471EBE call sub_403F54 ??call LoadString(?)
471EC7 = color
471ECB = y-Pos
471ED0 = x-Pos considers FaceGraphic //set manually: [B2 .. 90]
471ED3 mov eax,[ebx+14] get Ptr on Window to print the VocabString into
471ED8 call print VocabString(?)
471EDB mov eax,[ebx+30] get Ptr on Window (GoldWindow)
471EE0 call update GoldWindow
471EF0 mov edx,[eax+64] get new OwnedItemAmount into EDX(?)
471EF5 call sub_4713E4 update OwnedEquippedWindow
471EFF call ??update Sellwindow(?)
471F02 mov eax,[ebx+20] get Ptr on Window (VendingWindow)
471F05 xor edx, edx set EDX to 0
471F07 mov [eax+64],edx set Item_ID to 0 //for clearing the VendingWindow(?)
471F0C call update VendingWindow (clear because Item_ID = 0)
471F0F mov [ebx+44],1E delay after purchase //default: [1E] = 30 Frames(?)
471F3C <>ShopMainLoop (2k3: 494630)
471F41 cmp Was the ShopScene already drawn/initialized?
471F45 jnz jump if already initialized
471F49 call sub_470FD4 call DrawShopWindows
471F50 mov al,[ebx+C] get SubScene_ID (change navigation between ShopWindows)
471F53 cmp Is the ID below/same 6?
471F56 ja jump if above 6 (jump to default / do nothing)
471F5C jmp branch jump according to the SubScene_ID
[ebx+C] = 0 jump loc_471F7F (go to ShopMenu)
[ebx+C] = 1 jump loc_472024 (go to BuyWindow)
[ebx+C] = 2 jump loc_472125 (go to VendingWindow(Buy))
[ebx+C] = 3 jump loc_47219D (go back to BuyWindow)
[ebx+C] = 4 jump loc_4721BC (go to SellWindow)
[ebx+C] = 5 jump loc_4722A0 (go to VendingWindow(Sell))
[ebx+C] = 6 jump loc_47230E (go back to SellWindow)
loc_471F7F (ShopMenuNavigation) (2k3: 494673)
471F7F mov eax,[ebx+14] get Ptr on Window (ShopMenu)
471F84 call allow directional CursorNavigation(?)
471F8E test Was DecisionKey pressed?
471F95 jz jump if not pressed //jump to "Was CancelKey pressed?"
471F9E call sub_46A4A0 get DecisionSound
471FAC call sub_46A0A8 call PlaySound
471FB1 mov eax,[ebx+14] get Ptr on Window (ShopMenu)
471FB4 mov eax,[eax+44] get CursorPos(?)
471FBA jb jump loc_471FC6 (on [Buy])
471FBC jz jump loc_471FD2 (on [Sell])
471FBF jz jump loc_471FDE (on [Leave])
471FC8 call sub_471A14 call BuyWindow
471FD4 call sub_471CD0 call SellWindow
471FE0 call sub_4711C0 call CloseShop
471FF1 test Was CancelKey pressed?
471FF8 jz jump if not pressed //jump to default(do nothing)
472005 call sub_46A588 get CancelSound
472013 call sub_46A0A8 call PlaySound
47201A call sub_4711C0 call CloseShop
loc_472024 (BuyWindowNavigation) (2k3: 494718)
472024 mov eax,[ebx+1C] get Ptr on Window (BuyMenu)
472027 call sub_4709A4 load ItemData
47202E mov eax,[ebx+1C] get Ptr on Window (BuyMenu)
472033 call allow directional CursorNavigation(?)
472036 mov eax,[ebx+1C] get Ptr on Window (BuyMenu)
472039 call sub_4709A4 load ItemData
47203E mov esi,eax memorize Item_ID
472040 cmp Was the Cursor scrolled unto a new Item?
472044 mov edx,esi get Item_ID
472048 call sub_4713E4 call OwnedEquippedWindow
472054 test Was a DecisionKey pressed?
47205B jz jump if not pressed //jump to CancelKey_check
47205D test esi, esi Is at least one Item listed?
47205F jz jump if there isn't (prevents "invalid item")
472068 mov edx,esi get Item_ID
47206A call sub_4631D0 call GetItemParam (by Item_ID from EDX)
47206F mov eax,[eax+14] get Item_Price
472072 off_49AA9C = InventoryDataPtr
47207A cmp Is Item_Price higher than current GoldAmount?
47207D jg jump if Item is not affordable
472088 call sub_47D2A0 get "Owned Items"Amount (into EAX)
47208D cmp eax, 63h Are there already 99 units of the Item in the inventory?
472090 jnz jump if there's still more room to buy the Item
472099 call sub_46A670 get BuzzerSound
4720A7 call sub_46A0A8 call PlaySound
4720B8 call sub_46A4A0 get DecisionSound
4720C6 call sub_46A0A8 call PlaySound
4720CD call sub_471AB0 call VendingWindow(Buy)
4720DE test Was a CancelKey pressed?
4720E5 jz jump if not pressed
4720F2 call sub_46A588 get CancelSound
472100 call sub_46A0A8 call PlaySound
472105 cmp [ebx+34], 0 Is BuySellOnly_Flag = false?
472109 jnz jump if BuySellOnly_Flag = true //-> call CloseShop
47210F call sub_471200 call ShopMenu(MBox)
47211B call sub_4711C0 call CloseShop (when BuyOnly)
loc_472125 (VendingWindow(Buy)) (2k3: 494819)
472125 mov eax,[ebx+24] get Ptr on Window (VendingWindow)
47212A call allow directional CursorNavigation(?)
472134 test Was a DecisionKey pressed?
47213B jz jump if not pressed
472144 call sub_46A4A0 get DecisionSound
472152 call sub_46A0A8 call PlaySound
472159 call sub_471BD4 call VendingTransaction(Buy)
47216A test Was a CancelKey pressed?
472171 jz jump if not pressed
47217E call sub_46A588 get CancelSound
47218C call sub_46A0A8 call PlaySound
472193 call sub_471A14 call BuyWindow
loc_47219D (ReturnToBuyWindow) (2k3: 494891)
47219D cmp [ebx+44], 0 Is the delay(?) at 0?
4721A1 jle jump if below/same 0
4721A3 dec [ebx+44] reduce the delay by 1 (cycle through until it's at 1)
4721A6 cmp [ebx+44], 0 Is the delay(?) at 0?
4721AA jnz jump if not yet 0 //jump to default (cycle through)
4721B2 call sub_471A14 call BuyWindow
loc_4721BC (SellWindowNavigation) (2k3: 4948B0)
4721BC mov eax,[ebx+20] get Ptr on Window (SellWindow)
4721BF call sub_470B20 call ItemOnDesicionKey //gets Item_ID into EDI
4721C6 mov eax,[ebx+20] get Ptr on Window (SellWindow)
4721CB call allow directional CursorNavigation(?)
4721CE mov eax,[ebx+20] get Ptr on Window (SellWindow)
4721D1 call sub_470B20 call ItemOnDesicionKey //gets new Item_ID into ESI
4721D8 cmp esi, edi Was another Item selected than before?
4721DA jz jump if it's the same Item_ID (= not a different Item)
4721E0 call sub_4713E4 call OwnedEquippedWindow (update to new Item)
4721EC test Was a DecisionKey pressed?
4721F3 jz jump if not pressed
4721F5 test esi, esi Is there any Item in the inventory?
4721F7 jz jump if there's no Items in the inventory
472200 mov edx, esi get Item_ID into EDX
472202 call sub_4631D0 call GetItemParam (by Item_ID from EDX)
472207 cmp [eax+14], 0 Is the Item_Price = 0 ?
47220B jnz jump if it's above 0 (= able to sell)
472214 call sub_46A670 get BuzzerSound
472222 call sub_46A0A8 call PlaySound
472233 call sub_46A4A0 get DecisionSound
472241 call sub_46A0A8 call PlaySound
472248 call sub_471D6C call VendingWindow(Sell)
472259 test Was a CancelKey pressed?
472260 jz jump if not pressed
47226D call sub_46A588 get CancelSound
47227B call sub_46A0A8 call PlaySound
472280 cmp [ebx+34], 0 Is BuySellOnly_Flag = false?
472284 jnz jump if BuySellOnly_Flag = true //-> call CloseShop
47228A call sub_471200 call ShopMenu(MBox)
472296 call sub_4711C0 call CloseShop (when SellOnly)
loc_4722A0 (VendingWindow(Sell)) (2k3: 494994)
4722A0 mov eax,[ebx+24] get Ptr on Window (VendingWindow)
4722A5 call allow directional CursorNavigation(?)
4722AF test Was a DecisionKey pressed?
4722B6 jz jump if not pressed
4722BF call sub_46A4A0 get DecisionSound
4722CD call sub_46A0A8 call PlaySound
4722D4 call sub_471E38 call VendingTransaction(Sell)
4722E2 test Was a CancelKey pressed?
4722F2 call sub_46A588 get CancelSound
472300 call sub_46A0A8 call PlaySound
472307 call sub_471CD0 call SellWindow
loc_47230E (ReturnToSellWindow) (2k3: 494A02)
47230E cmp [ebx+44], 0 Is the delay(?) at 0?
472312 jle jump if below/same 0
472314 dec [ebx+44] reduce the delay by 1 (cycle through until it's at 1)
472317 cmp [ebx+44], 0 is the delay(?) at 0?
47231B jnz jump if not yet 0 //jump to default (cycle through)
47231F call sub_471CD0 call SellWindow
472328 <>ShopGUIManager (2k3: 494A1C)
47232F cmp [esi+D], 0 ??Was the Shop already initialized(?)
472333 jz jump if 0
472339 cmp [esi+C], 0 Currently not in ShopMenu?
47233D jnz jump if not in ShopMenu
47233F mov eax,[esi+18] get Ptr on Window for InfoWindow
472344 call update InfoWindow
472347 mov eax,[esi+10] get Ptr on Window for SeperatorWindow
47234C call update/draw SeperatorWindow
47234F mov eax,[esi+14] get Ptr on Window for ShopMenuWindow
472354 call update/draw ShopMenuWindow
472357 jmp jump to loc_472417
47235C mov eax,[esi+18] get Ptr on Window for InfoWindow
472361 call update InfoWindow
472364 mov eax,[esi+14] get Ptr on Window for ShopMenuWindow
472369 call update/draw ShopMenuWindow
47236E mov al,[esi+C] get SubScene_ID(?)
472376 jmp branch jump according to the SubScene_ID(?)
[esi+C] = 0 jump loc_4723D3 -> default
[esi+C] = 1 jump loc_472399 -> draw BuyWindow
[esi+C] = 2 jump loc_4723A3 -> draw VendingWindow(Buy)
[esi+C] = 3 jump loc_4723AD -> draw VendingWindow(empty + delay)
[esi+C] = 4 jump loc_4723B7 -> draw SellWindow
[esi+C] = 5 jump loc_4723C1 -> draw VendingWindow(Sell)
[esi+C] = 6 jump loc_4723CB -> draw VendingWindow(empty + delay)
4723D3 cmp [esi+C], 4 Currently in SellWindow? (there's no PartyWindow etc.)
4723D7 jz jump if 4 //don't draw the PartyWindow
4723D9 mov eax,[esi+28] get Ptr on Window for PartyWindow
4723DE call draw PartyWindow (not the contents though)
4723E1 mov eax,[esi+2C] get Ptr on Window for EquippedOwnedWindow
4723E6 call draw EquippedOwnedWindow (contents included)
4723E9 mov eax,[esi+30] get Ptr on Window for GoldWindow
4723EE call draw GoldWindow (contents included)
4723F1 mov al,[esi+C] get SubScene_ID(?)
4723F8 jnb jump if currently in SellWindow(?)
4723FF call sub_471604 call PartyWindow (contents) from within the Vending(Sell)
472409 call sub_4709A4 load ItemData
472412 call sub_471604 call PartyWindow (contents) from within the BuyWindow
47241E call sub_469CE8 get FaceGraphic_Flag
472423 test Is FaceGraphic_Flag = true?
472425 jz jump if FaceGraphic_Flag = false
472432 cmp [eax+40], 0 Is FacePosition = left?
472436 jnz jump if FacePosition = right
47244E call sub_451C0C call LoadFaceGraphic(?)
47245F mov eax,[eax+34] get Sheet_ID(?) (is above every Window_ID)
472462 = y-Pos (Face = left)
472467 = x-Pos (Face = left)
47246C call sub_4527D0 call DrawFaceGraphic(?)
472489 call sub_451C0C call LoadFaceGraphic(?)
47249D = y-Pos (Face = right)
4724A2 = x-Pos (Face = right)
4724A7 call sub_4527D0 call DrawFaceGraphic(?)
4879E4 <>CallShop (2k3: 4AE708)
4879F9 mov [eax+4C], 1 allow FaceGraphic = true
487A01 call sub_45E524 call GetEvParam, into EAX (0=Normal 1=BuyOnly 2=SellOnly)
487A09 mov [edx+34],eax memorize AvailablaOptions at [edx+34]
487A13 call sub_45E524 call GetEvParam //get MessagePool (Shop A-C)
487A20 call sub_485CB0 create(?) DealSuccessHandler
487A29 call sub_485874 get Events in the DealSuccessHandler(?)
487A30 call sub_485CB0 add DealSuccessHandler(?)
487A4E get number of sold Items
487A51 sub ebx, 4 set ItemListEnd (e.g. sub 5 gets rid of bottommost Item)
487A55 test Is there at least one Item in the list?(?)
487A57 jl jump if there isn't
__________FillItemListLoop__________
487A5A xor edi, edi set EDI = 0 //set pointer on the first(?) Item on the list
487A61 call sub_45E524 call GetEvParam //get the listed Item
487A6E call sub_40F5D0 add Item to the list(?)
487A73 inc edi move pointer to the next Item on the list
487A74 dec ebx decrease the "to be processed"ItemList
487A75 jnz loop as long as the "to be processed"ItemList isn't empty -> copies the "to be processed"ItemList into a Shop-ItemList
____________________________________
487A8A mov [eax+4], 3 set GameScene to "Shop"