How to re-compile Mule ?

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

Moderator: Kroah

How to re-compile Mule ?

Postby zeelay » 21 Mar 2008, 11:29

Hello Kroah and all of you :D

You’ve done a great job here !

As an Atari 8bit Mule fan, I always enjoy playing this game.
But I am sometimes a bit frustrated at the end of the games, juste because it stops :(

So I was thinking about changing the ATR file by myself to let the game continue after the 12th month.
I didn’t plan to study the source code, so I simply try to find the 12 value and change it by 24 or more. I supposed that it should be preceded by a LDA or CMP, so finding it would not be so hard with a binary editor (ie Source Edit).
Unfortunally, it didn’t work. So I looked on the web and find kroah’s website ;)

Now that I have the sourcecode, I think that I could change it by myself.
But I don’t know how to compile the game and make it works as an ATR file.

Maybe someone can help ;)
Thanx.

Igor.
zeelay
 
Posts: 2
Joined: 21 Mar 2008, 09:10

Re: How to re-compile Mule ?

Postby Kroah » 29 Mar 2008, 22:20

zeelay wrote:Hello Kroah and all of you :D

Welcome aboard Igor!
Glad to see you here :).

zeelay wrote:As an Atari 8bit Mule fan, I always enjoy playing this game.
But I am sometimes a bit frustrated at the end of the games, juste because it stops :(

I agree with you, i've already thought to increase the number of month over 12.

zeelay wrote:I didn’t plan to study the source code, so I simply try to find the 12 value and change it by 24 or more. I supposed that it should be preceded by a LDA or CMP, so finding it would not be so hard with a binary editor (ie Source Edit).
Unfortunally, it didn’t work.

It's not so easy. As well as increasing 12 to 24 (for example), there're other parts of code to update (arrays, ...).

zeelay wrote:Now that I have the sourcecode, I think that I could change it by myself.
But I don’t know how to compile the game and make it works as an ATR file.

If you talk about the disassembled code i put on the website, it's only a disassembled code from a memory snapshot. Even if it looks like the mule source code, it can't be compiled.

But...

We can update the ATR image with the help of the disassembled code and the Atari 800 debugger. As long as the changes concerns updates (a value to another, but no addition nor suppression), it's easy.

I'll have a look.

Regards,
Pascal
Kroah
Site Admin
 
Posts: 412
Joined: 07 Feb 2006, 01:01
Location: France

Postby Kroah » 30 Mar 2008, 01:35

Well, i've tried to set the number of months to 24 for the Standard and Tournament level. You'll find the original and updated ATR in attachments.
I think 24 months are too much. 18 months may be better?

Remarks:
Even if they don't prevent playing, there're still 2 problems:
- after round 12, the wampus bonus is incorrect.
- after round 12, the gambling bonus is incorrect.

Here's the list of changes i've done to the ATR:

Code: Select all
Description: Music length differs every 4 rounds.
Change: Set to the maximum (as round 12).

252C:
search: LDA   numRound = A5 B1 (4A 4A 0A A8 B9 1F)
update: LDA   #12      = A9 0C

2540:
search: CMP   #12      = C9 0C (90 05 A9 00 8D A0)
update: CMP   #24      = C9 18


Code: Select all
Description: Food requirement increases every 4 rounds.
Change: Food requirement increases every 8 rounds.

315E:
search: AND   #3       = 29 03 (D0 01 C8 98 0A 0A)
update: AND   #7       = 29 07

6294:
search: AND   #3       = 29 03 (D0 03 EE 76 B3 AD)
update: AND   #7       = 29 07


Code: Select all
Description: Crystite price = round * 4 + 100.
Change: Crystite price = round * 2 + 100.

34A9:
search: ASL   A        = 0A (69 64 8D F7 B2 A2 03)
update: NOP            = EA


Code: Select all
Description: Gambling bonus = random [0; timeleft] + gambling_bonus_6A7E [round / 4] (max 250)
Change: None


Code: Select all
Description: Hardcoded month limit (12).
Change: Set to 24.

6E01:
search: CMP   #12      = C9 0C (D0 43 A9 10 85 D4)
update: CMP   #24      = C9 18

6F59:
search: CMP   #12      = C9 0C (D0 03 20 98 30 A9)
update: CMP   #24      = C9 18

7002:
search: CMP   #12      = C9 0C (D0 07 AD 25 B3 C9)
update: CMP   #24      = C9 18

70A9:
search: LDA   #12      = A9 0C (C5 B1 D0 12 AD 25)
update: LDA   #18      = A9 18

71E6:
search: LDY   #12      = A0 0C (C4 B1 D0 0C AC 25)
update: LDY   #18      = A0 18

89E0:
search: CMP   #12      = C9 0C (D0 03 4C 43 8D A9)
update: CMP   #24      = C9 18


Code: Select all
Description: Events quality (cash gained or lost) depends on round. Amount = A * 25 * (GAME_NUM_ROUND/4 + 1) with A between [1; 8] (50 to 800).
Change: Amount = A * 15 * (GAME_NUM_ROUND/4 + 1)

8292:
search: LDY   #25      = A0 19 (20 30 11 A8 A5 B1)
update: LDY   #15      = A0 0F


Code: Select all
Description: Wampus bonus = wamping_bonus_8D3B [round / 4].
Change: None


Code: Select all
Description: Initialization of the number of months for the tournament level (12).
Change: Set to 24.

45DA:
search: LDA   #12      = A9 0C (8D 6F B3 A9 00 8D)
update: LDA   #18      = A9 18


Code: Select all
Description: The event probability decreases when it occurs.
Change: Doubled all the events probability.

7B7D:
search: 03 02 03 03 03 02 02 02
update: 06 04 06 06 06 04 04 04


Code: Select all
Description: The success message depends on the score.
Change: Doubled the needed score for each message.

6E05: $2710 (10000) -> $4E20 (20000)
search: LDA   #$10     = A9 10 (85 D4 A9 27 85 D5 20 AA D9)
update: LDA   #$10     = A9 20

search: LDA   #$27     = A9 27 (85 D5 20 AA D9 20 B6 DD A2)
update: LDA   #$4E     = A9 4E

6E24: $4E20 (20000) -> $9C40 (40000)
search: LDA   #$20     = A9 20 (85 D4 A9 4E 85 D5 20 AA D9)
update: LDA   #$40     = A9 40

search: LDA   #$4E     = A9 4E (85 D5 20 AA D9 20 B6 DD A2)
update: LDA   #$9C     = A9 9C
Attachments
Mule - 24 months.zip
(72.14 KiB) Downloaded 98 times
Kroah
Site Admin
 
Posts: 412
Joined: 07 Feb 2006, 01:01
Location: France

Postby xot » 04 Apr 2008, 20:23

Wow, awesome patch, Kroah.
xot
 
Posts: 51
Joined: 11 Feb 2006, 00:04

It works ! It works !

Postby zeelay » 08 Apr 2008, 10:57

Hello Kroah,

Thank you very much, it works fine :)
For the first time, I played a long game and could see what happens after. I really appreciated that ;)

Your remarked that after level 12, there was a Wampus problem.
The first time, it increased my money for about $36256, but when I got over $99999, then it started back at $0 ;(
So I don’t try to find the Wampus anymore after level 12 ;)

24 round is fine to me (it could even be longer). When all the plots are owned, I enjoy making food and energy to sell it to my computer-friends at a very high price ;)
Mule seems to be a triple tamagotchi !

Can you give me the « procedure » to re-compile the game and make the ATR ? So I could make other changes by myself.

Thanks again ;)

Igor.
Attachments
Mule24-01.png
12th month…
Mule24-01.png (10.98 KiB) Viewed 3219 times
Mule24-02.png
… last month.
Mule24-02.png (11.12 KiB) Viewed 3216 times
zeelay
 
Posts: 2
Joined: 21 Mar 2008, 09:10

Re: How to re-compile Mule ?

Postby Kroah » 08 Apr 2008, 18:32

Hi Igor,

Thank you for your feedback.

Kroah wrote:
zeelay wrote:Now that I have the sourcecode, I think that I could change it by myself.
But I don’t know how to compile the game and make it works as an ATR file.

If you talk about the disassembled code i put on the website, it's only a disassembled code from a memory snapshot. Even if it looks like the mule source code, it can't be compiled.


I wanted to say here that i only worked on the disassembled memory snapshot, not the ATR. This code can't be compiled.

That's why i explained you how i could change the ATR:

Kroah wrote:We can update the ATR image with the help of the disassembled code and the Atari 800 debugger. As long as the changes concerns updates (a value to another, but no addition nor suppression), it's easy.


The ATR image is raw read 2 times:
- at the opening screen and game options,
- when the game begins "... IRATA ...".

With the help of the decompiled memory snapshot, i've been able to find parts of code to change. After this, i've looked for the hexadecimal values in the ATR and patched them with correct values. You can understand that as long as i don't add new piece of codes (only updates), it's easy.

If you plan to have an in-depth look at the disassembled memory snapshot, contact me by mail.

Regards,
Pascal
Kroah
Site Admin
 
Posts: 412
Joined: 07 Feb 2006, 01:01
Location: France

Postby xot » 19 Apr 2008, 11:40

The whole Wampus and gambling bonus problem was bugging me so I made a small patch to Kroah's patch to correct it. There are actually a couple of ways to go, what follows is one of them.

Warning: this hasn't been tested extensively, but it has worked for me in the few games I've tried.

In Kroah's mule_amo_24.atr disk image change these bytes from:
Code: Select all
0x0000cb46: 00 00 00 00 00 00 00 00 00 00
0x00012222: 4a 4a aa
0x000143d5: 4a 4a 0a

... to:
Code: Select all
0x0000cb46: 4a 4a 4a aa 60 4a 4a 4a 0a 60
0x00012222: 20 b6 13
0x000143d5: 20 bb 13


What that does is change the math used to compute the index to the two bonus tables. It replaces the existing math with a jump to an unused portion of memory (starting at $13B6) which has the updated routines. Basically it is the same math but with an extra divide-by-two step to account for double the number of rounds. That means the bonuses increase in value a half the normal rate, so now they are:
Code: Select all
Round | Wampus |  Gambling
  #   | Reward | Base Bonus
------+--------+-----------
 1-7  |  $100  |   $ 50
 8-15 |  $200  |   $100
16-23 |  $300  |   $150
  24  |  $400  |   $200


The other way to patch this would be to keep the original math and create new extended bonus tables at the same unused location. This would give you more control over the gambling base bonus and Wampus reward (for instance allowing it reach $800 by round 24). I'll explain that patch if there is interest. It uses slightly more memory, and I haven't tested it yet, but I'm confident it will work.

It took me three tries to find an area of memory that was actually usable. M.U.L.E. is positively stuffed with code and data! This small area of 74 bytes ($13B6 through $13FF) seems to be safe. There are some character graphics used to draw the full-sized store (M.U.L.E. corral, outfitters, pub, assay, etc.) starting at $1400.
xot
 
Posts: 51
Joined: 11 Feb 2006, 00:04

Postby Kroah » 21 Apr 2008, 21:55

Hi Xot,

Thank you for your help, but i've already done the patch to fix the gambling and wampus issue. It only needs some tests.

My choice was your second idea. I've chosen a free space in the ATR which was loaded in memory (0x166DB to 0x1678F included) and i put the 2 new extended arrays.

The gambling bonus array is now:
Code: Select all
round  1 to  3: 100
round  4 to  7: 125
round  8 to 11: 150
round 12 to 15: 175
round 16 to 19: 200
round 20 to 23: 225
round 24:       250

Instead of:
Code: Select all
round  1 to  3: 100
round  4 to  7: 150
round  8 to 11: 200
round 12:       250


The wampus bonus array is now:
Code: Select all
round  1 to  3: 100
round  4 to  7: 150
round  8 to 11: 200
round 12 to 15: 250
round 16 to 19: 300
round 20 to 23: 350
round 24:       400

Instead of:
Code: Select all
round  1 to  3: 100
round  4 to  7: 200
round  8 to 11: 300
round 12:       400


Here are the full changes i've done to the Mule ATR:
Code: Select all
Description: Music length differs every 4 rounds.
Change: Set to the maximum (as round 12).

252C:
search: LDA   numRound = A5 B1 4A 4A 0A A8 B9 1F
update: LDA   #12      = A9 0C

2540:
search: CMP   #12    = C9 0C 90 05 A9 00 8D A0
update: CMP   #24    = C9 18


Code: Select all
Description: Food requirement increases every 4 rounds.
Change: Food requirement increases every 8 rounds.

315E:
search: AND   #3     = 29 03 D0 01 C8 98 0A 0A
update: AND   #7     = 29 07

6294:
search: AND   #3     = 29 03 D0 03 EE 76 B3 AD
update: AND   #7     = 29 07


Code: Select all
Description: Crystite price = round * 4 + 100.
Change: Crystite price = round * 2 + 100.

34A9:
search: ASL   A      = 0A 69 64 8D F7 B2 A2 03
update: NOP          = EA


Code: Select all
Description: Hardcoded month limit (12).
Change: Set to 24.

6E01:
search: CMP   #12   = C9 0C D0 43 A9 10 85 D4
update: CMP   #24   = C9 18

6F59:
search: CMP   #12   = C9 0C D0 03 20 98 30 A9
update: CMP   #24   = C9 18

7002:
search: CMP   #12   = C9 0C D0 07 AD 25 B3 C9
update: CMP   #24   = C9 18

70A9:
search: LDA   #12   = A9 0C C5 B1 D0 12 AD 25
update: LDA   #18   = A9 18

71E6:
search: LDY   #12   = A0 0C C4 B1 D0 0C AC 25
update: LDY   #18   = A0 18

89E0:
search: CMP   #12   = C9 0C D0 03 4C 43 8D A9
update: CMP   #24   = C9 18


Code: Select all
Description: Events quality (cash gained or lost) depends on round. Amount = A * 25 * (GAME_NUM_ROUND/4 + 1) with A between [1; 8] (50 to 800).
Change: Amount = A * 15 * (GAME_NUM_ROUND/4 + 1)

8292:
search: LDY   #25   = A0 19 20 30 11 A8 A5 B1
update: LDY   #15   = A0 0F


Code: Select all
Description: Initialization of the number of months for the standard and tournament level (12).
Change: Set to 24.

45DA:
search: LDA   #12    = A9 0C 8D 6F B3 A9 00 8D
update: LDA   #18    = A9 18


Code: Select all
Description: The event probability decreases when it occurs.
Change: Doubled all the events probability.

7B7D:
search: 03 02 03 03 03 02 02 02
update: 06 04 06 06 06 04 04 04


Code: Select all
Description: The success message depends on the score.
Change: Doubled the needed score for each message.

6E05: $2710 (10000) -> $4E20 (20000)
search: LDA   #$10   = A9 10 85 D4 A9 27 85 D5
        LDA   #$27
update: LDA   #$10   = A9 20 85 D4 A9 4E 85 D5
        LDA   #$4E

6E24: $4E20 (20000) -> $9C40 (40000)
search: LDA   #$20   = A9 20 85 D4 A9 4E 85 D5
        LDA   #$4E
update: LDA   #$40   = A9 40 85 D4 A9 9C 85 D5
        LDA   #$9C


Code: Select all
Description: Wampus bonus = wamping_bonus_8D3B [round / 4].
round  1 to  3: 100
round  4 to  7: 200
round  8 to 11: 300
round 12:       400
Change: Wampus bonus = wamping_bonus_AF4B [round / 4].
round  1 to  3: 100
round  4 to  7: 150
round  8 to 11: 200
round 12 to 15: 250
round 16 to 19: 300
round 20 to 23: 350
round 24:       400

8C52:
search: ADC   $8D3B,X   = 7D 3B 8D 99 BA B2 B9 BB
update: ADC   $AF4B,X   = 7D 4B AF

8C5B:
search: ADC   $8D3C,X   = 7D 3C 8D 99 BB B2 B9 09
update: ADC   $AF4C,X   = 7D 4C AF

8C94, 8C97:
search: LDX   $8D3B,Y   = BE 3B 8D B9 3C 8D 20
        LDA   $8D3C,Y
update: LDX   $AF4B,Y   = BE 4B AF B9 4C AF
        LDA   $AF4C,Y

AF4B:
search: A6 8C 10 D0 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00
update:                64 00 96 00 C8 00 FA 00 2C 01 5E 01 90 01


Code: Select all
Description: Gambling bonus = random [0; timeleft] + gambling_bonus_6A7E [round / 4] (max 250)
round  1 to  3: 100
round  4 to  7: 150
round  8 to 11: 200
round 12:       250
Change: Gambling bonus = random [0; timeleft] + gambling_bonus_AF6B [round / 4] (max 250)
round  1 to  3: 100
round  4 to  7: 125
round  8 to 11: 150
round 12 to 15: 175
round 16 to 19: 200
round 20 to 23: 225
round 24:       250

6AA0:
search: ADC   $6A7E,X   = 7D 7E 6A 90 02 A9 FA AA
update: ADC   $AF6B,X   = 7D 6B AF

AF6B:
at address: 0x0166FB
change to:  64 7D 96 AF C8 E1 FA


Have fun!
Pascal
Attachments
Mule - 24 months - v0.2.zip
(36.12 KiB) Downloaded 100 times
Kroah
Site Admin
 
Posts: 412
Joined: 07 Feb 2006, 01:01
Location: France

Postby xot » 22 Apr 2008, 03:55

Ah cool, now I don't have to mess with it. But I'm a little confused about something. The normal base gambling bonuses are:
Code: Select all
;  -----------------------------------------------------------------------------
;  GAMBLING_PRIZE : $50,$100,$150,$200 as the game progresses
;  -----------------------------------------------------------------------------
L6A7E    .BYTE $32,$64,$96,$C8
;


Yet you write:
The gambling bonus array is now:
Code: Select all
round  1 to  3: 100
round  4 to  7: 125
round  8 to 11: 150
round 12 to 15: 175
round 16 to 19: 200
round 20 to 23: 225
round 24:       250


Instead of:
Code: Select all
round  1 to  3: 100
round  4 to  7: 150
round  8 to 11: 200
round 12:       250


You've boosted them by $50. Was that intentional?

Finding these available areas of memory is pretty useful information. It sounds like you found a 181 byte block area. A person could stick a lot of code in there. Did you find any other useful holes?
xot
 
Posts: 51
Joined: 11 Feb 2006, 00:04

Postby Kroah » 22 Apr 2008, 19:37

xot wrote:You've boosted them by $50. Was that intentional?


Yes. I played a test game, and i felt early game differs too much from original. Do you agree?

xot wrote:Finding these available areas of memory is pretty useful information. It sounds like you found a 181 byte block area. A person could stick a lot of code in there.

Sure it could be use to improve or add new features. It's not much free space, but enough to play around with.

xot wrote:Did you find any other useful holes?

I found 145 free bytes at the disk location $3390 to $3420 (loaded at memory address $843 to $8D3). It seems not used, but haven't tested this block in depth.
Kroah
Site Admin
 
Posts: 412
Joined: 07 Feb 2006, 01:01
Location: France


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests