Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

DARKPACT level 2 VC


Demarest
 Share

Recommended Posts

First things first: credit. This upgrade takes advantage of both VMA (variable memory access) and self-modifying code, both of which are techniques credited to our very own Y_Less.

 

What all is easier about it?

•no download required - If you have the original Vice City main.scm and Barton Waterduck's Mission Builder 0.22 for VC, you have everything you need to make a level 2 Darpactor for your mod. This thread serves as instructions, complete with images to aid in understanding. A download will be available from my site, but it's only to serve as representation on my site as it will be these exact same instructions/pics.

•smaller download of your mod - level 2 Darkpactors will be one SCM instead of 2, making you mod download smaller than it would be with the original Darkpact.

•half the work for the end user - With a level 2 Darkpactor, the end user will simply needs to replace their original main.scm with the level 2 Darkpactor of your mod. Darkpact level 2 is engineered to inject your code once and only once, so the end user can continue to save and load their game as they would with the original code. The exception to this is that if they go to start a new game, they will have to swap original code back in.

•use multiple Darkpacts back to back - Becuase Darkpact v1 would actually trap the firefighter thread, you would have to save your game, load original code+yourmod, save your game, and so on. This was true of Code Tools as well, which use the Darkpact technique to auto-launch. Since level 2 Darkpact repairs itself, the firefighter thread is not only free to use so that you can play that misison, but it also frees up the thread pointer so that subsequent SCMs with the Darkpact technique will auto-launch as intended without the need to restore original code and save first.

 

How do I do it? Easy enough. Use MB 0.22 and open up original code. Search for the word firefighter and page up. You're looking for address F211 as seen here:

 

before after
user posted image user posted image
After the initial wait 0 at F211, add the code
0417: start_mission  0?0002: jump ��Label00F211

...and comment out the first if and the first jump_if_false you find as diagrammed above.

 

Next, go to Mission 0 and delete all of it, escept the very first label in it (remember that mission 0 is only run at the start of a new game and Darkpact is to inject mods into existing games) like so:

 

before after
user posted image user posted image
The code you see here is far more straight forward than it looks. What we want to do is rewrite the lines in the firefighter thread so that it will continue to operate as normal, even after our editing of it. However, MB will not allow the writing of data outside of the define memory boundaries. So we use Y_Less's VMA technique to store the code inside unused, consecutive variables inside the define memory boundaries, and then we run it. This is Y_Less's technique for self-modifying code. Essentially, it restores the firefighter thread to the way it normally looks so that it will function as it normally would. We only "borrowed" it to auto-launch our code. But what's stopping it from creating another instance of our mod every time they load their game? That's what the if 124?? check is for 124?? is a defined, but unused DMA slot in original code. It will always be 0 unless we mess with it. Rather than saying if 124?? = 0, we use if 124?? != 1 so that the number there and the number we set it to if true are identical. This should make the mentality behind it a bit easier for those who wish to inject several mods. Now subsequent loads will auto launch Darkpact level 2, fix itself, see there's nothing to do, and self terminate. The entire process will be finished before the user even sees the fade in from their load. The code:

 

:Label031F3403A4: name_thread "DRKPCT2"0004:  368?? = 33588224&& 0004:  372?? = 100856341&& 0004:  376?? = 20736&& 0004:  96?? = 262358&& 0050: gosub 369&& 0008:  372?? +=  4?0004:  96?? = 134349398&& 0050: gosub 369&& 0008:  372?? +=  4?0004:  96?? = 16796928&& 0050: gosub 369&& 0008:  372?? +=  4?0004:  96?? = 62397&& 0050: gosub 369&&00D6: if  0?8038:   NOT    124?? ==  1?004D: jump_if_false £LabelDARKPACTLEVEL2END0004:  124?? =  1?004F: create_thread ££LabelDARKPACTLEVEL2:LabelDARKPACTLEVEL2END004E: end_thread

 

Then, it's just like before. But your code just before Misison 0 as seen in the pics below. If you want to add several mods at the same time, you can just put all your create_threads where the first one is in the picture. The second picture is to indicate how to inject a 2nd (and subsequent) mods into a SCM that's already had a mod injected into it. You'll note that the new mod has to come after the first, we've given it its own custom name as you can see, but most importantly, we've upped the if check. Now you can see that it was written as if NOT so that the numbers circled can always be the same and therefore a bit easier to impliment. What number you set it to is irrelevant as long as you know it's not what the value already is. Again, that DMA slot is unused by original code (though defined), so it will always equal 0 in untouched code or whatever the last level 2 Darkpactor author set it to. Granted, this makes it a smidge complex, but no more complex than the process of making a Darkpactor in the first place.

 

level 2 Darkpacting

untouched code

level 2 Darkpacting of

previously Darkpacted code

user posted image user posted image
As before, I'm asking script mod authors to make their work available via a level 2 Darkpactor. While I may have documented the procedure, the technology used is entirely the work of CyQ and Y_Less with the exception of using an aboandoned DMA slot to allow for "plug and play" functionality. I encourage authors to only release Darkpactors as an OPTION to prevent their mods from requiring individual attention for every single implimentation possibility. As before, there are recommended instructions to accompany a level 2 Darkpactor. They are the same as before, but without all the extra unneeded steps:
1 Backup your /data/main.scm file.2 Put l2DARKPACTcoordinatorVC.SCM in /data/ and rename it to main.scm3 Load your game.

...as well as make sure they understand that they can continue to play with that SCM up until the point where they decide to start a new game, at which point they will need to restore their copy of original code.

 

Darkpact uses DMA slots 96??, 124??, 368??, 372??, and 376??, all of which are established by original code, but never used. This is of little importance at this point in time, but if this process grows large enough in popularity with the advent of this one-step installation and or the incorporation of global vars, a registry will need to be kept not unlike ID#'s were back in the early days of GTA3 map mods. At any rate, HOLD ONTO YOUR SOURCES. I don't believe MB can decompile code make with Darkpact level 2 because of the gosub ints.

Edited by Demarest
Link to comment
Share on other sites

One question on this Demarest. Shouldn't you disable custom id's when you decompile original scm. Because when you recompile the code, variables like $DEFAULT_WAIT_TIME will get a different address than in the original scm.

 

 

Link to comment
Share on other sites

Dem, I didn't see this before I PM'd you, so ignore some of it. According to my site, those variables ARE used, what was wrong with the original ones I sent you? Also, I think you can start a new game (read my PM).
Link to comment
Share on other sites

One question on this Demarest. Shouldn't you disable custom id's when you decompile original scm.

Considering we're going for savegame compatibility, the easy answer is yes. Taking as many things out of the picture that could potentially disrupt compatibility is the superior way. Originally, I was going to ask you if you were sure because Darkpact and my Code Tools have been in circulation for about 2+ months now and I have yet to witness a single occurance of incompatibility. But then I chose to test it for myself and all was preserved. This leads me to believe that scm.ini is used on compile and Y_Less has confirmed it. Good point just the same though.

 

My apologies as when I originally posted this topic, I was in a major rush. Forgot to give Y_Less credit as his var tool helped me pick out the DMA slots to use much faster than I could've on my own. To pre-emptively answer questions, yes I plan on applying this to GTA3 and SA as well. SA will be a bit more challenging since Barton ditched hex addressing, but that just means it will take a bit more effort.

 

In the original Darkpact thread, we documented the 102 DMA addresses that original code left as holes for us. At that time, I recommended that those wanting to inject mods with globals rewrite it to use those DMA slots. At this time, it is believed after some research that that is NOT necessary and that MB will automatically flood the holes with the first 102 globals it encounters. This makes Darkpact even more user friendly. Those who ARE more proficient coders and interested in using Darkpact should stick to abandoned DMA slots and leave the free ones for others. To answer Y_Less's question publically, that is why I shifted from the DMA slots he originally provided me with in favor of abandoned vars. His were in the 102 holes, so lets say somebody used Darkpact to inject a mod with globals and MB gave it those slots (very realistic since they were right at the beginning of the list). Now a person goes to inject ANOTHER mod and boom, Darkpact overwrites globals in use by the first mod. Abandoned DMA slots are not at risk for those, which is why I went that route because then all I have to do is say "yo world, these 5 DMA slots are off-limits." Much less risk involved. I plan on documenting and releasing all abandoned DMA slots by position in game soon enough.

Link to comment
Share on other sites

demarest bit off topic but i've kinda been wanting ur neo mod for ages on san andreas..... i aint great at moddin but cud u let me kno how step by step i cud convert it over?..or maybe u do it for me! tounge.gifbiggrin.gifsmile.gif i'd prefer that please!!

Link to comment
Share on other sites

@SAZ: Hijack a thread of less importance please. Or PM me. This is about Darkpact level 2 and it happens to be fairly advanced technique that breaks a 3 year old coding stigma.

 

Anyways, Y_Less pointed out to me that originally, I had screens indicating gosub 367&& when I meant gosub 369&&. He also pointed out that I ONLY made the code available via image. Apologies for that oversight. All is fixed now. Also, last night I made a ZIP of these images/instructions for local consulting if you really want it.

 

On a side note, this is such a wonderful pet to have. Somebody IMed me with a teenie mod request. I whipped it up, dropped it into Darkpact level 2 and was off. Didn't matter which slot I loaded, etc. VERY flexible.

 

Not sure how necessary making claims to this and that will be for now (beyond DPl2's 5 DMA slots), but for now, I know that my Code Tools will probably be where you see this taking place the most. For that reason, I'm hereby reserving 124?? = 218& and beyond. Right now there are 9 CT's, all slated for level 2 upgrading. So for now, that's 218 - 226 reserved.

Edited by Demarest
Link to comment
Share on other sites

 

Considering we're going for savegame compatibility, the easy answer is yes. Taking as many things out of the picture that could potentially disrupt compatibility is the superior way. Originally, I was going to ask you if you were sure because Darkpact and my Code Tools have been in circulation for about 2+ months now and I have yet to witness a single occurance of incompatibility. But then I chose to test it for myself and all was preserved. This leads me to believe that scm.ini is used on compile and Y_Less has confirmed it. Good point just the same though.

I had a totally different experience with MB 0.22. If I decompile original main.scm, don't touch one bit recompile and decompile it again all variables are changed. The only way to keep them intact is to disable custom ids so everything is DMA. You are positive it does reverse lookup of variables in scm.ini on compilation?

Link to comment
Share on other sites

Because an accomplished programmer is challenging it, no, I cannot say for certain. But my limited testing of it suggests that it does. Y_Less similarly recalled an experience like you're relaying. He tested it again and found that they are preserved. My only real reason to believe all is well is because while we have no way of ascertaining how widespread Darkpact and my Code Tool series usage extends, Spuds has noted the way the advent of Time Vault has all but killed Save N Play traffic. All of the above has been in circulation for 2+ months and there have been no reports of incompatibility. Similarly, I do alot of testing during development myself and have never had an issue, nor have I ever disabled scm.ini usage.
Link to comment
Share on other sites

I completely understand. As when Y_Less and I had this discussion, I told him point blank that if I'm wrong, I'd like to know. This is a big deal to me and it would be quite irresponsible to lead anybody astray. To me, the word challenge just means to test it once more. No harm in that, especially between peers, yeah? smile.gif

 

That said, believe it or not, Darkpact level III has been mastered wow.gif Documentation and release shortly. For VC only right now, but ALL perceived barriers are broken, so expect as swift as possible conversions to GTA3 and SA.

Link to comment
Share on other sites

I just tested myself, yes it seems that 0.22 preserves addresses of named variables. Sorry for spooking, I guess I confused this wth the older version of MB.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.