MULE - again.

Talk about everything related to general reverse engineering of computer games!

Moderator: Kroah

MULE - again.

Postby Mattb » 21 Jul 2012, 08:01

Hi There!

I'm starting to walk through your decomposition document and got stuck on the number of MULEs available. The document states that the corral will hold 14 and those used will be replaced by new MULEs at a cost of 2 smithore. I've found that on round 3 (and later) this is not the case. The number of MULEs can exceed 14 and it seems more MULEs are produced than Smithore would allow. Am I missing something?

Thanks!

Matt
Mattb
 
Posts: 1
Joined: 20 Jun 2012, 06:27

Re: MULE - again.

Postby Kroah » 21 Jul 2012, 14:14

Hello Mattb,

I don't have much time to test this with a real (emulated) game, but this is an interesting question.

Here's the pseudo code of the function used to build the mules:
Code: Select all
ROM:339A BuildAndCalcPriceMule:        ; ...
ROM:339A   LDA   goodsStoreNb+2
ROM:339D   LSR   A                     ; // construction des mules
ROM:339D                               ; int nbMulesBuildable = goodsStoreNb [Smithore] / 2
ROM:339E   BEQ   calcMulePrice         ; if (nbMulesBuildable != 0) {
ROM:33A0   STA   byte_80
ROM:33A2   LDA   #14                   ;   // le store contient 14 mules au max
ROM:33A4   SEC
ROM:33A5   SBC   goodsStoreNb+4        ;   int nbMulesMissingInStore = 14 - goodsStoreNb [Mule]
ROM:33A8   BEQ   calcMulePrice         ;   if (nbMulesMissingInStore != 0) {
ROM:33A8                               ;
ROM:33AA   CMP   byte_80               ;     int nbMulesToBuild = nbMulesMissingInStore
ROM:33AC   BCC   loc_33B0              ;     if (nbMulesToBuild >= nbMulesBuildable ) {
ROM:33AE   LDA   byte_80               ;       nbMulesToBuild = nbMulesBuildable
ROM:33AE                               ;     }
ROM:33B0
ROM:33B0 loc_33B0:                     ; ...
ROM:33B0   ASL   A                     ;     // A contient le nb de mules qui peuvent
ROM:33B0                               ;     // etre construites par rapport au smithore dispo
ROM:33B0                               ;     // 1 MULE prend 2 SMITHORE
ROM:33B1   STA   byte_88               ;     nbSmithoresForBuild = nbMulesToBuild * 2
ROM:33B3   LDA   goodsStoreNb+2
ROM:33B6   SEC
ROM:33B7   SBC   byte_88
ROM:33B9   STA   goodsStoreNb+2        ;     goodsStoreNb [Smithore] -= nbSmithoresForBuild
ROM:33BC   LSR   byte_88
ROM:33BE   LDA   goodsStoreNb+4
ROM:33C1   CLC
ROM:33C2   ADC   byte_88
ROM:33C4   STA   goodsStoreNb+4        ;     goodsStoreNb [Mule] += nbMulesToBuild
ROM:33C4                               ;   }
ROM:33C4                               ; }
ROM:33C7
ROM:33C7 calcMulePrice:                ; ...
ROM:33C7   LDA   goodsPrice+4          ; // calcul du nouveau prix des mules
ROM:33CA   LDY   goodsPrice+5          ; Y/A = GOODS_PRICE [SMITHORE]
ROM:33CD   LDX   #5
ROM:33CF   JSR   Div16Bits             ; Y/A /= 5
ROM:33D2   LDX   #10
ROM:33D4   JSR   Mul16BitsBy8Bits      ; Y/A *= 10
ROM:33D4                               ; // Y/A = GOODS_PRICE [SMITHORE] * 2
ROM:33D7   STA   mulePriceL
ROM:33DA   STY   mulePriceH            ; mulePrice = (goodsPrice [Smithore] - goodsPrice [Smithore] % 5) * 2
ROM:33DD   RTS
ROM:33DD ; End of function BuildAndCalcPriceMule


As is, i don't see how the mules can exceed 14. But i may miss something of course.

Do you have an Atari800win save state or a video showing the behavior you describe ?
Kroah
Site Admin
 
Posts: 430
Joined: 07 Feb 2006, 01:01
Location: France


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron