|
| 1 | +# System Architecture |
| 2 | + |
| 3 | +## Class Diagram |
| 4 | + |
| 5 | +``` |
| 6 | +blupi.cpp ← Win32 WinMain, main message loop, global state |
| 7 | + │ |
| 8 | + ├─ CEvent ← Phase manager, input router, toolbar, demo rec/play |
| 9 | + │ ├─ CButton[] ← Toolbar buttons (up to 40) |
| 10 | + │ ├─ CJauge[] ← HUD gauges (energy, progress) |
| 11 | + │ └─ CMenu ← Context-action popup menu |
| 12 | + │ |
| 13 | + ├─ CDecor ← Game world: grid, characters, animations, I/O |
| 14 | + │ ├─ Cellule[100][100] ← World tile grid |
| 15 | + │ ├─ Blupi[100] ← Characters (player + enemies) |
| 16 | + │ ├─ Move[100] ← Animated decoration elements |
| 17 | + │ ├─ arrange.cpp ← Auto-tiling |
| 18 | + │ ├─ obstacle.cpp ← Passability / pathfinding helpers |
| 19 | + │ ├─ decblupi.cpp ← Character lifecycle & goal interpreter |
| 20 | + │ ├─ decmove.cpp ← Animated decoration steps & fire spread |
| 21 | + │ ├─ decio.cpp ← Save/load world files |
| 22 | + │ ├─ decmap.cpp ← Minimap |
| 23 | + │ ├─ decstat.cpp ← Statistics panel |
| 24 | + │ ├─ chemin.cpp ← A* pathfinding (CPileTriee) |
| 25 | + │ └─ decor.cpp ← Rendering, coordinate transforms, undo |
| 26 | + │ |
| 27 | + ├─ CPixmap ← DirectDraw sprite renderer (image channels) |
| 28 | + ├─ CSound ← DirectSound audio manager (WAV + MIDI) |
| 29 | + └─ CMovie ← MCI AVI video player (cinematics) |
| 30 | +``` |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## Single Tick Lifecycle |
| 35 | + |
| 36 | +``` |
| 37 | +WM_TIMER (every 50 ms) |
| 38 | + │ |
| 39 | + ├─ CDecor::BlupiStep(bFirst=FALSE) |
| 40 | + │ for each rank 0..MAXBLUPI-1: |
| 41 | + │ BlupiNextAction(rank) ← animation step, icon update |
| 42 | + │ BlupiNextGoal(rank) ← advance GOAL_* sequence |
| 43 | + │ BlupiPushFog(rank) ← fog of war update |
| 44 | + │ |
| 45 | + ├─ CDecor::MoveStep(bFirst=FALSE) |
| 46 | + │ for each slot 0..MAXMOVE-1: |
| 47 | + │ advance decoration animation, fire spread |
| 48 | + │ |
| 49 | + ├─ CDecor::StatisticUpdate() ← recalculate stats (if m_bStatRecalc) |
| 50 | + │ |
| 51 | + └─ redraw scene |
| 52 | + BuildGround(clip) ← floor layer |
| 53 | + BuildMoveObject(…) ← object layer (lower) |
| 54 | + BlupiDrawHili() ← selection highlight |
| 55 | + BuildMoveObject(…) ← object layer (upper overlay) |
| 56 | + StatisticDraw() ← statistics panel |
| 57 | + minimap draw ← minimap |
| 58 | + HUD draw ← gauges, buttons, text |
| 59 | +``` |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +## Subsystem Dependencies |
| 64 | + |
| 65 | +``` |
| 66 | +CEvent ─────────────────────→ CDecor (owns instance) |
| 67 | + │ │ |
| 68 | + │ ├─ CSound* (shared reference) |
| 69 | + │ └─ CPixmap* (shared reference) |
| 70 | + │ |
| 71 | + ├─ CSound* (shared reference) |
| 72 | + ├─ CPixmap* (shared reference) |
| 73 | + └─ CMovie* (owns instance) |
| 74 | +``` |
| 75 | + |
| 76 | +Global instances declared in `blupi.cpp`: |
| 77 | +```cpp |
| 78 | +CEvent* pEvent; |
| 79 | +CDecor* pDecor; |
| 80 | +CSound* pSound; |
| 81 | +CPixmap* pPixmap; |
| 82 | +CMovie* pMovie; |
| 83 | +HWND g_hWnd; |
| 84 | +``` |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +## CDecor Split Across Translation Units |
| 89 | + |
| 90 | +`CDecor` is a single class distributed across several `.cpp` files for clarity: |
| 91 | + |
| 92 | +| Translation unit | Responsibility | |
| 93 | +|-----------------|----------------| |
| 94 | +| `decor.cpp` | Creation, init, rendering, coordinate helpers, undo, misc utilities | |
| 95 | +| `decblupi.cpp` | Complete character lifecycle, GOAL interpreter, selection, highlight | |
| 96 | +| `decgoal.cpp` | Static opcode tables for 130+ action types (WM_ACTION_*) | |
| 97 | +| `decio.cpp` | Binary read/write of `.blp` world files | |
| 98 | +| `decmap.cpp` | Minimap generation and rendering | |
| 99 | +| `decmove.cpp` | Animated decorations, fire spread, icon tables | |
| 100 | +| `decstat.cpp` | Statistics panel (Blupi counts, fires, homes, enemies) | |
| 101 | +| `arrange.cpp` | Auto-tiling: flood-fill, terrain transitions, walls, buildings | |
| 102 | +| `obstacle.cpp` | Passability tables, enemy target search helpers | |
| 103 | +| `chemin.cpp` | A* pathfinding with CPileTriee open-list | |
| 104 | +| `fog.cpp` | Fog of war quadrant bit encoding/decoding | |
0 commit comments