A native Windows port to C of Army Men II (The 3DO Company, 1999), made by statically recompiling the original game with pcrecomp. Unofficial; not affiliated with or endorsed by Take-Two Interactive, 2K Games or The 3DO Company. "Army Men" is Take-Two's trademark and is used here only to say which game this is.
This repository contains no game code and no game data. You supply your own copy of the game; the
setup script lifts your ArmyMen2.exe to C on your PC and builds it with the host in src/host. The
original 1999 code, lifted to C, runs natively, as a normal program on 64-bit Windows. The host adds:
- its own DirectDraw and a Direct3D 11 presenter, in a resizable window;
- a mouse that follows the Windows pointer;
- a HUD that scales separately from the battlefield;
- a battlefield that fills the window, however big, with zoom (+/- buttons on a keyboard).
Tested with three editions of the game: the original English retail CD, the Russian edition (GSC, WebColl) and the GOG release. Multiplayer is only in the disc builds (see "Multiplayer"); GOG and Steam have none.
Status: version 1.0. Menus, missions and, on the disc builds, LAN games work on the tested editions. Not yet checked: real 4K displays, very small maps, every mission dialog. What was measured: NOTES.md. The resolution plan: docs/R_hires.md.
- Bring your own copy. The input is your own copy of the game: the retail disc's files (copied
from the disc or from a mounted image), or a GOG or Steam install.
game/is a local working copy of that folder, because the game writesOptions.cfgand its saves into its working folder. It is gitignored and never shared. - The lifted C never leaves your machine. It is a derivative of the original program, so
src/recomp/gen/,work/and every build output are gitignored, and nothing built from them is ever distributed. Please don't share them or ask for them. - No copy protection is bypassed. The lift is of the exe as it shipped. On the retail disc build the CD check runs when SINGLE PLAYER or BOOT CAMP is chosen and wants the disc (or a mounted image of it) in a drive. pcrecomp's DRM tools are not used, and an exe wrapped in Steam's DRM is refused.
- Run
audit_repo.pybefore anything is shared.python third_party/pcrecomp/tools/audit_repo.py .must report clean.
The code and documents in this repository (src/host, scripts, docs, the .bat files) are under
the MIT licence, see LICENSE. That covers this repository only: it grants nothing in Army Men II,
which belongs to its rights holders, nor in pcrecomp or cnc-ddraw (both MIT, their own licences apply).
On https://github.com/prcd001/plasticrecomp press Code > Download ZIP and unpack it into a folder you can write to
(for example C:\plasticrecomp), or, if you use Git: git clone https://github.com/prcd001/plasticrecomp. Then read on.
- Windows 10 or 11, 64-bit. (Army Men II is a 32-bit program, so the lifted game and its host are built as 32-bit; Windows runs those out of the box, nothing to install.)
- Python 3, installed once by hand (3.11 is the tested one; tick "Add python.exe to PATH").
Nothing else: no Git (download this repository as a ZIP) and no PowerShell 7 (
Setup.batuses the Windows PowerShell that every Windows 10 and 11 has). - The C++ compiler, Build Tools for Visual Studio 2022 ("Desktop development
with C++"):
Setup.batoffers to install it when it is missing (Microsoft's installer, its signature checked; about 3 GB, 10 to 30 minutes, Windows asks for administrator approval). Already installed is found automatically (VCVARS32can point at anothervcvars32.bat). - Your own copy of Army Men II (see Rules).
- The third-party pieces are not in this repository (
third_party/and.venvare gitignored).Setup.batfetches them for you on its first run: pcrecomp (GitHub's zip of the commit pinned inNOTES.md), cnc-ddraw v7.1.0.0 (downloaded from its GitHub release and checked against the SHA-256 inNOTES.md) and a.venvwith the lifter's two packages (capstone,pefile).scripts\setup.ps1 -NoFetchdownloads nothing: put them in place by hand (unpack the pinned commit's zip,https://github.com/sp00nznet/pcrecomp/archive/<commit>.zip, so that its folder isthird_party/pcrecomp, unpackcnc-ddraw.zipintothird_party/cnc-ddraw/v7.1.0.0/,py -3.11 -m venv .venv, then.venv\Scripts\pip install capstone pefile).
| path | what | in git |
|---|---|---|
src/host/main.c |
the host: maps the guest at 0x00400000 and runs it on pcrecomp's native32; import shims, options, diagnostics | yes |
src/host/vddraw.c |
the virtual DirectDraw (COM objects, DIB-section surfaces), the window, the presenter thread and the HUD/battlefield layout | yes |
src/host/present.c |
the D3D11 presenter: palette lookup in the shader, nearest/sharp-bilinear, area average when a region is shrunk (zoom below 1x), regions at different scales | yes |
src/host/hires.c |
step 4: host wrappers that run in front of lifted functions (map load, HUD create, panel update, HudPaint, cursor draw, edge scroll, state requests) and make the battlefield as big as the window: the game's screen geometry, zoom, the HUD column | yes |
src/host/config.c |
plastic.ini: read at start, written on exit |
yes |
src/host/mouse.c |
the game's DirectInput mouse, fed from the Windows cursor | yes |
scripts/ |
lift (run_lift.py), setup for disc/GOG/Steam owners (setup.ps1), host build, presenter test, run, screenshot, key and hashing tools, the unattended Boot Camp run (auto_bootcamp.ps1, compare_shots.py) |
yes |
docs/ |
R_hires.md (resolution research and plan), R_step4_plan.md, R_features.md and the other design notes |
yes |
third_party/pcrecomp/ |
pcrecomp checkout (MIT), commit in NOTES.md |
no |
third_party/cnc-ddraw/ |
cnc-ddraw v7.1.0.0 (MIT), used only with --cnc-ddraw |
no |
src/recomp/gen/, work/, build/ |
lifted C, analysis output, objects and the host exe | no |
game/ |
working copy of the disc's files | no |
- First time: install Python (see "What you need"), then double-click
Setup.bat. It asks for the folder with your ownArmyMen2.exe(the disc's drive letter such asE:\is fine, or a copy or an install; Enter alone looks for GOG and Steam) and runsscripts\setup.ps1: it fetches the third-party pieces, copies the game, lifts it and builds the host. Expect several minutes. - Every time after: double-click
Play.bat. It checks the build and the game folder, refuses a second copy, starts the game and keeps the output inbuild\last_run.log. Options pass through:Play.bat --fullscreen. - The retail disc build wants the disc (or a mounted image of it) when you pick SINGLE PLAYER or BOOT CAMP.
Open an issue on GitHub and say which edition you use (English CD, Russian, GOG or Steam), what you did and what happened. Attach
build\last_run.log (Play.bat writes it on every run). Please do not attach game files, the lifted C or screenshots of the game
(see "Rules").
From the repository root, in PowerShell:
.venv\Scripts\python.exe scripts\run_lift.py game\ArmyMen2.exe src\recomp\gen --report work\table_arms.json
cmd /c scripts\build_host.bat
cmd /c "build\plasticrecomp.exe --game game > build\user_run.log 2>&1"- Don't relink while the game runs. Windows locks a running exe, so
build_host.batfails to link while the game is open. - Only one copy at a time. The game allows a single copy (its mutex
ArmyMenMutex), and the host says so if one is already running. - First-time setup for any owner (disc, GOG or Steam):
powershell -File scripts\setup.ps1 -From <game folder>. It fetches pcrecomp, cnc-ddraw and the.venvwhen they are missing, copies the game intogame\, puts cnc-ddraw in place, lifts that exe and builds the host. Without-Fromit looks up GOG's and Steam's install records. Pass-Fromto choose the copy yourself. scripts/run_lift.pyis pcrecomp's default pipeline plus the jump-table arms it misses. Plainpython -m toolsoutput crashes in memmove. It also records which exe it lifted (recomp_target.h), and the host refuses to run any other. It also renames the lifted definitions of the functions the host wraps (WRAPin the script: map load, HUD create, HudPaint, cursor draw, edge scroll, state request, the camera) tosub_X_liftedand writesrecomp_wrap.h(their split entries), whichsrc/host/hires.cuses: re-lift after pulling.
| key | what |
|---|---|
| Shift+Plus / Shift+Minus | in a mission: HUD smaller / larger, in half steps from 1x up to the window's fit size |
| Plus / Minus | in a mission: battlefield zoom in / out through 0.25x, 0.5x, 1x, 1.5x, 2x, 3x, 4x (1x: one game pixel is one screen pixel, so a 1080p window shows 1920x1050 pixels of map; 0.5x shows four times the map, in a 3840x2160 view that the presenter shrinks to the window). The view never exceeds 3840x2160 (the surfaces' size) or the map, so a window can show 0.5x at most on 1080p (3840x2160 = 2 x 1920x1080): there 0.25x asks for more than there is room for, and the zoom is raised in both directions to what fits (a 1280x960 window: 0.44x, a 2560x1440 one: 0.67x), so the window stays filled. The title bar names the zoom you really get (window / view) for 2 s, and F3's line carries it with the view's size. A step that would show the same zoom as the present one is skipped (Minus on a 1080p window at 0.5x says "furthest out" and does nothing), so no key press is dead. Zooming out shrinks the game's pointer along with the map (it is drawn into the battlefield): at 0.25x it is a few pixels |
| Escape | as in the original (skips movies, opens the mission menu). The mission's own screens (game menu, audio, controls, save, load, the HQ message, the instruction sheet and F1's map) are shown as the 640x480 picture they are built for, centred at the HUD's scale (Shift+Plus / Minus) over the battlefield as it was when they opened, filling the window at the zoom in play with the HUD around it. Small ones (the menu, the HQ box, the sheet) leave the world visible around their widgets; the full-screen ones (Controls, Audio, F1's map) dim it. The pointer works over the whole window and is held to the picture |
| F12 (Shift+F12 backwards) | scaling mode, for the battlefield and the HUD alike: sharp-bilinear (default), nearest (whole-number scales only: the 640x480 picture of the menus, movies and dialogs and the HUD at the largest whole multiple that fits, black bars for the rest; the battlefield at a whole zoom (1x, 2x, 3x, 4x) in whole-pixel steps, up to zoom-1 black pixels at a window edge; the 1.5x zoom and a capped view stay smooth fit), smooth bilinear, scanlines (sharp-bilinear with each source row dimmed towards its edges; visible from 2x scale up). The title bar names the mode for 2 s |
| F8 | mouse confine on / off: in a mission, the Windows cursor is kept inside the window's client area (ClipCursor). It is let go in the menus, in the mission's dialogs (game menu, audio, controls, the sheet), when the window loses the foreground (Alt-Tab, a click elsewhere), when minimised, and when the game ends. On by default; the title bar says "Mouse confine on/off" |
| F9 | edge scrolling on / off. Off: the game's cursor is held 4 px inside its clamp rectangle, where the edge scroll (3 px) cannot fire, so the map scrolls only by the minimap and by following Sarge (the game has no keyboard scrolling). On by default |
| F11, Alt+Enter | borderless fullscreen on the window's monitor and back; leaving restores the window's rect (maximised or not). The battlefield re-fits the new size |
| F3 | FPS readout in the title bar: presenter fps, frame time (average, max), the game loop's rate and, in a mission, the effective zoom and the view's size. (Borderless fullscreen has no title bar, so the notices and this line are not visible there) |
| F10, PrintScreen | screenshot: a PNG of the picture as presented (palette lookup and scaling done, window-sized) in game\screenshots\plastic_<date>_<time>.png; the title bar names the file |
The host's keys never reach the game: they are cleared from the DirectInput keyboard state the game reads
(src/host/mouse.c, swallow_host_keys). The game's own keys are DIK 1 (Escape), 2..9, 0x0F (Tab), 0x1C
(Enter), 0x1D, 0x2A, 0x36, 0x39 (Space), 0x3B (F1), the arrows, and the bindings in game\Options.cfg
(shipped: W S A D Q E C F, Alt, Space, Shift, Tab, ` X, R G T Y H, Backspace, F1, Esc; the Controls screen lets
the player rebind). No shipped binding or fixed key collides with F3, F8, F10, F11, F12, PrintScreen, Plus or
Minus, so nothing is lost, but those keys cannot be bound in the Controls screen. Alt+Enter hides its Enter
(Alt stays, it is WALK). Plus and Minus (also Shift+, and the numpad's) are the host's only while no text field has
the focus (chat, names, save names) and no mission dialog is up, so they can be typed and bound there.
| option | what |
|---|---|
--game DIR |
the game folder (default game) |
--log FILE |
write the host's stdout and stderr to FILE (and let go of the console it was started in, so start "" plasticrecomp.exe --log FILE leaves no terminal window; Play.bat does this, log in build\last_run.log). The cmd /c "... > log 2>&1" way still works |
--watchdog S |
report where the guest is after S seconds, then end the run |
--dry |
map and bind only |
--cnc-ddraw |
draw through the game folder's ddraw.dll (cnc-ddraw) instead of the host's virtual DirectDraw and D3D11 presenter |
--multicore |
don't pin the process to one CPU core (movies then stall at random frames: smackw32's audio races) |
--raw-mouse |
the game gets DirectInput's raw mouse counts, as in 1999 (default: it follows the Windows cursor) |
--mouse-log |
log the game's mouse device calls and each cursor correction |
--movie-log |
every 2 s: movie frames decoded, SmackWait go/hold, frames presented, foreground |
--hires-log |
every 2 s in a mission: view size, zoom, game frame time (Flip to Flip), presenter fps, the camera's eye (0x514E0C), the mission state; and a limits line: row pools A (decals, cap 450) and B (troopers, vehicles, roaches, cap 90) with their evictions, SEQ evictions, the depth list's peak (500) and the dirty list's (500), the object table |
--dd-trace |
log the virtual DirectDraw's surfaces and window messages |
--imports |
with --watchdog: where each USER32/GDI32/DINPUT import slot really points |
--no-route |
with --cnc-ddraw: leave USER32 as native32 bound it, skipping cnc-ddraw's hooks |
--route-gdi |
with --cnc-ddraw: also route GDI32 (breaks movie colours; for experiments) |
--native-trace, --callbacks |
native32's per-call traces (huge) |
--dplay-check |
create the game's DirectPlay object and list its connections, then exit |
--fullscreen, --windowed |
start in borderless fullscreen / in a window (overrides plastic.ini) |
--scaling MODE, --vsync 0|1 |
start with that scaling mode (sharp, nearest, smooth, scanlines) / vsync (overrides plastic.ini) |
--ini FILE, --no-ini |
use that settings file / neither read nor write one |
Not available from a GOG or Steam install: multiplayer was cut from the 2017 re-release (GOG's; Steam's store page lists "Single-player" only and says "Multiplayer is not supported"), so the game's menu has no network game there. Multiplayer needs the retail disc build (English or Russian).
The game's network play (LAN, TCP/IP) goes through Windows' legacy DirectPlay and works with the host's own DirectDraw; it was tested between two PCs on a LAN (lobby, deployment screen, mission, ESC / ABORT).
- Both PCs need the DirectPlay Windows feature:
Enable-WindowsOptionalFeature -Online -FeatureName DirectPlay -Allin an admin PowerShell (plasticrecomp.exe --dplay-checksays whether it is there). - Both PCs run the same build of the host and the lifted game, and the firewall must let
plasticrecomp.exethrough. - DirectPlay does not cross NAT: over the internet, put the players on a virtual LAN (Tailscale, ZeroTier, Radmin VPN, Hamachi).
- Windows names the connections in the system's language; the host shows the original English names.
PLASTIC_DPNAMES=0leaves them as Windows gives them. PLASTIC_MULTI=1lets a second copy run on one PC (the game normally allows one). Give each copy its own--gamefolder and--ini, and join over127.0.0.1.- During the deployment phase the game shows its classic 640x480 layout; the high-resolution view returns when the mission starts.
Settings that persist, read at start and written when the game exits (a run that is killed writes
nothing). The host looks for plastic.ini next to plasticrecomp.exe first, then in the game folder,
and writes back to the file it read (or next to the exe if there was none). key = value lines; # or
; start a comment; unknown keys are ignored and kept.
zoom_x = 1 # battlefield zoom as a value: 0.25 0.5 1 1.5 2 3 4 (the nearest step)
zoom = 0 # the older builds' index (0..4 = 1x 1.5x 2x 3x 4x), kept for them; read only when zoom_x is absent
ui_scale = 0 # HUD scale in half steps (2 = 1x, 3 = 1.5x ...); 0 = follows the window
scaling = sharp-bilinear # nearest | sharp-bilinear | smooth | scanlines (or 0..3)
fullscreen = 0 # borderless fullscreen
hires = 1 # 0: the battlefield stays 640x480 as in the original
vsync = 1 # 0: Present does not wait for the vertical blank (the 60 fps cap stays)
confine = 1 # F8: keep the mouse in the window while a mission is played
edge_scroll = 1 # F9: scroll the map when the mouse is at the window's edge
game_fps = 60 # the game thread's pace in Flips a second (0 = unlimited: vehicles then cannot drive, see docs/R_step4_plan.md section 14)For one run, environment variables override the file (PLASTIC_ZOOM, PLASTIC_UI_HALVES, PLASTIC_HIRES,
PLASTIC_SCALING, PLASTIC_FULLSCREEN, PLASTIC_VSYNC, PLASTIC_CONFINE, PLASTIC_EDGE_SCROLL, PLASTIC_GAME_FPS), and command-line flags override both.
Test switches (environment variables, for diagnosis only):
PLASTIC_HIRES=0: the battlefield stays 640x480 as in the original (the old layout;1turns the feature on).PLASTIC_ZOOM=z: the first zoom, a value (0.25, 0.5, 1, 1.5, 2, 3, 4; the nearest step; it was an index 0..4 before the zoom-out steps).PLASTIC_DUMP_LOAD=dir: while a mission loads, write the presented frame asdir\load_n_WxH_stateS.bmpevery 100 ms.PLASTIC_FORCE_LAYOUT=1: the mission layout applies everywhere.PLASTIC_UI_HALVES=n: preset the UI scale to n/2.PLASTIC_NO_PRESENT=1,PLASTIC_NO_SUBCLASS=1,PLASTIC_NO_RESTYLE=1,PLASTIC_NO_DPI=1: switch one piece of the virtual path off.PLASTIC_PRESENT_WARP=1,PLASTIC_PRESENT_BLT=1: presenter fallbacks.PLASTIC_PRESENTER_PRIO=0: the presenter thread keeps normal priority (default: one step above, so it preempts the game on their shared core and holds 60 fps while the game loop spins at ~2900 Flips/s; with normal priority it fell to ~30 fps while the camera scrolled).PLASTIC_FLIP_SLEEP=ms: the game thread sleeps that long after each Flip (a throttle; off).HOST_ONLY=1 cmd /c scripts\build_host.bat: rebuild only the host files, reusing the lifted C's objects.PLASTIC_LOGICAL_PROBE=WxH: once the game has made its world surface, set the primary, back buffer and world surface's logical size to W x H (within the capacity), to check that menus, movies and the HUD still show the 640x480 picture.PLASTIC_CAP=WxH: the largest battlefield is W x H (at least 640x480, at most 3840x2160, the default whatever the monitor: the zoom-out steps need it even on a 1080p screen; the surfaces are made for that, the window keeps its size).PLASTIC_VIEW=WxH: size the battlefield as if the window's client area were W x H (the presenter then scales it into the real window). Together they run a 4K view on any PC:PLASTIC_CAP=3840x2160 PLASTIC_VIEW=3840x2160.PLASTIC_DUMP_VIEW=dir: F10 / PrintScreen also write the battlefield as the game drew it, 1:1, todir\view_<n>_<w>x<h>.bmp(a window cannot be bigger than the monitor, so this is how a 4K view is looked at).PLASTIC_LOG_DRAWOBJ=1: log the first 200DrawMapObjectscalls (the region, its recursion level).PLASTIC_NO_DRAWFIX=1: leave the game's own splitting of a crowded region as it is (see "Limits" indocs/R_step4_plan.md).PLASTIC_OBJDUMP=dirwithPLASTIC_OBJDUMP_AT="t1,t2"(host seconds): dumps the game's object table and trig tables to dir;PLASTIC_OBJTRACE="id,from,to": logs one unit's state every 50 ms (section 14).PLASTIC_DUMP_CORNER=dir: while a mission dialog is up, its 640x480 picture as the game drew it (the see-through pixels magenta) goes todir\corner_<n>.bmpabout every 0.7 s (at most 80).PLASTIC_BLT_STRETCH=1: a Blt between rectangles of different sizes stretches again, as DirectDraw does (default: a 1:1 copy of the smaller, see "Pointer smear" indocs/R_step4_plan.mdsection 11).PLASTIC_SCRIPT="t:x,y[,click];...": drives the game's cursor with no real mouse. From the first step whose timet(seconds since the host process started) has passed, the cursor target is game pixel x,y (the game's frame: 640x480 in menus; in a mission with the hires layout the frame is bigger, the battlefield at 0,21), whichever window has the foreground.t:@x,yis a window client pixel instead, mapped as the Windows cursor would be (negative: from the right / bottom edge, so@-1,500is the right edge and exercises the edge snapping). With,clicka left click (button 0 down, then up on the next poll) follows once the cursor has arrived;,rclickis the right button. A timetis seconds since the host process started, or relative to the mission's modal screens:s24+1is 1 s after the mission's sub-state 24 (0x00511DBC; Boot Camp's HQ box) was first seen,s22+3after 22 (the instruction sheet, F1's map),s23the game menu,s27audio,s28controls,g+Nafter 33 (play; seen first at the load, so rather use the state of the last dialog). The sub-states are cleared by each map load, and an event whose state has not come yet waits (a script is ordered), which makes a run independent of how long the load took.PLASTIC_KEYS="t:KEY;...": holds a DirectInput key down for 3 keyboard polls from timet.KEYis a DIK scancode (decimal or0x..) or ESC, ENTER, SPACE, MINUS, EQUALS, F1, P. ESC skips the intro movies. ZOOMIN / ZOOMOUT are no keys: they step the battlefield zoom once, like Plus / Minus in the window.
Unattended test run (the author's setup: needs the disc image mounted at H: and no plasticrecomp.exe running):
pwsh scripts\auto_bootcamp.ps1 -Tag before -Duration 80 -Shots 12,28,40,60,75
python scripts\compare_shots.py before after # Pillow; compares build\screens\before_*s.png with after_*s.pngscripts\auto_bootcamp.ps1 starts the game with a watchdog, skips the movies (ESC at 6 s and 20 s),
clicks BOOT CAMP (game pixel 307,142), clicks OK on the "Welcome to Boot Camp!" box (478,225), closes
the instruction sheet with Space, parks the pointer, takes screenshots at the -Shots times into
build\screens\<Tag>_<time>s.png, and kills the game at -Duration. The mission is on screen about 35 s
after launch. Two runs of the same build give pixel-identical screenshots, apart from a few animated pixels.
This project stands on other people's work, and thanks go to them:
- sp00nznet for pcrecomp (MIT): the recompilation toolkit and the 32-bit native runtime this whole host is built on. Without it there would be no project.
- FunkyFr3sh and the cnc-ddraw contributors for cnc-ddraw
(MIT): the DirectDraw wrapper that carried the early work and still serves the
--cnc-ddrawpath. Setup downloads it from their release. - borancar for the inspiration.
- The authors of Capstone (Nguyen Anh Quynh and contributors, BSD) and pefile (Ero Carrera, MIT), the two Python packages the lifter uses; setup installs both.
- The Wine project, whose
dplay.hwas the check for the DirectPlay interface layout used by--dplay-check. - The developers of Army Men II at The 3DO Company, for the game itself. This project only helps it run on a modern PC; the game and its art remain theirs and their rights holders'.
All of these keep their own licences, which apply to their own code (see "Licence").