Mac Coding Quest

This forum is dedicated to platform-specific issues, discussions and tools relating to D2 modding for the Mac.

Moderator: Contrail

0
No votes
 
Total votes: 0

User avatar
Necrolis
Senior Admin
Throne
Posts: 9125
Joined: Sat Mar 25, 2006 1:22 pm
Location: The Land of the Dead
South Africa

Hand-picked

Mac Coding Quest

Post by Necrolis » Sat Jun 16, 2007 7:31 pm

split from the Eastern Sun v3.1 Plan topic...[Myhr]
tsuru";p="329066" wrote:"+XX% to Magic Skill Damage" and "-XX% Enemy Magic Resist" don't exist in LoD.

More properly, the mods exist but don't work. Blizzard saved their work because those mods aren't used in LoD.

Well, something may be needed for Magic damage spellcasters to make up it. Making Conviction also reduce Magic damage a little, for example.
magic pierce is easily fixed in the pc version, as for +% to magic skill damage it can be done on both pc and mac with a stat synergy(the magic mastery stat does work but it is very buggy). as for the ring rewards on mac, it could be that the item type line is reference and not the rin code. i would like to offer my assistance with regards to mac ce, i don't have experience with macs but i believe i can be of some help.
Last edited by Necrolis on Sat Jun 16, 2007 10:45 pm, edited 1 time in total.
Image
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal

User avatar
Hans
Dark Alliance Beta Test
Dominion
Posts: 6438
Joined: Sat Oct 02, 2004 5:14 pm
Location: Toronto, Ontario, Canada

Post by Hans » Sat Jun 16, 2007 7:42 pm

Necrolis I am currently trying to find the Akara reward for the skill points in it. If you have any Ideas I can test them out on my Parents Mac.
"Hi. My name is Hans, and I am addicted to a game that is not yet been made" - Card carrying member of D3 Addictions Anonymous, since June 2008.
Card carrying member of Mentaldom, since May 2006 - Zy-El Hardcore.
"German pornstar/Bee Gee lookalike" & "The Blacksmith"
Trying to picture Hans as a Dominion...nah it isn't working sorry. It's the mustache that gets me every time - Al-T.
"All men play on 127" O-H - Hans
"Okay, time out. This is Zy-El. The mod of total excess. Since when would any Zy-El lover do only what's necessary?" - Metropolis Man
Zy-El Wiki|New Zy-El Website

User avatar
Necrolis
Senior Admin
Throne
Posts: 9125
Joined: Sat Mar 25, 2006 1:22 pm
Location: The Land of the Dead
South Africa

Hand-picked

Post by Necrolis » Sat Jun 16, 2007 7:57 pm

Hans";p="331375" wrote:Necrolis I am currently trying to find the Akara reward for the skill points in it. If you have any Ideas I can test them out on my Parents Mac.
cool, all i need is a copy of the mac files(not mpqs), (could anybody e mail them to me?) and i'll have a look at school and see what i can do.
Image
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal

User avatar
Myhrginoc
Retired Admin
Cherub
Posts: 12100
Joined: Sat May 25, 2002 7:28 am
Location: Percussion U
United States of America

Hand-picked

Post by Myhrginoc » Sat Jun 16, 2007 10:38 pm

Hans" wrote:I am currently trying to find the Akara reward for the skill points in it. If you have any Ideas I can test them out on my Parents Mac.
If you haven't seen it already, there is a sticky thread on quest rewards in the Code Editing Forum. The code is Intel, of course, but the logic should be somewhat similar across platforms. The key thing to determine would be the all-important functions: set stat, add to stat, get stat. There are four forms of the get stat function, two are identical in v1.10 and return total stat values, the third one gets base stats (nothing equipped) and the last gets the difference from your equipment and charms. If you identify the stat functions, you should be able to set breakpoints ahead of events such as talking to Akara (uses AddToStat) after clearing out the Den. In fact, identifying those functions and trapping events would lead you to a LOT of other code to compare against our writings.

The 1.10 versions of these functions would look like below in high level languages. nParameter is zero for most stats. One common use of nParameter is skill ID for stat_singleskill and stat_oskill.

GetStat(pPlayer, nStatIndex, nParameter)
SetStat(pPlayer, nStatIndex, nValue, nParameter)
AddToStat(pPlayer, nStatIndex, nValue, nParameter)

Beyond this short list, there is a considerably longer list of function forms in another sticky in the Code Editing Forum. A third reference would be the ptUnit and ptGame sticky, as I would imagine the data structures will be the same or very similar.
Last edited by Myhrginoc on Sat Jun 16, 2007 10:49 pm, edited 2 times in total.
Do the right thing. It will gratify some people and astonish the rest.
~ Mark Twain
Run Diablo II in any version for mods: tutorial
The Terms of Service!! Know them, abide by them, and enjoy the forums at peace.
The Beginner's Guide v1.4: (MS Word | PDF) || Mod Running Scripts || TFW: Awakening

User avatar
Necrolis
Senior Admin
Throne
Posts: 9125
Joined: Sat Mar 25, 2006 1:22 pm
Location: The Land of the Dead
South Africa

Hand-picked

Post by Necrolis » Sun Jun 17, 2007 5:52 am

this was actually the method i am going to take, addstat should be the first one to be traced down as it is used the most, the skill ones also don't use nparameter(as skill points require no params from what i've seen) so we'd look for the mac equivalent of: push 5(stat val for skill points), push 1(no. of skill points), call xxx(d2 common #10018 for the pc version, its in the funcs list). anybody got some good recommendations for a pc to mac emulator?
Last edited by Necrolis on Sun Jun 17, 2007 5:56 am, edited 1 time in total.
Image
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal

User avatar
tsuru
Retired staff
Principality
Posts: 2417
Joined: Tue Sep 16, 2003 8:14 pm
Location: tokyo

Re: Mac Coding Quest

Post by tsuru » Sun Jun 17, 2007 6:12 am

Necrolis";p="331378" wrote:
Hans";p="331375" wrote:Necrolis I am currently trying to find the Akara reward for the skill points in it. If you have any Ideas I can test them out on my Parents Mac.
cool, all i need is a copy of the mac files(not mpqs), (could anybody e mail them to me?) and i'll have a look at school and see what i can do.
Thank you for offering the help.

http://miyoshino.la.coocan.jp/files/es3 ... _q_fix.zip
This is the 1.10 Mac executable (equivalent for Windows game.exe + dlls), with 4 quest drops already changed.

Succesfully changed quest drops are as follows:

Andariel drops runes and better gems at the first kill.

Code: Select all

D2game.dll

(LoD)
00104000: gcv gcr gcb gcy gcg gcw skc gsv gsr gsb gsy gsg gsw sku

(ES)
00104000: gzv glb glg glr glw gly skl gzk r05 r06 r07 r08 r09 r10


Diablo II (Carbon) -Mac executable

(LoD)
00448F46: gcv gcr gcb gcy gcg gcw skc gsv gsr gsb gsy gsg gsw sku

(ES)
00448F46: gzv glb glg glr glw gly skl gzk r05 r06 r07 r08 r09 r10
Hellforge quest drops better runes and gems.

Code: Select all

D2game.dll

(LoD)
0010B754: r01 r02 r03 r04 r05 r06 r07 r08 r09 r10 r11 r12 r13 r14 r15 r16
          r17 r18 r19 r20 r21 r22 r23 r24 r25 gpv gpr gpb gpy gpg gpw skz
          gzv glr glb gly glg glw skl gsv gsr gsb gsy gsg gsw sku

(ES)
0010B754: r18 r19 r20 r21 r22 r23 r24 r25 r26 r27 r28 r29 r30 r31 r32 r33
          r34 r35 r36 r37 r38 r39 r40 r41 r42 gvb grb gbb gyb ggb gwb skb
          gpv gpr gpb gpy gpg gpw skz gzv glr glb gly glg glw skl


Diablo II (Carbon) -Mac executable

(LoD)
0044A4FD: r01 r02 r03 r04 r05 r06 r07 r08 r09 r10 r11 r12 r13 r14 r15 r16
          r17 r18 r19 r20 r21 r22 r23 r24 r25 gpv gpr gpb gpy gpg gpw skz
          gzv glr glb gly glg glw skl gsv gsr gsb gsy gsg gsw sku

(ES)
0044A4FD: r18 r19 r20 r21 r22 r23 r24 r25 r26 r27 r28 r29 r30 r31 r32 r33
          r34 r35 r36 r37 r38 r39 r40 r41 r42 gvb grb gbb gyb ggb gwb skb
          gpv gpr gpb gpy gpg gpw skz gzv glr glb gly glg glw skl
Qual-Kehk gives a Dragon Stone, a Perfect Obsidian and a Flag instead of a Tal, a Ral and an Ort.

Code: Select all

D2game.dll

(LoD)
0010CD79: r07 r08 r09

(ES)
0010CD79: ppp gbk flg


Diablo II (Carbon) -Mac executable

(LoD)
0044AFE3: r07 r08 r09 (LoD)

(ES)
0044AFE3: ppp gbk flg
Anya gives a unique stone instead of the class specific rare.

Code: Select all

D2game.dll

(LoD)
0010D5C4: am1 am2 am3 am4 am5 am6 am7 am8 am9 ama amb amc amd ame amf ba1
          ba2 ba3 ba4 ba5 ba6 ba7 ba8 ba9 baa bab bac bad bae baf ne1 ne2
          ne3 ne4 ne5 ne6 ne7 ne8 ne9 nea neb nec ned nee nef pa1 pa2 pa3
          pa4 pa5 pa6 pa7 pa8 pa9 paa pab pac pad pae paf ob1 ob2 ob3 ob4
          ob5 ob6 ob7 ob8 ob9 oba obb obc obd obe obf dr1 dr2 dr3 dr4 dr5
          dr6 dr7 dr8 dr9 dra drb drc drd dre drf ktr wrb axf ces clw btl
          skr 9ar 9wb 9xf 9cs 9lw 9tw 9qr 7ar 7wb 7xf 7cs 7lw 7tw 7qr

(LoD)
0010D5C4: an0 an0 an0 an0 an0 an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an0
          an0 an0 an0 an0 an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an0 an0
          an0 an0 an0 an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an0 an0 an0
          an0 an0 an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an0 an0 an0 an0
          an0 an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an0 an0 an0 an0 an0
          an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an0 an0 an0 an0 an0 an0
          an0 an1 an1 an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an2 an2

Diablo II (Carbon) -Mac executable

(LoD)
0044B158: am1 am2 am3 am4 am5 am6 am7 am8 am9 ama amb amc amd ame amf ba1
          ba2 ba3 ba4 ba5 ba6 ba7 ba8 ba9 baa bab bac bad bae baf ne1 ne2
          ne3 ne4 ne5 ne6 ne7 ne8 ne9 nea neb nec ned nee nef pa1 pa2 pa3
          pa4 pa5 pa6 pa7 pa8 pa9 paa pab pac pad pae paf ob1 ob2 ob3 ob4
          ob5 ob6 ob7 ob8 ob9 oba obb obc obd obe obf dr1 dr2 dr3 dr4 dr5
          dr6 dr7 dr8 dr9 dra drb drc drd dre drf ktr wrb axf ces clw btl
          skr 9ar 9wb 9xf 9cs 9lw 9tw 9qr 7ar 7wb 7xf 7cs 7lw 7tw 7qr

(ES)
0044B158: an0 an0 an0 an0 an0 an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an0
          an0 an0 an0 an0 an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an0 an0
          an0 an0 an0 an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an0 an0 an0
          an0 an0 an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an0 an0 an0 an0
          an0 an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an0 an0 an0 an0 an0
          an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an0 an0 an0 an0 an0 an0
          an0 an1 an1 an1 an1 an1 an1 an1 an2 an2 an2 an2 an2 an2 an2


The changes not applied to the Mac version are as follows:

Code: Select all

D2game.dll

Akara gives 2 skill points insted of 1 for Den of Evil quest.
00067CF6: 01 -> 02

Akara gives a magic/rare small charm instead of a magic/rare ring for resquing Kain.
0006B49D: 72 69 6E -> 63 6D 31 (rin -> cm1)

Unknown change
0006B4AC: 04 -> 07

Cow King drops 8 D-Stones instead of 8 Stamina Potions at the first kill.
0006C2D8: 76 70 73 -> 70 70 70 (vps -> ppp)

Horadric Cube chest drops Ancient Decipherers instead of Cube.
00071352: 62 6F 78 -> 64 64 64 (box -> ddd)
00071412: 62 6F 78 -> 64 64 64 (box -> ddd)

Ormus gives a rare jewel instead of a rare ring for Gidbinn quest.
00079700: 72 69 6E -> 6A 77 6C (rin -> jwl)

Mephisto drops Ancient Decipherers instead of his soulstones.
0007CD1B: 6D 73 73 -> 64 64 64 (mss -> ddd)

Increased the number of items in the gamble window.
0009ADF3: 0E -> 19 (15 -> 25)

Code: Select all

D2common.dll

Carrying more gold in the inventory
00081DAC: 04 -> 07

Carrying more gold in the stash
00082671: 04 -> 06
For example, Akara's quest reward is stored as the code "rin", but no code "rin" is found in the Mac executable. Some other rewards like Hellforge runes are stored in the same format, so I wonder why they aren't.

Lastly I quote the PM about Akara's reward I sent to Hans on June 01, which can be some help for the discussion.
The windows codes for A1Q1 is discussed here.
viewtopic.php?t=30445&highlight=67cf6
Myhrginoc" wrote:It depends on what tool you are using. If you use a hex editor, you need file offsets, which are bytes starting at 00000000. If you are using a disassembler/debugger on a DLL in active memory, you need the memory offsets, which start at the DLL base loading address. For that you need a memory map, which the debugger can give you. (In Ollydbg, click on the blue 'E' button after attaching to a running game.)

Most D2 DLLs load in specific places, but the v1.10 D2Common.dll is too big for its assigned spot so it gets relocated. D2Mod.dll, PlugY.dll and most D2Mod plugin dlls are assigned the same default address so they get relocated too. Relocation means a memory offset must be figured from the actual load address, not from the default address seen in most messages here. And it will differ between sessions.

Let's say you want to edit the skill points you get from Akara for the Den of Evil quest. The quest code is in D2Game.dll, as shown in this thread.

Code: Select all

6FC97CF4   53               PUSH EBX 
6FC97CF5   6A 01            PUSH 1   <--- amount of reward 
6FC97CF7   6A 05            PUSH 5   <--- type of reward 
6FC97CF9   51               PUSH ECX 
6FC97CFA   E8 BB3B0800      CALL <JMP.&D2Common.#10518>
So you would edit the 01 at 6FC97CF6 to change the amount. The type is the stat ID from ItemStatCost.txt, and D2Common.#10518 is the function that adds a value to a stat. Using a hex editor? Convert to file offset by subtracting 6FC30000 (D2Game.dll base loading address from the memory map) from 6FC97CF6, this gets file offset 00067CF6. You should see the byte stream shown in the second column of the machine code listing:

00067CF0: xx xx xx xx 53 6A 01 6A 05 51 E8 BB 3B 08 00 xx xx

I highlighted the award byte here. (I didn't have the first four or last two bytes so I show them as "xx". Most hex editors show 16 bytes on a line.)

The Den of Evil award is a common code form, used for skill points per level-up and for many other quest rewards as shown in the survey thread. Just remember if a valshift exists for a stat (e.g. HP in Potion of Life award), apply it to your award number too. So +20 HP becomes 1400 instead of 14, because HP has valshift 8.
The characteristic pattern is "6A 01 6A 05", which stands for the x86 machine language;

PUSH 1
PUSH 5

(The command PUSH is 6A in hex in x86 machine language.)

So this part will also be like "XX 01 XX 05" in a Power PC program.

A mac expert may be able to tell which Power PC code is corresponding to PUSH. Or you can search "00 01 00 05", then "01 01 01 05", until "FF 01 FF 05".

I don't know about Power PC programming, but the corresponding code and/or the numbers may not be 1 byte long. Then the codes we're searching would be like;

"XX YY 01 XX YY 05" or
"XX 00 01 XX 00 01" or
"XX YY 00 01 XX YY 00 05"

which would be very difficult to find.
Last edited by tsuru on Sun Jun 17, 2007 6:23 am, edited 1 time in total.

User avatar
Necrolis
Senior Admin
Throne
Posts: 9125
Joined: Sat Mar 25, 2006 1:22 pm
Location: The Land of the Dead
South Africa

Hand-picked

Post by Necrolis » Sun Jun 17, 2007 6:35 am

that code will help alot, and thanks for posting the mac stuff. i'm going to see id i can find anything on power pc notation, but id i can't find anything we can use the above code as a reference point and see id we can figure out stuff from there as they should have the same funcs(we could also use known error assertions for this as well), as i said above they could reference line nos for items(like they do for mercs equipment), this can be checked by switching the ring lines in itemtypes and misc to something else and seeing what happens(if it crashes or changes its a line no). finally that unknown byte change looks like a quality shift from rare(4) to set or unique...
Image
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal

User avatar
Myhrginoc
Retired Admin
Cherub
Posts: 12100
Joined: Sat May 25, 2002 7:28 am
Location: Percussion U
United States of America

Hand-picked

Re: Mac Coding Quest

Post by Myhrginoc » Sun Jun 17, 2007 4:25 pm

You might have found what you need about Power PC assembly, in which case please skip the following.

I googled "Power PC" and "assembly language". The problem I see is the Power PC and the Intel x86 are not built to the same philosophy at all. In addition to endian-ness, the Power PC is a RISC processor, the x86 is not. The RISC idea is many fast instructions can outrun a few slow instructions. So the assembly we have posted will need to be devolved further. One particularly thorny translation will be how the stack is emulated in Mac coding, since from what I can tell the IBM chip has no microcoded stack handling instructions (e.g. PUSH, POP).

This is the IBM language reference. In the Intel world, the equivalent is this series of manuals, with Volumes 2A and 2B being the instruction set alone. (As both companies maintain internal Web departments, expect these links to get stale fast. Those people have to justify their existence...)
Do the right thing. It will gratify some people and astonish the rest.
~ Mark Twain
Run Diablo II in any version for mods: tutorial
The Terms of Service!! Know them, abide by them, and enjoy the forums at peace.
The Beginner's Guide v1.4: (MS Word | PDF) || Mod Running Scripts || TFW: Awakening

User avatar
Necrolis
Senior Admin
Throne
Posts: 9125
Joined: Sat Mar 25, 2006 1:22 pm
Location: The Land of the Dead
South Africa

Hand-picked

Post by Necrolis » Sun Jun 17, 2007 5:06 pm

those intel manauls are a hell of a thing to read(1400 odd pages gf memory serves) but are good reference, i hadn't done much on this today, so that link will come in handy... i'll start studying this tomorrow(what i'd be interested to know is if mac has certain bug fixes not in the x86 version and visa versa)
Image
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal

Return to “Mac Modding”