I worked on SCR's emulator and I am glad the community liked it so far. It was a long task but we finally achieved a high level of success.
The EUD emulator also works on Mac OS now. It does lots of house keeping because it is not possible to do a simple pass-thru or forwarding emulation.
* A note about partial values
The EUD triggers do not provide primitives such as: "A = B" and hence the epScript compiler generates a bunch of triggers to do a binary search on the desired value and construct its value in parts.
When the emulator detects such access to pointer fields, it will start buffering the changes (because pointers are incomplete) until the changed pointer value (in the emulator's view) correspond to an actual in-game pointer of the same type.
This approach works most of the times and is used a lot in the CUnit emulation.
* CUnit
The following are the supported fields
Quote
// 0x000
// 0x004
// 0x008
// 0x00C
// 0x010
// 0x014
// 0x020
// 0x024
// 0x028
// 0x02C
// 0x030
// 0x034
// 0x038
// 0x03C
// 0x040
// 0x044
// 0x048
// 0x04C
// 0x050
// 0x054
// 0x058
// 0x05C
// 0x060
// 0x064
// 0x068
// 0x06C
// 0x070
// 0x07C
// 0x080
// 0x084
// 0x08C
// 0x090
// 0x094
// 0x098
// 0x09C
// 0x0A0
// 0x0A4
// 0x0A8
// 0x0AC
// 0x0C0
// 0x0C4
// 0x0C8
// 0x0CC
// 0x0D0
// 0x0D4
// 0x0D8
// 0x0DC
// 0x0F8
// 0x0FC
// 0x104
// 0x110
// 0x114
// 0x118
// 0x11C
// 0x120
// 0x124
// 0x14C
// 0x004
// 0x008
// 0x00C
// 0x010
// 0x014
// 0x020
// 0x024
// 0x028
// 0x02C
// 0x030
// 0x034
// 0x038
// 0x03C
// 0x040
// 0x044
// 0x048
// 0x04C
// 0x050
// 0x054
// 0x058
// 0x05C
// 0x060
// 0x064
// 0x068
// 0x06C
// 0x070
// 0x07C
// 0x080
// 0x084
// 0x08C
// 0x090
// 0x094
// 0x098
// 0x09C
// 0x0A0
// 0x0A4
// 0x0A8
// 0x0AC
// 0x0C0
// 0x0C4
// 0x0C8
// 0x0CC
// 0x0D0
// 0x0D4
// 0x0D8
// 0x0DC
// 0x0F8
// 0x0FC
// 0x104
// 0x110
// 0x114
// 0x118
// 0x11C
// 0x120
// 0x124
// 0x14C
* Unit selection array
It is possible to read/write to the unit selection array. The only allowed values that will take effect in the real game are proper CUnit pointer values.
Any incomplete values remain visible to the emulator alone and not the game.
* AI scripts
Both AIScripts and AIScripts2 (BW) are supported.
You cannot change the AI pointer script but you can overwrite whatever it points to. The original AI script was around 40kb. I noticed some EUD maps write more than the original allocate size, therefore the emulator now allocates extra 0x6000 bytes for custom AI scripts.
* CSprite
It is possible to change offsets 0, 4 and 8 only. Writing anything else will result in an EUD error.
The values that can be written should be valid pointers in to the sgUnitsMem array.
* CImage array
Regarding the CImage array, at the time being, it is a no-operation dummy buffer. The CImage array is present so that the games work. No graphical changes can take place.
* MPQ frozen maps
Regarding MPQ frozen maps: the emulator supports the MPQ freeze feature by trgk. It exposes just enough Storm data structures to let the EUD map retrieve the dynamic triggers decryption keys.
* Strings chunk / table
It is not possible to change the real pointer value of the strings chunk. Map makers write to it and what not but it does not have effect in the game.
The strings in that table are also initialized once and any changes to the strings values are not reflected.
What is important to note though that anything after the end of the string table (but still within the strings chunk) is readable and writable. Only EUD maps are aware of the data in the strings chunk (beyond the string table).
The strings chunk emulation is what allow the compiled maps (epScript) to work.
* Cards and buttons
Cards and buttons are re-written when the emulator detect changes from the EUD map. The button changes are reflected after all the triggers have executed.
By re-writing the cards/buttons, we allow the map makers to create more buttons than originally was possible. The map makers can change the pBtn pointer in the card structure to point to any memory address that is EUD accessible
* Palettes and bitmaps
Most GFX elements are also a NOP. The static buffers are initialized to zero. The dynamic buffers are allocated in the emulator and have the original sizes as 1.16.1 but read/write do nothing.
* Dialogs and Controls
There are lots of TCtrl static pointers in SC 1.16.1. From the emulator's perspective, most of those pointers are initialized with NULL.
Map makers should test for NULL and not blindly derefence those controls pointers.
Changing controls is not allowed in the emulator.
* Wireframes
Wireframes are partially supported. There are 3 wireframes supported: trans wire, mulsel wire and stat wire.
The emulator provides the same original data as SC 1.16.1 and lets the EUD map change the GROUP and FRAME information as they please, however:
- If the wires are dirty, after all the triggers execute, the emulator will proceed and rebuild the wire data
- Providing new wire FRAME data is not supported
- Shuffling FRAME data is supported -> An EUD map can duplicate wire frames for 10 units for instance. As long as the FRAME checksum is one of the checksums of the old SC 1.16.1 frames, then the emulator will allow duplication or reshuffling of the frames.
These limitations exist because SCR does not have the same FRAME format no longer.
* Stat Text
Stat text is emulated as well. You can only change the buffer pointed to by the static pointer. Changing the pointer itself is not supported.
When changes to stat text are detected, the custom hotkeys profile will be disabled and the hotkeys specified in the stat text strings will be effective.
* Other addresses
There are lots of data structures in SC 1.16.1 that no longer exist or make sense in SCR. For convenience, the emulator provides such data structures as empty NOP buffers (think /dev/null).
There are some maps that for some reason (checking SC's version by code byte checks?) read the code section of SC. For such maps to work, I have a bunch of supported code locations that are allowed to be read from the emulator.
The emulator will serve the same exact bytes as SC 1.16.1. Writing to code locations is a NOP.
* Storm
Storm also contains lots of data structures. Unfortunately, Storm has changed alot in SCR and no longer mirrors the old game. There's very limited support in the emulator when it comes to doing Storm changes.
For instance, some maps try to access the MPQ archive list in memory and what not. That is supported just enough for MPQ freeze to work and nothing else.
* Final notes
The EUD emulator has be re-written twice so far and the second re-write is much elegant than the first internal version.
Please keep in mind that supporting all EUD aspects of 1.16.1 is a big task and that's why it is limited for now.
Next year's SCR patch will feature all of the stuff I described above. The current patch is still limited.
If you have specific questions, please ask them in this thread.
If you find a problem, please provide exact details on how to reproduce the issue (screenshots, GIF files with illustration/steps, test maps, etc).
None.