Troubleshooting a Mangling Machine-related patch

Request patches for Keens 1-3.
Post Reply
User avatar
Flyingmouse
Posts: 104
Joined: Wed Aug 05, 2009 8:33 pm
Location: Procrastination

Troubleshooting a Mangling Machine-related patch

Post by Flyingmouse » Mon Oct 08, 2018 9:18 pm

To give a bit of background, I figured I'd try my hand at adding in a second Mangling Machine conversation over some of the code for the About ID screen, since that offers well over 3,000 bytes of space if left out. I've run into a problem with the call to $02BD, though, as it's too far away for a Near Call to reach.
Here's the setup code; I need to shorten it since the initial conditional jump hasn't done anything, but it serves its purpose

Code: Select all

#MM check moved to jump table
%patch $85CF $E9 $1AF8W
#Jump table - level 1 and 6 use new code, while level 15 uses original code 
%patch $A0CA $83 $7E $04 $02 $74 $16 $83 $7E $04 $03 $75 $05 $E8 $0A4FW  $EB #New code shows in level 3
%patch $A0DA $10 $83 $7E $04 $01 $75 $05 $E8 $B621W  $EB $05 $EB $08 $E9 $E4EDW  #Original shows in level 1
%patch $A0EB     $C7 $46 $FE $0000W  $E9 $E4EAW 
OPTION 1 - VIA A CALL TABLE WITH E9 JUMPS:

Code: Select all

%patch $AB28 $55 $88 $EC
#Window 1
%patch $AB2B $B8 $0003W  $50 $B8 $0023W  $50 $E8 $AA9EW  $59 $59 $E8 $1671W 
             $B8 $2AA2W  $50 $E8 $AB60W  $59 $0B $C0 $74 $06 $E8 $AD2AW  $E9 
             $012BW  $B8 $00B4W  $50 $E8 $AB00W  $59 $0B $C0 $74 $06 $E8 $AD17W  
                 $E9 $0119W  $E8 $AD11W  $E8 $1647W  
#Window 2
%patch $AB65 $B8 $0004W  $50 $B8 $0025W  $50 $E8 $AA64W  $59 $59 #AB72
             $B8 $35CAW  $50 $E8 $AB29W  $59 $0B $C0 $74 $06 $E9 $AD05W  $E9 
             $00F4W  $B8 $00F0W  $50 $E8 $AB37W  $59 $0B $C0 $74 $06 $E9 $ACF9W  
                 $E9 $00E2W  $E9 $ACF9W  $E8 $1610W  
#Window 3
%patch $AB9C $B8 $0002W  $50 $B8 $0023W  $50 $E8 $AA2DW  $59 $59 #ABA9
             $B8 $2AFFW  $50 $E8 $AAF2W  $59 $0B $C0 $74 $06 $E9 $ACE0W  $E9 
             $00BDW  $B8 $00B4W  $50 $E8 $AB6EW  $59 $0B $C0 $74 $06 $E9 $ACD4W
                 $E9 $00ABW  $E9 $ACD4W  $E8 $15D9W  
#Window 4
%patch $ABD3 $B8 $0003W  $50 $B8 $0025W  $50 $E8 $A9F6W  $59 $59 #ABE0
             $B8 $317FW  $50 $E8 $AABBW  $59 $0B $C0 $74 $06 $E9 $ACBBW  $E9 
             $0086W  $B8 $00B4W  $50 $E8 $ABA5W  $59 $0B $C0 $74 $06 $E9 $ACAFW  
                 $E9 $0074W  $E9 $ACAFW  $E8 $15A2W  
#Window 5
%patch $AC0A $B8 $0005W  $50 $B8 $0026W  $50 $E8 $A9BFW  $59 $59 #AC17
             $B8 $2D30W  $50 $E8 $AA84W  $59 $0B $C0 $74 $06 $E9 $AC96W  $E9
             $004FW  $B8 $00B4W  $50 $E8 $ABDCW  $59 $0B $C0 $74 $06 $E9 $AC8AW  
                 $E9 $003DW  $E9 $AC8AW  $E8 $156BW
#Window 6
%patch $AC41 $B8 $0001W  $50 $B8 $0019W  $50 $E8 $A988W  $59 $59 #AC4E
             $B8 $31D9W  $50 $E8 $AA4DW  $59 $0B $C0 $74 $06 $E9 $AC71W  $E9
             $0018W  $B8 $00F0W  $50 $E8 $AC13W  $59 $0B $C0 $74 $06 $E9 $AC65W  
                 $E9 $0006W  $E9 $AC65W  $E8 $1534W  $5D $C3
#Jump table 
%patch $5874 $E8 $AA46W  $E9 $52D0W  $E8 $AA40W  $E9 $52DCW  $E8 $AA3AW  $E9 $52DCW
%patch $5886 $E8 $AA34W  $E9 $52F5W  $E8 $AA2EW  $E9 $5301W  $E8 $AA28W  $E9 $5301W
%patch $5898 $E8 $AA22W  $E9 $531AW  $E8 $AA1CW  $E9 $5326W  $E8 $AA16W  $E9 $5326W
%patch $58AA $E8 $AA10W  $E9 $533FW  $E8 $AA0AW  $E9 $534BW  $E8 $AA04W  $E9 $534BW
%patch $58BC $E8 $A9FEW  $E9 $5364W  $E8 $A9F8W  $E9 $5370W  $E8 $A9F2W  $E9 $5370W
%patch $58CE $E8 $A9ECW  $E9 $5389W  $E8 $A9E6W  $E9 $5395W  $E8 $A9E0W  $E9 $5395W
OPTION 2 - VIA FAR CALLS (attempted with $9A $02BDW $0800W and $9A $02BDW $0000W):

Code: Select all

%patch $AB28 $55 $88 $EC
#Window 1
%patch $AB2B $B8 $0003W  $50 $B8 $0023W  $50 $E8 $AA9EW  $59 $59 $E8 $1671W 
%patch $AB3B $B8 $2AA2W  $50 $E8 $AB60W  $59 $0B $C0 $74 $06 $9A $02BDW  $0800W  $E9 
%patch $AB4D $014CW  $B8 $00B4W  $50 $E8 $AAFEW  $59 $0B $C0 $74 $06 $9A $02BDW  $0800W    
%patch $AB60 $E9 $0139W  $9A $02BDW  $0800W  $E8 $1641W  
#Window 2
%patch $AB6B $B8 $0004W  $50 $B8 $0025W  $50 $E8 $AA5EW  $59 $59 
%patch $AB78 $B8 $35CAW  $50 $E8 $AB23W  $59 $0B $C0 $74 $06 $9A $02BDW  $0800W  $E9 
%patch $AB8A $010FW  $B8 $00F0W  $50 $E8 $AAC1W  $59 $0B $C0 $74 $06 $9A $02BDW  $0800W  
%patch $AB9D $E9 $00FCW  $9A $02BDW  $0800W  $E8 $1604W 
#Window 3
%patch $ABA8 $B8 $0002W  $50 $B8 $0023W  $50 $E8 $AA21W  $59 $59 
%patch $ABB5 $B8 $2AFFW  $50 $E8 $AAE6W  $59 $0B $C0 $74 $06 $9A $02BDW  $0800W  $E9 
%patch $ABC7 $00D2W  $B8 $00B4W  $50 $E8 $AA84W  $59 $0B $C0 $74 $06 $9A $02BDW  $0800W
%patch $ABDA $E9 $00BFW  $9A $02BDW  $0800W  $E8 $15C7W  
#Window 4
%patch $ABE5 $B8 $0003W  $50 $B8 $0025W  $50 $E8 $A9E4W  $59 $59
%patch $ABF2 $B8 $317FW  $50 $E8 $AAA9W  $59 $0B $C0 $74 $06 $9A $02BDW  $0800W  $E9 
%patch $AC04 $0095W  $B8 $00B4W  $50 $E8 $AA47W  $59 $0B $C0 $74 $06 $9A $02BDW  $0800W  
%patch $AC17 $E9 $0082W  $9A $02BDW  $0800W  $E8 $158AW  
#Window 5
%patch $AC22 $B8 $0005W  $50 $B8 $0026W  $50 $E8 $A9A7W  $59 $59
%patch $AC2F $B8 $2D30W  $50 $E8 $AA6CW  $59 $0B $C0 $74 $06 $9A $02BDW  $0800W  $E9
%patch $AC41 $0058W  $B8 $00B4W  $50 $E8 $AA0AW  $59 $0B $C0 $74 $06 $9A $02BDW  $0800W  
%patch $AC54 $E9 $0045W  $9A $02BDW  $0800W  $E8 $154DW
#Window 6
%patch $AC5F $B8 $0001W  $50 $B8 $0019W  $50 $E8 $A96AW  $59 $59
%patch $AC6C $B8 $31D9W  $50 $E8 $AA2FW  $59 $0B $C0 $74 $06 $9A $02BDW  $0800W  $E9
%patch $AC7E $001BW  $B8 $00F0W  $50 $E8 $A9CDW  $59 $0B $C0 $74 $06 $9A $02BDW  $0800W  
%patch $AC91 $E9 $0008W  $9A $02BDW  $0800W  $E8 $1510W  $5D $C3
Here's the text used if you need it (mild spoilers for the mod I'm working on, but who cares honestly)

Code: Select all

%patch $1C2C2 $98 ":...J--ko? Juk-o, ar- you a-rig-t?" $0A
             "...There, signal seems to be back" $0A
             "online. What happened?" $00
%patch $1CDEA $97 ":Ugh... something must have hit me" $0A
             "mid-flight. ...Diagnostics complete." $0A
             "Seems like most of my weaponry and" $0A
             "wings got damaged." $00
%patch $1C31F $98 ":Lovely... Try to hold on as long" $0A
             "as you can; I'm sending in backup." $00
%patch $1C99F $97 ":I-I... no, I can't. I need to find" $0A
             "Diola, and fast. I don't want to" $0A
             "disobey you, but..." $00
%patch $1C550 $98 ":No, no, I understand. There should" $0A
             "be a few emergency weapons aboard" $0A
             "the ship - you should be able to use" $0A
             "those. Just... please come back alive," $0A
             "Jukko. I don't want to lose you too." $00
%patch $1C9F9 $97 ":Right. I'll do my best." $00
THE PROBLEM:
Starting the game gives me the following error messages in DOSBox's status window, which is harmless and (I think) deals with either TSRMusic or the palette patch:

Code: Select all

Illegal write to cc0082a1, CS:IP     f000:    11c4
Illegal write to cc0082a1, CS:IP     f000:    11c4
The game functions normally in all cases, and the first textbox from AB2B plays normally when I enter level 3, but then something different happens when I either close the textbox or it tries to progress to the second one:
  • With Option 1, the game crashes with no additional messages in DOSBox.
  • With Option 2, when using $0800W as the second word in the far call, the game crashes with a "Exit to error: Illegal GRP4 Call 6" error and then closes itself shortly after.
  • If I instead use $0000W, the game crashes while repeating the "Illegal write" error above (which has happened before when my patches read code from the wrong place).
In all cases, it freezes on the first textbox without clearing it, so I'm pretty sure it's the jump to 02BD that's getting screwed up. I'm likely butchering the $9A call somehow since I have no idea how far calls work (especially in Vorticons).

Post Reply