# DirectDraw Flow

Executable: `/home/exedev/hwanse/Hwanse2.exe`
Promotion status: `render-pipeline-grounded`

## Import And Entry

- `DirectDrawCreate` IAT: `0x005a0374`
- import thunk/wrapper: `0x00435d98`
- call sites: `0x00415602`, `0x00415618`
- output global: `0x004676c0`
- mode/window globals: display mode `0x004676ec`, hwnd `0x004676f0`, flags `0x004676d4`

The two call sites pass either device selector `0` or `2` based on the graphics flag at `0x004676d4`, then store the created `IDirectDraw*` in `0x004676c0`.

## Display Mode

- target mode: `640x480x8`
- `SetDisplayMode` call: `0x004156c8`

| call | method | notes |
| --- | --- | --- |
| `0x00415660` | `SetCooperativeLevel` | flags 0x00000008 |
| `0x0041568d` | `SetCooperativeLevel` | flags 0x00000011 |
| `0x004156c8` | `SetDisplayMode` | 640x480x8 |

## Surfaces

Surface wrappers are indexed from `0x0055abd8`. The initialization path creates a primary/front wrapper, an offscreen/back wrapper, and in fullscreen flip mode an attached backbuffer wrapper.

| slot | wrapper | role |
| ---: | --- | --- |
| 0 | `0x0055abd8` | primary/front surface wrapper |
| 1 | `0x0055abdc` | offscreen/back surface wrapper |
| 191 | `0x0055aed4` | attached backbuffer wrapper |

| call | method | role | notes |
| --- | --- | --- | --- |
| `0x00415766` | `CreateSurface` | primary flipping surface candidate | DDSD_CAPS|DDSD_BACKBUFFERCOUNT, caps 0x218 |
| `0x0041579d` | `CreateSurface` | simple primary surface candidate | DDSD_CAPS, caps 0x200 |
| `0x004158d1` | `CreateSurface` | offscreen 640x480 surface candidate | DDSD_CAPS|HEIGHT|WIDTH, caps include 0x40 |
| `0x00415a0f` | `CreateSurface` | offscreen 640x480 surface candidate | DDSD_CAPS|HEIGHT|WIDTH, caps include 0x40 |

## Palette

The palette buffer at `0x004676e4` stores a 256-entry DirectDraw palette; the raw entries start at `0x004676e8`.

| call | method | role | notes |
| --- | --- | --- | --- |
| `0x0041652e` | `CreatePalette` | palette creation | 256-entry palette buffer |
| `0x00416555` | `SetPalette` | primary SetPalette | palette 0x004676c4 |
| `0x00416606` | `SetPalette` | refresh primary SetPalette | palette 0x004676c4 |
| `0x00416649` | `SetEntries` | SetEntries | writes changed palette range |
| `0x00416708` | `SetEntries` | SetEntries | writes changed palette range |
| `0x00416856` | `GetEntries` | GetEntries | reads palette range |

## Presentation

- classification: `directdraw-640x480x8-paletted-surfaces`
- flip calls: `0x0041769b`
- blt calls: `0x00417722`, `0x0041784b`, `0x00417938`, `0x00417b4b`, `0x00417b8a`, `0x00417bdf`
- implication: The web runtime should preserve 640x480 indexed-image assumptions, then present through canvas scaling rather than inventing a higher-resolution native layout.

## Verification

| check | value |
| --- | --- |
| `directDrawCreateImportMatches` | `True` |
| `directDrawCreateCallsReachWrapper` | `True` |
| `directDrawOutputGlobalMatches` | `True` |
| `hardwareDeviceBranchPushes2` | `True` |
| `displayModeIs640x480x8` | `True` |
| `paletteHeaderIs256Entries` | `True` |
| `allKnownVtableOffsetsMatch` | `True` |
| `createSurfaceCallCountAtLeast4` | `True` |
| `presentationHasFlipAndBlt` | `True` |

## Open Questions

- Exact draw-order and dirty-rectangle rules still require deeper renderer tracing.
- The static vtable labels assume DirectDraw 1 era COM layouts, which match the import shape but are not symbol names from the binary.
- Event and route promotion are not affected by this report.