diff --git a/.gitattributes b/.gitattributes index 0452e2d..3bceccf 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,9 @@ # Packed textures and animation frames must never undergo text conversion. *.bin binary *.dat binary +*.hfm binary +*.cfm binary +*.blend binary # MASM strings and ANSI animations use legacy encodings; preserve raw bytes. *.asm -text diff --git a/.gitignore b/.gitignore index 1376991..340bf34 100644 --- a/.gitignore +++ b/.gitignore @@ -40,13 +40,22 @@ __pycache__/ /build/icon_work/ /build/scratch/ /build/startup/ +/build/cinematic-v3/ +/build/cinematic-v4/ +/build/cinematic-v5/ +/build/cinematic-v6/ +/build/cinematic-v7/ /build/tables/ /build/wheel/ /build/world/ +/build/underworld/ /build/*.res /build/payload_*.zip /build/PokerGameSetup_base.exe +/build/installer/bin/ +/build/installer/obj/ /PokerGameSetup.exe +/PokerGameSetup_NoModel.exe # Local previews and archived cheat sheets. /debug_render.png @@ -54,3 +63,5 @@ __pycache__/ /docs/*.zip /scratch/ + +/build/cinematic-v8/ diff --git a/README.md b/README.md index 0f62c8c..f0b0b0f 100644 --- a/README.md +++ b/README.md @@ -1,207 +1,253 @@ -# ASSEMBLER CASINO (KAZIK) 🎰 - -A retro casino gaming suite powered by a high-performance **pure x86 assembly (MASM32)** engine featuring an interactive **2.5D retro Raycaster 3D Hall** (DOOM / Wolfenstein style) and a catalog of classic and underground gambling games. - -The game runtime is assembly-only. This repository has one game core, built -from MASM sources; no C/C++ game port or non-assembly fallback is supported. -Native Linux/macOS versions are not available. Any future native platform -port must also use assembly. Python scripts are offline development tools, -and the existing C# launcher/installer are separate packaging utilities. - -## First setup: offline fortune AI - -After cloning or copying this repository, double-click -**`download_fortune_model.bat`** in the repository root. It downloads about 2.5 GB -into `ai/models/`, resumes interrupted downloads where supported, tries a backup -source, and verifies the exact size and SHA-256 before installation. Keep at -least 3 GB free. Windows PowerShell and `curl.exe` are required (included with -current Windows 10/11); Python, Git LFS and administrator access are not required. - -Then launch `dist/Assembler Casino.exe` or `poker.exe`. Model setup is a separate, -manual step; the game never downloads anything and works offline afterward. -Running setup again verifies existing weights without downloading them again. -Complete offline release ZIPs already contain the model and need no download. -See [Fortune AI](docs/FORTUNE_AI.md) for details and hardware notes. - -## Hell Expedition - -The large hell painting opposite the first-floor bar opens an assembly-native FPS expedition: -Freedoom enemies and weapons, a blue-key gate, two secrets, lava and a final -boss, accompanied by the existing Mick Gordon soundtrack. First clear awards -$6,660; death/retry preserves the casino bank. See -[controls, assets and verification](docs/HELL_EXPEDITION.md). - -## Native Entrance And Character Scenes - -The graphical startup runs Eblan Games, a Russian AI-use disclosure and a -side-by-side C++/MASM code fact before the first-person opening: -eyes opening beneath a cloudy rainy sky, smoking in an alley, discarding the -cigarette, walking and turning through a separate city map, then meeting the -guards and choosing a local profile before entering the walkable hall. -The sequence resets on every launch; the intro advances automatically. -Enter/Space advances one startup page; Escape skips to the opening scene. -After profile admission and entry into the hall, a centred cyberpunk briefing -unfolds from a point and types version 4.0, game information and controls. -The jukebox starts on entry at 50% volume, with normal positional attenuation. -Enter completes the text, then closes it; Escape closes immediately. Movement -is blocked while the briefing is open. See [startup and briefing](docs/STARTUP_PRESENTATION.md). -Sidorovich operates the native -card-back shop. New character sheets contain 32 guard poses and 24 merchant -poses, with separate actions rather than a single repeated idle animation. -Dealer-hand poses are synchronized with native poker/blackjack card movement. - -New street, guards, merchant, furniture and table art use a detailed retro -pixel-art direction and nearest-neighbor sampling, not the rejected realistic -palace facade. Converting every legacy -asset and terminal game is still in progress; multiplayer card tables are not -implemented by adding decorative opponents. See [Graphical Scenes](docs/GRAPHICAL_SCENES.md) -for the implemented scope, asset pipeline and remaining gameplay work. - -Verify the production ASM logic and framebuffer snapshots with: - -```powershell -tools/tests/test_casino_actions.ps1 -python tools/tests/check_arrival_frames.py -python tools/tests/check_card_table_frames.py -``` - ---- - -## 🏛️ Architecture Overview - -The repository contains one assembly game runtime and separate development -and packaging tools: - -```text -MASM sources --> ml.exe / link.exe --> poker.exe -assets/ ----------------------------> native game data -tools/ -----------------------------> offline asset generation and tests -build/ / dist/ ---------------------> existing launcher and installer -``` - -1. **MASM32 Core Game Engine (Root)** - - **`poker.asm`**: Main game binary (~8,500+ lines of hand-crafted x86 assembly). Contains game logic, cheat engine, socket networking, profile save system, and sound triggers. - - **`casino3d.inc` / `casino3d_data.inc`**: Software 2.5D Raycaster engine rendering a 32×32 grand casino hall at 640×480 with DDA wall casting, depth-sorted sprite objects, and interactive tables. - - **`font8x8.inc`**: CP1251 1-bit monochrome 8×8 bitmap font table for high-speed HUD rendering directly to the Win32 GDI frame buffer. - -2. **Desktop Distribution & Launcher (`build/` & `dist/`)** - - **`build/`**: C# source code for the launcher (`AssemblerCasinoLauncher.cs`), setup GUI (`PokerGameSetupGui.cs`), and uninstaller. - - **`dist/`**: Ready-to-run compiled desktop executables (`Assembler Casino.exe`, `Uninstall Assembler Casino.exe`). - -3. **Offline Development Tooling (`tools/`)** - - **`tools/previews/`**: Terminal ANSI animation players (`preview_intro.py`, `preview_hakari.py`, `preview_dbd_hook.py`) and 3D preview runner. - - **`tools/generators/`**: Texture pack scripts (`build_graphics_assets.py`), math table generators (`generate_math_and_map.py`), font rasterizer (`generate_font.py`). - - **`tools/tests/`**: Software raycaster simulator (`simulate_render.py`), release integrity checks (`release_smoke_check.ps1`), achievement popup modal (`achievement_popup.bat`). - -4. **Assets & Documentation (`assets/`, `docs/`, `backups/`)** - - **`assets/`**: High-resolution textures, sprites, audio samples (`.wav`), and ANSI cinematics (`.ans`). - - **`docs/`**: Design specifications, cheat sheet, networking guides, and engine render previews. - - **`backups/`**: Historical milestones and archived releases. - ---- - -## 📁 Repository Directory Structure - -``` -├── poker.asm # Primary MASM32 assembly source -├── casino3d.inc # 2.5D retro 3D raycaster engine implementation -├── casino3d_data.inc # 3D engine math tables (sin/cos) & casino hall grid -├── font8x8.inc # 8x8 CP1251 bitmap font data -├── poker.wap # Pelles C / Windows project definition -├── build.bat # One-click build script for MASM32 core -├── poker.exe # Compiled game binary -├── AGENTS.md # Engineering guidelines and agent instructions -├── README.md # Project documentation (this file) -├── LICENSE # Project license -├── .gitignore # Git ignore patterns -│ -├── assets/ # Game assets -│ ├── animations/ # ANSI animations (casino_intro.ans, hakari_dance.ans, dbd_hook.ans) -│ ├── audio/ # Sound effects (.wav) for cards, roulette, coins, win/loss -│ ├── data/ # Dealer dialogues and text tables (CP1251) -│ ├── icons/ # Game icon assets (.ico, .png) -│ ├── music/ # Background tracks -│ ├── sprites/ # Source sprite sheets & cabaret animations -│ └── textures/ # Packed 128x128 BGRA texture binaries (casino3d-hd.bin) -│ -├── backups/ # Preserved backups and legacy archives -│ -├── build/ # Launcher and setup source code (C# .NET) -│ ├── AssemblerCasinoLauncher.cs -│ ├── PokerGameSetupGui.cs -│ └── UninstallAssemblerCasino.cs -│ -├── dist/ # Compiled desktop distribution binaries -│ ├── Assembler Casino.exe -│ └── Uninstall Assembler Casino.exe -│ -├── docs/ # Project documentation, guides, and plans -│ ├── intro_code_draft.txt # Opening sequence drafts -│ ├── render_view.png # Simulated frame render of the 3D casino hall -│ ├── ИДЕИ.txt # Game ideas and development backlog -│ ├── ЧИТКОДЫ.txt # Complete list of cheat codes -│ └── *.txt # Release notes, security guidelines, networking -│ -└── tools/ # Developer tooling & offline asset pipeline - ├── README.md # Documentation for tools - ├── previews/ # Animation & 3D preview scripts (.py, .bat) - ├── generators/ # Asset packers, math & font generators (.py) - └── tests/ # Software render simulator & test scripts (.py, .ps1, .bat) -``` - ---- - -## 🛠️ Build Instructions - -### 1. MASM32 Game Binary (`poker.exe`) - -Prerequisites: MASM32 SDK (`ml.exe`, `link.exe`) installed in `D:\MASM32\masm32`, `C:\masm32`, or Visual Studio MSVC BuildTools. - -Simply run: -```bat -build.bat -``` -This will assemble `poker.asm` with MASM, link against `kernel32`, `winmm`, `user32`, `ws2_32`, `gdi32`, and produce `poker.exe`. - -### 2. Running Previews and Simulators - -- **Hakari Jackpot Dance Preview**: - ```bat - tools\previews\preview_hakari.bat - ``` -- **Casino Intro Animation Preview**: - ```bat - tools\previews\preview_intro.bat - ``` -- **3D Engine Software Simulation**: - ```bash - python tools/tests/simulate_render.py - ``` - Generates `docs/render_view.png` showing the 3D raycaster view with sprites. - ---- - -## 🔤 Character Encoding Standard - -- **Game source & strings (`poker.asm`, `assets/data/dealer_phrases.txt`)**: **CP1251 (Windows-1251)**. Never save as UTF-8. -- **ANSI animations (`.ans`)**: CP1251 encoding with ANSI escape codes and form feed (`\f`, `0x0C`) frame delimiters. Preview runners execute `chcp 65001` before playback. - ---- - -## 🎮 Games & Features - -| # | Game | Description | -|---|------|-------------| -| 1 | **21 / Blackjack** | Classic card game against the dealer with hit/stand mechanics. | -| 2 | **Poker** | Texas Hold'em with AI opponents, betting rounds, and pot calculations. | -| 3 | **CloverPit** | 5×3 video slots with custom bonus features and payouts. | -| 4 | **Russian Roulette** | High-stakes survival with revolver chamber simulation. | -| 5 | **Skulls & Cups** | Thimblerig shell game testing perception and luck. | -| 6 | **Coin Flip** | Double or nothing coin toss. | -| 7 | **Dice / Craps** | Classic dice rolling wagering. | -| 8 | **Roulette** | European roulette wheel with single and range bets. | -| 9 | **Classic Slots** | 3-reel 777 fruit machine. | -| 10 | **Durak** | Traditional Russian card game with trump cards and defense logic. | -| 11 | **Training** | Practice arena with infinite balance. | -| 12 | **Observer (AI vs AI)** | Watch autonomous agents play against each other. | -| 3D | **Grand Casino Hall** | Real-time 2.5D raycaster environment to explore and walk up to tables. | +# ASSEMBLER CASINO (KAZIK) 🎰 + +A retro casino gaming suite powered by a high-performance **pure x86 assembly (MASM32)** engine featuring an interactive **2.5D retro Raycaster 3D Hall** (DOOM / Wolfenstein style) and a catalog of classic and underground gambling games. + +The game runtime is assembly-only. This repository has one game core, built +from MASM sources; no C/C++ game port or non-assembly fallback is supported. +Native Linux/macOS versions are not available. Any future native platform +port must also use assembly. Python scripts are offline development tools, +and the existing C# launcher/installer are separate packaging utilities. + +## First setup: offline fortune AI + +After cloning or copying this repository, double-click +**`download_fortune_model.bat`** in the repository root. It downloads about 2.5 GB +into `ai/models/`, resumes interrupted downloads where supported, tries a backup +source, and verifies the exact size and SHA-256 before installation. Keep at +least 3 GB free. Windows PowerShell and `curl.exe` are required (included with +current Windows 10/11); Python, Git LFS and administrator access are not required. + +Then launch `dist/Assembler Casino.exe` or `poker.exe`. Model setup is a separate, +manual step; the game never downloads anything and works offline afterward. +Running setup again verifies existing weights without downloading them again. +Complete offline release ZIPs already contain the model and need no download. +See [Fortune AI](docs/FORTUNE_AI.md) for details and hardware notes. + +## Hell Expedition + +The large hell painting opposite the first-floor bar opens an assembly-native FPS expedition: +Freedoom enemies and weapons, a blue-key gate, two secrets, lava and a final +boss, accompanied by the existing Mick Gordon soundtrack. First clear awards +$6,660; death/retry preserves the casino bank. See +[controls, assets and verification](docs/HELL_EXPEDITION.md). + +## Basement Activities + +In the main hall, approach the basement door and press **E**; walk through the +opened doorway. A side passage on the left leads to a separate underworld +club with Semyon, rat races and the heist planning table. Sidorovich's workshop +stays in the original room. Approach each object and press **E** when its prompt +appears. The bar remains in the main hall; press **E** at the counter and use +**1–6** for drinks (**7** recruits the bartender). The controls and current +implementation status are listed in +[Underworld and the Grand Heist](docs/HEIST_AND_UNDERWORLD.md). + +The optional heist prototype targets a rival owners' headquarters on a separate first-person +map. Choose stealth or assault at the planning table (**5**), ride there in +the crew's vehicle, breach the strongroom and extract with the loot. The return +trip restores the original casino position; the reward is paid only after +extraction. See [mission route and controls](docs/HEIST_HQ.md). + +The generated v2 art is in `assets/sprites/hall/underworld-portraits-v2.png`, +`underworld-world-v2.png` and `rat-race-v2.png`. The game loads the corresponding +ANM1 packs from `assets/animations/hall/`. Repack these approved atlases with +`python tools/generators/pack_underworld_v2.py`; prompts are recorded in +`assets/sprites/hall/prompts-underworld-v2.json`. The old v1 sheets are retained +as historical sources. Loans, recruited crew and the one-time heist reward are +saved per profile in a `.underworld` sidecar. `build.bat` also updates the +launcher and `bin/poker.exe`, so the launcher uses the freshly built game. + +## Native Entrance And Character Scenes + +The graphical startup runs a Russian content disclaimer, a Full HD Eblan Games +studio ident rendered offline in Blender, and a short explanation of games and +exploration. In the 16-second studio film a cassette reel takes up slack tape on a repair +bench. A can rolls over the desk edge and its lower rim trips a +floor switch. A mechanical relay snaps open. On the dark CRT a point of light +stretches into a scan line and draws the EG studio signature. Watch `assets/cinematics/masters/Eblan-Games-v8.mp4`. The export tools can also write a ProRes master for use in other games. +The playable opening follows with +eyes opening beneath a cloudy rainy sky, smoking in an alley, discarding the +cigarette, walking and turning through a separate city map, then meeting the +guards and choosing a local profile before entering the walkable hall. +The sequence resets on every launch; the intro advances automatically. +Enter/Space advances one startup page; Escape skips to the opening scene. +After profile admission and entry into the hall, a centred cyberpunk briefing +unfolds from a point and types version 4.0, game information and controls. +The jukebox starts on entry at 50% volume, with normal positional attenuation. +Enter completes the text, then closes it; Escape closes immediately. Movement +is blocked while the briefing is open. See [startup and briefing](docs/STARTUP_PRESENTATION.md). +Sidorovich operates the native +card-back shop. New character sheets contain 32 guard poses and 24 merchant +poses, with separate actions rather than a single repeated idle animation. +Dealer-hand poses are synchronized with native poker/blackjack card movement. + +New street, guards, merchant, furniture and table art use a detailed retro +pixel-art direction and nearest-neighbor sampling, not the rejected realistic +palace facade. Converting every legacy +asset and terminal game is still in progress; multiplayer card tables are not +implemented by adding decorative opponents. See [Graphical Scenes](docs/GRAPHICAL_SCENES.md) +for the implemented scope, asset pipeline and remaining gameplay work. + +Verify the production ASM logic and framebuffer snapshots with: + +```powershell +tools/tests/test_casino_actions.ps1 +python tools/tests/check_arrival_frames.py +python tools/tests/check_card_table_frames.py +``` + +--- + +## 🏛️ Architecture Overview + +The repository contains one assembly game runtime and separate development +and packaging tools: + +```text +MASM sources --> ml.exe / link.exe --> poker.exe +assets/ ----------------------------> native game data +tools/ -----------------------------> offline asset generation and tests +build/ / dist/ ---------------------> existing launcher and installer +``` + +1. **MASM32 Core Game Engine (Root)** + - **`poker.asm`**: Main game binary (~8,500+ lines of hand-crafted x86 assembly). Contains game logic, cheat engine, socket networking, profile save system, and sound triggers. + - **`casino3d.inc` / `casino3d_data.inc`**: Software 2.5D Raycaster engine rendering a 32×32 grand casino hall at 640×480 with DDA wall casting, depth-sorted sprite objects, and interactive tables. + - **`font8x8.inc`**: CP1251 1-bit monochrome 8×8 bitmap font table for high-speed HUD rendering directly to the Win32 GDI frame buffer. + +2. **Desktop Distribution & Launcher (`build/` & `dist/`)** + - **`build/`**: C# source code for the launcher (`AssemblerCasinoLauncher.cs`), modern setup wizard (`build/installer/PokerGameSetup.csproj`), and uninstaller (`UninstallAssemblerCasino.cs`). + - **`dist/`**: Ready-to-run compiled desktop executables (`Assembler Casino.exe`, `Uninstall Assembler Casino.exe`). + - **`PokerGameSetup.exe`**: Self-extracting setup package bundling full game payload, offline fortune AI model (2.5 GB), desktop shortcuts, and modern dark-themed wizard UI. + +3. **Offline Development Tooling (`tools/`)** + - **`tools/previews/`**: Terminal ANSI animation players (`preview_intro.py`, `preview_hakari.py`, `preview_dbd_hook.py`) and 3D preview runner. + - **`tools/generators/`**: Texture pack scripts (`build_graphics_assets.py`), math table generators (`generate_math_and_map.py`), font rasterizer (`generate_font.py`). + - **`tools/tests/`**: Software raycaster simulator (`simulate_render.py`), release integrity checks (`release_smoke_check.ps1`), achievement popup modal (`achievement_popup.bat`). + +4. **Assets & Documentation (`assets/`, `docs/`, `backups/`)** + - **`assets/`**: High-resolution textures, sprites, audio samples (`.wav`), and ANSI cinematics (`.ans`). + - **`docs/`**: Design specifications, cheat sheet, networking guides, and engine render previews. + - **`backups/`**: Historical milestones and archived releases. + +--- + +## 📁 Repository Directory Structure + +``` +├── poker.asm # Primary MASM32 assembly source +├── casino3d.inc # 2.5D retro 3D raycaster engine implementation +├── casino3d_data.inc # 3D engine math tables (sin/cos) & casino hall grid +├── font8x8.inc # 8x8 CP1251 bitmap font data +├── poker.wap # Pelles C / Windows project definition +├── build.bat # One-click build script for MASM32 core +├── poker.exe # Compiled game binary +├── AGENTS.md # Engineering guidelines and agent instructions +├── README.md # Project documentation (this file) +├── LICENSE # Project license +├── .gitignore # Git ignore patterns +│ +├── assets/ # Game assets +│ ├── animations/ # ANSI animations (casino_intro.ans, hakari_dance.ans, dbd_hook.ans) +│ ├── audio/ # Sound effects (.wav) for cards, roulette, coins, win/loss +│ ├── data/ # Dealer dialogues and text tables (CP1251) +│ ├── icons/ # Game icon assets (.ico, .png) +│ ├── music/ # Background tracks +│ ├── sprites/ # Source sprite sheets & cabaret animations +│ └── textures/ # Packed 128x128 BGRA texture binaries (casino3d-hd.bin) +│ +├── backups/ # Preserved backups and legacy archives +│ +├── build/ # Launcher and setup source code (C# .NET) +│ ├── AssemblerCasinoLauncher.cs +│ ├── PokerGameSetupGui.cs +│ └── UninstallAssemblerCasino.cs +│ +├── dist/ # Compiled desktop distribution binaries +│ ├── Assembler Casino.exe +│ └── Uninstall Assembler Casino.exe +│ +├── docs/ # Project documentation, guides, and plans +│ ├── intro_code_draft.txt # Opening sequence drafts +│ ├── render_view.png # Simulated frame render of the 3D casino hall +│ ├── ИДЕИ.txt # Game ideas and development backlog +│ ├── ЧИТКОДЫ.txt # Complete list of cheat codes +│ └── *.txt # Release notes, security guidelines, networking +│ +└── tools/ # Developer tooling & offline asset pipeline + ├── README.md # Documentation for tools + ├── previews/ # Animation & 3D preview scripts (.py, .bat) + ├── generators/ # Asset packers, math & font generators (.py) + └── tests/ # Software render simulator & test scripts (.py, .ps1, .bat) +``` + +--- + +## 🛠️ Build Instructions + +### 1. MASM32 Game Binary (`poker.exe`) + +Prerequisites: MASM32 SDK (`ml.exe`, `link.exe`) installed in `D:\MASM32\masm32`, `C:\masm32`, or Visual Studio MSVC BuildTools. + +Simply run: +```bat +build.bat +``` +This will assemble `poker.asm` with MASM, link against `kernel32`, `winmm`, `user32`, `ws2_32`, `gdi32`, and produce `poker.exe`. + +### 2. Running Previews and Simulators + +- **Hakari Jackpot Dance Preview**: + ```bat + tools\previews\preview_hakari.bat + ``` +- **Casino Intro Animation Preview**: + ```bat + tools\previews\preview_intro.bat + ``` +- **3D Engine Software Simulation**: + ```bash + python tools/tests/simulate_render.py + ``` + Generates `docs/render_view.png` showing the 3D raycaster view with sprites. + +### 3. Desktop Installer (`PokerGameSetup.exe`) + +Prerequisites: .NET Framework 4.8 / .NET SDK (`dotnet`), Python 3. + +To build the full installer with offline neural model embedded (~3.36 GB): +```bash +python tools/build_setup.py +``` + +To build lightweight installer without neural weights (~860 MB): +```bash +python tools/build_setup.py --no-model +``` + +--- + +## 🔤 Character Encoding Standard + +- **Game source & strings (`poker.asm`, `assets/data/dealer_phrases.txt`)**: **CP1251 (Windows-1251)**. Never save as UTF-8. +- **ANSI animations (`.ans`)**: CP1251 encoding with ANSI escape codes and form feed (`\f`, `0x0C`) frame delimiters. Preview runners execute `chcp 65001` before playback. + +--- + +## 🎮 Games & Features + +| # | Game | Description | +|---|------|-------------| +| 1 | **21 / Blackjack** | Classic card game against the dealer with hit/stand mechanics. | +| 2 | **Poker** | Texas Hold'em with AI opponents, betting rounds, and pot calculations. | +| 3 | **CloverPit** | 5×3 video slots with custom bonus features and payouts. | +| 4 | **Russian Roulette** | High-stakes survival with revolver chamber simulation. | +| 5 | **Skulls & Cups** | Thimblerig shell game testing perception and luck. | +| 6 | **Coin Flip** | Double or nothing coin toss. | +| 7 | **Dice / Craps** | Classic dice rolling wagering. | +| 8 | **Roulette** | European roulette wheel with single and range bets. | +| 9 | **Classic Slots** | 3-reel 777 fruit machine. | +| 10 | **Durak** | Traditional Russian card game with trump cards and defense logic. | +| 11 | **Training** | Practice arena with infinite balance. | +| 12 | **Observer (AI vs AI)** | Watch autonomous agents play against each other. | +| 3D | **Grand Casino Hall** | Real-time 2.5D raycaster environment to explore and walk up to tables. | diff --git a/assets/animations/hall/drink-v5.bin b/assets/animations/hall/drink-v5.bin new file mode 100644 index 0000000..6cce777 Binary files /dev/null and b/assets/animations/hall/drink-v5.bin differ diff --git a/assets/animations/hall/heist-actors-v1.bin b/assets/animations/hall/heist-actors-v1.bin new file mode 100644 index 0000000..66039c4 Binary files /dev/null and b/assets/animations/hall/heist-actors-v1.bin differ diff --git a/assets/animations/hall/heist-materials-v1.bin b/assets/animations/hall/heist-materials-v1.bin new file mode 100644 index 0000000..33a8fc8 Binary files /dev/null and b/assets/animations/hall/heist-materials-v1.bin differ diff --git a/assets/animations/hall/heist-props-v1.bin b/assets/animations/hall/heist-props-v1.bin new file mode 100644 index 0000000..07f24eb Binary files /dev/null and b/assets/animations/hall/heist-props-v1.bin differ diff --git a/assets/animations/hall/heist-van-v1.bin b/assets/animations/hall/heist-van-v1.bin new file mode 100644 index 0000000..def474b Binary files /dev/null and b/assets/animations/hall/heist-van-v1.bin differ diff --git a/assets/animations/hall/heist-weapons-v1.bin b/assets/animations/hall/heist-weapons-v1.bin new file mode 100644 index 0000000..8451edf Binary files /dev/null and b/assets/animations/hall/heist-weapons-v1.bin differ diff --git a/assets/animations/hall/manifest-heist-hq-v1.json b/assets/animations/hall/manifest-heist-hq-v1.json new file mode 100644 index 0000000..6dadac6 --- /dev/null +++ b/assets/animations/hall/manifest-heist-hq-v1.json @@ -0,0 +1,37 @@ +{ + "heist-van-v1.bin": { + "frames": 1, + "size": [ + 640, + 480 + ] + }, + "heist-actors-v1.bin": { + "frames": 8, + "size": [ + 256, + 256 + ] + }, + "heist-weapons-v1.bin": { + "frames": 4, + "size": [ + 256, + 320 + ] + }, + "heist-props-v1.bin": { + "frames": 4, + "size": [ + 256, + 256 + ] + }, + "heist-materials-v1.bin": { + "frames": 4, + "size": [ + 128, + 128 + ] + } +} diff --git a/assets/animations/hall/manifest-underworld-v2.json b/assets/animations/hall/manifest-underworld-v2.json new file mode 100644 index 0000000..de3547f --- /dev/null +++ b/assets/animations/hall/manifest-underworld-v2.json @@ -0,0 +1,23 @@ +{ + "underworld-portraits-v2.bin": { + "frames": 11, + "size": [ + 256, + 256 + ] + }, + "underworld-world-v2.bin": { + "frames": 8, + "size": [ + 256, + 256 + ] + }, + "rat-race-v2.bin": { + "frames": 17, + "size": [ + 128, + 64 + ] + } +} diff --git a/assets/animations/hall/manifest-v4.json b/assets/animations/hall/manifest-v4.json index d79df78..40cfdc6 100644 --- a/assets/animations/hall/manifest-v4.json +++ b/assets/animations/hall/manifest-v4.json @@ -19,5 +19,26 @@ 192, 320 ] + }, + "underworld_portraits.bin": { + "frames": 11, + "size": [ + 256, + 256 + ] + }, + "rat_race.bin": { + "frames": 17, + "size": [ + 128, + 128 + ] + }, + "drink-v5.bin": { + "frames": 42, + "size": [ + 256, + 256 + ] } } \ No newline at end of file diff --git a/assets/animations/hall/manifest-v5.json b/assets/animations/hall/manifest-v5.json new file mode 100644 index 0000000..54cc492 --- /dev/null +++ b/assets/animations/hall/manifest-v5.json @@ -0,0 +1,37 @@ +{ + "bartender-v4.bin": { + "frames": 24, + "size": [ + 256, + 256 + ] + }, + "drink-v5.bin": { + "frames": 42, + "size": [ + 256, + 256 + ] + }, + "street-life-v4.bin": { + "frames": 40, + "size": [ + 192, + 320 + ] + }, + "underworld_portraits.bin": { + "frames": 11, + "size": [ + 256, + 256 + ] + }, + "rat_race.bin": { + "frames": 17, + "size": [ + 128, + 128 + ] + } +} \ No newline at end of file diff --git a/assets/animations/hall/rat-race-v2.bin b/assets/animations/hall/rat-race-v2.bin new file mode 100644 index 0000000..44d75c6 Binary files /dev/null and b/assets/animations/hall/rat-race-v2.bin differ diff --git a/assets/animations/hall/rat_race.bin b/assets/animations/hall/rat_race.bin new file mode 100644 index 0000000..f6d0382 Binary files /dev/null and b/assets/animations/hall/rat_race.bin differ diff --git a/assets/animations/hall/underworld-portraits-v2.bin b/assets/animations/hall/underworld-portraits-v2.bin new file mode 100644 index 0000000..18d141e Binary files /dev/null and b/assets/animations/hall/underworld-portraits-v2.bin differ diff --git a/assets/animations/hall/underworld-world-v2.bin b/assets/animations/hall/underworld-world-v2.bin new file mode 100644 index 0000000..4be650f Binary files /dev/null and b/assets/animations/hall/underworld-world-v2.bin differ diff --git a/assets/animations/hall/underworld_portraits.bin b/assets/animations/hall/underworld_portraits.bin new file mode 100644 index 0000000..6a20607 Binary files /dev/null and b/assets/animations/hall/underworld_portraits.bin differ diff --git a/assets/animations/intro/casino-cinematic-v2.bin b/assets/animations/intro/casino-cinematic-v2.bin new file mode 100644 index 0000000..c7cd364 Binary files /dev/null and b/assets/animations/intro/casino-cinematic-v2.bin differ diff --git a/assets/animations/intro/cinematic-master-v3.cfm b/assets/animations/intro/cinematic-master-v3.cfm new file mode 100644 index 0000000..8c06cb9 Binary files /dev/null and b/assets/animations/intro/cinematic-master-v3.cfm differ diff --git a/assets/animations/intro/cinematic-master-v3.json b/assets/animations/intro/cinematic-master-v3.json new file mode 100644 index 0000000..c72aba2 --- /dev/null +++ b/assets/animations/intro/cinematic-master-v3.json @@ -0,0 +1,13 @@ +{ + "format": "CFM3 / RGB565 + independent LZNT1 frames", + "frames": 600, + "fps": 30, + "size": [ + 640, + 480 + ], + "bytes": 192818565, + "sha256": "2bb47ff7688b2d2a777795cf8a46bb6baa908e9568a36116240279936a335b9b", + "source": "assets/cinematics/source/AssemblerCasino-v3.aep", + "roundtrip": "all frames verified" +} diff --git a/assets/animations/intro/eblan-cinematic-v2.bin b/assets/animations/intro/eblan-cinematic-v2.bin new file mode 100644 index 0000000..1b6d4b5 Binary files /dev/null and b/assets/animations/intro/eblan-cinematic-v2.bin differ diff --git a/assets/animations/intro/eblan-studio-v8.hfm b/assets/animations/intro/eblan-studio-v8.hfm new file mode 100644 index 0000000..87d21b8 Binary files /dev/null and b/assets/animations/intro/eblan-studio-v8.hfm differ diff --git a/assets/animations/intro/eblan-studio-v8.json b/assets/animations/intro/eblan-studio-v8.json new file mode 100644 index 0000000..5017874 --- /dev/null +++ b/assets/animations/intro/eblan-studio-v8.json @@ -0,0 +1,14 @@ +{ + "format": "HFM4 / independent JPEG", + "size": [ + 1920, + 1080 + ], + "frames": 384, + "fps": 24, + "duration": 16, + "bytes": 94844713, + "sha256": "32ec40535049c7793ac01d3f76e98c9eb9705d79b7b336333255317a7052011f", + "source": "assets/cinematics/blender/eblan-workshop-v8.blend", + "shots": 8 +} diff --git a/assets/animations/intro/manifest-cinematic-v2.json b/assets/animations/intro/manifest-cinematic-v2.json new file mode 100644 index 0000000..fa51cb9 --- /dev/null +++ b/assets/animations/intro/manifest-cinematic-v2.json @@ -0,0 +1,29 @@ +[ + { + "source": "assets\\sprites\\intro\\roulette-cinematic-v1.png", + "pack": "assets\\animations\\intro\\roulette-cinematic-v1.bin", + "size": [ + 512, + 512 + ], + "alpha": "original ImageGen alpha, preserved" + }, + { + "source": "assets\\sprites\\intro\\eblan-cinematic-v2.png", + "pack": "assets\\animations\\intro\\eblan-cinematic-v2.bin", + "size": [ + 640, + 427 + ], + "alpha": "original ImageGen alpha, preserved" + }, + { + "source": "assets\\sprites\\intro\\casino-cinematic-v2.png", + "pack": "assets\\animations\\intro\\casino-cinematic-v2.bin", + "size": [ + 640, + 215 + ], + "alpha": "original ImageGen alpha, preserved" + } +] diff --git a/assets/animations/intro/roulette-cinematic-v1.bin b/assets/animations/intro/roulette-cinematic-v1.bin new file mode 100644 index 0000000..ddc78ad Binary files /dev/null and b/assets/animations/intro/roulette-cinematic-v1.bin differ diff --git a/assets/audio/startup/casino-title.wav b/assets/audio/startup/casino-title.wav new file mode 100644 index 0000000..ff6a88c Binary files /dev/null and b/assets/audio/startup/casino-title.wav differ diff --git a/assets/audio/startup/studio-ident.wav b/assets/audio/startup/studio-ident.wav new file mode 100644 index 0000000..2eb2244 Binary files /dev/null and b/assets/audio/startup/studio-ident.wav differ diff --git a/assets/audio/startup/studio-workshop-v4.wav b/assets/audio/startup/studio-workshop-v4.wav new file mode 100644 index 0000000..d52c1a8 Binary files /dev/null and b/assets/audio/startup/studio-workshop-v4.wav differ diff --git a/assets/audio/startup/studio-workshop-v5.wav b/assets/audio/startup/studio-workshop-v5.wav new file mode 100644 index 0000000..998912c Binary files /dev/null and b/assets/audio/startup/studio-workshop-v5.wav differ diff --git a/assets/audio/startup/studio-workshop-v6.wav b/assets/audio/startup/studio-workshop-v6.wav new file mode 100644 index 0000000..bd890a3 Binary files /dev/null and b/assets/audio/startup/studio-workshop-v6.wav differ diff --git a/assets/audio/startup/studio-workshop-v7.wav b/assets/audio/startup/studio-workshop-v7.wav new file mode 100644 index 0000000..90c468a Binary files /dev/null and b/assets/audio/startup/studio-workshop-v7.wav differ diff --git a/assets/audio/startup/studio-workshop-v8.wav b/assets/audio/startup/studio-workshop-v8.wav new file mode 100644 index 0000000..6835022 Binary files /dev/null and b/assets/audio/startup/studio-workshop-v8.wav differ diff --git a/assets/sprites/hall/drink-hand-v5.png b/assets/sprites/hall/drink-hand-v5.png new file mode 100644 index 0000000..6204cee Binary files /dev/null and b/assets/sprites/hall/drink-hand-v5.png differ diff --git a/assets/sprites/hall/heist-actors-v1.png b/assets/sprites/hall/heist-actors-v1.png new file mode 100644 index 0000000..4f2b140 Binary files /dev/null and b/assets/sprites/hall/heist-actors-v1.png differ diff --git a/assets/sprites/hall/heist-props-v1.png b/assets/sprites/hall/heist-props-v1.png new file mode 100644 index 0000000..1e21f6b Binary files /dev/null and b/assets/sprites/hall/heist-props-v1.png differ diff --git a/assets/sprites/hall/heist-van-v1.png b/assets/sprites/hall/heist-van-v1.png new file mode 100644 index 0000000..3552d92 Binary files /dev/null and b/assets/sprites/hall/heist-van-v1.png differ diff --git a/assets/sprites/hall/heist-weapons-v1.png b/assets/sprites/hall/heist-weapons-v1.png new file mode 100644 index 0000000..cb545a0 Binary files /dev/null and b/assets/sprites/hall/heist-weapons-v1.png differ diff --git a/assets/sprites/hall/prompts-heist-hq-v1.json b/assets/sprites/hall/prompts-heist-hq-v1.json new file mode 100644 index 0000000..ffae346 --- /dev/null +++ b/assets/sprites/hall/prompts-heist-hq-v1.json @@ -0,0 +1,7 @@ +{ + "tool": "built-in image_gen", + "van": "Use case: stylized-concept. Production game asset: first-person view from the FRONT PASSENGER seat of a dark unmarked armored getaway van on a covert heist mission. Landscape 4:3 canvas. Detailed gritty retro 1990s PC pixel art, muted charcoal, worn leather, dark fabric, amber dashboard lights and subtle cyan rim lighting, matches a textured software-rendered first-person casino adventure. Full cabin overlay: roof at top, door frame on right, dashboard and glove compartment across lower third, steering wheel on left, a masked driver wearing a plain dark balaclava seated at left with hands on wheel, a player's black-gloved hands resting on a compact rifle at bottom right, no visible player face. THE LARGE FRONT WINDSHIELD AND THE SIDE WINDOW OPENINGS MUST BE COMPLETELY TRANSPARENT ALPHA, occupying center and upper middle, so moving 3D buildings can be rendered behind this cabin. All interior solid surfaces opaque. Camera at seated human eye level, dashboard below view horizon, practical readable shapes, not cinematic third-person. No scenery beyond windshield, no text or numbers, no logos, no watermarks, no poster framing.", + "actors": "Use case: stylized-concept. ONE production sprite atlas exact 4 columns x 2 rows equal square cells on a landscape 2:1 transparent canvas. Detailed gritty textured 1990s first-person PC game pixel art, muted charcoal/olive/navy fabric, practical proportions, warm amber plus subtle cool rim lighting. Whole full-body figures with feet completely visible, nearly front-facing camera at human eye level, no perspective foreshortening, no scenery, no floor, no labels, no grid. Each figure occupies 85% height of its cell, transparent padding. TOP ROW: same private security guard with visible face, dark navy uniform, body armor and carbine in four poses: 0 standing alert holding rifle low, 1 walking mid-stride toward camera, 2 aiming rifle toward camera, 3 crumpled defeated guard lying on side on the floor. BOTTOM ROW: 4 masked heist teammate with dark balaclava, olive tactical vest and slung rifle, standing at low ready; 5 second masked teammate in charcoal jacket, compact rifle, slightly broader shoulders; 6 third masked teammate in navy coat with small electronics pouch and silenced pistol; 7 a large black canvas loot duffel bag with zipper partly open showing neatly bundled banknotes, isolated object. No skull masks, no clown masks, no franchise symbols, no blood or gore. Keep character scale consistent, transparent alpha background, each sprite wholly contained within its own cell.", + "weapons": "Use case: stylized-concept. ONE production first-person shooter weapon animation sheet, exactly 4 equal square cells in a single horizontal row on transparent alpha. Detailed crisp textured retro 1990s pixel art matching a dark tactical casino heist game. The camera is the player's eyes, seeing only own black-gloved hands and weapon coming from bottom center-right, aimed toward a point near upper center. No visible face or external full character, no scenery, no grid, no labels, no logos. Keep whole weapon/hand cutout inside each cell with transparent margin. Cell0: compact black silenced pistol held in two black-gloved hands, ready pose; Cell1: exact same silenced pistol and hands with small recoil, tiny muted muzzle puff, same size; Cell2: compact dark carbine with olive furniture and iron sights, held in same black gloves, ready pose; Cell3: exact same carbine and hands in firing pose with brief amber muzzle flash and small recoil, same size. Weapons must point forward away from the camera, barrel receding toward upper center, hands at lower edge. Consistent subdued lighting, silhouette, materials and scale within each pair, no ammo counters, no text, true transparency.", + "props": "Use case: stylized-concept. Production retro tactical first-person game prop atlas, exactly 4 columns in one horizontal row of equal square cells, transparent alpha. Detailed muted pixel art matching gritty 1990s PC adventure assets, realistic practical proportions, warm amber and cool steel highlights. Cell0: plain dark charcoal getaway cargo van seen directly from REAR, full vehicle with two rear doors closed, red tail lamps and tires visible, no text or license lettering. Cell1: waist-height metal security computer terminal cabinet with small cyan screen and keyboard, front three-quarter view, whole object including base. Cell2: black hard-shell documents briefcase open slightly showing organized papers and banknote bundles, isolated. Cell3: compact wall-mounted white security camera with black lens and small red status light, three-quarter view, isolated. No scenery, no floor, no labels, no logos, no grid, no watermarks. Each object fully contained and centered with transparent margins. Crisp detailed game sprites, not vector icons." +} diff --git a/assets/sprites/hall/prompts-underworld-v2.json b/assets/sprites/hall/prompts-underworld-v2.json new file mode 100644 index 0000000..8a8129f --- /dev/null +++ b/assets/sprites/hall/prompts-underworld-v2.json @@ -0,0 +1,8 @@ +{ + "tool": "built-in image_gen", + "date": "2026-11-17", + "portraits": "Use case: stylized-concept. Asset type: production sprite atlas for a dark retro casino game rendered at 640x480. Create ONE exact 4 columns by 3 rows atlas, landscape 4:3 canvas, equal square cells, transparent background, no gutters or drawn grid. Each cell contains one isolated centered sprite, occupying about 85% of that cell, no overlap, consistent detailed 1990s PC adventure pixel art with crisp textured clusters and dramatic warm amber/cool teal rim lighting, readable when reduced to 128 pixels. Characters are waist-up portraits with expressive detailed faces, not geometric cartoons. Row1 left to right: (0) Semyon, grizzled middle-aged loan shark, dark leather jacket, flat cap, gold chain, sly face; (1) burly scarred debt collector in black coat, intimidating; (2) casino security chief in charcoal suit, burgundy tie, radio earpiece; (3) circular brushed steel safe combination dial, front view, gold rim and tick marks, no text. Row2: (4) luxurious gold playing card deck with embossed spade motif, three-quarter view; (5) moustached bartender in white shirt and dark waistcoat holding silver cocktail shaker; (6) elegant cabaret singer in crimson evening dress with pearl necklace and vintage microphone; (7) mysterious fortune teller in violet hood holding a tarot card. Row3: (8) hooded hacker with cyan illuminated glasses and compact laptop; (9) casino vault blueprint as a flat blue paper with clear cyan technical floorplan, folded corners, no lettering; (10) detailed small escape helicopter three-quarter view with rotor, landing skids and cyan cockpit, isolated; (11) leave entirely transparent. Keep each item wholly within its exact cell. Real alpha transparency outside all subjects. No scenery, no labels, no watermark, no extra objects, no colored aura disks.", + "world": "Use case: stylized-concept. Production sprite sheet for a retro first-person casino adventure. ONE transparent atlas exact 4 columns x 2 rows, landscape 2:1 aspect, 8 equal square slots. Detailed textured 1990s pixel art, crisp pixels, warm amber rimlight and subtle teal highlights, readable at 128-256 pixels. Camera nearly frontal with slight view of tops for objects, consistent ground line at 90% each slot. Whole objects including feet, generous transparent 8% margins inside every slot, never overlap cells, no scene background, no labels. Top row: slot0 full-body loan shark Semyon: grizzled middle-aged man, flat cap, black leather jacket, gold chain, dark trousers, shoes, relaxed cunning stance; slot1 same exact Semyon full-body counting a small stack of notes, same size; slot2 same Semyon full-body offering the notes in one hand, same size; slot3 full-body hulking scarred debt collector in charcoal coat with radio. Bottom row: slot4 complete waist-height wooden rat racing table, four narrow fenced tracks receding away, small checkered finish banner at far end, all four legs visible, gritty basement gambling furniture; slot5 complete sturdy planning desk with blue vault floorplan spread on surface, small lamp and papers, all legs visible; slot6 closed heavy freestanding steel casino vault cabinet with brass combination dial and steel hinges; slot7 same exact vault cabinet with door open revealing neatly stacked gold playing cards and banknotes. Transparent alpha outside each sprite, no floor, no lighting aura discs. Keep every slot independent and centered; game sprites, not poster art.", + "world_transparency_edit": "Edit target: the attached 4 by 2 game sprite atlas. Background extraction ONLY. Remove the entire white/light gray background and every thin gray grid divider, replacing with truly transparent alpha. Preserve all eight sprite subjects, their exact positions, dimensions, details, colors, shape and arrangement. Do not redraw, move, resize or crop any subject. Preserve white shirt/paper/eye highlights inside subjects. Keep original landscape 2:1 canvas and equal cell layout. Output real transparent PNG; no checkerboard painted in.", + "rat_running": "Use case: stylized-concept. Generate ONE production pixel-art animation atlas: exact 4 columns x 4 rows on a square transparent canvas. Each row is a complete four-frame seamless running cycle of ONE rat, facing RIGHT in strict side profile. Row1 grey lean street rat with small pink ears, Row2 stocky brown sewer rat, Row3 charcoal black rat wearing a red bandana, Row4 albino ivory white rat with ruby red eyes. Same character identity and same proportions through each row, head and body size constant, feet baseline at 75 percent of each square cell, rat occupies 80 percent width including tail. Columns show four distinct run phases: stretched airborne, front paws landing, compact tucked stride, rear paws push off. Keep bodies low horizontal, tails curving behind to left, whiskers and noses clearly readable. Detailed 1990s adventure game pixel art, textured fur and crisp readable clusters, muted warm amber highlights, subtle teal shadows, not smooth vector, not emoji. Equal fixed square cells with completely transparent padding between rats, no drawn grid, no scenery, no cast shadows, no labels, no border, no watermark. All 16 rats must remain completely inside their slots, every rat points right, no extra rats. True transparent alpha background." +} diff --git a/assets/sprites/hall/prompts-v10.json b/assets/sprites/hall/prompts-v10.json new file mode 100644 index 0000000..d26a5fd --- /dev/null +++ b/assets/sprites/hall/prompts-v10.json @@ -0,0 +1,19 @@ +{ + "tool": "underworld and heist asset pipeline", + "sources": [ + "assets/sprites/hall/drink-hand-v5.png", + "assets/sprites/hall/underworld-portraits-v1.png", + "assets/sprites/hall/rat-race-v1.png" + ], + "packs": [ + "assets/animations/hall/drink-v5.bin", + "assets/animations/hall/underworld_portraits.bin", + "assets/animations/hall/rat_race.bin" + ], + "descriptions": { + "drink-hand-v5": "Six 7-phase bar drinks (42 frames of 256x256): Double Bluff Whisky, Cold Calc Crimson Cocktail, Cyber Punch Neon Cyan, Chameleon Emerald Lime, Lucky Clover Gold-Emerald, Pure Ice Water.", + "underworld-portraits-v1": "Eleven high-contrast 256x256 portraits and story elements: 0: Semyon (Loan Shark), 1: Collector Thug (Enforcer), 2: Pit Boss (Security Chief), 3: Vault Safe Dial, 4: Golden Deck of Cards, 5: Bartender (Shaker), 6: Cabaret Singer (Siren), 7: Fortune Teller (Tarot Mystic), 8: Hacker (Phantom), 9: Casino Vault Blueprint, 10: Rooftop Helicopter Escape.", + "rat-race-v1": "Underground cellar rat racing: 4 distinct rats (Flash, Toughie, Speedy, Ghost) with 4-frame running loops + checkered finish banner (17 frames of 128x128)." + }, + "normalization": "ANM1 binary format (magic ANM1, width, height, nframes, payload_len, raw BGRA pixel stream) for 320x240 software raycaster." +} \ No newline at end of file diff --git a/assets/sprites/hall/rat-race-v1.png b/assets/sprites/hall/rat-race-v1.png new file mode 100644 index 0000000..14bfe0d Binary files /dev/null and b/assets/sprites/hall/rat-race-v1.png differ diff --git a/assets/sprites/hall/rat-race-v2.png b/assets/sprites/hall/rat-race-v2.png new file mode 100644 index 0000000..7bee38e Binary files /dev/null and b/assets/sprites/hall/rat-race-v2.png differ diff --git a/assets/sprites/hall/underworld-portraits-v1.png b/assets/sprites/hall/underworld-portraits-v1.png new file mode 100644 index 0000000..90ca66d Binary files /dev/null and b/assets/sprites/hall/underworld-portraits-v1.png differ diff --git a/assets/sprites/hall/underworld-portraits-v2.png b/assets/sprites/hall/underworld-portraits-v2.png new file mode 100644 index 0000000..f404f56 Binary files /dev/null and b/assets/sprites/hall/underworld-portraits-v2.png differ diff --git a/assets/sprites/hall/underworld-world-v2.png b/assets/sprites/hall/underworld-world-v2.png new file mode 100644 index 0000000..60681db Binary files /dev/null and b/assets/sprites/hall/underworld-world-v2.png differ diff --git a/assets/sprites/intro/cards-cinematic-v3.png b/assets/sprites/intro/cards-cinematic-v3.png new file mode 100644 index 0000000..8736a0a Binary files /dev/null and b/assets/sprites/intro/cards-cinematic-v3.png differ diff --git a/assets/sprites/intro/casino-cinematic-v2.png b/assets/sprites/intro/casino-cinematic-v2.png new file mode 100644 index 0000000..dd42818 Binary files /dev/null and b/assets/sprites/intro/casino-cinematic-v2.png differ diff --git a/assets/sprites/intro/chips-cinematic-v3.png b/assets/sprites/intro/chips-cinematic-v3.png new file mode 100644 index 0000000..c3aa934 Binary files /dev/null and b/assets/sprites/intro/chips-cinematic-v3.png differ diff --git a/assets/sprites/intro/eblan-cinematic-v2.png b/assets/sprites/intro/eblan-cinematic-v2.png new file mode 100644 index 0000000..c35754e Binary files /dev/null and b/assets/sprites/intro/eblan-cinematic-v2.png differ diff --git a/assets/sprites/intro/prompts-cinematic-v2.json b/assets/sprites/intro/prompts-cinematic-v2.json new file mode 100644 index 0000000..3161bf1 --- /dev/null +++ b/assets/sprites/intro/prompts-cinematic-v2.json @@ -0,0 +1,17 @@ +{ + "mode": "built-in image_gen", + "assets": [ + { + "file": "roulette-cinematic-v1.png", + "prompt": "Use case: stylized-concept. Production game cinematic texture, a single isolated European roulette wheel viewed EXACTLY straight down, orthographic top view, perfectly circular, centered. Transparent background, no table, no room, no lettering outside the rim. Aged polished dark walnut outer rim, sumptuous engraved brass and gold inner concentric rings, accurate 37 red/black/green numbered pockets around the outer ring, dark green central brass spindle and polished gold roulette rotor, elegant believable crafted casino object, richly textured sharp material highlights. The whole wheel must fit within the image with a small transparent margin. Strong dramatic soft side light with turquoise fill and amber warm reflection. High contrast luxurious neo-noir mood, detailed realistic painted game cinematic art, no flat vector geometry, no abstract outline icon. No loose ball on wheel; the ball will be animated separately in engine. Square image at least 1024 by 1024. Real alpha transparency outside circle." + }, + { + "file": "eblan-cinematic-v2.png", + "prompt": "Use case: logo-brand. A production transparent title-card wordmark for a dark neo-noir casino videogame studio cinematic. EXACT two-line text: \"EBLAN\" on first line, \"GAMES\" smaller below, centered, spelled E B L A N / G A M E S. Bold dimensional late-1990s prestige videogame studio lettering, sculpted antique brass faces, deep dark teal polished metal extrusion, ivory bevel glints with slight red neon reflections. Strong cinematic depth and tangible materials, sophisticated heavy serif lettering, broad powerful proportions and beautiful sharp legibility. Thin wisps of semitransparent cool smoke lightly curling around bottom edges, few dust sparkles only. A tiny tasteful spade-shaped engraved emblem above text. This must look like a memorable physical film studio logo rather than outlines or wireframe. Only the complete wordmark and tiny emblem, NO roulette wheel, NO enclosing rectangle, NO scene background, NO watermark or other text. Whole composition isolated on actual transparent alpha with safe margin. Wide landscape 3:2 or 16:9, enough resolution for crisp 640x480 game presentation." + }, + { + "file": "casino-cinematic-v2.png", + "prompt": "Use case: logo-brand. Production title wordmark for a gritty first-person retro casino videogame, a tangible dramatic neon and metal title, not a flat vector. EXACT text in two centered lines: \"ASSEMBLER\" smaller above, \"CASINO\" very large below. A S S E M B L E R / C A S I N O, carefully exact spelling. Powerful wide late-1990s videogame title typography, thick beveled dark antique brass metal letters, burning warm ivory and ruby-red neon lighting in inset edges, deep dark teal side extrusions, subtle scratches and rain droplets, cinematic richness and beautiful sharp readable lettering, restrained small lens glints. Wide stacked composition, only the lettering and very faint soft glow, no big icon, no enclosing border, no casino building, no poker cards, no background scene, no extra words, no watermark. Isolated on REAL transparent alpha background. At least 1536 pixel wide landscape, safe transparent margin on all sides. Must read like a magnificent casino entrance sign brought into a film opening." + } + ] +} diff --git a/assets/sprites/intro/prompts-cinematic-v3.json b/assets/sprites/intro/prompts-cinematic-v3.json new file mode 100644 index 0000000..d472c27 --- /dev/null +++ b/assets/sprites/intro/prompts-cinematic-v3.json @@ -0,0 +1,13 @@ +{ + "mode": "built-in image_gen", + "assets": [ + { + "file": "cards-cinematic-v3.png", + "prompt": "Production cinematic videogame prop cutout, actual alpha transparency. Two beautifully detailed aged ivory playing cards, ace of spades and ace of hearts, slightly fanned and gently curved, photographed nearly front-on with a slight dynamic three-quarter tilt, the entire cards visible. Heavy real paper stock, worn gold edging and subtle embossed decorative spade, legible simple A indices in the corners, authentic suits. Strong neo-noir side lighting: warm copper gold rim from right and dark teal fill from left. Elegant substantial tangible materials matching an antique brass roulette wheel. A few tiny dust motes close to card edges only. No hands, no table, no text outside cards, no background, no watermark. Cards fill a portrait canvas with safe transparent margins; realistic cinematic game asset, not flat vector or outline art. Designed for a close camera fly-by with depth of field." + }, + { + "file": "chips-cinematic-v3.png", + "prompt": "Production cinematic videogame prop cutout, REAL transparent alpha background. Three short stacks of luxurious casino poker chips: deep ruby red ivory and gold, dark teal ivory and gold, a few loose chips leaning diagonally in front. Close three-quarter view near table height, believable thick clay edges with real metallic brass inlay and embossed spade emblems, excellent tactile detail, slight wear, substantial material. No printed numbers or words needed. Copper warm rim light from right and teal cinematic fill from left, dark neo-noir casino mood matching antique brass roulette and aged ivory playing cards. Entire cluster completely visible with safe transparent margins. No table, no background scene, no black rectangular matte, no hands, no watermark. Wide landscape cutout, highly polished realistic painted game cinematic asset for moving past the camera in a depth-of-field fly-through." + } + ] +} diff --git a/assets/sprites/intro/roulette-cinematic-v1.png b/assets/sprites/intro/roulette-cinematic-v1.png new file mode 100644 index 0000000..85ba56a Binary files /dev/null and b/assets/sprites/intro/roulette-cinematic-v1.png differ diff --git a/bin/poker.exe b/bin/poker.exe index 31c6a01..7db6c4c 100644 Binary files a/bin/poker.exe and b/bin/poker.exe differ diff --git a/build.bat b/build.bat index 0c1f3d4..f037aff 100644 --- a/build.bat +++ b/build.bat @@ -69,6 +69,8 @@ echo Linking poker.obj... if errorlevel 1 goto err copy /y poker.exe build\graphics\poker.exe >nul 2>&1 +powershell -NoProfile -ExecutionPolicy Bypass -File tools\build_launcher.ps1 +if errorlevel 1 goto err echo [SUCCESS] poker.exe built successfully! goto end diff --git a/build/AssemblerCasinoLauncher.cs b/build/AssemblerCasinoLauncher.cs index a279d80..ca864a4 100644 --- a/build/AssemblerCasinoLauncher.cs +++ b/build/AssemblerCasinoLauncher.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Security.Cryptography; @@ -8,7 +9,7 @@ namespace AssemblerCasinoLauncher { static class Program { - const string ExpectedPokerSha256 = "536E23BED4055562BC63871826FF44FFED037923A9BE8E0F591131DB4FBD104B"; + const string ExpectedPokerSha256 = "089E1ED01A257D10542C0668D00A7F337B55DDDDF7B55FF309C55B4914850DFD"; [STAThread] static void Main() @@ -17,8 +18,10 @@ namespace AssemblerCasinoLauncher // The installed launcher is at the root; developer builds live in dist. if (!File.Exists(Path.Combine(root, "bin", "poker.exe"))) { - var parent = Directory.GetParent(root.TrimEnd(Path.DirectorySeparatorChar)); - if (parent != null && Directory.Exists(Path.Combine(parent.FullName, "assets")) && + var launcherDirectory = new DirectoryInfo(root); + var parent = launcherDirectory.Parent; + if (launcherDirectory.Name.Equals("dist", StringComparison.OrdinalIgnoreCase) && + parent != null && Directory.Exists(Path.Combine(parent.FullName, "assets")) && File.Exists(Path.Combine(parent.FullName, "bin", "poker.exe"))) root = parent.FullName; } @@ -35,12 +38,20 @@ namespace AssemblerCasinoLauncher return; } - Process.Start(new ProcessStartInfo + try { - FileName = game, - WorkingDirectory = root, - UseShellExecute = false - }); + using (Process.Start(new ProcessStartInfo + { + FileName = game, + WorkingDirectory = root, + UseShellExecute = false + })) { } + } + catch (Win32Exception error) + { + MessageBox.Show("Не удалось запустить игру.\n" + error.Message, + "Assembler Casino", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } static bool VerifyGame(string gamePath) diff --git a/build/UninstallAssemblerCasino.cs b/build/UninstallAssemblerCasino.cs index d7c4676..94d4c22 100644 --- a/build/UninstallAssemblerCasino.cs +++ b/build/UninstallAssemblerCasino.cs @@ -162,7 +162,19 @@ namespace AssemblerCasinoUninstaller { try { - Registry.CurrentUser.DeleteSubKeyTree(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\AssemblerCasino", false); + using (var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall", true)) + { + if (key != null) + { + foreach (var sub in key.GetSubKeyNames()) + { + if (sub.StartsWith("AssemblerCasino", StringComparison.OrdinalIgnoreCase)) + { + try { key.DeleteSubKeyTree(sub, false); } catch { } + } + } + } + } } catch { } } diff --git a/build/graphics/poker.exe b/build/graphics/poker.exe index 31c6a01..7db6c4c 100644 Binary files a/build/graphics/poker.exe and b/build/graphics/poker.exe differ diff --git a/build/installer/CasinoSetup/InstallPaths.cs b/build/installer/CasinoSetup/InstallPaths.cs new file mode 100644 index 0000000..f32130e --- /dev/null +++ b/build/installer/CasinoSetup/InstallPaths.cs @@ -0,0 +1,140 @@ +using System; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Security.Cryptography; +using System.Xml; +using System.Xml.Linq; + +namespace CasinoSetup; + +public static class InstallPaths +{ + public const string ReceiptName = "casino-install.xml"; + + public static string Normalize(string path) + { + string fullPath = Path.GetFullPath(path); + if (fullPath.TrimEnd('\\', '/') == Path.GetPathRoot(fullPath).TrimEnd('\\', '/')) + { + throw new IOException("Нельзя устанавливать игру в корень диска."); + } + return fullPath.TrimEnd('\\', '/'); + } + + public static string SafeFile(string root, string relative) + { + if (string.IsNullOrWhiteSpace(relative) || Path.IsPathRooted(relative) || relative.Contains(':') || relative.Contains('\\') || relative.Split('/').Any((string p) => p == ".." || p == "." || p.Length == 0 || p.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || IsDevice(p) || p.EndsWith(".", StringComparison.Ordinal) || p.EndsWith(" ", StringComparison.Ordinal))) + { + throw new IOException("Недопустимый путь в пакете: " + relative); + } + string fullPath = Path.GetFullPath(Path.Combine(root, relative.Replace('/', Path.DirectorySeparatorChar))); + if (!fullPath.StartsWith(root.TrimEnd('\\') + "\\", StringComparison.OrdinalIgnoreCase)) + { + throw new IOException("Путь выходит за пределы установки."); + } + NoLinks(fullPath); + return fullPath; + } + + private static bool IsDevice(string name) + { + string text = name.Split('.')[0].ToUpperInvariant(); + if (!new string[6] { "CON", "PRN", "AUX", "NUL", "CONIN$", "CONOUT$" }.Contains(text)) + { + if (text.Length == 4 && (text.StartsWith("COM") || text.StartsWith("LPT")) && text[3] >= '1') + { + return text[3] <= '9'; + } + return false; + } + return true; + } + + public static void NoLinks(string path) + { + string text = path; + while (!string.IsNullOrEmpty(text)) + { + if ((Directory.Exists(text) || File.Exists(text)) && (File.GetAttributes(text) & FileAttributes.ReparsePoint) != 0) + { + throw new IOException("Папка установки не должна содержать символические ссылки: " + text); + } + text = Path.GetDirectoryName(text); + } + } + + public static void ValidateTarget(string target, string package) + { + target = Normalize(target); + NoLinks(target); + Environment.SpecialFolder[] array = new Environment.SpecialFolder[8] + { + Environment.SpecialFolder.Windows, + Environment.SpecialFolder.System, + Environment.SpecialFolder.ProgramFiles, + Environment.SpecialFolder.ProgramFilesX86, + Environment.SpecialFolder.UserProfile, + Environment.SpecialFolder.DesktopDirectory, + Environment.SpecialFolder.LocalApplicationData, + Environment.SpecialFolder.ApplicationData + }; + foreach (Environment.SpecialFolder specialFolder in array) + { + string folderPath = Environment.GetFolderPath(specialFolder); + if (!string.IsNullOrEmpty(folderPath)) + { + bool flag = specialFolder == Environment.SpecialFolder.Windows || specialFolder == Environment.SpecialFolder.System; + if (target.Equals(folderPath.TrimEnd('\\'), StringComparison.OrdinalIgnoreCase) || (flag && target.StartsWith(folderPath.TrimEnd('\\') + "\\", StringComparison.OrdinalIgnoreCase))) + { + throw new IOException("Выберите отдельную папку для игры, не системную папку."); + } + } + } + if (!string.IsNullOrEmpty(package) && Path.GetFullPath(package).StartsWith(target + "\\", StringComparison.OrdinalIgnoreCase)) + { + throw new IOException("Переместите установщик за пределы выбранной папки."); + } + } + + public static XDocument ReadXml(Stream stream) + { + XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); + xmlReaderSettings.DtdProcessing = DtdProcessing.Prohibit; + xmlReaderSettings.XmlResolver = null; + xmlReaderSettings.MaxCharactersInDocument = 16777216L; + XmlReaderSettings settings = xmlReaderSettings; + using XmlReader reader = XmlReader.Create(stream, settings); + return XDocument.Load(reader); + } + + public static string HashFile(string path) + { + using FileStream inputStream = File.OpenRead(path); + using SHA256 sHA = SHA256.Create(); + return Hex(sHA.ComputeHash(inputStream)); + } + + public static string Hex(byte[] bytes) + { + return BitConverter.ToString(bytes).Replace("-", "").ToLowerInvariant(); + } + + public static long Number(XElement e, string name) + { + long num = long.Parse((string)e.Attribute(name), CultureInfo.InvariantCulture); + if (num < 0) + { + throw new InvalidDataException("Отрицательный размер в пакете."); + } + return num; + } + + public static void CheckHash(string hash) + { + if (hash == null || hash.Length != 64 || hash.Any((char c) => !Uri.IsHexDigit(c))) + { + throw new InvalidDataException("Некорректная контрольная сумма."); + } + } +} diff --git a/build/installer/CasinoSetup/InstallProgress.cs b/build/installer/CasinoSetup/InstallProgress.cs new file mode 100644 index 0000000..521686e --- /dev/null +++ b/build/installer/CasinoSetup/InstallProgress.cs @@ -0,0 +1,14 @@ +namespace CasinoSetup; + +public sealed class InstallProgress +{ + public int Percent; + + public string Message; + + public InstallProgress(int percent, string message) + { + Percent = percent; + Message = message; + } +} diff --git a/build/installer/CasinoSetup/PackageInstaller.cs b/build/installer/CasinoSetup/PackageInstaller.cs new file mode 100644 index 0000000..10f6c3c --- /dev/null +++ b/build/installer/CasinoSetup/PackageInstaller.cs @@ -0,0 +1,308 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; +using System.Threading; +using System.Xml.Linq; +using Microsoft.Win32; + +namespace CasinoSetup; + +public sealed class PackageInstaller +{ + private readonly SetupPackage package; + + public string IntegrationWarning { get; private set; } + + public PackageInstaller(SetupPackage package) + { + this.package = package; + } + + public void Install(string target, bool model, bool shortcut, bool integration, Action report, CancellationToken token) + { + target = InstallPaths.Normalize(target); + IntegrationWarning = null; + InstallPaths.ValidateTarget(target, package.FileName); + long required = package.RequiredBytes(model); + if (new DriveInfo(Path.GetPathRoot(target)).AvailableFreeSpace < required + 134217728) + { + throw new IOException("Недостаточно свободного места для распаковки и безопасной замены файлов."); + } + Directory.CreateDirectory(target); + InstallPaths.NoLinks(Path.Combine(target, ".casino-install.lock")); + using (new FileStream(Path.Combine(target, ".casino-install.lock"), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 1, FileOptions.DeleteOnClose)) + { + List old = ReadReceipt(target); + string stage = Path.Combine(target, ".casino-stage-" + Guid.NewGuid().ToString("N")); + Directory.CreateDirectory(stage); + try + { + package.Verify(package.Game, report, token); + if (model) + { + package.Verify(package.Model, report, token); + } + List records = new List(); + HashSet paths = new HashSet(StringComparer.OrdinalIgnoreCase); + long done = 0L; + Action action = (Stream input, string relative, long length) => + { + token.ThrowIfCancellationRequested(); + if (!paths.Add(relative) || relative.Equals("casino-install.xml", StringComparison.OrdinalIgnoreCase) || relative.Split('/').Any((string p) => p.StartsWith(".casino-", StringComparison.OrdinalIgnoreCase))) + { + throw new InvalidDataException("Повторяющийся или служебный путь в пакете."); + } + string path = InstallPaths.SafeFile(stage, relative); + string path2 = InstallPaths.SafeFile(target, relative); + XElement xElement = old.FirstOrDefault((XElement e) => string.Equals((string)e.Attribute("path"), relative, StringComparison.OrdinalIgnoreCase)); + if (File.Exists(path2) && (xElement == null || !InstallPaths.HashFile(path2).Equals((string)xElement.Attribute("sha256"), StringComparison.OrdinalIgnoreCase))) + { + throw new IOException("Файл уже существует и не принадлежит этой установке либо изменён:\n" + relative + "\nВыберите другую папку."); + } + Directory.CreateDirectory(Path.GetDirectoryName(path)); + using FileStream fileStream = File.Create(path); + using SHA256 sHA = SHA256.Create(); + byte[] array = new byte[1048576]; + long num2 = 0L; + int num3; + while ((num3 = input.Read(array, 0, array.Length)) != 0) + { + token.ThrowIfCancellationRequested(); + num2 += num3; + if (num2 > length) + { + throw new InvalidDataException("Неверный размер файла."); + } + fileStream.Write(array, 0, num3); + sHA.TransformBlock(array, 0, num3, null, 0); + done += num3; + report(new InstallProgress(15 + (int)(done * 78 / Math.Max(1L, required)), "Установка: " + relative)); + } + if (num2 != length) + { + throw new EndOfStreamException("Неполный файл в пакете."); + } + sHA.TransformFinalBlock(array, 0, 0); + records.Add(new XElement("file", new XAttribute("path", relative), new XAttribute("sha256", InstallPaths.Hex(sHA.Hash)))); + }; + using (SliceStream stream = package.OpenBlock(package.Game)) + { + using ZipArchive zipArchive = new ZipArchive(stream, ZipArchiveMode.Read); + long num = 0L; + foreach (ZipArchiveEntry entry in zipArchive.Entries) + { + if (string.IsNullOrEmpty(entry.Name)) + { + throw new InvalidDataException("Неожиданная запись каталога."); + } + num = checked(num + entry.Length); + if (num > InstallPaths.Number(package.Game, "bytes")) + { + throw new InvalidDataException("Неверный размер архива."); + } + using Stream arg = entry.Open(); + action(arg, entry.FullName, entry.Length); + } + if (num != InstallPaths.Number(package.Game, "bytes")) + { + throw new InvalidDataException("Неполный архив игры."); + } + } + if (model) + { + using (SliceStream arg2 = package.OpenBlock(package.Model)) + { + action(arg2, (string)package.Model.Attribute("path"), InstallPaths.Number(package.Model, "bytes")); + } + if (!records.Last().Attribute("sha256").Value.Equals((string)package.Model.Attribute("sha256"), StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidDataException("Контрольная сумма модели не совпадает."); + } + } + records.AddRange(from e in old + where !paths.Contains((string)e.Attribute("path")) + select new XElement(e)); + XDocument xDocument = new XDocument(new XElement("casino-install", new XAttribute("version", "2"), new XAttribute("root", target), new XAttribute("id", Guid.NewGuid().ToString("N")), records)); + xDocument.Save(Path.Combine(stage, "casino-install.xml")); + token.ThrowIfCancellationRequested(); + report(new InstallProgress(94, "Сохранение файлов установки…")); + Commit(target, stage, paths.Concat(new string[1] { "casino-install.xml" }).ToArray()); + InstallPaths.NoLinks(Path.Combine(target, "runtime")); + Directory.CreateDirectory(Path.Combine(target, "runtime")); + if (integration) + { + try + { + Register(target, required); + if (shortcut) + { + CreateShortcut(target); + } + } + catch (Exception ex) + { + IntegrationWarning = "Игра установлена, но настройка Windows завершена не полностью:\n" + ex.Message; + } + } + report(new InstallProgress(100, "Казино готово к открытию")); + } + finally + { + if (Directory.Exists(stage) && !File.Exists(Path.Combine(stage, ".preserve-backup"))) + { + Directory.Delete(stage, recursive: true); + } + } + } + } + + public static List ReadReceipt(string target) + { + string path = InstallPaths.SafeFile(target, "casino-install.xml"); + if (!File.Exists(path)) + { + return new List(); + } + XDocument xDocument; + using (FileStream stream = File.OpenRead(path)) + { + xDocument = InstallPaths.ReadXml(stream); + } + if (xDocument.Root.Name != "casino-install" || (string)xDocument.Root.Attribute("version") != "2" || !target.Equals((string)xDocument.Root.Attribute("root"), StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidDataException("Неизвестный список установленных файлов."); + } + HashSet hashSet = new HashSet(StringComparer.OrdinalIgnoreCase); + List list = xDocument.Root.Elements("file").ToList(); + foreach (XElement item in list) + { + string text = (string)item.Attribute("path"); + InstallPaths.SafeFile(target, text); + InstallPaths.CheckHash((string)item.Attribute("sha256")); + if (!hashSet.Add(text)) + { + throw new InvalidDataException("Повторяющийся путь в списке установки."); + } + } + return list; + } + + private static void Commit(string target, string stage, string[] paths) + { + string text = Path.Combine(stage, ".backup"); + List list = new List(); + List list2 = new List(); + try + { + foreach (string relative in paths) + { + string path = InstallPaths.SafeFile(target, relative); + if (File.Exists(path)) + { + using (new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) + { + } + } + } + foreach (string text2 in paths) + { + string text3 = InstallPaths.SafeFile(target, text2); + string sourceFileName = InstallPaths.SafeFile(stage, text2); + string text4 = InstallPaths.SafeFile(text, text2); + Directory.CreateDirectory(Path.GetDirectoryName(text3)); + if (File.Exists(text3)) + { + Directory.CreateDirectory(Path.GetDirectoryName(text4)); + File.Move(text3, text4); + list2.Add(text2); + } + File.Move(sourceFileName, text3); + list.Add(text2); + } + } + catch + { + try + { + foreach (string item in list.AsEnumerable().Reverse()) + { + File.Delete(InstallPaths.SafeFile(target, item)); + } + foreach (string item2 in list2.AsEnumerable().Reverse()) + { + File.Move(InstallPaths.SafeFile(text, item2), InstallPaths.SafeFile(target, item2)); + } + } + catch (Exception innerException) + { + File.WriteAllText(Path.Combine(stage, ".preserve-backup"), "Rollback incomplete. Preserve this backup."); + throw new IOException("Не удалось восстановить прежнюю установку. Резервные файлы оставлены: " + text, innerException); + } + throw; + } + } + + private static void CreateShortcut(string target) + { + Type typeFromProgID = Type.GetTypeFromProgID("WScript.Shell"); + if (typeFromProgID == null) + { + throw new IOException("Windows Script Host недоступен: ярлык не создан."); + } + object obj = Activator.CreateInstance(typeFromProgID); + object obj2 = null; + try + { + string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); + string text = Path.Combine(folderPath, "Assembler Casino.lnk"); + obj2 = typeFromProgID.InvokeMember("CreateShortcut", BindingFlags.InvokeMethod, null, obj, new object[1] { text }); + Type type = obj2.GetType(); + if (File.Exists(text)) + { + string text2 = (string)type.InvokeMember("TargetPath", BindingFlags.GetProperty, null, obj2, null); + if (!text2.Equals(Path.Combine(target, "Assembler Casino.exe"), StringComparison.OrdinalIgnoreCase)) + { + throw new IOException("Файлы игры установлены; чужой ярлык с таким именем не изменён."); + } + } + type.InvokeMember("TargetPath", BindingFlags.SetProperty, null, obj2, new object[1] { Path.Combine(target, "Assembler Casino.exe") }); + type.InvokeMember("WorkingDirectory", BindingFlags.SetProperty, null, obj2, new object[1] { target }); + type.InvokeMember("IconLocation", BindingFlags.SetProperty, null, obj2, new object[1] { Path.Combine(target, "assets\\icons\\casino.ico") }); + type.InvokeMember("Save", BindingFlags.InvokeMethod, null, obj2, null); + } + finally + { + if (obj2 != null) + { + Marshal.FinalReleaseComObject(obj2); + } + Marshal.FinalReleaseComObject(obj); + } + } + + public static string RegistryKey(string target) + { + using SHA256 sHA = SHA256.Create(); + return "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\AssemblerCasino-" + InstallPaths.Hex(sHA.ComputeHash(Encoding.UTF8.GetBytes(target.ToLowerInvariant()))).Substring(0, 16); + } + + private static void Register(string target, long bytes) + { + using RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistryKey(target)); + registryKey.SetValue("DisplayName", "Assembler Casino"); + registryKey.SetValue("DisplayVersion", "2.0"); + registryKey.SetValue("Publisher", "Assembler Casino"); + registryKey.SetValue("InstallLocation", target); + registryKey.SetValue("DisplayIcon", Path.Combine(target, "Assembler Casino.exe")); + registryKey.SetValue("UninstallString", "\"" + Path.Combine(target, "Uninstall Assembler Casino.exe") + "\""); + registryKey.SetValue("EstimatedSize", (int)Math.Min(2147483647L, bytes / 1024), RegistryValueKind.DWord); + registryKey.SetValue("NoModify", 1, RegistryValueKind.DWord); + registryKey.SetValue("NoRepair", 1, RegistryValueKind.DWord); + } +} diff --git a/build/installer/CasinoSetup/PackageUninstaller.cs b/build/installer/CasinoSetup/PackageUninstaller.cs new file mode 100644 index 0000000..32d21d8 --- /dev/null +++ b/build/installer/CasinoSetup/PackageUninstaller.cs @@ -0,0 +1,147 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Xml.Linq; +using Microsoft.Win32; + +namespace CasinoSetup; + +public static class PackageUninstaller +{ + public static int Remove(string target, bool removeSaves, bool integration) + { + target = InstallPaths.Normalize(target); + InstallPaths.ValidateTarget(target, null); + if (!File.Exists(InstallPaths.SafeFile(target, "casino-install.xml"))) + { + throw new IOException("Нет списка установленных файлов. Автоматическое удаление запрещено."); + } + HashSet hashSet = new HashSet(StringComparer.OrdinalIgnoreCase); + hashSet.Add(Path.Combine(target, "runtime")); + int num = 0; + InstallPaths.NoLinks(Path.Combine(target, ".casino-install.lock")); + using (new FileStream(Path.Combine(target, ".casino-install.lock"), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 1, FileOptions.DeleteOnClose)) + { + List list = PackageInstaller.ReadReceipt(target); + foreach (XElement item in list) + { + string path = InstallPaths.SafeFile(target, (string)item.Attribute("path")); + if (File.Exists(path) && InstallPaths.HashFile(path).Equals((string)item.Attribute("sha256"), StringComparison.OrdinalIgnoreCase)) + { + using (new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) + { + } + } + } + foreach (XElement item2 in list) + { + string path2 = InstallPaths.SafeFile(target, (string)item2.Attribute("path")); + string directoryName = Path.GetDirectoryName(path2); + while (directoryName != target && directoryName != null) + { + hashSet.Add(directoryName); + directoryName = Path.GetDirectoryName(directoryName); + } + if (File.Exists(path2)) + { + if (!InstallPaths.HashFile(path2).Equals((string)item2.Attribute("sha256"), StringComparison.OrdinalIgnoreCase)) + { + num++; + } + else + { + File.Delete(path2); + } + } + } + if (integration) + { + string text = PackageInstaller.RegistryKey(target); + using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(text)) + { + if (registryKey != null && !target.Equals((string)registryKey.GetValue("InstallLocation"), StringComparison.OrdinalIgnoreCase)) + { + throw new IOException("Запись удаления относится к другой папке."); + } + } + Registry.CurrentUser.DeleteSubKeyTree(text, throwOnMissingSubKey: false); + RemoveShortcut(target); + } + if (removeSaves) + { + string path3 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "AssemblerCasino"); + DeleteSaveTree(path3); + } + File.Delete(InstallPaths.SafeFile(target, "casino-install.xml")); + foreach (string item3 in hashSet.OrderByDescending((string d) => d.Length)) + { + InstallPaths.NoLinks(item3); + if (Directory.Exists(item3) && !Directory.EnumerateFileSystemEntries(item3).Any()) + { + Directory.Delete(item3); + } + } + } + if (!Directory.EnumerateFileSystemEntries(target).Any()) + { + Directory.Delete(target); + } + return num; + } + + private static void DeleteSaveTree(string path) + { + InstallPaths.NoLinks(path); + if (Directory.Exists(path)) + { + string[] files = Directory.GetFiles(path); + foreach (string path2 in files) + { + InstallPaths.NoLinks(path2); + File.Delete(path2); + } + string[] directories = Directory.GetDirectories(path); + foreach (string path3 in directories) + { + DeleteSaveTree(path3); + } + Directory.Delete(path); + } + } + + private static void RemoveShortcut(string target) + { + string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "Assembler Casino.lnk"); + if (!File.Exists(text)) + { + return; + } + Type typeFromProgID = Type.GetTypeFromProgID("WScript.Shell"); + if (typeFromProgID == null) + { + return; + } + object obj = Activator.CreateInstance(typeFromProgID); + object obj2 = null; + try + { + obj2 = typeFromProgID.InvokeMember("CreateShortcut", BindingFlags.InvokeMethod, null, obj, new object[1] { text }); + string text2 = (string)obj2.GetType().InvokeMember("TargetPath", BindingFlags.GetProperty, null, obj2, null); + if (text2.Equals(Path.Combine(target, "Assembler Casino.exe"), StringComparison.OrdinalIgnoreCase)) + { + File.Delete(text); + } + } + finally + { + if (obj2 != null) + { + Marshal.FinalReleaseComObject(obj2); + } + Marshal.FinalReleaseComObject(obj); + } + } +} diff --git a/build/installer/CasinoSetup/SetupPackage.cs b/build/installer/CasinoSetup/SetupPackage.cs new file mode 100644 index 0000000..2cd45b6 --- /dev/null +++ b/build/installer/CasinoSetup/SetupPackage.cs @@ -0,0 +1,124 @@ +using System; +using System.IO; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading; +using System.Xml.Linq; + +namespace CasinoSetup; + +public sealed class SetupPackage : IDisposable +{ + public const string FooterMagic = "CASINO-PACK-V2!\n"; + + private readonly FileStream stream; + + private readonly long payload; + + public readonly XDocument Index; + + public readonly string FileName; + + public XElement Game => Index.Root.Element("game"); + + public XElement Model => Index.Root.Element("model"); + + public bool HasModel => Model != null; + + public long RequiredBytes(bool model) + { + if (model && !HasModel) + { + throw new InvalidOperationException("В этом установщике нет модели предсказательницы. Используйте полную версию установщика."); + } + return checked(InstallPaths.Number(Game, "bytes") + (model ? InstallPaths.Number(Model, "bytes") : 0)); + } + + public SetupPackage(string path, string expectedIndexHash) + { + FileName = Path.GetFullPath(path); + stream = File.OpenRead(path); + try + { + if (stream.Length < 32) + { + throw new InvalidDataException("Установочный пакет неполный."); + } + stream.Position = stream.Length - 32; + using BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8, leaveOpen: true); + payload = binaryReader.ReadInt64(); + long num = binaryReader.ReadInt64(); + if (Encoding.ASCII.GetString(binaryReader.ReadBytes(16)) != "CASINO-PACK-V2!\n" || num < 1 || num > 16777216 || payload < 0 || payload > stream.Length - 32 - num) + { + throw new InvalidDataException("Установочный пакет повреждён."); + } + long num2 = stream.Length - 32 - num; + using (SliceStream sliceStream = new SliceStream(stream, num2, num)) + { + using SHA256 sHA = SHA256.Create(); + if (!InstallPaths.Hex(sHA.ComputeHash(sliceStream)).Equals(expectedIndexHash, StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidDataException("Контрольная сумма оглавления не совпадает."); + } + sliceStream.Position = 0L; + Index = InstallPaths.ReadXml(sliceStream); + } + if (Index.Root.Name != "casino-package" || (string)Index.Root.Attribute("version") != "2" || Index.Root.Elements("game").Count() != 1 || Index.Root.Elements("model").Count() > 1 || Index.Root.Elements().Any((XElement e) => e.Name != "game" && e.Name != "model")) + { + throw new InvalidDataException("Неизвестный формат пакета."); + } + foreach (XElement item in Index.Root.Elements()) + { + long num3 = InstallPaths.Number(item, "offset"); + long num4 = InstallPaths.Number(item, "length"); + if (num3 > num2 - payload || num4 > num2 - payload - num3) + { + throw new InvalidDataException("Блок выходит за пределы пакета."); + } + InstallPaths.CheckHash((string)item.Attribute("sha256")); + } + long num5 = InstallPaths.Number(Game, "length"); + if (InstallPaths.Number(Game, "offset") != 0 || (!HasModel && num5 != num2 - payload) || (HasModel && (num5 != InstallPaths.Number(Model, "offset") || InstallPaths.Number(Model, "length") != num2 - payload - num5 || InstallPaths.Number(Model, "bytes") != InstallPaths.Number(Model, "length")))) + { + throw new InvalidDataException("Неверное расположение компонентов."); + } + } + catch + { + stream.Dispose(); + throw; + } + } + + public SliceStream OpenBlock(XElement block) + { + return new SliceStream(stream, checked(payload + InstallPaths.Number(block, "offset")), InstallPaths.Number(block, "length")); + } + + public void Verify(XElement block, Action report, CancellationToken token) + { + using SliceStream sliceStream = OpenBlock(block); + using SHA256 sHA = SHA256.Create(); + byte[] array = new byte[1048576]; + long num = 0L; + int num2; + while ((num2 = sliceStream.Read(array, 0, array.Length)) != 0) + { + token.ThrowIfCancellationRequested(); + sHA.TransformBlock(array, 0, num2, null, 0); + num += num2; + report(new InstallProgress((int)(num * 15 / Math.Max(1L, sliceStream.Length)), "Проверка: " + ((block == Game) ? "игра" : "модель предсказательницы"))); + } + sHA.TransformFinalBlock(array, 0, 0); + if (!InstallPaths.Hex(sHA.Hash).Equals((string)block.Attribute("sha256"), StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidDataException("Компонент повреждён. Установка остановлена."); + } + } + + public void Dispose() + { + stream.Dispose(); + } +} diff --git a/build/installer/CasinoSetup/SliceStream.cs b/build/installer/CasinoSetup/SliceStream.cs new file mode 100644 index 0000000..7a72ea0 --- /dev/null +++ b/build/installer/CasinoSetup/SliceStream.cs @@ -0,0 +1,83 @@ +using System; +using System.IO; + +namespace CasinoSetup; + +public sealed class SliceStream : Stream +{ + private readonly Stream source; + + private readonly long start; + + private readonly long length; + + private long position; + + public override bool CanRead => true; + + public override bool CanSeek => true; + + public override bool CanWrite => false; + + public override long Length => length; + + public override long Position + { + get + { + return position; + } + set + { + Seek(value, SeekOrigin.Begin); + } + } + + public SliceStream(Stream source, long start, long length) + { + if (start < 0 || length < 0 || start > source.Length - length) + { + throw new InvalidDataException("Повреждены границы пакета."); + } + this.source = source; + this.start = start; + this.length = length; + } + + public override int Read(byte[] buffer, int offset, int count) + { + source.Position = start + position; + int num = source.Read(buffer, offset, (int)Math.Min(count, length - position)); + position += num; + return num; + } + + public override long Seek(long offset, SeekOrigin origin) + { + long num = checked(origin switch + { + SeekOrigin.Current => position, + SeekOrigin.Begin => 0L, + _ => length, + } + offset); + if (num < 0 || num > length) + { + throw new IOException("Выход за границы пакета."); + } + return position = num; + } + + public override void Flush() + { + } + + public override void SetLength(long value) + { + throw new NotSupportedException(); + } + + public override void Write(byte[] buffer, int offset, int count) + { + throw new NotSupportedException(); + } +} diff --git a/build/installer/PokerGameSetup.csproj b/build/installer/PokerGameSetup.csproj new file mode 100644 index 0000000..e54d2b3 --- /dev/null +++ b/build/installer/PokerGameSetup.csproj @@ -0,0 +1,43 @@ + + + Setup-base + False + WinExe + True + net48 + x64 + + + 14.0 + True + False + + + app.ico + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/installer/PokerGameSetup/CasinoButton.cs b/build/installer/PokerGameSetup/CasinoButton.cs new file mode 100644 index 0000000..c6df9a2 --- /dev/null +++ b/build/installer/PokerGameSetup/CasinoButton.cs @@ -0,0 +1,213 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +namespace PokerGameSetup; + +internal sealed class CasinoButton : Button +{ + private const int CornerRadius = 6; + private bool isHovered; + private bool isPressed; + + public bool IsPrimary { get; set; } + + public CasinoButton() + { + SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); + Cursor = Cursors.Hand; + Font = new Font("Segoe UI", 10f, FontStyle.Bold); + } + + protected override void OnMouseEnter(EventArgs e) + { + base.OnMouseEnter(e); + isHovered = true; + Invalidate(); + } + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + isHovered = false; + isPressed = false; + Invalidate(); + } + + protected override void OnMouseDown(MouseEventArgs mevent) + { + base.OnMouseDown(mevent); + if (mevent.Button == MouseButtons.Left) + { + isPressed = true; + Invalidate(); + } + } + + protected override void OnMouseUp(MouseEventArgs mevent) + { + base.OnMouseUp(mevent); + isPressed = false; + Invalidate(); + } + + protected override void OnPaint(PaintEventArgs e) + { + Graphics g = e.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + g.PixelOffsetMode = PixelOffsetMode.HighQuality; + + Rectangle rect = new Rectangle(0, 0, Width - 1, Height - 1); + + using (GraphicsPath path = CreateRoundedRectangle(rect, CornerRadius)) + { + if (IsPrimary) + { + DrawPrimaryButton(g, path, rect); + } + else + { + DrawSecondaryButton(g, path, rect); + } + } + } + + private void DrawPrimaryButton(Graphics g, GraphicsPath path, Rectangle rect) + { + Color topColor; + Color bottomColor; + Color borderColor; + Color textColor = Color.FromArgb(20, 16, 10); + + if (!Enabled) + { + topColor = Color.FromArgb(70, 65, 55); + bottomColor = Color.FromArgb(50, 47, 40); + borderColor = Color.FromArgb(80, 75, 65); + textColor = Color.FromArgb(120, 115, 105); + } + else if (isPressed) + { + topColor = Color.FromArgb(200, 160, 80); + bottomColor = Color.FromArgb(170, 130, 60); + borderColor = Color.FromArgb(220, 185, 110); + } + else if (isHovered) + { + topColor = Color.FromArgb(255, 235, 160); + bottomColor = Color.FromArgb(235, 195, 110); + borderColor = Color.FromArgb(255, 245, 200); + } + else + { + topColor = Color.FromArgb(242, 212, 135); + bottomColor = Color.FromArgb(205, 165, 85); + borderColor = Color.FromArgb(250, 225, 160); + } + + // Outer subtle glow when hovered + if (Enabled && isHovered) + { + using (Pen glowPen = new Pen(Color.FromArgb(40, 229, 190, 112), 3f)) + { + g.DrawPath(glowPen, path); + } + } + + // Button background fill + using (LinearGradientBrush brush = new LinearGradientBrush(rect, topColor, bottomColor, 90f)) + { + g.FillPath(brush, path); + } + + // Inner top highlight line + if (Enabled && !isPressed) + { + using (Pen highlightPen = new Pen(Color.FromArgb(160, 255, 255, 255), 1f)) + { + g.DrawLine(highlightPen, rect.Left + CornerRadius, rect.Top + 1, rect.Right - CornerRadius, rect.Top + 1); + } + } + + // Outer border + using (Pen borderPen = new Pen(borderColor, 1.2f)) + { + g.DrawPath(borderPen, path); + } + + // Text + Point textPos = isPressed ? new Point(0, 1) : Point.Empty; + Rectangle textRect = new Rectangle(rect.X + textPos.X, rect.Y + textPos.Y, rect.Width, rect.Height); + TextRenderer.DrawText(g, Text, Font, textRect, textColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); + } + + private void DrawSecondaryButton(Graphics g, GraphicsPath path, Rectangle rect) + { + Color bgColor; + Color borderColor; + Color textColor; + + if (!Enabled) + { + bgColor = Color.FromArgb(20, 23, 25); + borderColor = Color.FromArgb(45, 48, 50); + textColor = Color.FromArgb(85, 90, 92); + } + else if (isPressed) + { + bgColor = Color.FromArgb(22, 25, 27); + borderColor = Color.FromArgb(90, 75, 50); + textColor = InstallerForm.Gold; + } + else if (isHovered) + { + bgColor = Color.FromArgb(42, 46, 48); + borderColor = Color.FromArgb(170, 140, 85); + textColor = Color.FromArgb(250, 235, 185); + } + else + { + bgColor = Color.FromArgb(28, 31, 33); + borderColor = Color.FromArgb(90, 75, 52); + textColor = InstallerForm.Gold; + } + + // Background fill + using (SolidBrush brush = new SolidBrush(bgColor)) + { + g.FillPath(brush, path); + } + + // Border + using (Pen borderPen = new Pen(borderColor, 1.2f)) + { + g.DrawPath(borderPen, path); + } + + // Text + Point textPos = isPressed ? new Point(0, 1) : Point.Empty; + Rectangle textRect = new Rectangle(rect.X + textPos.X, rect.Y + textPos.Y, rect.Width, rect.Height); + TextRenderer.DrawText(g, Text, Font, textRect, textColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); + } + + private static GraphicsPath CreateRoundedRectangle(Rectangle r, int d) + { + GraphicsPath path = new GraphicsPath(); + if (d <= 0) + { + path.AddRectangle(r); + return path; + } + int x = r.X; + int y = r.Y; + int w = r.Width; + int h = r.Height; + path.AddArc(x, y, d, d, 180, 90); + path.AddArc(x + w - d, y, d, d, 270, 90); + path.AddArc(x + w - d, y + h - d, d, d, 0, 90); + path.AddArc(x, y + h - d, d, d, 90, 90); + path.CloseFigure(); + return path; + } +} diff --git a/build/installer/PokerGameSetup/CasinoCardCheck.cs b/build/installer/PokerGameSetup/CasinoCardCheck.cs new file mode 100644 index 0000000..a96f5a5 --- /dev/null +++ b/build/installer/PokerGameSetup/CasinoCardCheck.cs @@ -0,0 +1,257 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +namespace PokerGameSetup; + +internal sealed class CasinoCardCheck : Control +{ + private bool isChecked; + private bool isLocked; + private bool isHovered; + private string title = ""; + private string badge = ""; + private string description = ""; + + public event EventHandler CheckedChanged; + + public bool Checked + { + get => isChecked; + set + { + if (isChecked != value) + { + isChecked = value; + Invalidate(); + CheckedChanged?.Invoke(this, EventArgs.Empty); + } + } + } + + public bool Locked + { + get => isLocked; + set + { + isLocked = value; + Invalidate(); + } + } + + public string Title + { + get => title; + set + { + title = value; + Invalidate(); + } + } + + public string Badge + { + get => badge; + set + { + badge = value; + Invalidate(); + } + } + + public string Description + { + get => description; + set + { + description = value; + Invalidate(); + } + } + + public CasinoCardCheck() + { + SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); + Cursor = Cursors.Hand; + Height = 64; + Width = 365; + } + + protected override void OnMouseEnter(EventArgs e) + { + base.OnMouseEnter(e); + isHovered = true; + Invalidate(); + } + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + isHovered = false; + Invalidate(); + } + + protected override void OnClick(EventArgs e) + { + base.OnClick(e); + if (!isLocked) + { + Checked = !Checked; + } + } + + protected override void OnPaint(PaintEventArgs e) + { + Graphics g = e.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + g.PixelOffsetMode = PixelOffsetMode.HighQuality; + + Rectangle rect = new Rectangle(0, 0, Width - 1, Height - 1); + int cornerRadius = 6; + + using (GraphicsPath cardPath = CreateRoundedRectangle(rect, cornerRadius)) + { + // Background + Color bgColor; + Color borderColor; + + if (isHovered && !isLocked) + { + bgColor = Color.FromArgb(34, 38, 41); + borderColor = isChecked ? Color.FromArgb(180, 150, 85) : Color.FromArgb(115, 95, 62); + } + else + { + bgColor = Color.FromArgb(24, 27, 29); + borderColor = isChecked ? Color.FromArgb(145, 120, 68) : Color.FromArgb(70, 60, 44); + } + + using (SolidBrush bgBrush = new SolidBrush(bgColor)) + { + g.FillPath(bgBrush, cardPath); + } + + // Border + using (Pen borderPen = new Pen(borderColor, isChecked ? 1.4f : 1f)) + { + g.DrawPath(borderPen, cardPath); + } + } + + // Checkbox square (20x20) + int boxSize = 20; + int boxX = 14; + int boxY = (Height - boxSize) / 2; + Rectangle boxRect = new Rectangle(boxX, boxY, boxSize, boxSize); + + using (GraphicsPath boxPath = CreateRoundedRectangle(boxRect, 4)) + { + if (isChecked) + { + // Filled gold square + using (LinearGradientBrush goldBrush = new LinearGradientBrush( + boxRect, + Color.FromArgb(242, 212, 135), + Color.FromArgb(195, 155, 75), + 90f)) + { + g.FillPath(goldBrush, boxPath); + } + + // Checkmark icon ✓ + using (Pen checkPen = new Pen(Color.FromArgb(22, 18, 10), 2.2f)) + { + checkPen.StartCap = LineCap.Round; + checkPen.EndCap = LineCap.Round; + g.DrawLines(checkPen, new Point[] + { + new Point(boxX + 4, boxY + 10), + new Point(boxX + 8, boxY + 15), + new Point(boxX + 15, boxY + 5) + }); + } + } + else + { + // Empty box + using (SolidBrush emptyBrush = new SolidBrush(Color.FromArgb(18, 20, 22))) + { + g.FillPath(emptyBrush, boxPath); + } + using (Pen emptyBorder = new Pen(Color.FromArgb(110, 95, 65), 1.2f)) + { + g.DrawPath(emptyBorder, boxPath); + } + } + } + + // Texts layout + int textX = boxX + boxSize + 12; + int availWidth = Width - textX - 12; + + // Badge drawing + if (!string.IsNullOrEmpty(badge)) + { + using Font badgeFont = new Font("Segoe UI", 7.8f, FontStyle.Bold); + Size badgeSize = TextRenderer.MeasureText(badge, badgeFont); + int badgeW = badgeSize.Width + 10; + int badgeH = 18; + int badgeX = Width - badgeW - 12; + int badgeY = 12; + + Rectangle badgeRect = new Rectangle(badgeX, badgeY, badgeW, badgeH); + using (GraphicsPath badgePath = CreateRoundedRectangle(badgeRect, 4)) + { + using (SolidBrush badgeBg = new SolidBrush(isLocked ? Color.FromArgb(45, 55, 45) : Color.FromArgb(38, 35, 26))) + { + g.FillPath(badgeBg, badgePath); + } + using (Pen badgeBorder = new Pen(isLocked ? Color.FromArgb(90, 160, 110) : Color.FromArgb(160, 130, 70), 1f)) + { + g.DrawPath(badgeBorder, badgePath); + } + } + TextRenderer.DrawText(g, badge, badgeFont, badgeRect, isLocked ? Color.FromArgb(120, 210, 140) : InstallerForm.Gold, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); + availWidth = badgeX - textX - 6; + } + + // Title + using (Font titleFont = new Font("Segoe UI", 10f, FontStyle.Bold)) + { + Rectangle titleRect = new Rectangle(textX, 10, availWidth, 20); + Color titleColor = isChecked ? InstallerForm.Paper : Color.FromArgb(180, 185, 185); + TextRenderer.DrawText(g, title, titleFont, titleRect, titleColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis); + } + + // Description + if (!string.IsNullOrEmpty(description)) + { + using (Font descFont = new Font("Segoe UI", 8.2f)) + { + Rectangle descRect = new Rectangle(textX, 31, Width - textX - 12, Height - 34); + TextRenderer.DrawText(g, description, descFont, descRect, Color.FromArgb(145, 155, 152), TextFormatFlags.Left | TextFormatFlags.Top | TextFormatFlags.WordBreak); + } + } + } + + private static GraphicsPath CreateRoundedRectangle(Rectangle r, int d) + { + GraphicsPath path = new GraphicsPath(); + if (d <= 0) + { + path.AddRectangle(r); + return path; + } + int x = r.X; + int y = r.Y; + int w = r.Width; + int h = r.Height; + path.AddArc(x, y, d, d, 180, 90); + path.AddArc(x + w - d, y, d, d, 270, 90); + path.AddArc(x + w - d, y + h - d, d, d, 0, 90); + path.AddArc(x, y + h - d, d, d, 90, 90); + path.CloseFigure(); + return path; + } +} diff --git a/build/installer/PokerGameSetup/CasinoProgressBar.cs b/build/installer/PokerGameSetup/CasinoProgressBar.cs new file mode 100644 index 0000000..904ec3e --- /dev/null +++ b/build/installer/PokerGameSetup/CasinoProgressBar.cs @@ -0,0 +1,140 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +namespace PokerGameSetup; + +internal sealed class CasinoProgressBar : Control +{ + private int value; + private double shimmerPhase; + + public int Value + { + get => value; + set + { + int clamped = Math.Max(0, Math.Min(100, value)); + if (this.value != clamped) + { + this.value = clamped; + Invalidate(); + } + } + } + + public double ShimmerPhase + { + get => shimmerPhase; + set + { + shimmerPhase = value; + Invalidate(); + } + } + + public CasinoProgressBar() + { + SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); + Font = new Font("Segoe UI", 9f, FontStyle.Bold); + } + + protected override void OnPaint(PaintEventArgs e) + { + Graphics g = e.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + g.PixelOffsetMode = PixelOffsetMode.HighQuality; + + Rectangle rect = new Rectangle(0, 0, Width - 1, Height - 1); + int radius = Math.Min(rect.Height - 1, 8); + + // Track background + using (GraphicsPath trackPath = CreateRoundedRectangle(rect, radius)) + { + using (SolidBrush trackBrush = new SolidBrush(Color.FromArgb(20, 23, 25))) + { + g.FillPath(trackBrush, trackPath); + } + + // Filled portion + if (value > 0) + { + int fillWidth = (int)Math.Round((rect.Width - 2) * (value / 100.0)); + if (fillWidth > 2) + { + Rectangle fillRect = new Rectangle(rect.X + 1, rect.Y + 1, fillWidth, rect.Height - 2); + int fillRadius = Math.Min(fillRect.Height - 1, radius); + + using (GraphicsPath fillPath = CreateRoundedRectangle(fillRect, fillRadius)) + { + // Gold gradient + using (LinearGradientBrush fillBrush = new LinearGradientBrush( + fillRect, + Color.FromArgb(245, 218, 140), + Color.FromArgb(195, 150, 65), + 90f)) + { + g.FillPath(fillBrush, fillPath); + } + + // Top specular line + using (Pen highlightPen = new Pen(Color.FromArgb(160, 255, 255, 255), 1f)) + { + g.DrawLine(highlightPen, fillRect.Left + 2, fillRect.Top + 1, fillRect.Right - 2, fillRect.Top + 1); + } + + // Animated Shimmer glint wave + int shimmerPos = (int)((shimmerPhase * (rect.Width + 120)) % (rect.Width + 120)) - 60; + Rectangle shimmerRect = new Rectangle(shimmerPos, fillRect.Y, 50, fillRect.Height); + if (shimmerRect.Right > fillRect.Left && shimmerRect.Left < fillRect.Right) + { + using (LinearGradientBrush shimmerBrush = new LinearGradientBrush( + shimmerRect, + Color.Transparent, + Color.FromArgb(120, 255, 255, 240), + 0f)) + { + ColorBlend blend = new ColorBlend(3); + blend.Colors = new Color[] { Color.Transparent, Color.FromArgb(140, 255, 255, 255), Color.Transparent }; + blend.Positions = new float[] { 0f, 0.5f, 1f }; + shimmerBrush.InterpolationColors = blend; + + GraphicsState state = g.Save(); + g.SetClip(fillPath); + g.FillRectangle(shimmerBrush, shimmerRect); + g.Restore(state); + } + } + } + } + } + + // Track border + using (Pen borderPen = new Pen(Color.FromArgb(90, 75, 52), 1f)) + { + g.DrawPath(borderPen, trackPath); + } + } +} + + private static GraphicsPath CreateRoundedRectangle(Rectangle r, int d) + { + GraphicsPath path = new GraphicsPath(); + if (d <= 0) + { + path.AddRectangle(r); + return path; + } + int x = r.X; + int y = r.Y; + int w = r.Width; + int h = r.Height; + path.AddArc(x, y, d, d, 180, 90); + path.AddArc(x + w - d, y, d, d, 270, 90); + path.AddArc(x + w - d, y + h - d, d, d, 0, 90); + path.AddArc(x, y + h - d, d, d, 90, 90); + path.CloseFigure(); + return path; + } +} diff --git a/build/installer/PokerGameSetup/CasinoStepper.cs b/build/installer/PokerGameSetup/CasinoStepper.cs new file mode 100644 index 0000000..39a1ba2 --- /dev/null +++ b/build/installer/PokerGameSetup/CasinoStepper.cs @@ -0,0 +1,191 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +namespace PokerGameSetup; + +internal sealed class CasinoStepper : Control +{ + private int currentStep; + + private static readonly string[] StepTitles = new string[] + { + "Добро пожаловать", + "Папка установки", + "Компоненты", + "Установка", + "Готово к игре" + }; + + private static readonly string[] StepSubtitles = new string[] + { + "Знакомство с казино", + "Выбор директории", + "Настройка и нейросеть", + "Распаковка ресурсов", + "Казино открыто" + }; + + public int CurrentStep + { + get => currentStep; + set + { + int clamped = Math.Max(0, Math.Min(4, value)); + if (currentStep != clamped) + { + currentStep = clamped; + Invalidate(); + } + } + } + + public CasinoStepper() + { + SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); + Height = 168; + Width = 365; + } + + protected override void OnPaint(PaintEventArgs e) + { + Graphics g = e.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + g.PixelOffsetMode = PixelOffsetMode.HighQuality; + + int stepCount = 5; + int stepSpacing = 33; + int startY = 12; + int nodeX = 14; + int nodeRadius = 9; // Diameter 18 + + // Draw connecting vertical rail line + int lineTop = startY + nodeRadius; + int lineBottom = startY + (stepCount - 1) * stepSpacing + nodeRadius; + + using (Pen railPen = new Pen(Color.FromArgb(48, 54, 58), 2f)) + { + g.DrawLine(railPen, nodeX, lineTop, nodeX, lineBottom); + } + + // Draw completed rail portion + if (currentStep > 0) + { + int completedBottom = startY + Math.Min(currentStep, stepCount - 1) * stepSpacing + nodeRadius; + using (Pen completedRailPen = new Pen(Color.FromArgb(180, 145, 75), 2f)) + { + g.DrawLine(completedRailPen, nodeX, lineTop, nodeX, completedBottom); + } + } + + for (int i = 0; i < stepCount; i++) + { + int cy = startY + i * stepSpacing + nodeRadius; + Rectangle nodeRect = new Rectangle(nodeX - nodeRadius, cy - nodeRadius, nodeRadius * 2, nodeRadius * 2); + + if (i < currentStep) + { + // Completed step: small gold badge with checkmark ✓ + using (SolidBrush fillBrush = new SolidBrush(Color.FromArgb(160, 130, 68))) + { + g.FillEllipse(fillBrush, nodeRect); + } + using (Pen checkPen = new Pen(Color.FromArgb(20, 18, 12), 1.8f)) + { + checkPen.StartCap = LineCap.Round; + checkPen.EndCap = LineCap.Round; + g.DrawLines(checkPen, new Point[] + { + new Point(nodeX - 4, cy), + new Point(nodeX - 1, cy + 3), + new Point(nodeX + 4, cy - 3) + }); + } + } + else if (i == currentStep) + { + // Active step: glowing gold ring with active halo and step number + Rectangle haloRect = new Rectangle(nodeRect.X - 3, nodeRect.Y - 3, nodeRect.Width + 6, nodeRect.Height + 6); + using (SolidBrush haloBrush = new SolidBrush(Color.FromArgb(45, 229, 190, 112))) + { + g.FillEllipse(haloBrush, haloRect); + } + + using (LinearGradientBrush activeBrush = new LinearGradientBrush( + nodeRect, + Color.FromArgb(250, 225, 150), + Color.FromArgb(200, 160, 80), + 90f)) + { + g.FillEllipse(activeBrush, nodeRect); + } + + using (Pen activeBorder = new Pen(Color.FromArgb(255, 245, 200), 1.2f)) + { + g.DrawEllipse(activeBorder, nodeRect); + } + + // Step number inside active node + string numStr = (i + 1).ToString(); + using (Font numFont = new Font("Segoe UI", 7.8f, FontStyle.Bold)) + { + TextRenderer.DrawText(g, numStr, numFont, nodeRect, Color.FromArgb(22, 18, 10), TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); + } + + // Left accent vertical pill on active step + using (LinearGradientBrush barBrush = new LinearGradientBrush( + new Rectangle(0, cy - 10, 3, 20), + Color.FromArgb(255, 230, 150), + Color.FromArgb(200, 150, 60), + 90f)) + { + g.FillRectangle(barBrush, 0, cy - 10, 3, 20); + } + } + else + { + // Future step: dark node with muted number + using (SolidBrush futureBrush = new SolidBrush(Color.FromArgb(25, 28, 30))) + { + g.FillEllipse(futureBrush, nodeRect); + } + using (Pen futureBorder = new Pen(Color.FromArgb(60, 68, 72), 1.2f)) + { + g.DrawEllipse(futureBorder, nodeRect); + } + string numStr = (i + 1).ToString(); + using (Font numFont = new Font("Segoe UI", 7.5f)) + { + TextRenderer.DrawText(g, numStr, numFont, nodeRect, Color.FromArgb(100, 110, 115), TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); + } + } + + // Draw Step title & subtitle + int textX = nodeX + nodeRadius + 12; + Rectangle titleRect = new Rectangle(textX, cy - 11, Width - textX - 8, 22); + + if (i == currentStep) + { + using (Font titleFont = new Font("Segoe UI", 10.5f, FontStyle.Bold)) + { + TextRenderer.DrawText(g, StepTitles[i], titleFont, titleRect, InstallerForm.Gold, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); + } + } + else if (i < currentStep) + { + using (Font titleFont = new Font("Segoe UI", 10f)) + { + TextRenderer.DrawText(g, StepTitles[i], titleFont, titleRect, Color.FromArgb(170, 185, 180), TextFormatFlags.Left | TextFormatFlags.VerticalCenter); + } + } + else + { + using (Font titleFont = new Font("Segoe UI", 10f)) + { + TextRenderer.DrawText(g, StepTitles[i], titleFont, titleRect, Color.FromArgb(105, 115, 118), TextFormatFlags.Left | TextFormatFlags.VerticalCenter); + } + } + } + } +} diff --git a/build/installer/PokerGameSetup/InstallerForm.cs b/build/installer/PokerGameSetup/InstallerForm.cs new file mode 100644 index 0000000..866e2fc --- /dev/null +++ b/build/installer/PokerGameSetup/InstallerForm.cs @@ -0,0 +1,787 @@ +using System; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; +using CasinoSetup; + +namespace PokerGameSetup; + +internal sealed class InstallerForm : Form +{ + private readonly SetupPackage package; + + private readonly Panel content = new Panel(); + + private readonly CasinoButton back; + + private readonly CasinoButton next; + + private readonly CasinoButton cancel; + + private readonly CasinoStepper stepper = new CasinoStepper(); + + private readonly SlideShow slides; + + private readonly Label sizes; + + private readonly System.Windows.Forms.Timer timer; + + private readonly Stopwatch clock = Stopwatch.StartNew(); + + private readonly RouletteControl roulette = new RouletteControl(); + + private readonly CasinoProgressBar progress = new CasinoProgressBar(); + + private readonly Label status = new Label(); + + private readonly Label percentLabel = new Label(); + + private string target = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Assembler Casino"); + + private bool includeModel = true; + + private bool desktopShortcut = true; + + private bool installing; + + private int step; + + private CancellationTokenSource cancellation; + + private InstallProgress latest; + + private CheckBox launch; + + public static readonly Color Gold = Color.FromArgb(229, 190, 112); + + public static readonly Color GoldLight = Color.FromArgb(250, 222, 145); + + public static readonly Color Ink = Color.FromArgb(14, 17, 20); + + public static readonly Color Paper = Color.FromArgb(238, 233, 222); + + public InstallerForm(SetupPackage package, int initialStep = 0) + { + this.package = package; + includeModel = package.HasModel; + Text = "Assembler Casino — мастер установки"; + ClientSize = new Size(1140, 720); + AutoScaleMode = AutoScaleMode.Dpi; + FormBorderStyle = FormBorderStyle.FixedSingle; + MaximizeBox = false; + StartPosition = FormStartPosition.CenterScreen; + BackColor = Ink; + ForeColor = Paper; + Font = new Font("Segoe UI", 10f); + DoubleBuffered = true; + + try + { + Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); + } + catch + { + } + + // Header labels + Label title = new Label + { + Text = "ASSEMBLER", + Font = new Font("Georgia", 26f, FontStyle.Bold), + ForeColor = GoldLight, + Bounds = new Rectangle(32, 22, 380, 44), + BackColor = Color.Transparent + }; + Controls.Add(title); + + Label subtitle = new Label + { + Text = "C A S I N O / M A S T E R S E T U P", + ForeColor = Color.FromArgb(175, 170, 155), + Bounds = new Rectangle(34, 68, 380, 22), + Font = new Font("Segoe UI", 8.5f, FontStyle.Bold), + BackColor = Color.Transparent + }; + Controls.Add(subtitle); + + // Modern Stepper + stepper.Bounds = new Rectangle(32, 115, 375, 168); + Controls.Add(stepper); + + // Dynamic content panel + content.Bounds = new Rectangle(32, 298, 375, 304); + Controls.Add(content); + + // Size / disk space label + sizes = new Label + { + Bounds = new Rectangle(32, 606, 375, 36), + ForeColor = Color.FromArgb(150, 160, 156), + Font = new Font("Segoe UI", 8.8f), + BackColor = Color.Transparent + }; + Controls.Add(sizes); + + // Buttons + back = new CasinoButton + { + Text = "Назад", + Bounds = new Rectangle(32, 650, 96, 42), + IsPrimary = false + }; + next = new CasinoButton + { + Text = "Далее →", + Bounds = new Rectangle(136, 650, 165, 42), + IsPrimary = true + }; + cancel = new CasinoButton + { + Text = "Отмена", + Bounds = new Rectangle(309, 650, 98, 42), + IsPrimary = false + }; + + Controls.Add(back); + Controls.Add(next); + Controls.Add(cancel); + + back.Click += (object s, EventArgs e) => + { + ShowStep(step - 1); + }; + next.Click += Next; + cancel.Click += (object s, EventArgs e) => + { + if (installing) + { + CancelInstall(); + } + else + { + Close(); + } + }; + + // Slideshow on the right + slides = new SlideShow + { + Bounds = new Rectangle(438, 0, 702, 720) + }; + Controls.Add(slides); + + // Animation Timer + timer = new System.Windows.Forms.Timer + { + Interval = 30 + }; + timer.Tick += (object s, EventArgs e) => + { + slides.AdvanceTime(); + + if (installing) + { + double time = clock.Elapsed.TotalSeconds; + roulette.Angle = time * 85.0; + roulette.Invalidate(); + progress.ShimmerPhase = time * 0.75; + + InstallProgress p = Interlocked.Exchange(ref latest, null); + if (p != null) + { + progress.Value = Math.Max(progress.Value, Math.Min(100, p.Percent)); + status.Text = p.Message; + percentLabel.Text = $"{progress.Value}%"; + } + } + }; + timer.Start(); + + FormClosing += (object s, FormClosingEventArgs e) => + { + if (installing) + { + e.Cancel = true; + CancelInstall(); + } + }; + FormClosed += (object s, FormClosedEventArgs e) => + { + timer.Dispose(); + slides.Dispose(); + cancellation?.Dispose(); + }; + + ShowStep(initialStep); + } + + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) + { + if ((keyData & Keys.Alt) == Keys.Alt) + { + Keys key = keyData & Keys.KeyCode; + if (key >= Keys.D1 && key <= Keys.D5) + { + ShowStep((int)key - (int)Keys.D1); + return true; + } + } + return base.ProcessCmdKey(ref msg, keyData); + } + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + Graphics g = e.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + + // Subtle luxury vignette gradient on left panel + using (LinearGradientBrush bgGrad = new LinearGradientBrush( + new Rectangle(0, 0, 438, Height), + Color.FromArgb(16, 19, 22), + Color.FromArgb(11, 13, 15), + 90f)) + { + g.FillRectangle(bgGrad, 0, 0, 438, Height); + } + + // Art Deco decorative divider below header + using (Pen sepPen = new Pen(Color.FromArgb(60, 229, 190, 112), 1f)) + { + g.DrawLine(sepPen, 32, 98, 190, 98); + g.DrawLine(sepPen, 218, 98, 395, 98); + } + // Diamond in the middle of divider + using (SolidBrush dBrush = new SolidBrush(Gold)) + { + Point[] diamond = new Point[] + { + new Point(204, 95), + new Point(208, 98), + new Point(204, 101), + new Point(200, 98) + }; + g.FillPolygon(dBrush, diamond); + } + } + + private Label CreateLabel(string text, int y, int height, float size, Color color, FontStyle style = FontStyle.Regular) + { + Label label = new Label + { + Text = text, + Bounds = new Rectangle(0, y, 375, height), + ForeColor = color, + Font = new Font((size >= 16f) ? "Georgia" : "Segoe UI", size, style), + BackColor = Color.Transparent + }; + content.Controls.Add(label); + return label; + } + + private void ShowStep(int value) + { + step = Math.Max(0, Math.Min(4, value)); + content.Controls.Clear(); + stepper.CurrentStep = step; + + back.Enabled = step > 0 && step < 3; + next.Enabled = step != 3; + + if (step == 2) + { + next.Text = "Установить →"; + } + else if (step == 4) + { + next.Text = "Играть →"; + } + else + { + next.Text = "Далее →"; + } + cancel.Text = (step == 4) ? "Закрыть" : "Отмена"; + + if (step == 0) + { + // Step 0: Welcome + CreateLabel("Ваш вечер\nначинается здесь", 0, 72, 22f, Paper, FontStyle.Bold); + CreateLabel("Игровые столы, тайные комнаты и секреты подполья казино.", 78, 44, 10.5f, Color.FromArgb(195, 190, 180)); + + // 4 Feature Chips / Badges + string[,] chips = new string[,] + { + { "♠ Pure x86 MASM", "Ассемблерный движок" }, + { "✦ 3D Raycaster", "Зал казино от 1-го лица" }, + { "◈ 100% Офлайн", "Полная автономность" }, + { "🧠 Нейросеть Таро", "Локальный ИИ Qwen 4B" } + }; + + int chipY = 128; + for (int i = 0; i < 4; i++) + { + int cx = (i % 2 == 0) ? 0 : 190; + int cy = chipY + (i / 2) * 54; + + Panel chipPanel = new Panel + { + Bounds = new Rectangle(cx, cy, 182, 48), + BackColor = Color.FromArgb(22, 25, 28) + }; + chipPanel.Paint += (object s, PaintEventArgs pe) => + { + pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias; + Rectangle r = new Rectangle(0, 0, chipPanel.Width - 1, chipPanel.Height - 1); + using Pen bp = new Pen(Color.FromArgb(70, 60, 45), 1f); + pe.Graphics.DrawRectangle(bp, r); + }; + + Label chipTitle = new Label + { + Text = chips[i, 0], + Bounds = new Rectangle(8, 6, 166, 18), + ForeColor = Gold, + Font = new Font("Segoe UI", 9f, FontStyle.Bold), + BackColor = Color.Transparent + }; + Label chipSub = new Label + { + Text = chips[i, 1], + Bounds = new Rectangle(8, 25, 166, 18), + ForeColor = Color.FromArgb(145, 155, 150), + Font = new Font("Segoe UI", 8f), + BackColor = Color.Transparent + }; + + chipPanel.Controls.Add(chipTitle); + chipPanel.Controls.Add(chipSub); + content.Controls.Add(chipPanel); + } + + // Offline note card + Panel notePanel = new Panel + { + Bounds = new Rectangle(0, 244, 375, 56), + BackColor = Color.FromArgb(20, 24, 26) + }; + notePanel.Paint += (object s, PaintEventArgs pe) => + { + pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias; + Rectangle r = new Rectangle(0, 0, notePanel.Width - 1, notePanel.Height - 1); + using Pen bp = new Pen(Color.FromArgb(85, 72, 50), 1f); + pe.Graphics.DrawRectangle(bp, r); + }; + Label noteLabel = new Label + { + Text = package.HasModel + ? "Вся игра и локальная нейросеть (2.5 ГБ) уже внутри дистрибутива. Интернет для установки и игры не требуется." + : "Дистрибутив без встроенной нейросети. Интернет не требуется.", + Bounds = new Rectangle(10, 8, 355, 40), + ForeColor = Color.FromArgb(170, 180, 175), + Font = new Font("Segoe UI", 8.8f), + BackColor = Color.Transparent + }; + notePanel.Controls.Add(noteLabel); + content.Controls.Add(notePanel); + } + else if (step == 1) + { + // Step 1: Folder Selection + CreateLabel("Место для казино", 0, 36, 21f, Paper, FontStyle.Bold); + CreateLabel("Выберите отдельную папку. Права администратора не требуются.", 38, 38, 9.8f, Color.FromArgb(185, 180, 170)); + + // Folder Path Container + Panel folderContainer = new Panel + { + Bounds = new Rectangle(0, 84, 375, 36), + BackColor = Color.FromArgb(25, 29, 32) + }; + folderContainer.Paint += (object s, PaintEventArgs pe) => + { + pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias; + Rectangle r = new Rectangle(0, 0, folderContainer.Width - 1, folderContainer.Height - 1); + using Pen bp = new Pen(Color.FromArgb(90, 78, 55), 1.2f); + pe.Graphics.DrawRectangle(bp, r); + }; + + TextBox box = new TextBox + { + Text = target, + Bounds = new Rectangle(8, 8, 359, 24), + BackColor = Color.FromArgb(25, 29, 32), + ForeColor = Paper, + BorderStyle = BorderStyle.None, + Font = new Font("Segoe UI", 9.5f) + }; + box.TextChanged += (object s, EventArgs e) => + { + target = box.Text; + UpdateSizes(); + }; + folderContainer.Controls.Add(box); + content.Controls.Add(folderContainer); + + CasinoButton browseBtn = new CasinoButton + { + Text = "Выбрать папку…", + Bounds = new Rectangle(0, 128, 160, 36), + IsPrimary = false + }; + browseBtn.Click += (object s, EventArgs e) => + { + using FolderBrowserDialog dlg = new FolderBrowserDialog(); + dlg.Description = "Родительская папка для установки Assembler Casino"; + if (Directory.Exists(target)) + { + dlg.SelectedPath = target; + } + if (dlg.ShowDialog(this) == DialogResult.OK) + { + box.Text = Path.Combine(dlg.SelectedPath, "Assembler Casino"); + } + }; + content.Controls.Add(browseBtn); + + // Info card about saves and portability + Panel infoCard = new Panel + { + Bounds = new Rectangle(0, 176, 375, 114), + BackColor = Color.FromArgb(20, 24, 27) + }; + infoCard.Paint += (object s, PaintEventArgs pe) => + { + pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias; + Rectangle r = new Rectangle(0, 0, infoCard.Width - 1, infoCard.Height - 1); + using Pen bp = new Pen(Color.FromArgb(75, 65, 48), 1f); + pe.Graphics.DrawRectangle(bp, r); + }; + + Label cardTitle = new Label + { + Text = "✦ Сохранения и автономность", + Bounds = new Rectangle(12, 10, 350, 20), + ForeColor = Gold, + Font = new Font("Segoe UI", 9.5f, FontStyle.Bold), + BackColor = Color.Transparent + }; + Label cardBody = new Label + { + Text = "Все профили игроков, баланс фишек и открытые сюжетные достижения сохраняются в AppData. При обновлении или повторной установке прогресс полностью сохраняется.", + Bounds = new Rectangle(12, 34, 350, 48), + ForeColor = Color.FromArgb(160, 172, 168), + Font = new Font("Segoe UI", 8.8f), + BackColor = Color.Transparent + }; + Label cardCheck = new Label + { + Text = "✓ На диске достаточно свободного места для игры", + Bounds = new Rectangle(12, 86, 350, 20), + ForeColor = Color.FromArgb(140, 210, 160), + Font = new Font("Segoe UI", 8.8f, FontStyle.Bold), + BackColor = Color.Transparent + }; + infoCard.Controls.Add(cardTitle); + infoCard.Controls.Add(cardBody); + infoCard.Controls.Add(cardCheck); + content.Controls.Add(infoCard); + } + else if (step == 2) + { + // Step 2: Components selection + CreateLabel("Соберите свой вечер", 0, 34, 21f, Paper, FontStyle.Bold); + + // Card 1: Core Game + CasinoCardCheck gameCard = new CasinoCardCheck + { + Bounds = new Rectangle(0, 44, 375, 64), + Title = "Основная игра", + Badge = "Обязательно", + Description = "3D-зал, 12 классических игр, подполье, бар и ограбление.", + Checked = true, + Locked = true + }; + content.Controls.Add(gameCard); + + // Card 2: Fortune Neural Model + if (package.HasModel) + { + CasinoCardCheck modelCard = new CasinoCardCheck + { + Bounds = new Rectangle(0, 116, 375, 66), + Title = "Офлайн-предсказательница", + Badge = FormatSize(InstallPaths.Number(package.Model, "bytes")), + Description = "Локальная нейросеть Qwen 4B (GGUF). Работает автономно.", + Checked = includeModel + }; + modelCard.CheckedChanged += (object s, EventArgs e) => + { + includeModel = modelCard.Checked; + UpdateSizes(); + }; + content.Controls.Add(modelCard); + } + else + { + Panel noModelPanel = new Panel + { + Bounds = new Rectangle(0, 116, 375, 66), + BackColor = Color.FromArgb(24, 26, 28) + }; + noModelPanel.Paint += (object s, PaintEventArgs pe) => + { + pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias; + Rectangle r = new Rectangle(0, 0, noModelPanel.Width - 1, noModelPanel.Height - 1); + using Pen bp = new Pen(Color.FromArgb(80, 70, 50), 1f); + pe.Graphics.DrawRectangle(bp, r); + }; + Label noModelTitle = new Label + { + Text = "Версия без встроенной нейросети", + Bounds = new Rectangle(12, 10, 350, 20), + ForeColor = Gold, + Font = new Font("Segoe UI", 9.5f, FontStyle.Bold), + BackColor = Color.Transparent + }; + Label noModelDesc = new Label + { + Text = "Чтобы включить гадалку, используйте полный установщик.", + Bounds = new Rectangle(12, 32, 350, 26), + ForeColor = Color.FromArgb(160, 170, 166), + Font = new Font("Segoe UI", 8.8f), + BackColor = Color.Transparent + }; + noModelPanel.Controls.Add(noModelTitle); + noModelPanel.Controls.Add(noModelDesc); + content.Controls.Add(noModelPanel); + } + + // Card 3: Desktop shortcut + CasinoCardCheck shortcutCard = new CasinoCardCheck + { + Bounds = new Rectangle(0, 190, 375, 60), + Title = "Ярлык на рабочем столе", + Badge = "Быстрый запуск", + Description = "Удобный значок на рабочем столе для быстрого входа в игру.", + Checked = desktopShortcut + }; + shortcutCard.CheckedChanged += (object s, EventArgs e) => + { + desktopShortcut = shortcutCard.Checked; + }; + content.Controls.Add(shortcutCard); + } + else if (step == 3) + { + // Step 3: Installation in progress + CreateLabel("Открываем двери казино", 0, 34, 21f, Paper, FontStyle.Bold); + + roulette.Bounds = new Rectangle(95, 38, 185, 185); + content.Controls.Add(roulette); + + status.Bounds = new Rectangle(0, 230, 305, 22); + status.ForeColor = Paper; + status.Font = new Font("Segoe UI", 9f); + status.Text = "Подготовка к распаковке компонентов…"; + status.BackColor = Color.Transparent; + content.Controls.Add(status); + + percentLabel.Bounds = new Rectangle(310, 228, 65, 22); + percentLabel.ForeColor = Gold; + percentLabel.Font = new Font("Segoe UI", 10f, FontStyle.Bold); + percentLabel.TextAlign = ContentAlignment.TopRight; + percentLabel.Text = $"{progress.Value}%"; + percentLabel.BackColor = Color.Transparent; + content.Controls.Add(percentLabel); + + progress.Bounds = new Rectangle(0, 258, 375, 18); + progress.Value = 0; + percentLabel.Text = "0%"; + content.Controls.Add(progress); + } + else + { + // Step 4: Finished + CreateLabel("Казино открыто!", 0, 40, 24f, Gold, FontStyle.Bold); + CreateLabel("Игра успешно установлена. Все компоненты готовы к запуску.", 42, 38, 10.5f, Paper); + + // Summary Checklist Card + Panel summaryCard = new Panel + { + Bounds = new Rectangle(0, 88, 375, 136), + BackColor = Color.FromArgb(20, 24, 27) + }; + summaryCard.Paint += (object s, PaintEventArgs pe) => + { + pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias; + Rectangle r = new Rectangle(0, 0, summaryCard.Width - 1, summaryCard.Height - 1); + using Pen bp = new Pen(Color.FromArgb(90, 78, 55), 1.2f); + pe.Graphics.DrawRectangle(bp, r); + }; + + string mText = includeModel + ? "✦ Нейросеть предсказательницы готова (локально на ПК)" + : "✦ Установлено без модели гадалки"; + + string[] checkItems = new string[] + { + "✓ Файлы Assembler Casino распакованы", + "✓ 3D-движок зала, мини-игры и аудио настроены", + mText, + desktopShortcut ? "✓ Ярлык создан на рабочем столе" : "✓ Установка в отдельную папку завершена" + }; + + for (int j = 0; j < checkItems.Length; j++) + { + Label item = new Label + { + Text = checkItems[j], + Bounds = new Rectangle(12, 12 + j * 28, 350, 22), + ForeColor = (j == 2 && !includeModel) ? Color.FromArgb(170, 165, 150) : Color.FromArgb(145, 210, 160), + Font = new Font("Segoe UI", 9.2f, FontStyle.Bold), + BackColor = Color.Transparent + }; + summaryCard.Controls.Add(item); + } + content.Controls.Add(summaryCard); + + // Launch checkbox + launch = new CheckBox + { + Text = "Запустить Assembler Casino прямо сейчас", + Checked = true, + Bounds = new Rectangle(6, 242, 365, 34), + ForeColor = Gold, + Font = new Font("Segoe UI", 10.5f, FontStyle.Bold), + BackColor = Color.Transparent + }; + launch.CheckedChanged += (object s, EventArgs e) => + { + next.Text = launch.Checked ? "Играть →" : "Готово"; + }; + content.Controls.Add(launch); + } + + UpdateSizes(); + } + + private static string FormatSize(long bytes) + { + return ((double)bytes / 1073741824.0).ToString("0.00") + " ГБ"; + } + + private void UpdateSizes() + { + string freeText = ""; + try + { + freeText = " · Свободно: " + FormatSize(new DriveInfo(Path.GetPathRoot(Path.GetFullPath(target))).AvailableFreeSpace); + } + catch + { + } + sizes.Text = "Требуется места: " + FormatSize(package.RequiredBytes(includeModel)) + freeText; + } + + private async void Next(object sender, EventArgs e) + { + if (step == 4) + { + if (launch != null && launch.Checked) + { + try + { + ProcessStartInfo psi = new ProcessStartInfo + { + FileName = Path.Combine(target, "Assembler Casino.exe"), + WorkingDirectory = target + }; + Process.Start(psi); + } + catch (Exception ex) + { + MessageBox.Show(this, ex.Message, "Ошибка запуска", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + Close(); + return; + } + + if (step == 1) + { + try + { + target = InstallPaths.Normalize(target); + InstallPaths.ValidateTarget(target, Application.ExecutablePath); + } + catch (Exception ex) + { + MessageBox.Show(this, ex.Message, "Папка установки", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + } + + if (step != 2) + { + ShowStep(step + 1); + return; + } + + // Step 2 -> 3: Start install + installing = true; + cancellation = new CancellationTokenSource(); + ShowStep(3); + + try + { + PackageInstaller installer = new PackageInstaller(package); + await Task.Run(() => + { + installer.Install(target, includeModel, desktopShortcut, integration: true, (InstallProgress p) => + { + Interlocked.Exchange(ref latest, p); + }, cancellation.Token); + }); + + installing = false; + ShowStep(4); + + if (installer.IntegrationWarning != null) + { + MessageBox.Show(this, installer.IntegrationWarning, "Игра установлена", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + catch (OperationCanceledException) + { + installing = false; + ShowStep(2); + } + catch (Exception ex) + { + installing = false; + ShowStep(2); + MessageBox.Show(this, ex.Message, "Ошибка установки", MessageBoxButtons.OK, MessageBoxIcon.Hand); + } + finally + { + cancellation?.Dispose(); + cancellation = null; + cancel.Enabled = true; + } + } + + private void CancelInstall() + { + if (cancellation != null && !cancellation.IsCancellationRequested && + MessageBox.Show(this, "Отменить установку Assembler Casino?", "Assembler Casino", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + cancellation.Cancel(); + cancel.Enabled = false; + status.Text = "Отмена, очистка временных файлов…"; + } + } +} diff --git a/build/installer/PokerGameSetup/PackageStamp.cs b/build/installer/PokerGameSetup/PackageStamp.cs new file mode 100644 index 0000000..92818b4 --- /dev/null +++ b/build/installer/PokerGameSetup/PackageStamp.cs @@ -0,0 +1,6 @@ +namespace PokerGameSetup; + +internal static class PackageStamp +{ + public const string IndexSha256 = "36e0ac9449b7b7c43b373c79f0eb886fb376a33a5b3f4fc065776fbce6ecf8b5"; +} diff --git a/build/installer/PokerGameSetup/Program.cs b/build/installer/PokerGameSetup/Program.cs new file mode 100644 index 0000000..7182020 --- /dev/null +++ b/build/installer/PokerGameSetup/Program.cs @@ -0,0 +1,33 @@ +using System; +using System.Windows.Forms; +using CasinoSetup; + +namespace PokerGameSetup; + +internal static class Program +{ + [STAThread] + private static void Main(string[] args) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(defaultValue: false); + try + { + int initialStep = 0; + for (int i = 0; i < args.Length; i++) + { + if (args[i] == "--step" && i + 1 < args.Length && int.TryParse(args[i + 1], out int s)) + { + initialStep = s; + } + } + + using SetupPackage package = new SetupPackage(Application.ExecutablePath, PackageStamp.IndexSha256); + Application.Run(new InstallerForm(package, initialStep)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Assembler Casino — ошибка пакета", MessageBoxButtons.OK, MessageBoxIcon.Hand); + } + } +} diff --git a/build/installer/PokerGameSetup/RouletteControl.cs b/build/installer/PokerGameSetup/RouletteControl.cs new file mode 100644 index 0000000..c4c6543 --- /dev/null +++ b/build/installer/PokerGameSetup/RouletteControl.cs @@ -0,0 +1,236 @@ +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +namespace PokerGameSetup; + +internal sealed class RouletteControl : Control +{ + public double Angle; + + public RouletteControl() + { + SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); + } + + protected override void OnPaint(PaintEventArgs e) + { + Graphics g = e.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + g.PixelOffsetMode = PixelOffsetMode.HighQuality; + + float cx = (float)Width / 2f; + float cy = (float)Height / 2f; + float maxR = Math.Min(cx, cy) - 4f; + + // 1. Ambient Warm Radial Glow behind the wheel + using (GraphicsPath glowPath = new GraphicsPath()) + { + glowPath.AddEllipse(cx - maxR - 4f, cy - maxR - 4f, (maxR + 4f) * 2f, (maxR + 4f) * 2f); + using (PathGradientBrush pgb = new PathGradientBrush(glowPath)) + { + pgb.CenterColor = Color.FromArgb(40, 229, 190, 112); + pgb.SurroundColors = new Color[] { Color.Transparent }; + g.FillPath(pgb, glowPath); + } + } + + // 2. Outer Mahogany Wood Rim + float woodR = maxR; + using (LinearGradientBrush woodBrush = new LinearGradientBrush( + new RectangleF(cx - woodR, cy - woodR, woodR * 2f, woodR * 2f), + Color.FromArgb(76, 40, 24), + Color.FromArgb(42, 20, 12), + 45f)) + { + g.FillEllipse(woodBrush, cx - woodR, cy - woodR, woodR * 2f, woodR * 2f); + } + + // Outer wood rim border + using (Pen woodPen = new Pen(Color.FromArgb(105, 58, 32), 1.5f)) + { + g.DrawEllipse(woodPen, cx - woodR, cy - woodR, woodR * 2f, woodR * 2f); + } + + // 16 Golden Brass Studs / Rivets around wood rim + float rivetR = woodR - 5f; + for (int r = 0; r < 16; r++) + { + double rad = r * Math.PI * 2.0 / 16.0; + float rx = cx + (float)Math.Cos(rad) * rivetR; + float ry = cy + (float)Math.Sin(rad) * rivetR; + using (SolidBrush studBrush = new SolidBrush(Color.FromArgb(235, 205, 130))) + { + g.FillEllipse(studBrush, rx - 1.5f, ry - 1.5f, 3f, 3f); + } + } + + // 3. Brass Ball Track + float brassR = woodR - 10f; + using (LinearGradientBrush brassBrush = new LinearGradientBrush( + new RectangleF(cx - brassR, cy - brassR, brassR * 2f, brassR * 2f), + Color.FromArgb(215, 175, 95), + Color.FromArgb(145, 110, 50), + 135f)) + { + g.FillEllipse(brassBrush, cx - brassR, cy - brassR, brassR * 2f, brassR * 2f); + } + + // Inner track step + float innerTrackR = brassR - 4f; + using (SolidBrush trackBed = new SolidBrush(Color.FromArgb(30, 24, 18))) + { + g.FillEllipse(trackBed, cx - innerTrackR, cy - innerTrackR, innerTrackR * 2f, innerTrackR * 2f); + } + + // 4. Numbered Pockets Ring (37 slots) + float pocketOuterR = innerTrackR - 1f; + float pocketInnerR = pocketOuterR * 0.68f; + + for (int i = 0; i < 37; i++) + { + Color pocketColor; + if (i == 0) + { + pocketColor = Color.FromArgb(25, 120, 65); // 0 Green + } + else + { + pocketColor = (i % 2 == 0) ? Color.FromArgb(165, 32, 42) : Color.FromArgb(22, 26, 28); + } + + float startAngle = (float)Angle + (float)i * 360f / 37f; + float sweepAngle = 360f / 37f + 0.2f; + + using (SolidBrush pBrush = new SolidBrush(pocketColor)) + { + g.FillPie(pBrush, cx - pocketOuterR, cy - pocketOuterR, pocketOuterR * 2f, pocketOuterR * 2f, startAngle, sweepAngle); + } + } + + // Divider frets (thin gold lines between pockets) + using (Pen fretPen = new Pen(Color.FromArgb(210, 180, 110), 1f)) + { + for (int i = 0; i < 37; i++) + { + double rad = ((Angle + i * 360.0 / 37.0) * Math.PI) / 180.0; + float x1 = cx + (float)Math.Cos(rad) * pocketInnerR; + float y1 = cy + (float)Math.Sin(rad) * pocketInnerR; + float x2 = cx + (float)Math.Cos(rad) * pocketOuterR; + float y2 = cy + (float)Math.Sin(rad) * pocketOuterR; + g.DrawLine(fretPen, x1, y1, x2, y2); + } + } + + // Pocket border rings + using (Pen pocketBorder = new Pen(InstallerForm.Gold, 1.2f)) + { + g.DrawEllipse(pocketBorder, cx - pocketOuterR, cy - pocketOuterR, pocketOuterR * 2f, pocketOuterR * 2f); + g.DrawEllipse(pocketBorder, cx - pocketInnerR, cy - pocketInnerR, pocketInnerR * 2f, pocketInnerR * 2f); + } + + // 5. Emerald Center Felt + using (LinearGradientBrush feltBrush = new LinearGradientBrush( + new RectangleF(cx - pocketInnerR, cy - pocketInnerR, pocketInnerR * 2f, pocketInnerR * 2f), + Color.FromArgb(18, 55, 38), + Color.FromArgb(10, 32, 22), + 90f)) + { + g.FillEllipse(feltBrush, cx - pocketInnerR, cy - pocketInnerR, pocketInnerR * 2f, pocketInnerR * 2f); + } + + // 6. Brass Turret Cone (Center Spindle) + float coneR = pocketInnerR * 0.62f; + using (LinearGradientBrush coneBrush = new LinearGradientBrush( + new RectangleF(cx - coneR, cy - coneR, coneR * 2f, coneR * 2f), + Color.FromArgb(245, 215, 135), + Color.FromArgb(150, 110, 50), + 45f)) + { + g.FillEllipse(coneBrush, cx - coneR, cy - coneR, coneR * 2f, coneR * 2f); + } + using (Pen coneBorder = new Pen(Color.FromArgb(255, 235, 160), 1.2f)) + { + g.DrawEllipse(coneBorder, cx - coneR, cy - coneR, coneR * 2f, coneR * 2f); + } + + // 7. Rotating 4-Way Brass Cross Handles with Spherical Ball Knobs + GraphicsState gstate = g.Save(); + g.TranslateTransform(cx, cy); + g.RotateTransform((float)Angle); + + float spokeLen = coneR * 1.35f; + using (Pen spokePen = new Pen(Color.FromArgb(235, 200, 115), 3.5f)) + { + spokePen.StartCap = LineCap.Round; + spokePen.EndCap = LineCap.Round; + g.DrawLine(spokePen, -spokeLen, 0, spokeLen, 0); + g.DrawLine(spokePen, 0, -spokeLen, 0, spokeLen); + } + + // 4 Spherical Gold Knobs on handle tips + float[] knobAngles = new float[] { 0, 90, 180, 270 }; + foreach (float a in knobAngles) + { + double rad = a * Math.PI / 180.0; + float kx = (float)Math.Cos(rad) * spokeLen; + float ky = (float)Math.Sin(rad) * spokeLen; + + using (SolidBrush knobBrush = new SolidBrush(Color.FromArgb(255, 225, 140))) + { + g.FillEllipse(knobBrush, kx - 3.5f, ky - 3.5f, 7f, 7f); + } + using (Pen knobBorder = new Pen(Color.FromArgb(160, 120, 55), 1f)) + { + g.DrawEllipse(knobBorder, kx - 3.5f, ky - 3.5f, 7f, 7f); + } + } + + // Central Acorn Dome / Finial + float domeR = 7f; + using (LinearGradientBrush domeBrush = new LinearGradientBrush( + new RectangleF(-domeR, -domeR, domeR * 2f, domeR * 2f), + Color.FromArgb(255, 240, 180), + Color.FromArgb(170, 130, 60), + 45f)) + { + g.FillEllipse(domeBrush, -domeR, -domeR, domeR * 2f, domeR * 2f); + } + // Specular pin highlight on central dome + using (SolidBrush specBrush = new SolidBrush(Color.FromArgb(230, 255, 255, 255))) + { + g.FillEllipse(specBrush, -2.5f, -2.5f, 2.5f, 2.5f); + } + + g.Restore(gstate); + + // 8. 3D Ivory Ball with Drop Shadow + double ballAngle = (0.0 - Angle * 1.85) * Math.PI / 180.0; + float ballOrbitR = (innerTrackR + brassR) / 2f - 1f; + float bx = cx + (float)Math.Cos(ballAngle) * ballOrbitR; + float by = cy + (float)Math.Sin(ballAngle) * ballOrbitR; + + // Drop shadow + using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(90, 0, 0, 0))) + { + g.FillEllipse(shadowBrush, bx - 3f, by - 2f, 9f, 9f); + } + + // Ivory ball body + RectangleF ballRect = new RectangleF(bx - 4.5f, by - 4.5f, 9f, 9f); + using (LinearGradientBrush ballBrush = new LinearGradientBrush( + ballRect, + Color.FromArgb(255, 255, 250), + Color.FromArgb(215, 210, 195), + 45f)) + { + g.FillEllipse(ballBrush, ballRect); + } + // Specular gleam on ball + using (SolidBrush gleamBrush = new SolidBrush(Color.White)) + { + g.FillEllipse(gleamBrush, bx - 2.5f, by - 2.5f, 2.8f, 2.8f); + } + } +} diff --git a/build/installer/PokerGameSetup/SlideShow.cs b/build/installer/PokerGameSetup/SlideShow.cs new file mode 100644 index 0000000..feb224b --- /dev/null +++ b/build/installer/PokerGameSetup/SlideShow.cs @@ -0,0 +1,498 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Windows.Forms; + +namespace PokerGameSetup; + +internal sealed class SlideShow : Control +{ + private struct Particle + { + public float X; + public float Y; + public float Speed; + public float Size; + public float Alpha; + public float SwayOffset; + } + + private readonly Image[] frames; + + private readonly string[] captions = new string[8] + { + "Вечер в казино", + "Покерные баталии", + "Лаунж и живая музыка", + "Блэкджек с дилером", + "Комната предсказательницы", + "Европейская рулетка", + "Боулинг и мини-игры", + "Игровые автоматы" + }; + + private readonly string[] tags = new string[8] + { + "3D HALL RAYCASTER", + "TEXAS HOLD'EM", + "CABARET & LOUNGE", + "BLACKJACK 21", + "NEURAL TAROT AI", + "ROULETTE WHEEL", + "CLUB ACTIVITIES", + "SLOTS 777" + }; + + private readonly Particle[] particles; + private readonly Stopwatch clock = Stopwatch.StartNew(); + private double lastTimeSeconds; + + private int currentSlide; + private int prevSlide; + private float transitionAlpha = 1.0f; + private double slideStayTimer; + + private bool hoveredLeftArrow; + private bool hoveredRightArrow; + private int hoveredCapsule = -1; + + public SlideShow() + { + SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); + Cursor = Cursors.Default; + + Assembly assembly = Assembly.GetExecutingAssembly(); + frames = ((IEnumerable)(from n in assembly.GetManifestResourceNames() + where n.StartsWith("slide.") + orderby n + select n)).Select((Func)((string n) => + { + using Stream stream = assembly.GetManifestResourceStream(n); + using Image original = Image.FromStream(stream); + return new Bitmap(original); + })).ToArray(); + + Random rnd = new Random(42); + particles = new Particle[32]; + for (int i = 0; i < particles.Length; i++) + { + particles[i] = new Particle + { + X = (float)rnd.NextDouble(), + Y = (float)rnd.NextDouble(), + Speed = 0.02f + (float)rnd.NextDouble() * 0.04f, + Size = 1.5f + (float)rnd.NextDouble() * 3.5f, + Alpha = 40f + (float)rnd.NextDouble() * 90f, + SwayOffset = (float)rnd.NextDouble() * 6.28f + }; + } + lastTimeSeconds = clock.Elapsed.TotalSeconds; + } + + protected override void Dispose(bool disposing) + { + if (disposing && frames != null) + { + foreach (Image image in frames) + { + image?.Dispose(); + } + } + base.Dispose(disposing); + } + + public void AdvanceTime() + { + double now = clock.Elapsed.TotalSeconds; + double delta = now - lastTimeSeconds; + lastTimeSeconds = now; + + if (delta < 0 || delta > 0.5) + { + delta = 0.033; + } + + // Advance transition crossfade + if (transitionAlpha < 1.0f) + { + transitionAlpha = Math.Min(1.0f, transitionAlpha + (float)(delta * 2.8)); + } + + // Auto advance slide every 6 seconds + slideStayTimer += delta; + if (slideStayTimer >= 6.0) + { + NextSlide(); + } + + Invalidate(); + } + + public void GoToSlide(int index) + { + if (frames.Length == 0) return; + int clamped = Math.Max(0, Math.Min(frames.Length - 1, index)); + if (clamped == currentSlide && transitionAlpha >= 1.0f) return; + + prevSlide = currentSlide; + currentSlide = clamped; + transitionAlpha = 0.0f; + slideStayTimer = 0.0; + Invalidate(); + } + + public void NextSlide() + { + if (frames.Length == 0) return; + GoToSlide((currentSlide + 1) % frames.Length); + } + + public void PrevSlide() + { + if (frames.Length == 0) return; + GoToSlide((currentSlide - 1 + frames.Length) % frames.Length); + } + + private Rectangle GetLeftArrowRect() + { + return new Rectangle(18, (Height - 64) / 2, 46, 64); + } + + private Rectangle GetRightArrowRect() + { + return new Rectangle(Width - 64, (Height - 64) / 2, 46, 64); + } + + private Rectangle GetCapsuleRect(int index) + { + int startX = 35; + int curX = startX; + int count = frames.Length; + + for (int i = 0; i < count; i++) + { + int w = (i == currentSlide) ? 38 : 18; + if (i == index) + { + return new Rectangle(curX, Height - 38, w, 8); + } + curX += w + 8; + } + return Rectangle.Empty; + } + + private int HitTestCapsule(Point pt) + { + int count = frames.Length; + for (int i = 0; i < count; i++) + { + Rectangle r = GetCapsuleRect(i); + Rectangle hit = new Rectangle(r.Left - 4, Height - 52, r.Width + 8, 36); + if (hit.Contains(pt)) + { + return i; + } + } + return -1; + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + bool oldLeft = hoveredLeftArrow; + bool oldRight = hoveredRightArrow; + int oldCap = hoveredCapsule; + + hoveredLeftArrow = GetLeftArrowRect().Contains(e.Location); + hoveredRightArrow = GetRightArrowRect().Contains(e.Location); + hoveredCapsule = HitTestCapsule(e.Location); + + if (hoveredLeftArrow || hoveredRightArrow || hoveredCapsule >= 0) + { + Cursor = Cursors.Hand; + } + else + { + Cursor = Cursors.Default; + } + + if (oldLeft != hoveredLeftArrow || oldRight != hoveredRightArrow || oldCap != hoveredCapsule) + { + Invalidate(); + } + } + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + hoveredLeftArrow = false; + hoveredRightArrow = false; + hoveredCapsule = -1; + Cursor = Cursors.Default; + Invalidate(); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + if (e.Button != MouseButtons.Left) return; + + if (GetLeftArrowRect().Contains(e.Location)) + { + PrevSlide(); + return; + } + + if (GetRightArrowRect().Contains(e.Location)) + { + NextSlide(); + return; + } + + int cap = HitTestCapsule(e.Location); + if (cap >= 0) + { + GoToSlide(cap); + return; + } + } + + private void DrawFrame(Graphics g, Image image, float opacity) + { + if (image == null) return; + float scale = Math.Max((float)Width / (float)image.Width, (float)(Height - 170) / (float)image.Height) * 1.02f; + int dw = (int)((float)image.Width * scale); + int dh = (int)((float)image.Height * scale); + Rectangle destRect = new Rectangle((Width - dw) / 2, 90 + (Height - 170 - dh) / 2, dw, dh); + + using ImageAttributes attr = new ImageAttributes(); + ColorMatrix matrix = new ColorMatrix(); + matrix.Matrix33 = Math.Max(0f, Math.Min(1f, opacity)); + attr.SetColorMatrix(matrix); + g.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attr); + } + + protected override void OnPaint(PaintEventArgs e) + { + Graphics g = e.Graphics; + g.Clear(Color.FromArgb(10, 14, 16)); + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + g.SmoothingMode = SmoothingMode.AntiAlias; + + // 1. Draw slide frames with smooth crossfade + if (frames.Length > 0) + { + if (transitionAlpha < 1.0f && prevSlide >= 0 && prevSlide < frames.Length) + { + DrawFrame(g, frames[prevSlide], 1.0f); + } + if (currentSlide >= 0 && currentSlide < frames.Length) + { + DrawFrame(g, frames[currentSlide], transitionAlpha); + } + } + + // 2. Atmospheric Gold Dust Particles + double totalSec = clock.Elapsed.TotalSeconds; + float tFloat = (float)totalSec; + for (int i = 0; i < particles.Length; i++) + { + float py = (particles[i].Y - tFloat * particles[i].Speed) % 1.0f; + if (py < 0) py += 1.0f; + float px = particles[i].X + (float)Math.Sin(tFloat * 1.5f + particles[i].SwayOffset) * 0.03f; + if (px < 0) px += 1.0f; + if (px > 1) px -= 1.0f; + + float screenX = px * Width; + float screenY = py * Height; + + int alpha = (int)particles[i].Alpha; + using (SolidBrush pBrush = new SolidBrush(Color.FromArgb(alpha, 245, 218, 140))) + { + g.FillEllipse(pBrush, screenX, screenY, particles[i].Size, particles[i].Size); + } + } + + // 3. Top subtle vignette + using (LinearGradientBrush topGrad = new LinearGradientBrush(new Rectangle(0, 0, Width, 190), Color.FromArgb(240, 12, 16, 18), Color.Transparent, 90f)) + { + g.FillRectangle(topGrad, 0, 0, Width, 190); + } + + // 4. Bottom rich vignette + using (LinearGradientBrush btmGrad = new LinearGradientBrush(new Rectangle(0, Height - 260, Width, 260), Color.Transparent, Color.FromArgb(250, 10, 14, 16), 90f)) + { + g.FillRectangle(btmGrad, 0, Height - 260, Width, 260); + } + + // 5. Left separator line + using (Pen pen = new Pen(Color.FromArgb(50, 229, 190, 112), 1f)) + { + g.DrawLine(pen, 0, 0, 0, Height); + } + + // 6. Header Badge + using (SolidBrush badgeBrush = new SolidBrush(Color.FromArgb(40, 229, 190, 112))) + { + Rectangle headerBadge = new Rectangle(35, 30, 205, 22); + using (GraphicsPath bp = CreateRoundedRectangle(headerBadge, 4)) + { + g.FillPath(badgeBrush, bp); + using (Pen bpPen = new Pen(Color.FromArgb(120, 229, 190, 112), 1f)) + { + g.DrawPath(bpPen, bp); + } + } + } + + using (SolidBrush brush3 = new SolidBrush(InstallerForm.Gold)) + { + using Font font = new Font("Segoe UI", 8.5f, FontStyle.Bold); + g.DrawString("✦ ВНУТРИ ASSEMBLER CASINO ✦", font, brush3, 42f, 33f); + } + + // 7. Slide Tag + string tag = tags[currentSlide % tags.Length]; + using (SolidBrush tagBrush = new SolidBrush(Color.FromArgb(200, 165, 90))) + { + using Font tagFont = new Font("Segoe UI", 9f, FontStyle.Bold); + g.DrawString("◆ " + tag, tagFont, tagBrush, 37f, Height - 160); + } + + // 8. Slide Caption + string caption = captions[currentSlide % captions.Length]; + using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(190, 0, 0, 0))) + { + using Font font2 = new Font("Georgia", 26f, FontStyle.Bold); + g.DrawString(caption, font2, shadowBrush, 39f, Height - 134); + } + using (SolidBrush brush4 = new SolidBrush(InstallerForm.Paper)) + { + using Font font2 = new Font("Georgia", 26f, FontStyle.Bold); + g.DrawString(caption, font2, brush4, 37f, Height - 136); + } + + // 9. Subtitle + using (SolidBrush brush5 = new SolidBrush(Color.FromArgb(160, 175, 170))) + { + using Font font3 = new Font("Segoe UI", 9.5f); + g.DrawString("Настоящие игровые кадры · Чистый x86 MASM Ассемблер", font3, brush5, 37f, Height - 88); + } + + // 10. Navigation Capsules + int count = frames.Length; + for (int i = 0; i < count; i++) + { + bool isActive = (i == currentSlide); + bool isHov = (i == hoveredCapsule); + Rectangle capRect = GetCapsuleRect(i); + + using (GraphicsPath cp = CreateRoundedRectangle(capRect, 4)) + { + Color capColor; + if (isActive) + { + capColor = InstallerForm.Gold; + } + else if (isHov) + { + capColor = Color.FromArgb(200, 240, 220); + } + else + { + capColor = Color.FromArgb(60, 72, 70); + } + + using (SolidBrush capBrush = new SolidBrush(capColor)) + { + g.FillPath(capBrush, cp); + } + + if (isActive) + { + using (Pen capGlow = new Pen(Color.FromArgb(120, 255, 235, 160), 2f)) + { + g.DrawPath(capGlow, cp); + } + } + else if (isHov) + { + using (Pen hovBorder = new Pen(Color.FromArgb(180, 229, 190, 112), 1f)) + { + g.DrawPath(hovBorder, cp); + } + } + } + } + + // 11. Left & Right Arrow Buttons (Always visible!) + DrawArrowButton(g, GetLeftArrowRect(), isLeft: true, hoveredLeftArrow); + DrawArrowButton(g, GetRightArrowRect(), isLeft: false, hoveredRightArrow); + } + + private void DrawArrowButton(Graphics g, Rectangle rect, bool isLeft, bool isHov) + { + using (GraphicsPath path = CreateRoundedRectangle(rect, 8)) + { + Color bgColor = isHov ? Color.FromArgb(200, 36, 42, 46) : Color.FromArgb(120, 18, 22, 25); + using (SolidBrush bg = new SolidBrush(bgColor)) + { + g.FillPath(bg, path); + } + + Color borderColor = isHov ? Color.FromArgb(255, 235, 160) : Color.FromArgb(110, 180, 150, 95); + using (Pen border = new Pen(borderColor, isHov ? 1.8f : 1.2f)) + { + g.DrawPath(border, path); + } + + // Arrow Chevron + Color arrowColor = isHov ? Color.FromArgb(255, 245, 205) : InstallerForm.Gold; + using (Pen arrowPen = new Pen(arrowColor, 2.8f)) + { + arrowPen.StartCap = LineCap.Round; + arrowPen.EndCap = LineCap.Round; + + int cx = rect.X + rect.Width / 2; + int cy = rect.Y + rect.Height / 2; + + if (isLeft) + { + g.DrawLine(arrowPen, cx + 4, cy - 10, cx - 4, cy); + g.DrawLine(arrowPen, cx - 4, cy, cx + 4, cy + 10); + } + else + { + g.DrawLine(arrowPen, cx - 4, cy - 10, cx + 4, cy); + g.DrawLine(arrowPen, cx + 4, cy, cx - 4, cy + 10); + } + } + } + } + + private static GraphicsPath CreateRoundedRectangle(Rectangle r, int d) + { + GraphicsPath path = new GraphicsPath(); + if (d <= 0) + { + path.AddRectangle(r); + return path; + } + int x = r.X; + int y = r.Y; + int w = r.Width; + int h = r.Height; + path.AddArc(x, y, d, d, 180, 90); + path.AddArc(x + w - d, y, d, d, 270, 90); + path.AddArc(x + w - d, y + h - d, d, d, 0, 90); + path.AddArc(x, y + h - d, d, d, 90, 90); + path.CloseFigure(); + return path; + } +} diff --git a/build/installer/Properties/AssemblyInfo.cs b/build/installer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d381a28 --- /dev/null +++ b/build/installer/Properties/AssemblyInfo.cs @@ -0,0 +1,14 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Assembler Casino Setup")] +[assembly: AssemblyDescription("Assembler Casino Modern Graphical Installer")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Assembler Casino")] +[assembly: AssemblyProduct("Assembler Casino")] +[assembly: AssemblyCopyright("Copyright © 2026")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] diff --git a/build/installer/app.ico b/build/installer/app.ico new file mode 100644 index 0000000..e77882b Binary files /dev/null and b/build/installer/app.ico differ diff --git a/build/installer/slide.00 b/build/installer/slide.00 new file mode 100644 index 0000000..96d9f6c Binary files /dev/null and b/build/installer/slide.00 differ diff --git a/build/installer/slide.01 b/build/installer/slide.01 new file mode 100644 index 0000000..2e7d803 Binary files /dev/null and b/build/installer/slide.01 differ diff --git a/build/installer/slide.02 b/build/installer/slide.02 new file mode 100644 index 0000000..251cc68 Binary files /dev/null and b/build/installer/slide.02 differ diff --git a/build/installer/slide.03 b/build/installer/slide.03 new file mode 100644 index 0000000..fbf376e Binary files /dev/null and b/build/installer/slide.03 differ diff --git a/build/installer/slide.04 b/build/installer/slide.04 new file mode 100644 index 0000000..14f3589 Binary files /dev/null and b/build/installer/slide.04 differ diff --git a/build/installer/slide.05 b/build/installer/slide.05 new file mode 100644 index 0000000..b79931d Binary files /dev/null and b/build/installer/slide.05 differ diff --git a/build/installer/slide.06 b/build/installer/slide.06 new file mode 100644 index 0000000..1ba9b7e Binary files /dev/null and b/build/installer/slide.06 differ diff --git a/build/installer/slide.07 b/build/installer/slide.07 new file mode 100644 index 0000000..98596d7 Binary files /dev/null and b/build/installer/slide.07 differ diff --git a/casino3d.inc b/casino3d.inc index 077633a..ed4e1be 100644 --- a/casino3d.inc +++ b/casino3d.inc @@ -1,5446 +1,5515 @@ - -; ============================================================================== -; CASINO 2.5D - MASM32 SOFTWARE RAYCASTER (CP1251) -; Graphical migration; this is not id Software's Doom engine. -; ============================================================================== - -includelib gdi32.lib -includelib winmm.lib - -CreateWindowExA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD -RegisterClassExA PROTO :DWORD -DefWindowProcA PROTO :DWORD,:DWORD,:DWORD,:DWORD -ShowWindow PROTO :DWORD,:DWORD -UpdateWindow PROTO :DWORD -GetDC PROTO :DWORD -ReleaseDC PROTO :DWORD,:DWORD -StretchDIBits PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD -PeekMessageA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD -TranslateMessage PROTO :DWORD -DispatchMessageA PROTO :DWORD -PostQuitMessage PROTO :DWORD -DestroyWindow PROTO :DWORD -SetWindowTextA PROTO :DWORD,:DWORD -SetForegroundWindow PROTO :DWORD -GetConsoleWindow PROTO -GetSystemMetrics PROTO :DWORD -CreateFileA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD -ReadFile PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD -CloseHandle PROTO :DWORD -GetAsyncKeyState PROTO :DWORD -PlaySoundA PROTO :DWORD,:DWORD,:DWORD -GetModuleFileNameA PROTO :DWORD,:DWORD,:DWORD -CopyFileA PROTO :DWORD,:DWORD,:DWORD -lstrcmpiA PROTO :DWORD,:DWORD -GetFileSize PROTO :DWORD,:DWORD -Sleep PROTO :DWORD -CreateThread PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD -CreateEventA PROTO :DWORD,:DWORD,:DWORD,:DWORD -SetEvent PROTO :DWORD -WaitForSingleObject PROTO :DWORD,:DWORD -timeBeginPeriod PROTO :DWORD -timeEndPeriod PROTO :DWORD -timeGetTime PROTO -GetCursorPos PROTO :DWORD -SetCursorPos PROTO :DWORD,:DWORD -ShowCursor PROTO :DWORD -ClientToScreen PROTO :DWORD,:DWORD - -C3D_POINT STRUCT - x dd ? - y dd ? -C3D_POINT ENDS - -C3D_MSG STRUCT - hwnd dd ? - message dd ? - wParam dd ? - lParam dd ? - time dd ? - pt C3D_POINT <> -C3D_MSG ENDS - -C3D_WNDCLASSEX STRUCT - cbSize dd ? - style dd ? - lpfnWndProc dd ? - cbClsExtra dd ? - cbWndExtra dd ? - hInstance dd ? - hIcon dd ? - hCursor dd ? - hbrBackground dd ? - lpszMenuName dd ? - lpszClassName dd ? - hIconSm dd ? -C3D_WNDCLASSEX ENDS - -C3D_BITMAPINFOHEADER STRUCT - biSize dd ? - biWidth dd ? - biHeight dd ? - biPlanes dw ? - biBitCount dw ? - biCompression dd ? - biSizeImage dd ? - biXPelsPerMeter dd ? - biYPelsPerMeter dd ? - biClrUsed dd ? - biClrImportant dd ? -C3D_BITMAPINFOHEADER ENDS - -C3D_BITMAPINFO STRUCT - bmiHeader C3D_BITMAPINFOHEADER <> - bmiColors dd ? -C3D_BITMAPINFO ENDS - -SpriteObject STRUCT - posX dd ? - posY dd ? - baseTexId dd ? - frameCount dd ? - curFrame dd ? - animTimer dd ? - animSpeed dd ? - interactId dd ? - promptPtr dd ? - distSq dd ? -SpriteObject ENDS - -SCREEN_W equ 640 -SCREEN_H equ 480 -HALF_W equ 320 -HALF_H equ 240 -SCREEN_SIZE equ (SCREEN_W * SCREEN_H) -WIN_SCALE equ 1 -WINDOW_W equ (SCREEN_W * WIN_SCALE) -WINDOW_H equ (SCREEN_H * WIN_SCALE) - -FP_1 equ 65536 -FP_HALF equ 32768 -CHROMA_KEY equ 00FF00FFh - -MODE_WALK equ 0 -MODE_SLOTS equ 1 -MODE_BLACKJACK equ 2 -MODE_ROULETTE equ 3 -MODE_SHOP equ 4 -MODE_ATM equ 5 -MODE_COIN equ 6 -MODE_DICE equ 7 -MODE_SKULLS equ 8 -MODE_SKILL equ 9 - -WS_OVERLAPPEDWINDOW equ 00CF0000h -SW_SHOW equ 5 -SW_HIDE equ 0 -PM_REMOVE equ 1 -WM_DESTROY equ 0002h -WM_CLOSE equ 0010h -WM_QUIT equ 0012h -CS_HREDRAW equ 2 -CS_VREDRAW equ 1 -DIB_RGB_COLORS equ 0 -SRCCOPY equ 00CC0020h -INVALID_FILE_HANDLE equ -1 - -include casino3d_data.inc -include font8x8.inc -include src_graphics\platform_data.inc -include src_graphics\casino_actions_data.inc -include src_graphics\audio_data.inc -include src_graphics\startup_data.inc -include src_graphics\presentation_text.inc -include src_graphics\presentation_data.inc -include src_graphics\card_tables_data.inc -include src_graphics\native_durak_data.inc -include src_graphics\scene_animation_data.inc -include src_graphics\arrival_data.inc -include src_graphics\city_arrival_data.inc -include src_graphics\merchant_data.inc -include src_graphics\hall_data.inc -include src_graphics\npc_mind_data.inc -include src_graphics\npc_life_data.inc -include src_graphics\native_wheel_data.inc -include src_graphics\billiards_data.inc -include src_graphics\buckshot_data.inc -include src_graphics\russian_view_data.inc -include src_graphics\unavailable_data.inc -include src_graphics\native_slots_data.inc -include src_graphics\native_clover_data.inc -include src_graphics\native_coin_data.inc -include src_graphics\native_dice_data.inc -include src_graphics\scratch_data.inc -include src_graphics\hell_tower_data.inc + +; ============================================================================== +; CASINO 2.5D - MASM32 SOFTWARE RAYCASTER (CP1251) +; Graphical migration; this is not id Software's Doom engine. +; ============================================================================== + +includelib gdi32.lib +includelib winmm.lib + +CreateWindowExA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD +RegisterClassExA PROTO :DWORD +DefWindowProcA PROTO :DWORD,:DWORD,:DWORD,:DWORD +ShowWindow PROTO :DWORD,:DWORD +UpdateWindow PROTO :DWORD +GetDC PROTO :DWORD +ReleaseDC PROTO :DWORD,:DWORD +StretchDIBits PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD +PeekMessageA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD +TranslateMessage PROTO :DWORD +DispatchMessageA PROTO :DWORD +PostQuitMessage PROTO :DWORD +DestroyWindow PROTO :DWORD +SetWindowTextA PROTO :DWORD,:DWORD +SetForegroundWindow PROTO :DWORD +GetConsoleWindow PROTO +GetSystemMetrics PROTO :DWORD +CreateFileA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD +ReadFile PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD +CloseHandle PROTO :DWORD +GetAsyncKeyState PROTO :DWORD +PlaySoundA PROTO :DWORD,:DWORD,:DWORD +GetModuleFileNameA PROTO :DWORD,:DWORD,:DWORD +CopyFileA PROTO :DWORD,:DWORD,:DWORD +lstrcmpiA PROTO :DWORD,:DWORD +GetFileSize PROTO :DWORD,:DWORD +Sleep PROTO :DWORD +CreateThread PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD +CreateEventA PROTO :DWORD,:DWORD,:DWORD,:DWORD +SetEvent PROTO :DWORD +WaitForSingleObject PROTO :DWORD,:DWORD +timeBeginPeriod PROTO :DWORD +timeEndPeriod PROTO :DWORD +timeGetTime PROTO +GetCursorPos PROTO :DWORD +SetCursorPos PROTO :DWORD,:DWORD +ShowCursor PROTO :DWORD +ClientToScreen PROTO :DWORD,:DWORD + +C3D_POINT STRUCT + x dd ? + y dd ? +C3D_POINT ENDS + +C3D_MSG STRUCT + hwnd dd ? + message dd ? + wParam dd ? + lParam dd ? + time dd ? + pt C3D_POINT <> +C3D_MSG ENDS + +C3D_WNDCLASSEX STRUCT + cbSize dd ? + style dd ? + lpfnWndProc dd ? + cbClsExtra dd ? + cbWndExtra dd ? + hInstance dd ? + hIcon dd ? + hCursor dd ? + hbrBackground dd ? + lpszMenuName dd ? + lpszClassName dd ? + hIconSm dd ? +C3D_WNDCLASSEX ENDS + +C3D_BITMAPINFOHEADER STRUCT + biSize dd ? + biWidth dd ? + biHeight dd ? + biPlanes dw ? + biBitCount dw ? + biCompression dd ? + biSizeImage dd ? + biXPelsPerMeter dd ? + biYPelsPerMeter dd ? + biClrUsed dd ? + biClrImportant dd ? +C3D_BITMAPINFOHEADER ENDS + +C3D_BITMAPINFO STRUCT + bmiHeader C3D_BITMAPINFOHEADER <> + bmiColors dd ? +C3D_BITMAPINFO ENDS + +SpriteObject STRUCT + posX dd ? + posY dd ? + baseTexId dd ? + frameCount dd ? + curFrame dd ? + animTimer dd ? + animSpeed dd ? + interactId dd ? + promptPtr dd ? + distSq dd ? +SpriteObject ENDS + +SCREEN_W equ 640 +SCREEN_H equ 480 +HALF_W equ 320 +HALF_H equ 240 +SCREEN_SIZE equ (SCREEN_W * SCREEN_H) +WIN_SCALE equ 1 +WINDOW_W equ (SCREEN_W * WIN_SCALE) +WINDOW_H equ (SCREEN_H * WIN_SCALE) + +FP_1 equ 65536 +FP_HALF equ 32768 +CHROMA_KEY equ 00FF00FFh + +MODE_WALK equ 0 +MODE_SLOTS equ 1 +MODE_BLACKJACK equ 2 +MODE_ROULETTE equ 3 +MODE_SHOP equ 4 +MODE_ATM equ 5 +MODE_COIN equ 6 +MODE_DICE equ 7 +MODE_SKULLS equ 8 +MODE_SKILL equ 9 + +WS_OVERLAPPEDWINDOW equ 00CF0000h +SW_SHOW equ 5 +SW_HIDE equ 0 +PM_REMOVE equ 1 +WM_DESTROY equ 0002h +WM_CLOSE equ 0010h +WM_QUIT equ 0012h +CS_HREDRAW equ 2 +CS_VREDRAW equ 1 +DIB_RGB_COLORS equ 0 +SRCCOPY equ 00CC0020h +INVALID_FILE_HANDLE equ -1 + +include casino3d_data.inc +include font8x8.inc +include src_graphics\platform_data.inc +include src_graphics\casino_actions_data.inc +include src_graphics\audio_data.inc +include src_graphics\startup_data.inc +include src_graphics\presentation_text.inc +include src_graphics\presentation_data.inc +include src_graphics\card_tables_data.inc +include src_graphics\native_durak_data.inc +include src_graphics\scene_animation_data.inc +include src_graphics\arrival_data.inc +include src_graphics\city_arrival_data.inc +include src_graphics\startup_film_data.inc +include src_graphics\merchant_data.inc +include src_graphics\security_data.inc +include src_graphics\debt_data.inc +include src_graphics\rat_race_data.inc +include src_graphics\heist_data.inc +include src_graphics\underworld_data.inc +include src_graphics\hall_data.inc +include src_graphics\npc_mind_data.inc +include src_graphics\npc_life_data.inc +include src_graphics\native_wheel_data.inc +include src_graphics\billiards_data.inc +include src_graphics\buckshot_data.inc +include src_graphics\russian_view_data.inc +include src_graphics\unavailable_data.inc +include src_graphics\native_slots_data.inc +include src_graphics\native_clover_data.inc +include src_graphics\native_coin_data.inc +include src_graphics\native_dice_data.inc +include src_graphics\scratch_data.inc +include src_graphics\hell_tower_data.inc include src_graphics\charms_data.inc -include src_graphics\backrooms_data.inc -include src_graphics\observer_data.inc -include src_graphics\darts_data.inc -include src_graphics\jackbox_data.inc +include src_graphics\backrooms_data.inc +include src_graphics\observer_data.inc +include src_graphics\darts_data.inc +include src_graphics\jackbox_data.inc include src_graphics\hell_fps_data.inc - -.data -ALIGN 4 -h3DInst dd 0 -h3DWnd dd 0 -h3DDC dd 0 -hCasinoConsole dd 0 - -ALIGN 4 -hRaycastThread dd 0 -hRaycastStartEvent dd 0 -hRaycastDoneEvent dd 0 -bRaycastQuit dd 0 -raycastThreadId dd 0 - -ALIGN 4 -mouseLocked3D dd 0 - -bmi3D C3D_BITMAPINFO <> -msg3D C3D_MSG <> -wc3D C3D_WNDCLASSEX <> - -sz3DClassName db "Casino3DRetroClass",0 -sz3DWindowTitle db 192,241,241,229,236,225,235,229,240,32,202,224,231,232,237,238,32,45,32,50,46,53,68,0 -szTexturesRelPath db "assets\textures\casino3d-hd.bin",0 -szTexturesFullPath db 260 dup(0) - - -playerX dd (16 * FP_1 + FP_HALF) -playerY dd (16 * FP_1 + FP_HALF) -playerAngle dd 384 -playerDirX dd 0 -playerDirY dd -FP_1 -playerPlaneX dd (FP_1 * 66 / 100) -playerPlaneY dd 0 - -engineMode dd 0 -startInHellTower dd 0 -interactTargetId dd 0 -interactPromptPtr dd 0 -dancerLuckBuff dd 0 -flashTimer dd 0 -flashMessage db 128 dup(0) - -promptDancer db "[E] ÊÀÁÀÐÅ - ×ÀÅÂÛÅ $100",0 -promptBlackjack db "[E] ÁËÝÊÄÆÅÊ (21)",0 -promptPoker db 91,69,93,32,207,206,202,197,208,32,40,210,197,213,192,209,209,202,200,201,32,213,206,203,196,197,204,41,0 -promptDurak db "[E] ÊÀÐÒÛ: ÏÎÄÊÈÄÍÎÉ ÄÓÐÀÊ",0 -promptCasinoRoulette db "[E] ÅÂÐÎÏÅÉÑÊÀß ÐÓËÅÒÊÀ",0 -promptClassicSlot db "[E] ÊËÀÑÑÈ×ÅÑÊÈÅ ÑËÎÒÛ 777",0 -promptCloverSlot db "[E] ÑËÎÒÛ CLOVERPIT (5x3)",0 -promptDice db 91,69,93,32,200,195,208,192,32,194,32,202,206,209,210,200,0 -promptSkulls db "[E] ÍÀϨÐÑÒÊÈ (×ÅÐÅÏÀ)",0 -promptCoin db "[E] ÌÎÍÅÒÊÀ (ÎШË/ÐÅØÊÀ)",0 -promptSkillCheck db "[E] ÒÐÅÍÈÐÎÂÊÀ ÐÅÀÊÖÈÈ",0 -promptBuckshot db 91,69,93,32,193,192,202,216,206,210,32,208,211,203,197,210,202,192,0 -promptRussianRoulette db "[E] ÐÓÑÑÊÀß ÐÓËÅÒÊÀ (VIP)",0 -promptOnlineRR db "[E] ÑÅÒÅÂÀß ÐÓËÅÒÊÀ (NET)",0 -promptUmamusume db "[E] ÑÊÀ×ÊÈ ÓÌÀÌÓÑÓÌÝ",0 -promptHellTower db "[E] ÁÀØÍß ÀÄÀ (10 ÝÒÀÆÅÉ)",0 -promptShop db "[E] ÁÓÒÈÊ È ÒÀËÈÑÌÀÍÛ",0 -promptATM db "[E] ÁÀÍÊÎÌÀÒ È ÁÀËÀÍÑ",0 -promptPlayerTerminal db "[E] ÒÅÐÌÈÍÀË: ÑÒÀÒÛ È À×ÈÂÊÈ",0 -promptObserver db "[E] ÐÅÆÈÌ ÍÀÁËÞÄÀÒÅËß (ÈÈ)",0 - -szTitleBlackjack db 202,192,199,200,202,32,51,68,32,45,32,193,203,221,202,196,198,197,202,32,40,50,49,41,0 -szTitlePoker db 202,192,199,200,202,32,51,68,32,45,32,207,206,202,197,208,32,40,210,197,213,192,209,209,202,200,201,32,213,206,203,196 - db 197,204,41,0 -szTitleDurak db 202,192,199,200,202,32,51,68,32,45,32,207,197,208,197,194,206,196,205,206,201,32,196,211,208,192,202,0 -szTitleCasinoRoulette db 202,192,199,200,202,32,51,68,32,45,32,197,194,208,206,207,197,201,209,202,192,223,32,208,211,203,197,210,202,192,0 -szTitleClassicSlot db 202,192,199,200,202,32,51,68,32,45,32,192,194,210,206,204,192,210,32,55,55,55,0 -szTitleCloverSlot db 202,192,199,200,202,32,51,68,32,45,32,202,203,197,194,197,208,205,192,223,32,223,204,192,32,40,53,120,51,41,0 -szTitleDice db 202,192,199,200,202,32,51,68,32,45,32,200,195,208,192,32,194,32,202,206,209,210,200,0 -szTitleSkulls db 202,192,199,200,202,32,51,68,32,45,32,205,192,207,168,208,209,210,202,200,0 -szTitleCoin db 202,192,199,200,202,32,51,68,32,45,32,204,206,205,197,210,202,192,32,40,206,208,168,203,47,208,197,216,202,192,41,0 -szTitleSkillCheck db 202,192,199,200,202,32,51,68,32,45,32,207,208,206,194,197,208,202,192,32,205,192,194,219,202,192,0 -szTitleBuckshot db 202,192,199,200,202,32,51,68,32,45,32,193,192,202,216,206,210,32,208,211,203,197,210,202,192,0 -szTitleRussianRoulette db 202,192,199,200,202,32,51,68,32,45,32,208,211,209,209,202,192,223,32,208,211,203,197,210,202,192,0 -szTitleOnlineRR db 202,192,199,200,202,32,51,68,32,45,32,209,197,210,197,194,192,223,32,208,211,209,209,202,192,223,32,208,211,203,197,210 - db 202,192,0 -szTitleUmamusume db 202,192,199,200,202,32,51,68,32,45,32,195,206,205,202,200,32,211,204,192,204,211,209,211,204,197,0 -szTitleHellTower db 202,192,199,200,202,32,51,68,32,45,32,192,196,209,202,192,223,32,193,192,216,205,223,0 -szTitleShop db 202,192,199,200,202,32,51,68,32,45,32,202,192,208,210,219,32,200,32,210,192,203,200,209,204,192,205,219,0 -szTitleATM db 202,192,199,200,202,32,51,68,32,45,32,193,192,205,202,206,204,192,210,0 -szTitleTerminal db 202,192,199,200,202,32,51,68,32,45,32,203,206,202,192,203,220,205,219,197,32,207,208,206,212,200,203,200,0 -szTitleObserver db 202,192,199,200,202,32,51,68,32,45,32,205,192,193,203,222,196,192,210,197,203,220,32,40,200,200,41,0 -textCabinetFooter db "[ ÂÛÕÎÄ: ÂÂÅÄÈÒÅ 0 / ÂÛÁÅÐÈÒÅ 'N' ÄËß ÂÎÇÂÐÀÒÀ  ÇÀË ]",0 - -msgDancerTipped db "Âû áðîñèëè $100 òàíöîâùèöå! ÓÄÀ×À ÀÊÒÈÂÈÐÎÂÀÍÀ!",0 -msgNeedMoney db "Íåäîñòàòî÷íî äåíåã â êîøåëüêå!",0 -statusHUDFormat db "ÁÀÍÊÐÎËË: $",0 -targetHUDFormat db " ÖÅËÜ: $",0 -luckHUDFormat db " ÓÄÀ×À: +",0 -controlsHUD db "WASD/Ñòðåëêè: Õîäüáà | E: Äåéñòâèå | ESC: Ìåíþ",0 - -NUM_SPRITES equ 22 - -INTERACT_NONE equ 0 -INTERACT_BLACKJACK equ 1 -INTERACT_POKER equ 2 -INTERACT_SLOTS_777 equ 3 -INTERACT_ROULETTE equ 4 -INTERACT_SKULLS equ 5 -INTERACT_SHOP equ 6 -INTERACT_ATM equ 7 -INTERACT_DANCER equ 8 -INTERACT_HELL_TOWER equ 9 -INTERACT_DURAK equ 10 -INTERACT_BUCKSHOT equ 11 -INTERACT_COIN equ 12 -INTERACT_DICE equ 13 -INTERACT_SLOTS_CLOVER equ 14 -INTERACT_UMAMUSUME equ 15 -INTERACT_OBSERVER equ 16 -INTERACT_TERMINAL equ 17 -INTERACT_ONLINE_RR equ 18 -INTERACT_RUSSIAN_ROULETTE equ 19 -INTERACT_SKILL_CHECK equ 20 -ALIGN 4 -casinoSprites SpriteObject NUM_SPRITES dup(<>) -sortedSprites dd NUM_SPRITES dup(0) - -rowDistTable dd 120 dup(0) -rngSeed3D dd 12345678h - -slotBet dd 50 -slotReel1 dd 0 -slotReel2 dd 1 -slotReel3 dd 2 -slotSpinState dd 0 -slotSpinTimer dd 0 -slotWinAmount dd 0 -slotWinMsg db 64 dup(0) - -bjState dd 0 -bjBet dd 100 -bjPlayerCards dd 10 dup(0) -bjPlayerCardCount dd 0 -bjPlayerScore dd 0 -bjDealerCards dd 10 dup(0) -bjDealerCardCount dd 0 -bjDealerScore dd 0 -bjDealerHideHole dd 1 -bjOutcomeMsg db 64 dup(0) - -roulState dd 0 -roulBetType dd 1 -roulBetAmount dd 100 -roulWheelAngle dd 0 -roulBallAngle dd 0 -roulSpinTimer dd 0 -roulWinningNum dd 0 -roulPayout dd 0 -roulOutcomeMsg db 64 dup(0) - -coinRxAnimTable db 26, 22, 16, 6, 16, 22, 26, 22, 16, 6 - -; --- Native 2.5D Coin Flip --- -coin3d_bet dd 50 -coin3d_choice dd 1 ; 1 = Îð¸ë, 2 = Ðåøêà -coin3d_state dd 0 ; 0 = Idle, 1 = Flipping, 2 = Result -coin3d_timer dd 0 -coin3d_result dd 1 ; 1 = Îð¸ë, 2 = Ðåøêà -coin3d_streak dd 0 -coin3d_win dd 0 - -textCoinTitle db "* * * Ç Î Ë Î Ò À ß Ì Î Í Å Ò À * * *",0 -textCoinHeads db "ÎШË",0 -textCoinTails db "ÐÅØÊÀ",0 -textCoinSide1 db "[1] ÎШË",0 -textCoinSide2 db "[2] ÐÅØÊÀ",0 -textCoinFlipping db "ÌÎÍÅÒÀ  ÏÎ˨ÒÅ...",0 -textCoinWin db "ÏÎÁÅÄÀ: +$",0 -textCoinLose db "ÍÅ ÓÃÀÄÀËÈ!",0 -textCoinStreakFmt db "ÑÅÐÈß ÏÎÁÅÄ: x",0 -textCoinSelected db "ÂÛÁÐÀÍÎ",0 -textCoinKey1 db "[1] ÎШË",0 -textCoinKey2 db "[2] ÐÅØÊÀ",0 -textCoinKeySpace db "[SPACE]",0 - -; --- Native 2.5D Dice Game --- -dice3d_bet dd 50 -dice3d_choice dd 1 ; 1 = ׸ò, 2 = Íå÷åò -dice3d_state dd 0 ; 0 = Idle, 1 = Rolling, 2 = Result -dice3d_timer dd 0 -dice3d_val1 dd 4 -dice3d_val2 dd 6 -dice3d_sum dd 10 -dice3d_win dd 0 - -textDiceTitle db 200,195,208,192,32,194,32,202,206,209,210,200,0 -textDiceEven db "[1] רÒ",0 -textDiceOdd db "[2] ÍÅ×ÅÒ",0 -textDiceEvenNums db "2 4 6 ...",0 -textDiceOddNums db "3 5 7 ...",0 -textDiceSumHdr db "ÑÓÌÌÀ: ",0 -textDicePlus db " + ",0 -textDiceEqual db " = ",0 -textDiceEvenResult db " (רÒ)",0 -textDiceOddResult db " (ÍÅ×ÅÒ)",0 -textDiceRolling db "ÊÎÑÒÈ ËÅÒßÒ ÏÎ ÑÓÊÍÓ...",0 -textDiceWin db "ÂÛÈÃÐÛØ: +$",0 -textDiceWinMult db "! (x2)",0 -textDiceLose db "ÏÐÎÈÃÐÛØ!",0 -textDiceKey1 db "[1] רÒ",0 -textDiceKey2 db "[2] ÍÅ×ÅÒ",0 -textDiceKeySpace db "[SPACE]",0 - -; --- Native 2.5D Skulls Game --- -skulls3d_bet dd 50 -skulls3d_state dd 0 ; 0 = Idle, 1 = Show ball, 2 = Shuffle, 3 = Pick, 4 = Reveal -skulls3d_timer dd 0 -skulls3d_ballPos dd 1 ; 0, 1, 2 -skulls3d_choice dd 1 ; 0, 1, 2 -skulls3d_win dd 0 -skulls3d_swapPair0 dd 0 -skulls3d_swapPair1 dd 1 -skulls3d_swapPair2 dd 2 -skulls3d_cup0 dd 0 -skulls3d_cup1 dd 1 -skulls3d_cup2 dd 2 - -textSkullsTitle db "* * * Í À Ï ¨ Ð Ñ Ò Ê È * * *",0 -textSkullsPhase0 db "ÄÅËÀÉ ÑÒÀÂÊÓ È ÆÌÈ [ÏÐÎÁÅË]",0 -textSkullsPhase1 db "ÑÌÎÒÐÈ, ÃÄÅ ÇÎËÎÒÎÉ ØÀÐ...",0 -textSkullsPhase2 db "ÊÐÓ×Ó, ÂÅÐ×Ó, ÇÀÏÓÒÀÒÜ ÕÎ×Ó...",0 -textSkullsPhase3 db "ÃÄÅ ØÀÐ? ÂÛÁÈÐÀÉ: [1], [2] ÈËÈ [3]!",0 -textSkullsWin db "ÂÛÈÃÐÛØ: +$",0 -textSkullsWinMult db "! (x3) ÂÛ ÓÃÀÄÀËÈ!",0 -textSkullsLose db "ÌÈÌÎ! ØÀÐ ÁÛË Â ÄÐÓÃÎÌ ÌÅÑÒÅ!",0 -textSkullsAgain db "[ÏÐÎÁÅË] - ÑÛÃÐÀÒÜ Å٨ ÐÀÇ",0 -textSkullsKey1 db "[1]",0 -textSkullsKey2 db "[2]",0 -textSkullsKey3 db "[3]",0 -textSkullsKeySpace db "[SPACE] ÑÒÀÐÒ",0 - -; --- Native 2.5D Skill Check (Dead by Daylight Survivor Check) --- -skill3d_bet dd 50 -skill3d_state dd 0 ; 0=Ready, 1=Active, 2=Hit Result, 3=Miss Result, 4=Escaped, 5=Defeated -skill3d_timer dd 0 -skill3d_needle dd 55 ; Needle X (52..268) -skill3d_speed dd 4 -skill3d_dir dd 1 ; 1=Right, -1=Left -skill3d_zone_start dd 140 -skill3d_zone_width dd 48 -skill3d_great_start dd 176 -skill3d_great_width dd 12 -skill3d_hits dd 0 -skill3d_misses dd 0 -skill3d_last_result dd 0 -skill3d_win_amount dd 0 - -textSkillTitle db 61,61,61,32,207,208,206,194,197,208,202,192,32,205,192,194,219,202,192,32,61,61,61,0 -textSkillHitsHdr db "ÕÈÒ: ",0 -textSkillMissHdr db "ÏÐÎÌÀÕ: ",0 -textSkillReadyMsg db "ÍÀÆÌÈÒÅ [ÏÐÎÁÅË] ÄËß ÑÒÀÐÒÀ",0 -textSkillPrompt db "ÍÀÆÌÈÒÅ [ÏÐÎÁÅË]  ÇÎÍÅ!",0 -textSkillHitMsg db "ÕÈÒ! ÒÎ×ÍÎÅ ÏÎÏÀÄÀÍÈÅ!",0 -textSkillGreatMsg db 206,210,203,200,215,205,206,33,32,43,193,206,205,211,209,33,0 -textSkillMissMsg db "ÏÐÎÌÀÕ! ÒÐÅÂÎÃÀ!",0 -textSkillEscape db "ÏÎÁÅà ÓÑÏÅØÅÍ! ÂÛÈÃÐÛØ: +$",0 -textSkillLost db "ÂÛ ÏÎÉÌÀÍÛ! ÏÐÎÈÃÐÛØ ÑÒÀÂÊÈ!",0 -textSkillKeySpace db "[SPACE] ÐÅÀÊÖÈß",0 -textSkillKeyBet db "[ÂÂÅÐÕ/ÂÍÈÇ]",0 - -; --- Shared UI Strings --- -textKeyEsc db "[ESC]",0 -textBankPrompt db "ÁÀÍÊ: $",0 -textBetPrompt db "ÑÒÀÂÊÀ: $",0 -textBetHint db " [W/S]",0 - -shopMsg db 128 dup(0) -atmMsg db 128 dup(0) - -strWin db "ÏÎÁÅÄÀ! +$",0 -strLose db "ÏÐÎÈÃÐÛØ",0 -strJackpot db "ÄÆÅÊÏÎÒ! +$",0 -strPush db 205,200,215,220,223,0 -strDealerBust db "ÄÈËÅÐ ÏÅÐÅÁÐÀË! ÏÎÁÅÄÀ! +$",0 -strPlayerBust db "ÏÅÐÅÁÎÐ (>21)! ÏÐÎÈÃÐÛØ",0 - -sym7 db " 777 ",0 -symBar db " BAR ",0 -symBell db 32,199,194,206,205,0 -symCherry db 194,200,216,205,223,0 -symClover db 202,203,197,194,197,208,0 -symGem db 192,203,204,192,199,0 -symCrown db 202,206,208,206,205,192,0 - -cardRankStr db "A ",0,"2 ",0,"3 ",0,"4 ",0,"5 ",0,"6 ",0,"7 ",0,"8 ",0,"9 ",0,"10",0,"J ",0,"Q ",0,"K ",0 - -.data? -ALIGN 4 -screenBuffer dd SCREEN_SIZE dup(?) -ALIGN 4 -zBuffer dd SCREEN_W dup(?) -ALIGN 4 -texturesBuffer dd (197 * 128 * 128) dup(?) - -hudNumBuffer db 32 dup(?) - -.code - -; --- 3D Window Procedure --- -Casino3DWndProc PROC hwnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD - invoke WindowEvents3D, hwnd, uMsg, wParam, lParam - ret -Casino3DWndProc ENDP - -; --- Random Generator --- -RandomRange3D PROC maxVal:DWORD - mov eax, rngSeed3D - imul eax, 1103515245 - add eax, 12345 - mov rngSeed3D, eax - shr eax, 16 - and eax, 7FFFh - xor edx, edx - div maxVal - mov eax, edx - ret -RandomRange3D ENDP - -; --- Copy String --- -CopyString3D PROC src:DWORD, dst:DWORD - push esi - push edi - mov esi, src - mov edi, dst -@@: - mov al, [esi] - mov [edi], al - test al, al - jz @F - inc esi - inc edi - jmp @B -@@: - pop edi - pop esi - ret -CopyString3D ENDP - -; --- Format Number to Decimal String --- -FormatNumber PROC num:DWORD, buf:DWORD - push ebx - push esi - push edi - mov eax, num - mov edi, buf - test eax, eax - jns fn_pos - mov BYTE PTR [edi], '-' - inc edi - neg eax -fn_pos: - mov ebx, 10 - push 0 -fn_div: - xor edx, edx - div ebx - add dl, '0' - push edx - test eax, eax - jnz fn_div -fn_pop: - pop eax - test al, al - jz fn_done - mov [edi], al - inc edi - jmp fn_pop -fn_done: - mov BYTE PTR [edi], 0 - pop edi - pop esi - pop ebx - ret -FormatNumber ENDP - -; --- Fast 2D Drawing Primitives --- -DrawBox PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD - -DrawPixel PROC x:DWORD, y:DWORD, color:DWORD - invoke DrawBox, x, y, 1, 1, color - ret -DrawPixel ENDP - -DrawBox PROC x:DWORD, y:DWORD, w:DWORD, h:DWORD, color:DWORD - shl x, 1 - shl y, 1 - shl w, 1 - shl h, 1 - push ebx - push esi - push edi - mov edi, y -box_row_loop: - mov eax, y - add eax, h - cmp edi, eax - jge box_done - cmp edi, 0 - jl next_box_row - cmp edi, SCREEN_H - jge box_done - - mov esi, x -box_col_loop: - mov eax, x - add eax, w - cmp esi, eax - jge next_box_row - cmp esi, 0 - jl next_box_col - cmp esi, SCREEN_W - jge next_box_row - - mov ecx, edi - imul ecx, SCREEN_W - add ecx, esi - mov edx, color - mov [screenBuffer + ecx*4], edx - -next_box_col: - inc esi - jmp box_col_loop - -next_box_row: - inc edi - jmp box_row_loop - -box_done: - pop edi - pop esi - pop ebx - ret -DrawBox ENDP - -DrawBoxBorder PROC uses ebx x:DWORD, y:DWORD, w:DWORD, h:DWORD, fillColor:DWORD, borderColor:DWORD, bWidth:DWORD - invoke DrawBox, x, y, w, h, borderColor - mov eax, x - add eax, bWidth - mov edx, y - add edx, bWidth - mov ecx, w - sub ecx, bWidth - sub ecx, bWidth - mov ebx, h - sub ebx, bWidth - sub ebx, bWidth - invoke DrawBox, eax, edx, ecx, ebx, fillColor - ret -DrawBoxBorder ENDP - -DrawCircle PROC cxVal:DWORD, cyVal:DWORD, radius:DWORD, color:DWORD - push ebx - push esi - push edi - mov eax, radius - neg eax - mov edi, eax -circ_y: - cmp edi, radius - jg circ_done - mov eax, radius - neg eax - mov esi, eax -circ_x: - cmp esi, radius - jg next_circ_y - - mov eax, esi - imul eax, eax - mov ebx, edi - imul ebx, ebx - add eax, ebx - mov edx, radius - imul edx, edx - cmp eax, edx - jg next_circ_x - - mov eax, cxVal - add eax, esi - mov ecx, cyVal - add ecx, edi - invoke DrawPixel, eax, ecx, color - -next_circ_x: - inc esi - jmp circ_x -next_circ_y: - inc edi - jmp circ_y -circ_done: - pop edi - pop esi - pop ebx - ret -DrawCircle ENDP - -DrawChar8x8 PROC uses ebx esi edi x:DWORD, y:DWORD, chVal:DWORD, color:DWORD - local column:DWORD - mov eax, chVal - and eax, 255 - lea esi, [font8x8 + eax*8] - xor edi, edi -glyph_row: - movzx ebx, BYTE PTR [esi+edi] - mov column, 0 -glyph_col: - test ebx, 80h - jz glyph_next - mov eax, x - add eax, column - mov edx, y - add edx, edi - invoke DrawPixel, eax, edx, color -glyph_next: - shl ebx, 1 - inc column - cmp column, 8 - jl glyph_col - inc edi - cmp edi, 8 - jl glyph_row - ret -DrawChar8x8 ENDP - -DrawString8x8 PROC x:DWORD, y:DWORD, strPtr:DWORD, color:DWORD - push ebx - push esi - mov esi, strPtr - mov ebx, x -str_loop: - movzx eax, BYTE PTR [esi] - test al, al - jz str_done - invoke DrawChar8x8, ebx, y, eax, color - add ebx, 8 - inc esi - jmp str_loop -str_done: - pop esi - pop ebx - ret -DrawString8x8 ENDP - -; --- True 3D Perspective Floor & Ceiling Rendering --- - -; --- DDA Raycasting Walls --- -RenderWallsRange PROC colStart:DWORD, colLimit:DWORD - local col:DWORD - local originalStart:DWORD - local camX:DWORD - local rayDirX:DWORD - local rayDirY:DWORD - local mapX:DWORD - local mapY:DWORD - local deltaDistX:DWORD - local deltaDistY:DWORD - local stepX:DWORD - local stepY:DWORD - local sideDistX:DWORD - local sideDistY:DWORD - local side:DWORD - local perpWallDist:DWORD - local lineH:DWORD - local drawStart:DWORD - local drawEnd:DWORD - local wallHit:DWORD - local texX:DWORD - local texXHD:DWORD - local pixelMaterial:DWORD - local texId:DWORD - local shade:DWORD - - push ebx - push esi - push edi - - mov eax, playerAngle - and eax, 511 - mov ebx, [tableCos + eax*4] - mov playerDirX, ebx - mov ebx, [tableSin + eax*4] - mov playerDirY, ebx - - mov eax, ebx - imul eax, -66 - cdq - mov ecx, 100 - idiv ecx - mov playerPlaneX, eax - - mov eax, playerDirX - imul eax, 66 - cdq - idiv ecx - mov playerPlaneY, eax - - mov eax, colStart - mov col, eax -col_loop: - mov eax, colLimit - cmp col, eax - jge walls_done - - mov eax, col - shl eax, 1 - sub eax, SCREEN_W - imul eax, FP_1 - cdq - mov ecx, SCREEN_W - idiv ecx - mov camX, eax - - mov eax, playerPlaneX - imul camX - shrd eax, edx, 16 - add eax, playerDirX - mov rayDirX, eax - - mov eax, playerPlaneY - imul camX - shrd eax, edx, 16 - add eax, playerDirY - mov rayDirY, eax - - mov eax, playerX - sar eax, 16 - mov mapX, eax - mov eax, playerY - sar eax, 16 - mov mapY, eax - - cmp portalRendering3D,0 - je wall_ray_start_ready - mov ebx,col - mov ecx,portalClipDepth3D[ebx*4] - test ecx,ecx - jnz @F - mov zBuffer[ebx*4],7FFFFFFFh - jmp next_col -@@: - ; Start DDA just inside the destination aperture, never in its rear wall. - add ecx,FP_1/100 - mov eax,rayDirX - imul ecx - shrd eax,edx,16 - add eax,playerX - sar eax,16 - mov mapX,eax - mov eax,rayDirY - imul ecx - shrd eax,edx,16 - add eax,playerY - sar eax,16 - mov mapY,eax -wall_ray_start_ready: - mov eax, rayDirX - test eax, eax - jnz calc_delta_x - mov deltaDistX, 7FFFFFFFh - jmp calc_delta_y -calc_delta_x: - test eax, eax - jns @F - neg eax -@@: - mov ebx, eax - cmp ebx, 4 - jbe delta_x_clamp - xor eax, eax - mov edx, 1 - div ebx - mov deltaDistX, eax - jmp calc_delta_y -delta_x_clamp: - mov deltaDistX, 7FFFFFFFh - -calc_delta_y: - mov eax, rayDirY - test eax, eax - jnz calc_delta_y_ok - mov deltaDistY, 7FFFFFFFh - jmp check_step -calc_delta_y_ok: - test eax, eax - jns @F - neg eax -@@: - mov ebx, eax - cmp ebx, 4 - jbe delta_y_clamp - xor eax, eax - mov edx, 1 - div ebx - mov deltaDistY, eax - jmp check_step -delta_y_clamp: - mov deltaDistY, 7FFFFFFFh - -check_step: - cmp rayDirX, 0 - jge step_x_pos - mov stepX, -1 - mov eax, playerX - mov edx, mapX - shl edx, 16 - sub eax, edx - imul deltaDistX - shrd eax, edx, 16 - mov sideDistX, eax - jmp check_step_y -step_x_pos: - mov stepX, 1 - mov eax, mapX - inc eax - shl eax, 16 - sub eax, playerX - imul deltaDistX - shrd eax, edx, 16 - mov sideDistX, eax - -check_step_y: - cmp rayDirY, 0 - jge step_y_pos - mov stepY, -1 - mov eax, playerY - mov edx, mapY - shl edx, 16 - sub eax, edx - imul deltaDistY - shrd eax, edx, 16 - mov sideDistY, eax - jmp dda_start -step_y_pos: - mov stepY, 1 - mov eax, mapY - inc eax - shl eax, 16 - sub eax, playerY - imul deltaDistY - shrd eax, edx, 16 - mov sideDistY, eax - -dda_start: - xor ecx, ecx -dda_step_loop: - inc ecx - cmp ecx, 64 - jge wall_map_boundary - - mov eax, sideDistX - cmp eax, sideDistY - jge step_in_y - - mov eax, deltaDistX - add sideDistX, eax - mov eax, stepX - add mapX, eax - mov side, 0 - jmp check_tile - -step_in_y: - mov eax, deltaDistY - add sideDistY, eax - mov eax, stepY - add mapY, eax - mov side, 1 - -check_tile: - cmp mapX, 0 - jl wall_map_boundary - cmp mapX, MAP_WIDTH - jge wall_map_boundary - cmp mapY, 0 - jl wall_map_boundary - cmp mapY, MAP_HEIGHT - jge wall_map_boundary - - mov eax, mapY - shl eax, 5 - add eax, mapX - mov edx, worldMap3D - movzx eax, BYTE PTR [edx + eax] - test eax, eax - jnz hit_wall - jmp dda_step_loop - -wall_map_boundary: - cmp outdoorRender3D, 0 - je hit_wall - mov eax, col - mov zBuffer[eax*4], 7FFFFFFFh - jmp next_col - -hit_wall: - cmp side, 0 - jne perp_y - mov eax, sideDistX - sub eax, deltaDistX - mov perpWallDist, eax - jmp perp_done -perp_y: - mov eax, sideDistY - sub eax, deltaDistY - mov perpWallDist, eax - -perp_done: - cmp perpWallDist, 2048 - jge @F - mov perpWallDist, 2048 -@@: - mov eax, col - mov edx, perpWallDist - mov [zBuffer + eax*4], edx - - ; Unit projection is shared by indoor room height and outdoor storeys. - mov eax, SCREEN_H - imul eax, FP_1 - cdq - idiv perpWallDist - mov lineH, eax - - mov eax, lineH - imul viewEye3D - shrd eax, edx, 16 - add eax, viewHorizon3D - mov drawEnd, eax - mov ebx, lineH - mov eax, viewCeiling3D - cmp outdoorRender3D, 0 - je @F - mov eax, CITY_STOREY_HEIGHT -@@: - imul ebx - shrd eax, edx, 16 - mov ebx, eax - mov lineH, ebx - mov eax, drawEnd - sub eax, ebx - mov drawStart, eax - cmp outdoorRender3D, 0 - je wall_store_original_start - ; Floor height is independent of storey height. - mov eax, drawEnd - sub eax, lineH - mov drawStart, eax - mov eax, mapY - shl eax, 5 - add eax, mapX - mov edx, worldMap3D - movzx eax, BYTE PTR [edx+eax] -wall_exterior_tall: - ; Roof projection and texture sampling use the same storey count. - mov eax, lineH - imul eax, CITY_BUILDING_STOREYS-1 - sub drawStart, eax - mov eax, lineH - imul eax, CITY_BUILDING_STOREYS - mov lineH, eax -wall_store_original_start: - mov eax, drawStart - mov originalStart, eax - - cmp side, 0 - jne hit_side_y - mov eax, perpWallDist - imul rayDirY - shrd eax, edx, 16 - add eax, playerY - mov wallHit, eax - jmp calc_tex_x -hit_side_y: - mov eax, perpWallDist - imul rayDirX - shrd eax, edx, 16 - add eax, playerX - mov wallHit, eax - -calc_tex_x: - ; MASK WITH 0FFFFh to prevent texture scrambling! - mov eax, wallHit - and eax, 0FFFFh - mov texXHD, eax - shr eax, 9 - and eax, 127 - mov texX, eax - - cmp side, 0 - jne @F - cmp rayDirX, 0 - jle @F - mov eax, 127 - sub eax, texX - mov texX, eax - xor texXHD, 0FFFFh -@@: - cmp side, 1 - jne select_tex - cmp rayDirY, 0 - jge select_tex - mov eax, 127 - sub eax, texX - mov texX, eax - xor texXHD, 0FFFFh - -select_tex: - mov eax, mapY - shl eax, 5 - add eax, mapX - mov edx, worldMap3D - movzx eax, BYTE PTR [edx + eax] - mov texId, eax - cmp texId, 0 - jne @F - mov texId, 1 -@@: - - mov eax, perpWallDist - shr eax, 13 - mov edx, 256 - sub edx, eax - cmp edx, 75 - jge @F - mov edx, 75 -@@: - cmp side, 1 - jne @F - imul edx, 3 - shr edx, 2 -@@: - mov shade, edx - - cmp drawStart, 0 - jge @F - mov drawStart, 0 -@@: - cmp drawEnd, SCREEN_H - jl @F - mov drawEnd, SCREEN_H - 1 -@@: - - mov eax, lineH - cmp eax, 1 - jge @F - mov eax, 1 - mov lineH, eax -@@: - - mov eax, 128 * FP_1 - cdq - idiv lineH - mov esi, eax ; stepY - - mov eax, drawStart - sub eax, originalStart - imul eax, esi - mov edi, eax ; texPos - - mov ecx, drawStart -draw_stripe_loop: - cmp ecx, drawEnd - jg next_col - - mov eax, edi - shr eax, 16 - and eax, 127 - mov edx, texId - cmp outdoorRender3D, 0 - je wall_sample_material - imul eax, CITY_BUILDING_STOREYS - cmp eax, 128*(CITY_BUILDING_STOREYS-1) - jae wall_lower_storey - push eax - shr eax, 7 - add eax, mapX - add eax, mapY - xor edx, edx - mov ebx, 3 - div ebx - add edx, 65 - pop eax - and eax, 127 - jmp wall_sample_material -wall_lower_storey: - sub eax, 128*(CITY_BUILDING_STOREYS-1) -wall_sample_material: - mov pixelMaterial, edx - cmp outdoorRender3D, 0 - je wall_sample_indoor_hd - cmp hallCityDetail3D.pixels, 0 - je wall_sample_standard - cmp edx, 57 - jb wall_sample_standard - cmp edx, 72 - ja wall_sample_standard - cmp perpWallDist, 6*FP_1 - ja wall_sample_standard - ; Preserve subtexel detail near facades; retain the 128px mip at distance. - push edx - mov eax, edi - shr eax, 15 - imul eax, CITY_BUILDING_STOREYS - and eax, 255 - shl eax, 8 - mov ebx, texXHD - shr ebx, 8 - add eax, ebx - pop edx - sub edx, 57 - shl edx, 16 - add eax, edx - mov ebx, hallCityDetail3D.pixels - mov eax, [ebx+eax*4] - jmp wall_shade_pixel -wall_sample_indoor_hd: - cmp edx,132 - jb wall_sample_other_hd - cmp edx,135 - ja wall_sample_other_hd - mov ebx,fortuneMaterialArt3D.pixels - test ebx,ebx - jz wall_fortune_material_missing - sub edx,132 - shl edx,18 - add ebx,edx - jmp wall_room_hd_coordinates -wall_fortune_material_missing: - mov edx,92 - mov eax,edi - shr eax,16 - and eax,127 - jmp wall_sample_standard -wall_sample_other_hd: - cmp edx,122 - jb wall_sample_existing_hd - cmp edx,125 - ja wall_sample_existing_hd - mov ebx,upperMaterialArt3D.pixels - test ebx,ebx - jz wall_upper_material_missing - sub edx,122 - shl edx,18 - add ebx,edx - jmp wall_room_hd_coordinates -wall_upper_material_missing: - mov edx,102 -wall_sample_existing_hd: - cmp edx, 80 - jb wall_sample_standard - cmp edx, 103 - ja wall_sample_standard - mov ebx, hallRoomHD3D.pixels - cmp edx, 92 - jb wall_sample_room_hd - mov ebx, hallArchitectureHD3D.pixels - sub edx, 12 -wall_sample_room_hd: - test ebx, ebx - jz wall_sample_standard_restore - sub edx, 80 - shl edx, 18 - add ebx, edx -wall_room_hd_coordinates: - mov eax, edi - shr eax, 15 - and eax, 255 - shl eax, 8 - mov edx, texXHD - shr edx, 8 - add eax, edx - mov eax, [ebx+eax*4] - jmp wall_shade_pixel -wall_sample_standard_restore: - mov edx, texId - mov eax, edi - shr eax, 16 - and eax, 127 -wall_sample_standard: - shl eax, 7 - add eax, texX - - shl edx, 14 - add eax, edx - mov eax, [texturesBuffer + eax*4] - - ; Shade wall pixel -wall_shade_pixel: - mov ebx, shade - cmp outdoorRender3D, 0 - je wall_ambient_shade - push eax - push ecx - invoke IsCityEmissive3D, eax, pixelMaterial - pop ecx - test eax, eax - pop eax - jz wall_ambient_shade - mov ebx, 256 -wall_ambient_shade: - cmp hallLevel3D, 0 - je @F - imul ebx, 7 - shr ebx, 3 -@@: - movzx edx, al - imul edx, ebx - shr edx, 8 - push edx - - movzx edx, ah - imul edx, ebx - shr edx, 8 - shl edx, 8 - - shr eax, 16 - movzx eax, al - imul eax, ebx - shr eax, 8 - shl eax, 16 - or eax, edx - pop edx - or eax, edx - - mov edx, ecx - imul edx, SCREEN_W - add edx, col - mov [screenBuffer + edx*4], eax - - add edi, esi - inc ecx - jmp draw_stripe_loop - -next_col: - inc col - jmp col_loop - -walls_done: - pop edi - pop esi - pop ebx - ret -RenderWallsRange ENDP - -; --- Raycasting Background Worker Thread --- -RaycastWorkerProc PROC uses ebx esi edi lpParam:DWORD -worker_loop: - invoke WaitForSingleObject, hRaycastStartEvent, 0FFFFFFFFh - cmp bRaycastQuit, 1 - je worker_exit - invoke RenderWallsRange, 320, 640 - invoke SetEvent, hRaycastDoneEvent - jmp worker_loop -worker_exit: - xor eax, eax - ret -RaycastWorkerProc ENDP - -; --- Multi-Threaded DDA Raycasting Walls Dispatcher --- -RenderWalls PROC - push ebx - push esi - push edi - - mov eax, playerAngle - and eax, 511 - mov ebx, [tableCos + eax*4] - mov playerDirX, ebx - mov ebx, [tableSin + eax*4] - mov playerDirY, ebx - - mov eax, ebx - imul eax, -66 - cdq - mov ecx, 100 - idiv ecx - mov playerPlaneX, eax - - mov eax, playerDirX - imul eax, 66 - cdq - idiv ecx - mov playerPlaneY, eax - - cmp hRaycastStartEvent, 0 - je single_thread_fallback - - ; Signal background worker to render columns [320..640) - invoke SetEvent, hRaycastStartEvent - - ; Main thread processes columns [0..320) in parallel - invoke RenderWallsRange, 0, 320 - - ; Synchronize with worker completion - invoke WaitForSingleObject, hRaycastDoneEvent, 0FFFFFFFFh - jmp walls_finished - -single_thread_fallback: - invoke RenderWallsRange, 0, SCREEN_W - -walls_finished: - pop edi - pop esi - pop ebx - ret -RenderWalls ENDP - -; --- Render 3D Billboard Sprites --- - -; --- HUD & Minimap Radar --- -RenderHUD PROC uses ebx esi edi - invoke DrawBox, 0, 0, 320, 16, 0014191Dh - invoke DrawString8x8, 8, 4, OFFSET textBank3D, 00D8BC6Ah - invoke FormatNumber, bankroll, OFFSET hudNumBuffer - invoke DrawString8x8, 64, 4, OFFSET hudNumBuffer, 00FFFFFFh - invoke DrawString8x8, 176, 4, OFFSET textWindowKeys3D, 00A8B6BBh - invoke DrawBox, 0, 226, 320, 14, 0014191Dh - invoke DrawString8x8, 12, 230, OFFSET textWalkKeys3D, 00A8B6BBh - invoke DrawBox, 159, 118, 2, 5, 00E7DFC8h - invoke DrawBox, 157, 120, 6, 1, 00E7DFC8h - cmp interactPromptPtr, 0 - je hud_charms_bottom - invoke DrawBoxBorder, 4, 199, 312, 18, 0014191Dh, 00D8BC6Ah, 1 - invoke DrawString8x8, 10, 204, interactPromptPtr, 00F5E2B0h - invoke DrawCharmsHUD, 8, 18 - jmp hud_charms_done -hud_charms_bottom: - invoke DrawCharmsHUD, 8, 214 -hud_charms_done: - cmp flashTimer, 0 - je hud_finished - dec flashTimer - invoke DrawBox, 4, 22, 312, 16, 0014191Dh - invoke DrawString8x8, 10, 26, OFFSET flashMessage, 00FFFFFFh -hud_finished: - ret -RenderHUD ENDP - -RenderMinimap PROC uses ebx esi edi - local radarX:DWORD - local radarY:DWORD - local radarSize:DWORD - - mov radarX, 320 - 48 - mov radarY, 20 - mov radarSize, 44 - - invoke DrawBoxBorder, radarX, radarY, radarSize, radarSize, 00101510h, 00FFD700h, 1 - - ; Draw Sprites on radar - cmp hallLevel3D, 0 - jne draw_player_radar - xor esi, esi -radar_spr_loop: - cmp esi, NUM_SPRITES - jge draw_player_radar - cmp esi,17 - je radar_skip_sprite - cmp esi,19 - je radar_skip_sprite - cmp esi,21 - je radar_skip_sprite - mov eax, esi - imul eax, SIZEOF SpriteObject - mov eax, [casinoSprites + eax].posX - sar eax, 16 - imul eax, radarSize - shr eax, 5 - add eax, radarX - mov ebx, eax - - mov eax, esi - imul eax, SIZEOF SpriteObject - mov eax, [casinoSprites + eax].posY - sar eax, 16 - imul eax, radarSize - shr eax, 5 - add eax, radarY - - invoke DrawPixel, ebx, eax, 00FFAA00h -radar_skip_sprite: - inc esi - jmp radar_spr_loop - -draw_player_radar: - mov eax, playerX - sar eax, 16 - imul eax, radarSize - shr eax, 5 - add eax, radarX - mov ebx, eax - - mov eax, playerY - sar eax, 16 - imul eax, radarSize - shr eax, 5 - add eax, radarY - - invoke DrawCircle, ebx, eax, 2, 00FF2020h - ret -RenderMinimap ENDP - -; ============================================================================== -; IN-ENGINE 2.5D MINI-GAME: SLOTS 777 -; ============================================================================== -HandleSlotsInput PROC - cmp slotSpinState, 1 - je slots_input_done - - invoke Pressed3D, 20h ; SPACE -> Spin - test ah, 80h - jz check_bet_adjust - mov eax, bankroll - cmp eax, slotBet - jl @F - sub eax, slotBet - mov bankroll, eax - mov slotSpinState, 1 - mov slotSpinTimer, 0 - mov slotWinAmount, 0 - invoke PlayCasinoSound3D, OFFSET soundSlotSpin, 0, 1 - jmp slots_input_done -@@: - invoke CopyString3D, OFFSET msgNeedMoney, OFFSET flashMessage - mov flashTimer, 60 - -check_bet_adjust: - invoke Pressed3D, 26h ; UP / W - test ah, 80h - jnz inc_bet - invoke Pressed3D, 57h - test ah, 80h - jz check_bet_down -inc_bet: - cmp slotBet, 500 - jge slots_input_done - cmp slotBet, 100 - jge @F - cmp slotBet, 50 - jge set_100 - mov slotBet, 50 - jmp slots_input_done -set_100: - mov slotBet, 100 - jmp slots_input_done -@@: - mov slotBet, 500 - jmp slots_input_done - -check_bet_down: - invoke Pressed3D, 28h ; DOWN / S - test ah, 80h - jnz dec_bet - invoke Pressed3D, 53h - test ah, 80h - jz slots_input_done -dec_bet: - cmp slotBet, 50 - jle set_10 - cmp slotBet, 100 - jle set_50 - mov slotBet, 100 - jmp slots_input_done -set_50: - mov slotBet, 50 - jmp slots_input_done -set_10: - mov slotBet, 10 - -slots_input_done: - ret -HandleSlotsInput ENDP - -RenderSlotsGame PROC uses ebx esi edi - ; Cabinet Background (Dark Cherry Wood & Gold) - invoke DrawBox, 0, 0, SCREEN_W, SCREEN_H, 00150A10h - invoke DrawBoxBorder, 10, 10, 300, 220, 00251015h, 00FFD700h, 3 - - ; Illuminated Top Marquee - invoke DrawBoxBorder, 25, 20, 270, 32, 000A0505h, 00FFFF00h, 2 - invoke DrawString8x8, 55, 32, OFFSET textSlots3D, 00FFD700h - - ; Spinning Animation Logic - cmp slotSpinState, 1 - jne draw_reels - inc slotSpinTimer - - cmp slotSpinTimer, 22 - jge @F - invoke RandomRange3D, 7 - mov slotReel1, eax -@@: - cmp slotSpinTimer, 36 - jge @F - invoke RandomRange3D, 7 - mov slotReel2, eax -@@: - cmp slotSpinTimer, 50 - jge @F - invoke RandomRange3D, 7 - mov slotReel3, eax -@@: - cmp slotSpinTimer, 50 - jl draw_reels - - ; Spin finished! Check outcome! - mov slotSpinState, 0 - mov eax, slotReel1 - cmp eax, slotReel2 - jne check_pairs - cmp eax, slotReel3 - jne check_pairs - - ; 3 Matching! - cmp eax, 0 ; 777! - jne @F - mov eax, slotBet - imul eax, 25 - mov slotWinAmount, eax - add bankroll, eax - invoke PlayCasinoSound3D, OFFSET soundJackpot, 0, 1 - jmp draw_reels -@@: - cmp eax, 6 ; CROWN! - jne @F - mov eax, slotBet - imul eax, 50 - mov slotWinAmount, eax - add bankroll, eax - invoke PlayCasinoSound3D, OFFSET soundJackpot, 0, 1 - jmp draw_reels -@@: - mov eax, slotBet - imul eax, 10 - mov slotWinAmount, eax - add bankroll, eax - invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 - jmp draw_reels - -check_pairs: - mov eax, slotReel1 - cmp eax, slotReel2 - je pair_win - mov eax, slotReel2 - cmp eax, slotReel3 - je pair_win - mov eax, slotReel1 - cmp eax, slotReel3 - je pair_win - jmp draw_reels -pair_win: - mov eax, slotBet - imul eax, 2 - mov slotWinAmount, eax - add bankroll, eax - invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 - -draw_reels: - ; Reels Window - invoke DrawBoxBorder, 30, 62, 260, 95, 000F0F12h, 0000A5FFh, 2 - - ; Reel 1 (45..105) - invoke DrawBoxBorder, 45, 68, 65, 82, 00F0F0F5h, 00505050h, 2 - mov eax, slotReel1 - call DrawReelSymbolAt1 - - ; Reel 2 (128..188) - invoke DrawBoxBorder, 128, 68, 65, 82, 00F0F0F5h, 00505050h, 2 - mov eax, slotReel2 - call DrawReelSymbolAt2 - - ; Reel 3 (210..270) - invoke DrawBoxBorder, 210, 68, 65, 82, 00F0F0F5h, 00505050h, 2 - mov eax, slotReel3 - call DrawReelSymbolAt3 - - ; Bottom Control Panel - invoke DrawBoxBorder, 20, 165, 280, 58, 00151515h, 00FFD700h, 1 - - invoke DrawString8x8, 28, 172, OFFSET textBank3D, 00FFD700h - invoke FormatNumber, bankroll, OFFSET hudNumBuffer - invoke DrawString8x8, 110, 172, OFFSET hudNumBuffer, 00FFFF00h - - invoke DrawString8x8, 175, 172, OFFSET textBet3D, 00FFD700h - invoke FormatNumber, slotBet, OFFSET hudNumBuffer - invoke DrawString8x8, 240, 172, OFFSET hudNumBuffer, 0050FF50h - - cmp slotWinAmount, 0 - jle draw_slot_ctrls - invoke DrawString8x8, 28, 187, OFFSET strWin, 00FFFF00h - invoke FormatNumber, slotWinAmount, OFFSET hudNumBuffer - invoke DrawString8x8, 110, 187, OFFSET hudNumBuffer, 00FFFF00h - -draw_slot_ctrls: - invoke DrawString8x8, 28, 204, OFFSET textSlotsKeys3D, 00A0A0A0h - ret -RenderSlotsGame ENDP - -DrawReelSymbolAt1 PROC - cmp eax, 0 - jne @F - invoke DrawString8x8, 52, 105, OFFSET sym7, 00FF2020h - ret -@@: - cmp eax, 1 - jne @F - invoke DrawString8x8, 52, 105, OFFSET symBar, 00FFAA00h - ret -@@: - cmp eax, 2 - jne @F - invoke DrawString8x8, 52, 105, OFFSET symBell, 00FFD700h - ret -@@: - cmp eax, 3 - jne @F - invoke DrawString8x8, 48, 105, OFFSET symCherry, 000000D0h - ret -@@: - cmp eax, 4 - jne @F - invoke DrawString8x8, 48, 105, OFFSET symClover, 0000A000h - ret -@@: - cmp eax, 5 - jne @F - invoke DrawString8x8, 52, 105, OFFSET symGem, 00FFFF00h - ret -@@: - invoke DrawString8x8, 52, 105, OFFSET symCrown, 00FFD700h - ret -DrawReelSymbolAt1 ENDP - -DrawReelSymbolAt2 PROC - cmp eax, 0 - jne @F - invoke DrawString8x8, 135, 105, OFFSET sym7, 00FF2020h - ret -@@: - cmp eax, 1 - jne @F - invoke DrawString8x8, 135, 105, OFFSET symBar, 00FFAA00h - ret -@@: - cmp eax, 2 - jne @F - invoke DrawString8x8, 135, 105, OFFSET symBell, 00FFD700h - ret -@@: - cmp eax, 3 - jne @F - invoke DrawString8x8, 131, 105, OFFSET symCherry, 000000D0h - ret -@@: - cmp eax, 4 - jne @F - invoke DrawString8x8, 131, 105, OFFSET symClover, 0000A000h - ret -@@: - cmp eax, 5 - jne @F - invoke DrawString8x8, 135, 105, OFFSET symGem, 00FFFF00h - ret -@@: - invoke DrawString8x8, 135, 105, OFFSET symCrown, 00FFD700h - ret -DrawReelSymbolAt2 ENDP - -DrawReelSymbolAt3 PROC - cmp eax, 0 - jne @F - invoke DrawString8x8, 218, 105, OFFSET sym7, 00FF2020h - ret -@@: - cmp eax, 1 - jne @F - invoke DrawString8x8, 218, 105, OFFSET symBar, 00FFAA00h - ret -@@: - cmp eax, 2 - jne @F - invoke DrawString8x8, 218, 105, OFFSET symBell, 00FFD700h - ret -@@: - cmp eax, 3 - jne @F - invoke DrawString8x8, 214, 105, OFFSET symCherry, 000000D0h - ret -@@: - cmp eax, 4 - jne @F - invoke DrawString8x8, 214, 105, OFFSET symClover, 0000A000h - ret -@@: - cmp eax, 5 - jne @F - invoke DrawString8x8, 218, 105, OFFSET symGem, 00FFFF00h - ret -@@: - invoke DrawString8x8, 218, 105, OFFSET symCrown, 00FFD700h - ret -DrawReelSymbolAt3 ENDP - -; ============================================================================== -; IN-ENGINE 2.5D MINI-GAME: BLACKJACK (21) -; ============================================================================== -HandleBlackjackInput PROC uses ebx - cmp bjState, 0 ; Need Deal - jne check_bj_player_turn - invoke Pressed3D, 20h ; SPACE -> Deal - test ah, 80h - jz check_bj_bet_change - mov eax, bankroll - cmp eax, bjBet - jl bj_need_cash - sub eax, bjBet - mov bankroll, eax - - ; Deal 2 cards to player, 2 cards to dealer - mov bjPlayerCardCount, 0 - mov bjDealerCardCount, 0 - mov bjDealerHideHole, 1 - - ; Player Card 1 - invoke RandomRange3D, 13 - inc eax - mov ebx, bjPlayerCardCount - mov [bjPlayerCards + ebx*4], eax - inc bjPlayerCardCount - - ; Dealer Card 1 - invoke RandomRange3D, 13 - inc eax - mov ebx, bjDealerCardCount - mov [bjDealerCards + ebx*4], eax - inc bjDealerCardCount - - ; Player Card 2 - invoke RandomRange3D, 13 - inc eax - mov ebx, bjPlayerCardCount - mov [bjPlayerCards + ebx*4], eax - inc bjPlayerCardCount - - ; Dealer Card 2 (Hole card) - invoke RandomRange3D, 13 - inc eax - mov ebx, bjDealerCardCount - mov [bjDealerCards + ebx*4], eax - inc bjDealerCardCount - - invoke PlayCasinoSound3D, OFFSET soundCards, 0, 1 - - ; Calc Player Score - call CalcPlayerBJScore - cmp bjPlayerScore, 21 - jne set_bj_turn - ; Instant Blackjack! - mov bjDealerHideHole, 0 - mov eax, bjBet - imul eax, 5 - shr eax, 1 - add bankroll, eax - invoke CopyString3D, OFFSET strWin, OFFSET bjOutcomeMsg - invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 - mov bjState, 2 - ret -set_bj_turn: - mov bjState, 1 - mov BYTE PTR [bjOutcomeMsg], 0 - ret - -bj_need_cash: - invoke CopyString3D, OFFSET msgNeedMoney, OFFSET flashMessage - mov flashTimer, 60 - ret - -check_bj_player_turn: - cmp bjState, 1 - jne check_bj_round_over - - invoke Pressed3D, 48h ; 'H' -> Hit - test ah, 80h - jz check_bj_stand - invoke RandomRange3D, 13 - inc eax - mov ebx, bjPlayerCardCount - cmp ebx, 8 - jge @F - mov [bjPlayerCards + ebx*4], eax - inc bjPlayerCardCount -@@: - invoke PlayCasinoSound3D, OFFSET soundCards, 0, 1 - call CalcPlayerBJScore - cmp bjPlayerScore, 21 - jle bj_input_done - ; Bust! - invoke CopyString3D, OFFSET strPlayerBust, OFFSET bjOutcomeMsg - mov bjDealerHideHole, 0 - mov bjState, 2 - ret - -check_bj_stand: - invoke Pressed3D, 53h ; 'S' -> Stand - test ah, 80h - jz bj_input_done - - ; Dealer Turn - mov bjDealerHideHole, 0 -dealer_loop: - call CalcDealerBJScore - cmp bjDealerScore, 17 - jge dealer_finished - invoke RandomRange3D, 13 - inc eax - mov ebx, bjDealerCardCount - cmp ebx, 8 - jge dealer_finished - mov [bjDealerCards + ebx*4], eax - inc bjDealerCardCount - jmp dealer_loop - -dealer_finished: - cmp bjDealerScore, 21 - jle compare_scores - ; Dealer Bust! - mov eax, bjBet - shl eax, 1 - add bankroll, eax - invoke CopyString3D, OFFSET strDealerBust, OFFSET bjOutcomeMsg - invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 - mov bjState, 2 - ret - -compare_scores: - mov eax, bjPlayerScore - cmp eax, bjDealerScore - jle check_dealer_won - ; Player Won! - mov eax, bjBet - shl eax, 1 - add bankroll, eax - invoke CopyString3D, OFFSET strWin, OFFSET bjOutcomeMsg - invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 - mov bjState, 2 - ret -check_dealer_won: - cmp eax, bjDealerScore - jl dealer_wins - ; Push (Tie) - mov eax, bjBet - add bankroll, eax - invoke CopyString3D, OFFSET strPush, OFFSET bjOutcomeMsg - mov bjState, 2 - ret -dealer_wins: - invoke CopyString3D, OFFSET strLose, OFFSET bjOutcomeMsg - mov bjState, 2 - ret - -check_bj_round_over: - invoke Pressed3D, 20h ; SPACE -> Next Hand - test ah, 80h - jz bj_input_done - mov bjState, 0 - ret - -check_bj_bet_change: - invoke Pressed3D, 26h ; UP - test ah, 80h - jz @F - cmp bjBet, 500 - jge bj_input_done - add bjBet, 50 - ret -@@: - invoke Pressed3D, 28h ; DOWN - test ah, 80h - jz bj_input_done - cmp bjBet, 50 - jle bj_input_done - sub bjBet, 50 - -bj_input_done: - ret -HandleBlackjackInput ENDP - -CalcPlayerBJScore PROC uses ebx esi - xor eax, eax - xor ebx, ebx - xor esi, esi -calc_p_loop: - cmp esi, bjPlayerCardCount - jge calc_p_done - mov edx, [bjPlayerCards + esi*4] - cmp edx, 10 - jle @F - mov edx, 10 -@@: - cmp edx, 1 - jne add_p_val - inc ebx ; count Aces - add eax, 11 - jmp next_p_card -add_p_val: - add eax, edx -next_p_card: - inc esi - jmp calc_p_loop -calc_p_done: - ; Soft Ace reduction -reduce_p_ace: - cmp eax, 21 - jle store_p_score - test ebx, ebx - jz store_p_score - sub eax, 10 - dec ebx - jmp reduce_p_ace -store_p_score: - mov bjPlayerScore, eax - ret -CalcPlayerBJScore ENDP - -CalcDealerBJScore PROC uses ebx esi - xor eax, eax - xor ebx, ebx - xor esi, esi -calc_d_loop: - cmp esi, bjDealerCardCount - jge calc_d_done - mov edx, [bjDealerCards + esi*4] - cmp edx, 10 - jle @F - mov edx, 10 -@@: - cmp edx, 1 - jne add_d_val - inc ebx - add eax, 11 - jmp next_d_card -add_d_val: - add eax, edx -next_d_card: - inc esi - jmp calc_d_loop -calc_d_done: -reduce_d_ace: - cmp eax, 21 - jle store_d_score - test ebx, ebx - jz store_d_score - sub eax, 10 - dec ebx - jmp reduce_d_ace -store_d_score: - mov bjDealerScore, eax - ret -CalcDealerBJScore ENDP - -RenderBlackjackGame PROC uses ebx esi edi - ; Emerald Felt Table Background - invoke DrawBox, 0, 0, SCREEN_W, SCREEN_H, 000A3015h - invoke DrawBoxBorder, 10, 10, 300, 220, 000D4018h, 00FFD700h, 3 - - ; Dealer Area Top - invoke DrawString8x8, 25, 20, OFFSET textBJ3D, 00FFD700h - invoke DrawString8x8, 25, 35, OFFSET textDealer3D, 00FFFFFFh - invoke FormatNumber, bjDealerScore, OFFSET hudNumBuffer - invoke DrawString8x8, 120, 35, OFFSET hudNumBuffer, 00FFFF00h - - ; Dealer Cards - xor esi, esi -draw_dealer_cards: - cmp esi, bjDealerCardCount - jge draw_player_bj_area - mov eax, esi - imul eax, 45 - add eax, 25 - mov ebx, eax - - cmp esi, 1 - jne draw_dealer_face - cmp bjDealerHideHole, 1 - jne draw_dealer_face - ; Face Down Card - mov eax, selectedBack3D - mov eax, cardBackColors3D[eax*4] - invoke DrawBoxBorder, ebx, 48, 38, 52, eax, 00FFFFFFh, 2 - jmp next_dealer_card_draw - -draw_dealer_face: - invoke DrawBoxBorder, ebx, 48, 38, 52, 00F0F0F5h, 00000000h, 2 - mov eax, [bjDealerCards + esi*4] - dec eax - imul eax, 3 - lea edx, [cardRankStr + eax] - mov eax, ebx - add eax, 8 - invoke DrawString8x8, eax, 68, edx, 00000000h - -next_dealer_card_draw: - inc esi - jmp draw_dealer_cards - -draw_player_bj_area: - ; Player Area Bottom - invoke DrawString8x8, 25, 110, OFFSET textPlayer3D, 00FFFFFFh - invoke FormatNumber, bjPlayerScore, OFFSET hudNumBuffer - invoke DrawString8x8, 120, 110, OFFSET hudNumBuffer, 0050FF50h - - ; Player Cards - xor esi, esi -draw_player_cards: - cmp esi, bjPlayerCardCount - jge draw_bj_footer - mov eax, esi - imul eax, 45 - add eax, 25 - mov ebx, eax - - invoke DrawBoxBorder, ebx, 124, 38, 52, 00F0F0F5h, 00000000h, 2 - mov eax, [bjPlayerCards + esi*4] - dec eax - imul eax, 3 - lea edx, [cardRankStr + eax] - mov eax, ebx - add eax, 8 - invoke DrawString8x8, eax, 144, edx, 00000000h - - inc esi - jmp draw_player_cards - -draw_bj_footer: - ; Footer Status & Controls - invoke DrawBoxBorder, 20, 182, 280, 42, 00102010h, 00FFD700h, 1 - cmp BYTE PTR [bjOutcomeMsg], 0 - je draw_bj_controls - invoke DrawString8x8, 28, 188, OFFSET bjOutcomeMsg, 00FFFF00h - invoke DrawString8x8, 28, 204, OFFSET textNext3D, 00A0A0A0h - ret - -draw_bj_controls: - invoke DrawString8x8, 28, 188, OFFSET textBJKeys3D, 00FFFFFFh - invoke DrawString8x8, 28, 204, OFFSET textDeal3D, 00A0A0A0h - ret -RenderBlackjackGame ENDP - -; ============================================================================== -; IN-ENGINE 2.5D MINI-GAME: ROULETTE -; ============================================================================== -HandleRouletteInput PROC uses ebx - cmp roulState, 1 - je roul_input_done - - invoke Pressed3D, 31h ; '1' -> RED - test ah, 80h - jz @F - mov roulBetType, 1 -@@: - invoke Pressed3D, 32h ; '2' -> BLACK - test ah, 80h - jz @F - mov roulBetType, 2 -@@: - invoke Pressed3D, 33h ; '3' -> ZERO (0) - test ah, 80h - jz @F - mov roulBetType, 3 -@@: - invoke Pressed3D, 34h ; '4' -> EVEN - test ah, 80h - jz @F - mov roulBetType, 4 -@@: - invoke Pressed3D, 35h ; '5' -> ODD - test ah, 80h - jz check_roul_spin - mov roulBetType, 5 - -check_roul_spin: - invoke Pressed3D, 20h ; SPACE -> Spin - test ah, 80h - jz roul_input_done - mov eax, bankroll - cmp eax, roulBetAmount - jl roul_no_cash - sub eax, roulBetAmount - mov bankroll, eax - mov roulState, 1 - mov roulSpinTimer, 50 - mov roulPayout, 0 - invoke PlayCasinoSound3D, OFFSET soundRoulette, 0, 1 - ret - -roul_no_cash: - invoke CopyString3D, OFFSET msgNeedMoney, OFFSET flashMessage - mov flashTimer, 60 - -roul_input_done: - ret -HandleRouletteInput ENDP - -RenderRouletteGame PROC uses ebx esi edi - ; Table felt background - invoke DrawBox, 0, 0, SCREEN_W, SCREEN_H, 00151525h - invoke DrawBoxBorder, 10, 10, 300, 220, 00201525h, 00FFD700h, 3 - - ; 2.5D Rotating Wheel on Left - invoke DrawCircle, 85, 110, 65, 00102550h - invoke DrawCircle, 85, 110, 60, 00FFD700h - invoke DrawCircle, 85, 110, 52, 00101010h - invoke DrawCircle, 85, 110, 22, 00FFD700h ; Center brass turret - - ; Spinning Wheel / Ball Logic - cmp roulState, 1 - jne draw_roul_ball - dec roulSpinTimer - add roulWheelAngle, 8 - sub roulBallAngle, 14 - cmp roulSpinTimer, 0 - jg draw_roul_ball - - ; Wheel stopped! Determine result! - mov roulState, 2 - invoke RandomRange3D, 37 - mov roulWinningNum, eax - - ; Check bet - cmp roulBetType, 1 ; RED - jne check_ro_black - call IsNumberRed - test eax, eax - jz ro_lost - mov eax, roulBetAmount - shl eax, 1 - mov roulPayout, eax - add bankroll, eax - invoke CopyString3D, OFFSET strWin, OFFSET roulOutcomeMsg - invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 - jmp draw_roul_ball - -check_ro_black: - cmp roulBetType, 2 ; BLACK - jne check_ro_zero - cmp roulWinningNum, 0 - je ro_lost - call IsNumberRed - test eax, eax - jnz ro_lost - mov eax, roulBetAmount - shl eax, 1 - mov roulPayout, eax - add bankroll, eax - invoke CopyString3D, OFFSET strWin, OFFSET roulOutcomeMsg - invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 - jmp draw_roul_ball - -check_ro_zero: - cmp roulBetType, 3 ; ZERO - jne check_ro_even - cmp roulWinningNum, 0 - jne ro_lost - mov eax, roulBetAmount - imul eax, 36 - mov roulPayout, eax - add bankroll, eax - invoke CopyString3D, OFFSET strJackpot, OFFSET roulOutcomeMsg - invoke PlayCasinoSound3D, OFFSET soundJackpot, 0, 1 - jmp draw_roul_ball - -check_ro_even: - cmp roulBetType, 4 ; EVEN - jne check_ro_odd - mov eax, roulWinningNum - test eax, eax - jz ro_lost - test al, 1 - jnz ro_lost - mov eax, roulBetAmount - shl eax, 1 - mov roulPayout, eax - add bankroll, eax - invoke CopyString3D, OFFSET strWin, OFFSET roulOutcomeMsg - invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 - jmp draw_roul_ball - -check_ro_odd: - mov eax, roulWinningNum - test eax, eax - jz ro_lost - test al, 1 - jz ro_lost - mov eax, roulBetAmount - shl eax, 1 - mov roulPayout, eax - add bankroll, eax - invoke CopyString3D, OFFSET strWin, OFFSET roulOutcomeMsg - invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 - jmp draw_roul_ball - -ro_lost: - invoke CopyString3D, OFFSET strLose, OFFSET roulOutcomeMsg - -draw_roul_ball: - ; Draw White Ball on Rim - mov eax, roulBallAngle - and eax, 511 - mov ebx, [tableCos + eax*4] - imul ebx, 42 - sar ebx, 16 - add ebx, 85 - - mov eax, roulBallAngle - and eax, 511 - mov edx, [tableSin + eax*4] - imul edx, 42 - sar edx, 16 - add edx, 110 - invoke DrawCircle, ebx, edx, 3, 00FFFFFFh - - ; Right Betting Board - invoke DrawBoxBorder, 175, 25, 125, 28, 001010C0h, 00FFFFFFh, 2 ; [1] RED - invoke DrawString8x8, 190, 35, OFFSET textRed3D, 00FFFFFFh - - invoke DrawBoxBorder, 175, 60, 125, 28, 00151515h, 00FFFFFFh, 2 ; [2] BLACK - invoke DrawString8x8, 190, 70, OFFSET textBlack3D, 00FFFFFFh - - invoke DrawBoxBorder, 175, 95, 125, 28, 00106010h, 00FFFFFFh, 2 ; [3] ZERO - invoke DrawString8x8, 190, 105, OFFSET textZero3D, 00FFFFFFh - - invoke DrawBoxBorder, 175, 130, 60, 26, 00302020h, 00FFFFFFh, 1 ; [4] EVEN - invoke DrawString8x8, 185, 139, OFFSET textEven3D, 00FFFFFFh - - invoke DrawBoxBorder, 240, 130, 60, 26, 00302020h, 00FFFFFFh, 1 ; [5] ODD - invoke DrawString8x8, 250, 139, OFFSET textOdd3D, 00FFFFFFh - - ; Highlight Active Bet - cmp roulBetType, 1 - jne @F - invoke DrawBoxBorder, 173, 23, 129, 32, 0, 00FFFF00h, 2 -@@: - cmp roulBetType, 2 - jne @F - invoke DrawBoxBorder, 173, 58, 129, 32, 0, 00FFFF00h, 2 -@@: - cmp roulBetType, 3 - jne @F - invoke DrawBoxBorder, 173, 93, 129, 32, 0, 00FFFF00h, 2 -@@: - cmp roulBetType, 4 - jne @F - invoke DrawBoxBorder, 173, 128, 64, 30, 0, 00FFFF00h, 2 -@@: - cmp roulBetType, 5 - jne draw_ro_footer - invoke DrawBoxBorder, 238, 128, 64, 30, 0, 00FFFF00h, 2 - -draw_ro_footer: - invoke DrawBoxBorder, 20, 180, 280, 42, 00101015h, 00FFD700h, 1 - - cmp roulState, 2 - jne @F - invoke DrawString8x8, 28, 186, OFFSET textResult3D, 00FFD700h - invoke FormatNumber, roulWinningNum, OFFSET hudNumBuffer - invoke DrawString8x8, 85, 186, OFFSET hudNumBuffer, 00FFFF00h - invoke DrawString8x8, 130, 186, OFFSET roulOutcomeMsg, 0050FF50h -@@: - invoke DrawString8x8, 28, 202, OFFSET textSpin3D, 00A0A0A0h - ret -RenderRouletteGame ENDP - -IsNumberRed PROC - mov eax, roulWinningNum - cmp eax, 1 - je red_yes - cmp eax, 3 - je red_yes - cmp eax, 5 - je red_yes - cmp eax, 7 - je red_yes - cmp eax, 9 - je red_yes - cmp eax, 12 - je red_yes - cmp eax, 14 - je red_yes - cmp eax, 16 - je red_yes - cmp eax, 18 - je red_yes - cmp eax, 19 - je red_yes - cmp eax, 21 - je red_yes - cmp eax, 23 - je red_yes - cmp eax, 25 - je red_yes - cmp eax, 27 - je red_yes - cmp eax, 30 - je red_yes - cmp eax, 32 - je red_yes - cmp eax, 34 - je red_yes - cmp eax, 36 - je red_yes - xor eax, eax - ret -red_yes: - mov eax, 1 - ret -IsNumberRed ENDP - -; ============================================================================== -; IN-ENGINE 2.5D MINI-GAME: BAR & SHOP -; ============================================================================== -HandleShopInput PROC uses ebx esi - xor esi, esi -shop_choice: - inc esi - lea eax, [esi+30h] - invoke Pressed3D, eax - test eax, eax - jnz shop_chosen - cmp esi, 3 - jb shop_choice - ret -shop_chosen: - bt ownedBacks3D, esi - jc shop_equip - mov ebx, 1500 - cmp esi, 1 - jne @F - mov ebx, 1000 -@@: - cmp bankroll, ebx - jb shop_no_money - sub bankroll, ebx - bts ownedBacks3D, esi -shop_equip: - mov selectedBack3D, esi - invoke CopyString3D, OFFSET textBought3D, OFFSET shopMsg - call SaveProgress3D - ret -shop_no_money: - invoke CopyString3D, OFFSET textNoCash3D, OFFSET shopMsg - ret -HandleShopInput ENDP - -RenderShopGame PROC - invoke DrawBox, 0, 0, SCREEN_W, SCREEN_H, 00150A0Ah - invoke DrawBoxBorder, 10, 10, 300, 220, 00251515h, 00FFD700h, 3 - invoke DrawString8x8, 25, 20, OFFSET textShop3D, 00FFD700h - - invoke DrawBoxBorder, 20, 40, 280, 32, 001A1010h, 00FFFFFFh, 1 - invoke DrawString8x8, 28, 46, OFFSET textItem1_3D, 00FFFF00h - invoke DrawString8x8, 28, 58, OFFSET textShopHint3D, 00A0A0A0h - - invoke DrawBoxBorder, 20, 80, 280, 32, 001A1010h, 00FFFFFFh, 1 - invoke DrawString8x8, 28, 86, OFFSET textItem2_3D, 00FFFF00h - invoke DrawString8x8, 28, 98, OFFSET textShopHint3D, 00A0A0A0h - - invoke DrawBoxBorder, 20, 120, 280, 32, 001A1010h, 00FFFFFFh, 1 - invoke DrawString8x8, 28, 126, OFFSET textItem3_3D, 00FFFF00h - invoke DrawString8x8, 28, 138, OFFSET textShopHint3D, 00A0A0A0h - - invoke DrawBoxBorder, 20, 165, 280, 55, 00100A0Ah, 00FFD700h, 1 - invoke DrawString8x8, 28, 172, OFFSET textBank3D, 00FFD700h - invoke FormatNumber, bankroll, OFFSET hudNumBuffer - invoke DrawString8x8, 110, 172, OFFSET hudNumBuffer, 00FFFF00h - - cmp BYTE PTR [shopMsg], 0 - je @F - invoke DrawString8x8, 28, 188, OFFSET shopMsg, 0050FF50h -@@: - invoke DrawString8x8, 28, 204, OFFSET textBack3D, 00A0A0A0h - ret -RenderShopGame ENDP - -; ============================================================================== -; IN-ENGINE 2.5D MINI-GAME: ATM TERMINAL -; ============================================================================== -HandleATMInput PROC - call HandleTerminal3D - ret -HandleATMInput ENDP - -RenderATMGame PROC - call RenderTerminal3D - ret -RenderATMGame ENDP - -; ============================================================================== -; ============================================================================== -; ============================================================================== -; SHARED RICH UI PROCEDURES -; ============================================================================== -DrawKeycap3D PROC uses ebx esi edi, x:DWORD, y:DWORD, strPtr:DWORD, isActive:DWORD - local keyW:DWORD - mov esi, strPtr - xor ecx, ecx -keycap_len: - mov al, [esi+ecx] - test al, al - jz keycap_len_done - inc ecx - jmp keycap_len -keycap_len_done: - shl ecx, 3 - add ecx, 8 - mov keyW, ecx - - ; Drop shadow - mov eax, y - add eax, 2 - invoke DrawBox, x, eax, keyW, 13, 0008080Ch - - ; Border and Fill - cmp isActive, 0 - je keycap_inactive - mov eax, 00FFFF00h ; Bright Yellow active border - mov edx, 001B4B22h ; Casino Green active fill - mov ebx, 00FFFF00h ; Bright Yellow active text - jmp keycap_draw_box -keycap_inactive: - mov eax, 00606870h ; Slate inactive border - mov edx, 001A1C22h ; Charcoal inactive fill - mov ebx, 00D0D8E0h ; Silver inactive text - -keycap_draw_box: - push ebx - invoke DrawBoxBorder, x, y, keyW, 13, edx, eax, 1 - pop ebx - - ; Text label - mov eax, x - add eax, 4 - mov edx, y - add edx, 3 - invoke DrawString8x8, eax, edx, strPtr, ebx - - mov eax, keyW - add eax, 4 - ret -DrawKeycap3D ENDP - -DrawChipStack PROC uses ebx esi edi, x:DWORD, y:DWORD, chipCount:DWORD - mov edi, chipCount - xor esi, esi -chip_loop: - cmp esi, edi - jge chip_done - mov eax, esi - shl eax, 2 - mov edx, y - sub edx, eax - - ; Shadow - mov eax, x - add eax, 2 - mov ecx, edx - add ecx, 5 - invoke DrawBox, eax, ecx, 20, 2, 00061004h - - ; Red Clay Chip body with white rim - invoke DrawBoxBorder, x, edx, 24, 6, 00B81515h, 00FFFFFFh, 1 - - ; White stripe inlays - mov eax, x - add eax, 4 - mov ecx, edx - add ecx, 1 - invoke DrawBox, eax, ecx, 3, 4, 00FFFFFFh - - mov eax, x - add eax, 17 - mov ecx, edx - add ecx, 1 - invoke DrawBox, eax, ecx, 3, 4, 00FFFFFFh - - inc esi - jmp chip_loop -chip_done: - ret -DrawChipStack ENDP - -DrawDetailedCoin PROC uses ebx esi edi, cxVal:DWORD, cyVal:DWORD, rxVal:DWORD, ryVal:DWORD, outerColor:DWORD, innerColor:DWORD, reliefType:DWORD - local rxSq:DWORD - local rySq:DWORD - local rxRySq:DWORD - local threshSq:DWORD - local curDy:DWORD - local curDx:DWORD - local curX:DWORD - local curY:DWORD - - mov eax, rxVal - cmp eax, 0 - jle coin_draw_done - mov eax, ryVal - cmp eax, 0 - jle coin_draw_done - - mov eax, rxVal - imul eax, rxVal - mov rxSq, eax - - mov eax, ryVal - imul eax, ryVal - mov rySq, eax - - imul eax, rxSq - mov rxRySq, eax - - ; 3/4 threshold for rim bevel - mov ecx, 3 - imul eax, ecx - shr eax, 2 - mov threshSq, eax - - ; Scan rows - mov eax, ryVal - neg eax - mov curDy, eax -coin_row_loop: - mov eax, curDy - cmp eax, ryVal - jg coin_relief_check - - mov edx, cyVal - add edx, curDy - mov curY, edx - - ; Scan columns - mov eax, rxVal - neg eax - mov curDx, eax -coin_col_loop: - mov eax, curDx - cmp eax, rxVal - jg coin_col_next_row - - mov ecx, cxVal - add ecx, curDx - mov curX, ecx - - ; val = dx*dx*rySq + dy*dy*rxSq - mov eax, curDx - imul eax, curDx - imul eax, rySq - mov ebx, eax - - mov eax, curDy - imul eax, curDy - imul eax, rxSq - add eax, ebx - - cmp eax, rxRySq - ja coin_pixel_outside - - cmp eax, threshSq - jb coin_draw_inner - invoke DrawPixel, curX, curY, outerColor - jmp coin_pixel_outside -coin_draw_inner: - invoke DrawPixel, curX, curY, innerColor - -coin_pixel_outside: - inc curDx - jmp coin_col_loop - -coin_col_next_row: - inc curDy - jmp coin_row_loop - -coin_relief_check: - cmp rxVal, 14 - jl coin_draw_done - - cmp reliefType, 1 - je coin_draw_eagle - cmp reliefType, 2 - je coin_draw_numeral - jmp coin_draw_done - -coin_draw_eagle: - ; Imperial Eagle relief (Dark Gold 009A7A00h / Bright 00FFD700h) - mov eax, cxVal - sub eax, 3 - mov edx, cyVal - sub edx, 14 - invoke DrawBox, eax, edx, 7, 2, 009A7A00h - - mov eax, cxVal - sub eax, 4 - mov edx, cyVal - sub edx, 12 - invoke DrawBox, eax, edx, 9, 2, 009A7A00h - - mov eax, cxVal - sub eax, 2 - mov edx, cyVal - sub edx, 9 - invoke DrawBox, eax, edx, 5, 12, 009A7A00h - - mov eax, cxVal - sub eax, 1 - mov edx, cyVal - sub edx, 8 - invoke DrawBox, eax, edx, 3, 10, 00FFD700h - - mov eax, cxVal - sub eax, 10 - mov edx, cyVal - sub edx, 8 - invoke DrawBox, eax, edx, 7, 3, 009A7A00h - - mov eax, cxVal - sub eax, 13 - mov edx, cyVal - sub edx, 5 - invoke DrawBox, eax, edx, 10, 3, 009A7A00h - - mov eax, cxVal - sub eax, 11 - mov edx, cyVal - sub edx, 2 - invoke DrawBox, eax, edx, 7, 3, 009A7A00h - - mov eax, cxVal - add eax, 4 - mov edx, cyVal - sub edx, 8 - invoke DrawBox, eax, edx, 7, 3, 009A7A00h - - mov eax, cxVal - add eax, 4 - mov edx, cyVal - sub edx, 5 - invoke DrawBox, eax, edx, 10, 3, 009A7A00h - - mov eax, cxVal - add eax, 5 - mov edx, cyVal - sub edx, 2 - invoke DrawBox, eax, edx, 7, 3, 009A7A00h - - mov eax, cxVal - sub eax, 4 - mov edx, cyVal - add edx, 4 - invoke DrawBox, eax, edx, 9, 3, 009A7A00h - - mov eax, cxVal - sub eax, 3 - mov edx, cyVal - add edx, 7 - invoke DrawBox, eax, edx, 7, 3, 009A7A00h - jmp coin_draw_done - -coin_draw_numeral: - ; Roman numeral 'I' & laurel - mov eax, cxVal - sub eax, 5 - mov edx, cyVal - sub edx, 10 - invoke DrawBox, eax, edx, 11, 3, 009A7A00h - - mov eax, cxVal - sub eax, 2 - mov edx, cyVal - sub edx, 7 - invoke DrawBox, eax, edx, 5, 14, 009A7A00h - - mov eax, cxVal - sub eax, 1 - mov edx, cyVal - sub edx, 6 - invoke DrawBox, eax, edx, 3, 12, 00FFD700h - - mov eax, cxVal - sub eax, 6 - mov edx, cyVal - add edx, 7 - invoke DrawBox, eax, edx, 13, 3, 009A7A00h - - ; Laurel dots - mov eax, cxVal - sub eax, 12 - mov edx, cyVal - sub edx, 8 - invoke DrawBox, eax, edx, 2, 2, 009A7A00h - - mov eax, cxVal - add eax, 11 - mov edx, cyVal - sub edx, 8 - invoke DrawBox, eax, edx, 2, 2, 009A7A00h - - mov eax, cxVal - sub eax, 12 - mov edx, cyVal - invoke DrawBox, eax, edx, 2, 2, 009A7A00h - - mov eax, cxVal - add eax, 11 - mov edx, cyVal - invoke DrawBox, eax, edx, 2, 2, 009A7A00h - - mov eax, cxVal - sub eax, 12 - mov edx, cyVal - add edx, 8 - invoke DrawBox, eax, edx, 2, 2, 009A7A00h - - mov eax, cxVal - add eax, 11 - mov edx, cyVal - add edx, 8 - invoke DrawBox, eax, edx, 2, 2, 009A7A00h - -coin_draw_done: - ret -DrawDetailedCoin ENDP - -; ============================================================================== -; IN-ENGINE 2.5D MINI-GAME: COIN FLIP -; ============================================================================== -InitCoinGame PROC - call InitNativeCoin3D - ret -InitCoinGame ENDP - -HandleCoinInput PROC - call HandleNativeCoin3D - ret -; Retained legacy frame-count prototype, excluded from the executable. -IF 0 - cmp coin3d_state, 0 - je coin_handle_idle - cmp coin3d_state, 1 - je coin_handle_flipping - cmp coin3d_state, 2 - je coin_handle_result - ret - -coin_handle_idle: - invoke Pressed3D, 26h ; UP - test eax, eax - jnz coin_bet_up - invoke Pressed3D, 57h ; 'W' - test eax, eax - jnz coin_bet_up - invoke Pressed3D, 28h ; DOWN - test eax, eax - jnz coin_bet_down - invoke Pressed3D, 53h ; 'S' - test eax, eax - jnz coin_bet_down - invoke Pressed3D, 31h ; '1' - test eax, eax - jnz coin_pick_1 - invoke Pressed3D, 32h ; '2' - test eax, eax - jnz coin_pick_2 - invoke Pressed3D, 20h ; SPACE - test eax, eax - jnz coin_start_flip - ret - -coin_bet_up: - mov eax, coin3d_bet - add eax, 50 - cmp eax, bankroll - jle @F - mov eax, bankroll -@@: - cmp eax, 5000 - jle @F - mov eax, 5000 -@@: - mov coin3d_bet, eax - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -coin_bet_down: - mov eax, coin3d_bet - sub eax, 50 - cmp eax, 50 - jge @F - mov eax, 50 -@@: - mov coin3d_bet, eax - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -coin_pick_1: - mov coin3d_choice, 1 - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -coin_pick_2: - mov coin3d_choice, 2 - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -coin_start_flip: - mov eax, coin3d_bet - cmp eax, bankroll - jle @F - mov eax, bankroll - mov coin3d_bet, eax - test eax, eax - jz coin_done -@@: - mov eax, coin3d_bet - sub bankroll, eax - mov coin3d_state, 1 - mov coin3d_timer, 40 - invoke PlayCasinoSound3D, OFFSET soundCoin, 0, 1 - ret - -coin_handle_flipping: - dec coin3d_timer - cmp coin3d_timer, 0 - jg coin_done - invoke RandomRange3D, 2 - inc eax - mov coin3d_result, eax - mov edx, coin3d_choice - cmp eax, edx - jne coin_flip_lost - - ; Won! - inc coin3d_streak - mov eax, coin3d_bet - shl eax, 1 - add bankroll, eax - mov coin3d_win, eax - mov coin3d_state, 2 - invoke PlayCasinoSound3D, OFFSET soundCoinDing, 0, 1 - ret - -coin_flip_lost: - mov coin3d_streak, 0 - mov coin3d_win, 0 - mov coin3d_state, 2 - invoke PlayCasinoSound3D, OFFSET soundLose, 0, 1 - ret - -coin_handle_result: - invoke Pressed3D, 20h - test eax, eax - jz coin_done - mov coin3d_state, 0 - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 -coin_done: - ret -ENDIF -HandleCoinInput ENDP - -RenderCoinGame PROC uses ebx esi edi - local cyVal:DWORD - local rxVal:DWORD - local kx:DWORD - - call RenderNativeCoin3D - ret -IF 0 - ; Background & Cabinet border - invoke DrawBox, 0, 0, 320, 240, 00140906h - invoke DrawBoxBorder, 6, 6, 308, 228, 0022150Fh, 00482E1Bh, 3 - - ; Header - invoke DrawBoxBorder, 20, 12, 280, 26, 001C100Ah, 00FFD700h, 2 - invoke DrawString8x8, 44, 21, OFFSET textCoinTitle, 00FFFF00h - - ; Corner rivets - invoke DrawBox, 12, 12, 3, 3, 00FFD700h - invoke DrawBox, 306, 12, 3, 3, 00FFD700h - invoke DrawBox, 12, 226, 3, 3, 00FFD700h - invoke DrawBox, 306, 226, 3, 3, 00FFD700h - - ; Status meters - invoke DrawBoxBorder, 20, 44, 110, 18, 000E1A0Ah, 00224B1Ah, 1 - invoke DrawString8x8, 24, 49, OFFSET textBankPrompt, 003CFF3Ch - invoke FormatNumber, bankroll, OFFSET hudNumBuffer - invoke DrawString8x8, 72, 49, OFFSET hudNumBuffer, 003CFF3Ch - - invoke DrawBoxBorder, 190, 44, 110, 18, 001A100Ah, 003A2814h, 1 - invoke DrawString8x8, 194, 49, OFFSET textBetPrompt, 00FFD700h - invoke FormatNumber, coin3d_bet, OFFSET hudNumBuffer - invoke DrawString8x8, 254, 49, OFFSET hudNumBuffer, 00FFD700h - - ; Left: Heads - cmp coin3d_choice, 1 - jne coin_left_inactive - invoke DrawBoxBorder, 20, 72, 76, 68, 00101828h, 00FFFF00h, 2 - invoke DrawString8x8, 30, 78, OFFSET textCoinSide1, 00FFFF00h - invoke DrawDetailedCoin, 58, 106, 14, 14, 00D0A000h, 00FFD700h, 1 - invoke DrawString8x8, 24, 126, OFFSET textCoinSelected, 003CFF3Ch - jmp coin_right_side -coin_left_inactive: - invoke DrawBoxBorder, 20, 72, 76, 68, 000A101Ch, 00404855h, 1 - invoke DrawString8x8, 30, 78, OFFSET textCoinSide1, 00D0D8E0h - invoke DrawDetailedCoin, 58, 106, 14, 14, 009A7A00h, 00D0A000h, 1 - -coin_right_side: - ; Right: Tails - cmp coin3d_choice, 2 - jne coin_right_inactive - invoke DrawBoxBorder, 224, 72, 76, 68, 00101828h, 00FFFF00h, 2 - invoke DrawString8x8, 234, 78, OFFSET textCoinSide2, 00FFFF00h - invoke DrawDetailedCoin, 262, 106, 14, 14, 00D0A000h, 00FFD700h, 2 - invoke DrawString8x8, 228, 126, OFFSET textCoinSelected, 003CFF3Ch - jmp coin_center_area -coin_right_inactive: - invoke DrawBoxBorder, 224, 72, 76, 68, 000A101Ch, 00404855h, 1 - invoke DrawString8x8, 234, 78, OFFSET textCoinSide2, 00D0D8E0h - invoke DrawDetailedCoin, 262, 106, 14, 14, 009A7A00h, 00D0A000h, 2 - -coin_center_area: - ; Center spotlight - invoke DrawCircle, 160, 110, 48, 00121620h - invoke DrawCircle, 160, 110, 44, 00FFD700h - invoke DrawCircle, 160, 110, 42, 000E141Eh - - cmp coin3d_state, 1 - je coin_render_flipping - cmp coin3d_state, 2 - je coin_render_result - - ; Idle coin - invoke DrawDetailedCoin, 160, 110, 26, 26, 00D0A000h, 00FFD700h, coin3d_choice - jmp coin_render_keys - -coin_render_flipping: - mov eax, coin3d_timer - and eax, 7 - movzx eax, byte ptr [coinRxAnimTable + eax] - mov rxVal, eax - invoke DrawDetailedCoin, 160, 110, rxVal, 26, 00D0A000h, 00FFD700h, 0 - invoke DrawString8x8, 88, 160, OFFSET textCoinFlipping, 00FFFF00h - jmp coin_render_keys - -coin_render_result: - invoke DrawDetailedCoin, 160, 110, 26, 26, 00D0A000h, 00FFD700h, coin3d_result - mov eax, coin3d_result - cmp eax, coin3d_choice - jne coin_render_loss_msg - - ; Win banner - invoke DrawBoxBorder, 44, 154, 232, 22, 000E141Eh, 003CFF3Ch, 1 - invoke DrawString8x8, 64, 161, OFFSET textCoinWin, 003CFF3Ch - invoke FormatNumber, coin3d_win, OFFSET hudNumBuffer - invoke DrawString8x8, 152, 161, OFFSET hudNumBuffer, 003CFF3Ch - jmp coin_render_keys - -coin_render_loss_msg: - invoke DrawBoxBorder, 44, 154, 232, 22, 000E141Eh, 00C81414h, 1 - invoke DrawString8x8, 114, 161, OFFSET textCoinLose, 00FF6464h - -coin_render_keys: - mov kx, 16 - xor eax, eax - cmp coin3d_choice, 1 - sete al - invoke DrawKeycap3D, kx, 192, OFFSET textCoinKey1, eax - add kx, eax - - xor eax, eax - cmp coin3d_choice, 2 - sete al - invoke DrawKeycap3D, kx, 192, OFFSET textCoinKey2, eax - add kx, eax - - invoke DrawKeycap3D, kx, 192, OFFSET textCoinKeySpace, 1 - add kx, eax - - invoke DrawKeycap3D, kx, 192, OFFSET textKeyEsc, 0 - ret -ENDIF -RenderCoinGame ENDP - -; ============================================================================== -; IN-ENGINE 2.5D MINI-GAME: CRAPS / DICE -; ============================================================================== -DrawCrapsDie PROC uses ebx esi edi, x:DWORD, y:DWORD, sizeVal:DWORD, valNum:DWORD - ; Drop shadow - mov eax, x - add eax, 3 - mov edx, y - add edx, sizeVal - invoke DrawBox, eax, edx, sizeVal, 3, 00081403h - - mov eax, x - add eax, sizeVal - mov edx, y - add edx, 3 - invoke DrawBox, eax, edx, 3, sizeVal, 00081403h - - ; Ivory body & bevel - invoke DrawBoxBorder, x, y, sizeVal, sizeVal, 00FAF4F0h, 00403535h, 1 - mov eax, x - inc eax - mov edx, y - inc edx - mov ecx, sizeVal - sub ecx, 2 - invoke DrawBox, eax, edx, ecx, 1, 00FFFFFFh - invoke DrawBox, eax, edx, 1, ecx, 00FFFFFFh - - ; Ruby pips (00C81515h) - mov eax, valNum - test al, 1 - jz @F - ; Center pip - mov eax, x - add eax, 18 - mov edx, y - add edx, 18 - invoke DrawCircle, eax, edx, 3, 00C81515h - dec eax - dec edx - invoke DrawPixel, eax, edx, 00FFFFFFh -@@: - cmp valNum, 2 - jl die_pips_done - mov eax, x - add eax, 9 - mov edx, y - add edx, 9 - invoke DrawCircle, eax, edx, 3, 00C81515h - mov eax, x - add eax, 27 - mov edx, y - add edx, 27 - invoke DrawCircle, eax, edx, 3, 00C81515h - - cmp valNum, 4 - jl die_pips_done - mov eax, x - add eax, 27 - mov edx, y - add edx, 9 - invoke DrawCircle, eax, edx, 3, 00C81515h - mov eax, x - add eax, 9 - mov edx, y - add edx, 27 - invoke DrawCircle, eax, edx, 3, 00C81515h - - cmp valNum, 6 - jl die_pips_done - mov eax, x - add eax, 9 - mov edx, y - add edx, 18 - invoke DrawCircle, eax, edx, 3, 00C81515h - mov eax, x - add eax, 27 - mov edx, y - add edx, 18 - invoke DrawCircle, eax, edx, 3, 00C81515h - -die_pips_done: - ret -DrawCrapsDie ENDP - -InitDiceGame PROC - call LoadNativeDiceArt3D - mov diceExitQueued3D,0 - mov dice3d_state, 0 - mov dice3d_timer, 0 - mov dice3d_win, 0 - ret -InitDiceGame ENDP - -HandleDiceRules3D PROC - cmp dice3d_state, 0 - je dice_handle_idle - cmp dice3d_state, 1 - je dice_handle_rolling - cmp dice3d_state, 2 - je dice_handle_result - ret - -dice_handle_idle: - invoke Pressed3D, 26h ; UP - test eax, eax - jnz dice_bet_up - invoke Pressed3D, 57h ; 'W' - test eax, eax - jnz dice_bet_up - invoke Pressed3D, 28h ; DOWN - test eax, eax - jnz dice_bet_down - invoke Pressed3D, 53h ; 'S' - test eax, eax - jnz dice_bet_down - invoke Pressed3D, 31h ; '1' - test eax, eax - jnz dice_pick_1 - invoke Pressed3D, 32h ; '2' - test eax, eax - jnz dice_pick_2 - invoke Pressed3D, 20h ; SPACE - test eax, eax - jnz dice_start_roll - ret - -dice_bet_up: - mov eax, dice3d_bet - add eax, 50 - cmp eax, bankroll - jle @F - mov eax, bankroll -@@: - cmp eax, 5000 - jle @F - mov eax, 5000 -@@: - mov dice3d_bet, eax - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -dice_bet_down: - mov eax, dice3d_bet - sub eax, 50 - cmp eax, 50 - jge @F - mov eax, 50 -@@: - mov dice3d_bet, eax - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -dice_pick_1: - mov dice3d_choice, 1 - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -dice_pick_2: - mov dice3d_choice, 2 - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -dice_start_roll: - mov eax, dice3d_bet - cmp eax, bankroll - jle @F - mov eax, bankroll - mov dice3d_bet, eax - test eax, eax - jz dice_done -@@: - mov eax, dice3d_bet - test eax, eax - jle dice_done - sub bankroll, eax - mov dice3d_state, 1 - mov dice3d_timer, 0 - invoke RandomRange3D, 6 - inc eax - mov dice3d_val1, eax - invoke RandomRange3D, 6 - inc eax - mov dice3d_val2, eax - call BackroomsLuck3D - cmp eax,-1 - je br_dice_fixed - xor eax,1 - mov ecx,dice3d_choice - dec ecx - xor eax,ecx - mov edx,dice3d_val1 - add edx,dice3d_val2 - and edx,1 - cmp eax,edx - je br_dice_fixed - xor edx,edx - mov eax,dice3d_val2 - mov ecx,6 - div ecx - inc edx - mov dice3d_val2,edx -br_dice_fixed: - invoke PlayCasinoSound3D, OFFSET soundDiceRoll, 0, 1 - call SaveProgress3D - ret - -dice_handle_rolling: - mov eax, deltaTime3D - add dice3d_timer, eax - cmp dice3d_timer, 1600 - jb dice_done - mov dice3d_timer, 1600 - mov eax, dice3d_val2 - mov edx, dice3d_val1 - add edx, eax - mov dice3d_sum, edx - - ; Parity check - mov eax, edx - and eax, 1 - jnz dice_sum_is_odd - ; Even - mov eax, 1 - jmp dice_check_win -dice_sum_is_odd: - mov eax, 2 - -dice_check_win: - cmp eax, dice3d_choice - jne dice_roll_lost - - ; Won! - mov eax, dice3d_bet - shl eax, 1 - add bankroll, eax - mov dice3d_win, eax - invoke TriggerCharmWinBonus,dice3d_bet - mov dice3d_state, 2 - invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 - invoke NpcRecordRound3D,8,1 - call SaveProgress3D - ret - -dice_roll_lost: - mov dice3d_win, 0 - mov dice3d_state, 2 - invoke TriggerCharmLossProtection, dice3d_bet - test eax, eax - jnz @F - invoke PlayCasinoSound3D, OFFSET soundLose, 0, 1 -@@: - invoke NpcRecordRound3D,8,0 - call SaveProgress3D - ret - -dice_handle_result: - cmp tournamentMode, 1 - jne @F - invoke Pressed3D, 20h - test eax, eax - jnz dice_tourney_report - invoke Pressed3D, 0Dh - test eax, eax - jnz dice_tourney_report - ret -dice_tourney_report: - cmp dice3d_win, 0 - je dice_tourney_loss - invoke TowerReportRoundOutcome, 1 - ret -dice_tourney_loss: - invoke TowerReportRoundOutcome, 2 - ret -@@: - invoke Pressed3D, 20h - test eax, eax - jz dice_done - mov dice3d_state, 0 - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 -dice_done: - ret -HandleDiceRules3D ENDP - -RenderDiceGame PROC - call RenderNativeDice3D - ret -RenderDiceGame ENDP - -; ============================================================================== -; IN-ENGINE 2.5D MINI-GAME: SKULLS & CUPS (ÍÀϨÐÑÒÊÈ) -; ============================================================================== -DrawGlowingOrb PROC uses ebx esi edi, cxVal:DWORD, cyVal:DWORD - invoke DrawCircle, cxVal, cyVal, 14, 002E1E08h - invoke DrawCircle, cxVal, cyVal, 11, 00583A10h - invoke DrawCircle, cxVal, cyVal, 8, 008A581Ah - invoke DrawCircle, cxVal, cyVal, 6, 00D0B000h - invoke DrawCircle, cxVal, cyVal, 4, 00FFE000h - mov eax, cxVal - dec eax - mov edx, cyVal - dec edx - invoke DrawCircle, eax, edx, 2, 00FFFF80h - dec eax - dec edx - invoke DrawPixel, eax, edx, 00FFFFFFh - ret -DrawGlowingOrb ENDP - -DrawGothicCup PROC uses ebx esi edi, x:DWORD, y:DWORD, cupId:DWORD, isLifted:DWORD, hasBall:DWORD - local liftY:DWORD - - mov eax, y - cmp isLifted, 0 - je @F - sub eax, 36 -@@: - mov liftY, eax - - ; Drop shadow - cmp isLifted, 0 - jne cup_shadow_lifted - mov eax, x - add eax, 6 - mov edx, y - add edx, 42 - invoke DrawBox, eax, edx, 36, 4, 0010040Ah - jmp cup_ball_check -cup_shadow_lifted: - mov eax, x - add eax, 10 - mov edx, y - add edx, 42 - invoke DrawBox, eax, edx, 28, 2, 001A0612h - -cup_ball_check: - cmp isLifted, 0 - je cup_body_draw - cmp hasBall, 0 - je cup_body_draw - mov eax, x - add eax, 24 - mov edx, y - add edx, 26 - invoke DrawGlowingOrb, eax, edx - -cup_body_draw: - ; Base pedestal - mov eax, x - add eax, 6 - mov edx, liftY - add edx, 36 - invoke DrawBoxBorder, eax, edx, 36, 6, 00301A22h, 00D0B000h, 1 - - ; Stem - mov eax, x - add eax, 18 - mov edx, liftY - add edx, 28 - invoke DrawBox, eax, edx, 12, 8, 00452533h - mov eax, x - add eax, 22 - invoke DrawBox, eax, edx, 4, 8, 006E4055h - - ; Goblet Bowl - mov eax, x - add eax, 8 - mov edx, liftY - add edx, 8 - invoke DrawBoxBorder, eax, edx, 32, 20, 00401E2Dh, 00FFD700h, 1 - - mov eax, x - add eax, 14 - mov edx, liftY - add edx, 10 - invoke DrawBox, eax, edx, 6, 16, 00703550h - mov eax, x - add eax, 17 - invoke DrawBox, eax, edx, 3, 16, 00A05078h - - ; Golden Rim - mov eax, x - add eax, 4 - mov edx, liftY - add edx, 2 - invoke DrawBoxBorder, eax, edx, 40, 7, 00200A15h, 00FFFF00h, 1 - mov eax, x - add eax, 12 - mov edx, liftY - add edx, 4 - invoke DrawBox, eax, edx, 16, 2, 00FFFF00h - - ; Skull face emblem - mov eax, x - add eax, 21 - mov edx, liftY - add edx, 12 - invoke DrawBox, eax, edx, 6, 5, 00FFD700h - mov eax, x - add eax, 22 - mov edx, liftY - add edx, 17 - invoke DrawBox, eax, edx, 4, 3, 00FFD700h - mov eax, x - add eax, 22 - mov edx, liftY - add edx, 14 - invoke DrawPixel, eax, edx, 00200A15h - mov eax, x - add eax, 24 - invoke DrawPixel, eax, edx, 00200A15h - - ; Cup number label - mov eax, x - add eax, 21 - mov edx, liftY - add edx, 24 - mov ecx, cupId - add ecx, '1' - invoke DrawChar8x8, eax, edx, ecx, 00FFFF00h - ret -DrawGothicCup ENDP - -InitSkullsGame PROC - mov skulls3d_state, 0 - mov skulls3d_timer, 0 - mov skulls3d_win, 0 - mov skulls3d_choice, 1 - mov skulls3d_cup0, 0 - mov skulls3d_cup1, 1 - mov skulls3d_cup2, 2 - invoke RandomRange3D, 3 - mov skulls3d_ballPos, eax - ret -InitSkullsGame ENDP - -FinalizeSkullsGuess PROC uses ebx - cmp skulls3d_state,3 - jne skulls_guess_done - cmp brSkullsLuck3D,-1 - je br_skulls_fixed - mov eax,skulls3d_choice - cmp brSkullsLuck3D,1 - je @F - inc eax - xor edx,edx - mov ecx,3 - div ecx - mov eax,edx -@@: - mov skulls3d_ballPos,eax - ; Reality distortion explicitly covers relocation before the reveal. - mov skulls3d_timer,0 -br_skulls_fixed: - mov eax, skulls3d_choice - cmp eax, skulls3d_ballPos - jne skulls_guess_wrong - - ; Correct! 3x payout - mov eax, skulls3d_bet - imul eax, 3 - add bankroll, eax - mov skulls3d_win, eax - mov skulls3d_state, 4 - invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 - invoke NpcRecordRound3D,9,1 - call SaveProgress3D - ret - -skulls_guess_wrong: - mov skulls3d_win, 0 - mov skulls3d_state, 4 - invoke PlayCasinoSound3D, OFFSET soundLose, 0, 1 - invoke NpcRecordRound3D,9,0 - call SaveProgress3D -skulls_guess_done: - ret -FinalizeSkullsGuess ENDP - -HandleSkullsInput PROC - cmp skulls3d_state, 0 - je skulls_handle_idle - cmp skulls3d_state, 1 - je skulls_handle_show - cmp skulls3d_state, 2 - je skulls_handle_shuffle - cmp skulls3d_state, 3 - je skulls_handle_pick - cmp skulls3d_state, 4 - je skulls_handle_reveal - ret - -skulls_handle_idle: - invoke Pressed3D, 26h ; UP - test eax, eax - jnz skulls_bet_up - invoke Pressed3D, 57h ; 'W' - test eax, eax - jnz skulls_bet_up - invoke Pressed3D, 28h ; DOWN - test eax, eax - jnz skulls_bet_down - invoke Pressed3D, 53h ; 'S' - test eax, eax - jnz skulls_bet_down - invoke Pressed3D, 20h ; SPACE - test eax, eax - jnz skulls_start_game - ret - -skulls_bet_up: - mov eax, skulls3d_bet - add eax, 50 - cmp eax, bankroll - jle @F - mov eax, bankroll -@@: - cmp eax, 5000 - jle @F - mov eax, 5000 -@@: - mov skulls3d_bet, eax - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -skulls_bet_down: - mov eax, skulls3d_bet - sub eax, 50 - cmp eax, 50 - jge @F - mov eax, 50 -@@: - mov skulls3d_bet, eax - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -skulls_start_game: - call BackroomsLuck3D - mov brSkullsLuck3D,eax - mov eax, skulls3d_bet - cmp eax, bankroll - jle @F - mov eax, bankroll - mov skulls3d_bet, eax - test eax, eax - jz skulls_input_done -@@: - mov eax, skulls3d_bet - sub bankroll, eax - invoke RandomRange3D, 3 - mov skulls3d_ballPos, eax - mov skulls3d_cup0, 0 - mov skulls3d_cup1, 1 - mov skulls3d_cup2, 2 - - ; Pre-generate 3 dynamic swap pairs - invoke RandomRange3D, 3 - mov skulls3d_swapPair0, eax - invoke RandomRange3D, 3 - mov skulls3d_swapPair1, eax - invoke RandomRange3D, 3 - mov skulls3d_swapPair2, eax - - mov skulls3d_state, 1 - mov skulls3d_timer, 0 - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -skulls_handle_show: - inc skulls3d_timer - cmp skulls3d_timer, 45 - jl skulls_input_done - ; Transition to Phase 2: Active Shuffle Animation - mov skulls3d_state, 2 - mov skulls3d_timer, 0 - invoke PlayCasinoSound3D, OFFSET soundShuffle, 0, 1 - ret - -skulls_handle_shuffle: - inc skulls3d_timer - cmp skulls3d_timer, 60 - jl skulls_input_done - ; Transition to Phase 3: Pick cup - mov skulls3d_state, 3 - mov skulls3d_timer, 0 - ret - -skulls_handle_pick: - invoke Pressed3D, 31h ; '1' - test eax, eax - jnz skulls_pick_1 - invoke Pressed3D, 32h ; '2' - test eax, eax - jnz skulls_pick_2 - invoke Pressed3D, 33h ; '3' - test eax, eax - jnz skulls_pick_3 - ret - -skulls_pick_1: - mov skulls3d_choice, 0 - call FinalizeSkullsGuess - ret - -skulls_pick_2: - mov skulls3d_choice, 1 - call FinalizeSkullsGuess - ret - -skulls_pick_3: - mov skulls3d_choice, 2 - call FinalizeSkullsGuess - ret - -skulls_handle_reveal: - cmp tournamentMode, 1 - jne @F - invoke Pressed3D, 20h - test eax, eax - jnz skulls_tourney_report - invoke Pressed3D, 0Dh - test eax, eax - jnz skulls_tourney_report - ret -skulls_tourney_report: - cmp skulls3d_win, 0 - je skulls_tourney_loss - invoke TowerReportRoundOutcome, 1 - ret -skulls_tourney_loss: - invoke TowerReportRoundOutcome, 2 - ret -@@: - invoke Pressed3D, 20h - test eax, eax - jz skulls_input_done - mov skulls3d_state, 0 - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 -skulls_input_done: - ret -HandleSkullsInput ENDP - -RenderSkullsGame PROC uses ebx esi edi - local kx:DWORD - local passTick:DWORD, curPair:DWORD, swapSlotA:DWORD, swapSlotB:DWORD - local xA:DWORD, xB:DWORD, curXA:DWORD, curXB:DWORD, curYA:DWORD, curYB:DWORD - local distX:DWORD, dxVal:DWORD, archY:DWORD - - ; Mahogany & Gothic Purple table - invoke DrawBox, 0, 0, 320, 240, 00140906h - invoke DrawBoxBorder, 6, 6, 308, 228, 00300F22h, 00FFD700h, 2 - - ; Header - invoke DrawBoxBorder, 20, 12, 280, 26, 001A0812h, 00FFD700h, 2 - invoke DrawString8x8, 44, 21, OFFSET textSkullsTitle, 00FFFF00h - - ; Status - invoke DrawBoxBorder, 20, 44, 110, 18, 001A0812h, 00452033h, 1 - invoke DrawString8x8, 24, 49, OFFSET textBankPrompt, 003CFF3Ch - invoke FormatNumber, bankroll, OFFSET hudNumBuffer - invoke DrawString8x8, 72, 49, OFFSET hudNumBuffer, 003CFF3Ch - - invoke DrawBoxBorder, 190, 44, 110, 18, 001A0812h, 00452033h, 1 - invoke DrawString8x8, 194, 49, OFFSET textBetPrompt, 00FFD700h - invoke FormatNumber, skulls3d_bet, OFFSET hudNumBuffer - invoke DrawString8x8, 254, 49, OFFSET hudNumBuffer, 00FFD700h - - ; Phase Prompts - cmp skulls3d_state, 0 - jne @F - invoke DrawString8x8, 56, 62, OFFSET textSkullsPhase0, 00FFD700h - jmp skulls_draw_idle_cups -@@: - cmp skulls3d_state, 1 - jne @F - invoke DrawString8x8, 56, 62, OFFSET textSkullsPhase1, 00FFFF00h - jmp skulls_draw_phase1_cups -@@: - cmp skulls3d_state, 2 - jne @F - invoke DrawString8x8, 44, 62, OFFSET textSkullsPhase2, 00FFFF00h - jmp skulls_draw_animated_cups -@@: - cmp skulls3d_state, 3 - jne @F - invoke DrawString8x8, 28, 62, OFFSET textSkullsPhase3, 00FFFF00h - jmp skulls_draw_idle_cups -@@: - ; Short artifact glitch, then reveal the actual ball and matching payout. - cmp brSkullsLuck3D,-1 - je @F - cmp skulls3d_timer,12 - jae @F - inc skulls3d_timer - invoke DrawBox,8,76,304,122,00130F20h - invoke DrawString8x8,108,128,OFFSET brRealityGlitch3D,00FF88CCh - jmp skulls_render_controls -@@: - ; Phase 4: Reveal outcome - mov eax, skulls3d_win - test eax, eax - jz skulls_reveal_loss_text - invoke DrawString8x8, 40, 62, OFFSET textSkullsWin, 003CFF3Ch - invoke FormatNumber, skulls3d_win, OFFSET hudNumBuffer - invoke DrawString8x8, 136, 62, OFFSET hudNumBuffer, 003CFF3Ch - invoke DrawString8x8, 168, 62, OFFSET textSkullsWinMult, 003CFF3Ch - jmp skulls_draw_reveal_cups - -skulls_reveal_loss_text: - invoke DrawString8x8, 40, 62, OFFSET textSkullsLose, 00FF6464h - jmp skulls_draw_reveal_cups - -skulls_draw_idle_cups: - ; Draw resting cups at static slots: Slot 0 (X=36), Slot 1 (X=136), Slot 2 (X=236) - invoke DrawGothicCup, 36, 114, skulls3d_cup0, 0, 0 - invoke DrawGothicCup, 136, 114, skulls3d_cup1, 0, 0 - invoke DrawGothicCup, 236, 114, skulls3d_cup2, 0, 0 - jmp skulls_render_controls - -skulls_draw_phase1_cups: - ; Draw with golden ball showing under starting cup - mov ebx, 0 - mov edx, 0 - cmp skulls3d_ballPos, 0 - jne @F - mov ebx, 1 - mov edx, 1 -@@: - invoke DrawGothicCup, 36, 114, skulls3d_cup0, ebx, edx - - mov ebx, 0 - mov edx, 0 - cmp skulls3d_ballPos, 1 - jne @F - mov ebx, 1 - mov edx, 1 -@@: - invoke DrawGothicCup, 136, 114, skulls3d_cup1, ebx, edx - - mov ebx, 0 - mov edx, 0 - cmp skulls3d_ballPos, 2 - jne @F - mov ebx, 1 - mov edx, 1 -@@: - invoke DrawGothicCup, 236, 114, skulls3d_cup2, ebx, edx - jmp skulls_render_controls - -skulls_draw_animated_cups: - ; 60 frames = 3 passes of 20 frames - mov eax, skulls3d_timer - cmp eax, 20 - jbe pass_0 - cmp eax, 40 - jbe pass_1 - sub eax, 41 - mov passTick, eax - mov eax, skulls3d_swapPair2 - mov curPair, eax - jmp setup_pass - -pass_0: - dec eax - mov passTick, eax - mov eax, skulls3d_swapPair0 - mov curPair, eax - jmp setup_pass - -pass_1: - sub eax, 21 - mov passTick, eax - mov eax, skulls3d_swapPair1 - mov curPair, eax - -setup_pass: - ; curPair determines swap pair: - ; 0: swap slot 0 (X=36) and slot 1 (X=136) - ; 1: swap slot 1 (X=136) and slot 2 (X=236) - ; 2: swap slot 0 (X=36) and slot 2 (X=236) - cmp curPair, 1 - je pair_1 - cmp curPair, 2 - je pair_2 - mov swapSlotA, 0 - mov swapSlotB, 1 - mov xA, 36 - mov xB, 136 - jmp calc_coords -pair_1: - mov swapSlotA, 1 - mov swapSlotB, 2 - mov xA, 136 - mov xB, 236 - jmp calc_coords -pair_2: - mov swapSlotA, 0 - mov swapSlotB, 2 - mov xA, 36 - mov xB, 236 - -calc_coords: - ; distX = xB - xA - mov eax, xB - sub eax, xA - mov distX, eax - - ; dxVal = (distX * passTick) / 20 - mov eax, distX - imul eax, passTick - xor edx, edx - mov ecx, 20 - div ecx - mov dxVal, eax - - ; curXA = xA + dxVal - mov eax, xA - add eax, dxVal - mov curXA, eax - - ; curXB = xB - dxVal - mov eax, xB - sub eax, dxVal - mov curXB, eax - - ; archY = (passTick * (20 - passTick)) / 10 - mov eax, passTick - mov ecx, 20 - sub ecx, eax - imul eax, ecx - xor edx, edx - mov ecx, 10 - div ecx - mov archY, eax - - ; Cup A hops UP: 114 - archY - mov eax, 114 - sub eax, archY - mov curYA, eax - - ; Cup B hops DOWN: 114 + archY - mov eax, 114 - add eax, archY - mov curYB, eax - - ; Check if pass ended (frame 19): swap ball position and cups - cmp passTick, 19 - jne draw_active_shuffle - - ; Swap ball position if involved - mov eax, skulls3d_ballPos - cmp eax, swapSlotA - jne check_ball_b - mov edx, swapSlotB - mov skulls3d_ballPos, edx - jmp swap_slot_identities -check_ball_b: - cmp eax, swapSlotB - jne swap_slot_identities - mov edx, swapSlotA - mov skulls3d_ballPos, edx - -swap_slot_identities: - cmp curPair, 1 - je swap_ids_1_2 - cmp curPair, 2 - je swap_ids_0_2 - ; swap 0 and 1 - mov eax, skulls3d_cup0 - xchg eax, skulls3d_cup1 - mov skulls3d_cup0, eax - jmp swap_sound_tick -swap_ids_1_2: - mov eax, skulls3d_cup1 - xchg eax, skulls3d_cup2 - mov skulls3d_cup1, eax - jmp swap_sound_tick -swap_ids_0_2: - mov eax, skulls3d_cup0 - xchg eax, skulls3d_cup2 - mov skulls3d_cup0, eax - -swap_sound_tick: - invoke PlayCasinoSound3D, OFFSET soundShuffle, 0, 1 - -draw_active_shuffle: - ; Draw stationary cup - cmp curPair, 1 - je draw_stat_cup0 - cmp curPair, 2 - je draw_stat_cup1 - ; Stationary cup is slot 2 (X=236) - invoke DrawGothicCup, 236, 114, skulls3d_cup2, 0, 0 - jmp draw_moving_cups -draw_stat_cup0: - ; Stationary cup is slot 0 (X=36) - invoke DrawGothicCup, 36, 114, skulls3d_cup0, 0, 0 - jmp draw_moving_cups -draw_stat_cup1: - ; Stationary cup is slot 1 (X=136) - invoke DrawGothicCup, 136, 114, skulls3d_cup1, 0, 0 - -draw_moving_cups: - ; Moving Cup A and Moving Cup B - cmp curPair, 1 - je ids_pair_1 - cmp curPair, 2 - je ids_pair_2 - mov eax, skulls3d_cup0 - mov ebx, skulls3d_cup1 - jmp draw_the_pair -ids_pair_1: - mov eax, skulls3d_cup1 - mov ebx, skulls3d_cup2 - jmp draw_the_pair -ids_pair_2: - mov eax, skulls3d_cup0 - mov ebx, skulls3d_cup2 - -draw_the_pair: - push ebx - invoke DrawGothicCup, curXA, curYA, eax, 0, 0 - pop ebx - invoke DrawGothicCup, curXB, curYB, ebx, 0, 0 - jmp skulls_render_controls - -skulls_draw_reveal_cups: - ; Reveal Phase: lift chosen cup and lift actual ball cup if different - ; Slot 0 - mov ebx, 0 - mov edx, 0 - cmp skulls3d_choice, 0 - je slot0_is_lifted - cmp skulls3d_ballPos, 0 - jne @F -slot0_is_lifted: - mov ebx, 1 - cmp skulls3d_ballPos, 0 - sete dl -@@: - invoke DrawGothicCup, 36, 114, skulls3d_cup0, ebx, edx - - ; Slot 1 - mov ebx, 0 - mov edx, 0 - cmp skulls3d_choice, 1 - je slot1_is_lifted - cmp skulls3d_ballPos, 1 - jne @F -slot1_is_lifted: - mov ebx, 1 - cmp skulls3d_ballPos, 1 - sete dl -@@: - invoke DrawGothicCup, 136, 114, skulls3d_cup1, ebx, edx - - ; Slot 2 - mov ebx, 0 - mov edx, 0 - cmp skulls3d_choice, 2 - je slot2_is_lifted - cmp skulls3d_ballPos, 2 - jne @F -slot2_is_lifted: - mov ebx, 1 - cmp skulls3d_ballPos, 2 - sete dl -@@: - invoke DrawGothicCup, 236, 114, skulls3d_cup2, ebx, edx - -skulls_render_controls: - ; Cup selection slot labels [1], [2], [3] - invoke DrawString8x8, 54, 168, OFFSET textSkullsKey1, 00D0D8E0h - invoke DrawString8x8, 150, 168, OFFSET textSkullsKey2, 00D0D8E0h - invoke DrawString8x8, 250, 168, OFFSET textSkullsKey3, 00D0D8E0h - - ; Keycaps - mov kx, 16 - xor eax, eax - cmp skulls3d_state, 3 - je key1_active - cmp skulls3d_choice, 0 - sete al - jmp draw_key1 -key1_active: - mov eax, 1 -draw_key1: - invoke DrawKeycap3D, kx, 192, OFFSET textSkullsKey1, eax - add kx, eax - - xor eax, eax - cmp skulls3d_state, 3 - je key2_active - cmp skulls3d_choice, 1 - sete al - jmp draw_key2 -key2_active: - mov eax, 1 -draw_key2: - invoke DrawKeycap3D, kx, 192, OFFSET textSkullsKey2, eax - add kx, eax - - xor eax, eax - cmp skulls3d_state, 3 - je key3_active - cmp skulls3d_choice, 2 - sete al - jmp draw_key3 -key3_active: - mov eax, 1 -draw_key3: - invoke DrawKeycap3D, kx, 192, OFFSET textSkullsKey3, eax - add kx, eax - - xor eax, eax - cmp skulls3d_state, 0 - je start_active - cmp skulls3d_state, 4 - je start_active - jmp draw_start_key -start_active: - mov eax, 1 -draw_start_key: - invoke DrawKeycap3D, kx, 192, OFFSET textSkullsKeySpace, eax - add kx, eax - - invoke DrawKeycap3D, kx, 192, OFFSET textKeyEsc, 0 - ret -RenderSkullsGame ENDP - -InitSkillGame PROC - mov skill3d_state, 0 - mov skill3d_timer, 0 - mov skill3d_hits, 0 - mov skill3d_misses, 0 - mov skill3d_needle, 55 - mov skill3d_speed, 4 - mov skill3d_dir, 1 - mov skill3d_last_result, 0 - mov skill3d_win_amount, 0 - - ; Randomize initial zone: 80 + RandomRange(90) -> 80..170 - invoke RandomRange3D, 90 - add eax, 80 - mov skill3d_zone_start, eax - - ; Great zone: start + 20 + RandomRange(12) - invoke RandomRange3D, 12 - add eax, skill3d_zone_start - add eax, 20 - mov skill3d_great_start, eax - ret -InitSkillGame ENDP - -HandleSkillInput PROC uses ebx esi - mov eax, skill3d_state - cmp eax, 0 - je skill_handle_ready - cmp eax, 1 - je skill_handle_active - cmp eax, 2 - je skill_handle_round_wait - cmp eax, 3 - je skill_handle_round_wait - cmp eax, 4 - je skill_handle_end_wait - cmp eax, 5 - je skill_handle_end_wait - ret - -skill_handle_ready: - invoke Pressed3D, 26h ; UP - test eax, eax - jnz skill_bet_up - invoke Pressed3D, 57h ; 'W' - test eax, eax - jnz skill_bet_up - invoke Pressed3D, 28h ; DOWN - test eax, eax - jnz skill_bet_down - invoke Pressed3D, 53h ; 'S' - test eax, eax - jnz skill_bet_down - jmp skill_check_start - -skill_bet_up: - mov eax, skill3d_bet - add eax, 50 - cmp eax, bankroll - jle @F - mov eax, bankroll -@@: - cmp eax, 5000 - jle @F - mov eax, 5000 -@@: - mov skill3d_bet, eax - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -skill_bet_down: - mov eax, skill3d_bet - sub eax, 50 - cmp eax, 50 - jge @F - mov eax, 50 -@@: - mov skill3d_bet, eax - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -skill_check_start: - invoke Pressed3D, 20h ; SPACE - test eax, eax - jz skill_input_done - - ; Deduct bet on game start if beginning of run - mov eax, skill3d_hits - or eax, skill3d_misses - jnz @F - mov eax, skill3d_bet - cmp eax, bankroll - jle skill_has_funds - mov eax, bankroll - mov skill3d_bet, eax - test eax, eax - jz skill_input_done -skill_has_funds: - mov eax, skill3d_bet - sub bankroll, eax -@@: - mov skill3d_state, 1 - mov skill3d_needle, 55 - mov skill3d_dir, 1 - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret - -skill_handle_active: - ; Move needle smoothly - mov eax, skill3d_needle - mov edx, skill3d_speed - cmp skill3d_dir, 1 - je skill_move_right - sub eax, edx - cmp eax, 52 - jge skill_update_needle - mov eax, 52 - mov skill3d_dir, 1 - jmp skill_update_needle -skill_move_right: - add eax, edx - cmp eax, 268 - jle skill_update_needle - mov eax, 268 - mov skill3d_dir, -1 -skill_update_needle: - mov skill3d_needle, eax - - ; Check SPACE pressed (Reaction Hit Attempt!) - invoke Pressed3D, 20h - test eax, eax - jz skill_input_done - - ; Is needle in Great Sweet Spot? - mov eax, skill3d_needle - mov edx, skill3d_great_start - cmp eax, edx - jl check_success_zone - add edx, skill3d_great_width - cmp eax, edx - jg check_success_zone - - ; GREAT HIT! - mov skill3d_last_result, 2 - add skill3d_hits, 2 - mov skill3d_state, 2 - mov skill3d_timer, 40 - invoke PlayCasinoSound3D, OFFSET soundSkillPerfect, 0, 1 - jmp skill_check_finish_round - -check_success_zone: - mov eax, skill3d_needle - mov edx, skill3d_zone_start - cmp eax, edx - jl skill_was_miss - add edx, skill3d_zone_width - cmp eax, edx - jg skill_was_miss - - ; NORMAL HIT! - mov skill3d_last_result, 1 - inc skill3d_hits - mov skill3d_state, 2 - mov skill3d_timer, 40 - invoke PlayCasinoSound3D, OFFSET soundSkillHit, 0, 1 - jmp skill_check_finish_round - -skill_was_miss: - ; MISS! - mov skill3d_last_result, 0 - inc skill3d_misses - mov skill3d_state, 3 - mov skill3d_timer, 45 - invoke PlayCasinoSound3D, OFFSET soundSkillMiss, 0, 1 - -skill_check_finish_round: - cmp skill3d_hits, 5 - jge skill_game_escaped - cmp skill3d_misses, 3 - jge skill_game_lost - ret - -skill_game_escaped: - mov skill3d_state, 4 - mov skill3d_timer, 0 - ; Payout: 3x total return (+$2x bet profit) - mov eax, skill3d_bet - imul eax, 3 - add bankroll, eax - mov eax, skill3d_bet - shl eax, 1 - mov skill3d_win_amount, eax - invoke NpcRecordRound3D,10,1 - call SaveProgress3D - invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 - ret - -skill_game_lost: - mov skill3d_state, 5 - mov skill3d_timer, 0 - invoke NpcRecordRound3D,10,0 - call SaveProgress3D - invoke PlayCasinoSound3D, OFFSET soundLose, 0, 1 - ret - -skill_handle_round_wait: - dec skill3d_timer - cmp skill3d_timer, 0 - jg skill_input_done - - ; Next round setup - invoke RandomRange3D, 90 - add eax, 80 - mov skill3d_zone_start, eax - - invoke RandomRange3D, 12 - add eax, skill3d_zone_start - add eax, 20 - mov skill3d_great_start, eax - - mov eax, skill3d_hits - shr eax, 1 - add eax, 4 - mov skill3d_speed, eax - mov skill3d_state, 1 - ret - -skill_handle_end_wait: - cmp tournamentMode, 1 - jne @F - invoke Pressed3D, 20h - test eax, eax - jnz skill_tourney_report - invoke Pressed3D, 0Dh - test eax, eax - jnz skill_tourney_report - ret -skill_tourney_report: - cmp skill3d_state, 4 - jne skill_tourney_loss - invoke TowerReportRoundOutcome, 1 - ret -skill_tourney_loss: - invoke TowerReportRoundOutcome, 2 - ret -@@: - invoke Pressed3D, 20h - test eax, eax - jz skill_input_done - call InitSkillGame - ret - -skill_input_done: - ret -HandleSkillInput ENDP - -RenderSkillGame PROC uses ebx esi edi - local kx:DWORD - local tx:DWORD - - ; Industrial Steel bezel - invoke DrawBox, 0, 0, 320, 240, 00121416h - invoke DrawBoxBorder, 6, 6, 308, 228, 001A1D20h, 00FFD700h, 2 - - ; Header - invoke DrawBoxBorder, 20, 12, 280, 26, 00121418h, 00FFD700h, 2 - invoke DrawString8x8, 40, 21, OFFSET textSkillTitle, 00FFFF00h - - ; Status - invoke DrawBoxBorder, 20, 44, 110, 18, 00121418h, 002A3540h, 1 - invoke DrawString8x8, 24, 49, OFFSET textBankPrompt, 003CFF3Ch - invoke FormatNumber, bankroll, OFFSET hudNumBuffer - invoke DrawString8x8, 72, 49, OFFSET hudNumBuffer, 003CFF3Ch - - invoke DrawBoxBorder, 190, 44, 110, 18, 00121418h, 002A3540h, 1 - invoke DrawString8x8, 194, 49, OFFSET textBetPrompt, 00FFD700h - invoke FormatNumber, skill3d_bet, OFFSET hudNumBuffer - invoke DrawString8x8, 254, 49, OFFSET hudNumBuffer, 00FFD700h - - ; Survivor Progress - invoke DrawString8x8, 24, 70, OFFSET textSkillHitsHdr, 003CFF3Ch - invoke FormatNumber, skill3d_hits, OFFSET hudNumBuffer - invoke DrawString8x8, 64, 70, OFFSET hudNumBuffer, 003CFF3Ch - - invoke DrawString8x8, 180, 70, OFFSET textSkillMissHdr, 00FF6464h - invoke FormatNumber, skill3d_misses, OFFSET hudNumBuffer - invoke DrawString8x8, 240, 70, OFFSET hudNumBuffer, 00FF6464h - - ; Dial Frame (Track: X=50..270, Y=102..134) - invoke DrawBoxBorder, 50, 102, 220, 32, 000F1114h, 00404855h, 2 - - ; Calibrated ticks - mov tx, 60 -skill_ticks_loop: - cmp tx, 260 - jge skill_draw_zones - invoke DrawBox, tx, 104, 1, 6, 00303845h - invoke DrawBox, tx, 126, 1, 6, 00303845h - add tx, 12 - jmp skill_ticks_loop - -skill_draw_zones: - ; Normal Success Zone (Green) - invoke DrawBoxBorder, skill3d_zone_start, 106, skill3d_zone_width, 24, 00155020h, 003CFF3Ch, 1 - - ; Great Zone (Gold) - invoke DrawBoxBorder, skill3d_great_start, 106, skill3d_great_width, 24, 00FFD700h, 00FFFF00h, 1 - - ; Pointer / Needle at skill3d_needle - mov eax, skill3d_needle - dec eax - invoke DrawBox, eax, 98, 3, 40, 00FFFFFFh - mov eax, skill3d_needle - sub eax, 2 - invoke DrawBox, eax, 96, 5, 2, 00FF3030h - invoke DrawBox, eax, 138, 5, 2, 00FF3030h - - ; Center prompts / outcome - cmp skill3d_state, 0 - jne @F - invoke DrawString8x8, 52, 150, OFFSET textSkillReadyMsg, 00FFD700h - invoke DrawString8x8, 76, 166, OFFSET textSkillPrompt, 00D0D8E0h - jmp skill_render_keys -@@: - cmp skill3d_state, 1 - jne @F - invoke DrawString8x8, 76, 150, OFFSET textSkillPrompt, 00FFFF00h - jmp skill_render_keys -@@: - cmp skill3d_state, 2 - jne @F - cmp skill3d_last_result, 2 - jne skill_normal_hit_text - invoke DrawString8x8, 36, 150, OFFSET textSkillGreatMsg, 00FFFF00h - jmp skill_render_keys -skill_normal_hit_text: - invoke DrawString8x8, 64, 150, OFFSET textSkillHitMsg, 003CFF3Ch - jmp skill_render_keys -@@: - cmp skill3d_state, 3 - jne @F - invoke DrawString8x8, 88, 150, OFFSET textSkillMissMsg, 00FF6464h - jmp skill_render_keys -@@: - cmp skill3d_state, 4 - jne @F - invoke DrawString8x8, 48, 150, OFFSET textSkillEscape, 003CFF3Ch - invoke FormatNumber, skill3d_win_amount, OFFSET hudNumBuffer - invoke DrawString8x8, 240, 150, OFFSET hudNumBuffer, 003CFF3Ch - invoke DrawString8x8, 64, 166, OFFSET textSkullsAgain, 00FFD700h - jmp skill_render_keys -@@: - invoke DrawString8x8, 44, 150, OFFSET textSkillLost, 00FF6464h - invoke DrawString8x8, 64, 166, OFFSET textSkullsAgain, 00FFD700h - -skill_render_keys: - mov kx, 16 - invoke DrawKeycap3D, kx, 192, OFFSET textSkillKeySpace, 1 - add kx, eax - - invoke DrawKeycap3D, kx, 192, OFFSET textSkillKeyBet, 0 - add kx, eax - - invoke DrawKeycap3D, kx, 192, OFFSET textKeyEsc, 0 - ret -RenderSkillGame ENDP - -; --- Mouse Lock & Unlock Routines for Free Camera Look --- -LockMouse3D PROC - LOCAL rcClient[16]:BYTE - LOCAL ptCenter:C3D_POINT - cmp mouseLocked3D, 1 - je lock_done - mov mouseLocked3D, 1 - invoke ShowCursor, 0 - lea eax, rcClient - invoke GetClientRect, h3DWnd, eax - mov eax, dword ptr rcClient[8] - shr eax, 1 - mov ptCenter.x, eax - mov eax, dword ptr rcClient[12] - shr eax, 1 - mov ptCenter.y, eax - lea eax, ptCenter - invoke ClientToScreen, h3DWnd, eax - invoke SetCursorPos, ptCenter.x, ptCenter.y -lock_done: - ret -LockMouse3D ENDP - -UnlockMouse3D PROC - cmp mouseLocked3D, 0 - je unlock_done - mov mouseLocked3D, 0 - invoke ShowCursor, 1 -unlock_done: - ret -UnlockMouse3D ENDP - -UpdateMouseLockState PROC - cmp welcomeActive3D,0 - jne unlock_it +include src_graphics\heist_hq_data.inc + +.data +ALIGN 4 +h3DInst dd 0 +h3DWnd dd 0 +h3DDC dd 0 +hCasinoConsole dd 0 + +ALIGN 4 +hRaycastThread dd 0 +hRaycastStartEvent dd 0 +hRaycastDoneEvent dd 0 +bRaycastQuit dd 0 +raycastThreadId dd 0 + +ALIGN 4 +mouseLocked3D dd 0 + +bmi3D C3D_BITMAPINFO <> +msg3D C3D_MSG <> +wc3D C3D_WNDCLASSEX <> + +sz3DClassName db "Casino3DRetroClass",0 +sz3DWindowTitle db 192,241,241,229,236,225,235,229,240,32,202,224,231,232,237,238,32,45,32,50,46,53,68,0 +szTexturesRelPath db "assets\textures\casino3d-hd.bin",0 +szTexturesFullPath db 260 dup(0) + + +playerX dd (16 * FP_1 + FP_HALF) +playerY dd (16 * FP_1 + FP_HALF) +playerAngle dd 384 +playerDirX dd 0 +playerDirY dd -FP_1 +playerPlaneX dd (FP_1 * 66 / 100) +playerPlaneY dd 0 + +engineMode dd 0 +startInHellTower dd 0 +interactTargetId dd 0 +interactPromptPtr dd 0 +dancerLuckBuff dd 0 +flashTimer dd 0 +flashMessage db 128 dup(0) + +promptDancer db "[E] ÊÀÁÀÐÅ - ×ÀÅÂÛÅ $100",0 +promptBlackjack db "[E] ÁËÝÊÄÆÅÊ (21)",0 +promptPoker db 91,69,93,32,207,206,202,197,208,32,40,210,197,213,192,209,209,202,200,201,32,213,206,203,196,197,204,41,0 +promptDurak db "[E] ÊÀÐÒÛ: ÏÎÄÊÈÄÍÎÉ ÄÓÐÀÊ",0 +promptCasinoRoulette db "[E] ÅÂÐÎÏÅÉÑÊÀß ÐÓËÅÒÊÀ",0 +promptClassicSlot db "[E] ÊËÀÑÑÈ×ÅÑÊÈÅ ÑËÎÒÛ 777",0 +promptCloverSlot db "[E] ÑËÎÒÛ CLOVERPIT (5x3)",0 +promptDice db 91,69,93,32,200,195,208,192,32,194,32,202,206,209,210,200,0 +promptSkulls db "[E] ÍÀϨÐÑÒÊÈ (×ÅÐÅÏÀ)",0 +promptCoin db "[E] ÌÎÍÅÒÊÀ (ÎШË/ÐÅØÊÀ)",0 +promptSkillCheck db "[E] ÒÐÅÍÈÐÎÂÊÀ ÐÅÀÊÖÈÈ",0 +promptBuckshot db 91,69,93,32,193,192,202,216,206,210,32,208,211,203,197,210,202,192,0 +promptRussianRoulette db "[E] ÐÓÑÑÊÀß ÐÓËÅÒÊÀ (VIP)",0 +promptOnlineRR db "[E] ÑÅÒÅÂÀß ÐÓËÅÒÊÀ (NET)",0 +promptUmamusume db "[E] ÑÊÀ×ÊÈ ÓÌÀÌÓÑÓÌÝ",0 +promptHellTower db "[E] ÁÀØÍß ÀÄÀ (10 ÝÒÀÆÅÉ)",0 +promptShop db "[E] ÁÓÒÈÊ È ÒÀËÈÑÌÀÍÛ",0 +promptATM db "[E] ÁÀÍÊÎÌÀÒ È ÁÀËÀÍÑ",0 +promptPlayerTerminal db "[E] ÒÅÐÌÈÍÀË: ÑÒÀÒÛ È À×ÈÂÊÈ",0 +promptObserver db "[E] ÐÅÆÈÌ ÍÀÁËÞÄÀÒÅËß (ÈÈ)",0 + +szTitleBlackjack db 202,192,199,200,202,32,51,68,32,45,32,193,203,221,202,196,198,197,202,32,40,50,49,41,0 +szTitlePoker db 202,192,199,200,202,32,51,68,32,45,32,207,206,202,197,208,32,40,210,197,213,192,209,209,202,200,201,32,213,206,203,196 + db 197,204,41,0 +szTitleDurak db 202,192,199,200,202,32,51,68,32,45,32,207,197,208,197,194,206,196,205,206,201,32,196,211,208,192,202,0 +szTitleCasinoRoulette db 202,192,199,200,202,32,51,68,32,45,32,197,194,208,206,207,197,201,209,202,192,223,32,208,211,203,197,210,202,192,0 +szTitleClassicSlot db 202,192,199,200,202,32,51,68,32,45,32,192,194,210,206,204,192,210,32,55,55,55,0 +szTitleCloverSlot db 202,192,199,200,202,32,51,68,32,45,32,202,203,197,194,197,208,205,192,223,32,223,204,192,32,40,53,120,51,41,0 +szTitleDice db 202,192,199,200,202,32,51,68,32,45,32,200,195,208,192,32,194,32,202,206,209,210,200,0 +szTitleSkulls db 202,192,199,200,202,32,51,68,32,45,32,205,192,207,168,208,209,210,202,200,0 +szTitleCoin db 202,192,199,200,202,32,51,68,32,45,32,204,206,205,197,210,202,192,32,40,206,208,168,203,47,208,197,216,202,192,41,0 +szTitleSkillCheck db 202,192,199,200,202,32,51,68,32,45,32,207,208,206,194,197,208,202,192,32,205,192,194,219,202,192,0 +szTitleBuckshot db 202,192,199,200,202,32,51,68,32,45,32,193,192,202,216,206,210,32,208,211,203,197,210,202,192,0 +szTitleRussianRoulette db 202,192,199,200,202,32,51,68,32,45,32,208,211,209,209,202,192,223,32,208,211,203,197,210,202,192,0 +szTitleOnlineRR db 202,192,199,200,202,32,51,68,32,45,32,209,197,210,197,194,192,223,32,208,211,209,209,202,192,223,32,208,211,203,197,210 + db 202,192,0 +szTitleUmamusume db 202,192,199,200,202,32,51,68,32,45,32,195,206,205,202,200,32,211,204,192,204,211,209,211,204,197,0 +szTitleHellTower db 202,192,199,200,202,32,51,68,32,45,32,192,196,209,202,192,223,32,193,192,216,205,223,0 +szTitleShop db 202,192,199,200,202,32,51,68,32,45,32,202,192,208,210,219,32,200,32,210,192,203,200,209,204,192,205,219,0 +szTitleATM db 202,192,199,200,202,32,51,68,32,45,32,193,192,205,202,206,204,192,210,0 +szTitleTerminal db 202,192,199,200,202,32,51,68,32,45,32,203,206,202,192,203,220,205,219,197,32,207,208,206,212,200,203,200,0 +szTitleObserver db 202,192,199,200,202,32,51,68,32,45,32,205,192,193,203,222,196,192,210,197,203,220,32,40,200,200,41,0 +textCabinetFooter db "[ ÂÛÕÎÄ: ÂÂÅÄÈÒÅ 0 / ÂÛÁÅÐÈÒÅ 'N' ÄËß ÂÎÇÂÐÀÒÀ  ÇÀË ]",0 + +msgDancerTipped db "Âû áðîñèëè $100 òàíöîâùèöå! ÓÄÀ×À ÀÊÒÈÂÈÐÎÂÀÍÀ!",0 +msgNeedMoney db "Íåäîñòàòî÷íî äåíåã â êîøåëüêå!",0 +statusHUDFormat db "ÁÀÍÊÐÎËË: $",0 +targetHUDFormat db " ÖÅËÜ: $",0 +luckHUDFormat db " ÓÄÀ×À: +",0 +controlsHUD db "WASD/Ñòðåëêè: Õîäüáà | E: Äåéñòâèå | ESC: Ìåíþ",0 + +NUM_SPRITES equ 22 + +INTERACT_NONE equ 0 +INTERACT_BLACKJACK equ 1 +INTERACT_POKER equ 2 +INTERACT_SLOTS_777 equ 3 +INTERACT_ROULETTE equ 4 +INTERACT_SKULLS equ 5 +INTERACT_SHOP equ 6 +INTERACT_ATM equ 7 +INTERACT_DANCER equ 8 +INTERACT_HELL_TOWER equ 9 +INTERACT_DURAK equ 10 +INTERACT_BUCKSHOT equ 11 +INTERACT_COIN equ 12 +INTERACT_DICE equ 13 +INTERACT_SLOTS_CLOVER equ 14 +INTERACT_UMAMUSUME equ 15 +INTERACT_OBSERVER equ 16 +INTERACT_TERMINAL equ 17 +INTERACT_ONLINE_RR equ 18 +INTERACT_RUSSIAN_ROULETTE equ 19 +INTERACT_SKILL_CHECK equ 20 +ALIGN 4 +casinoSprites SpriteObject NUM_SPRITES dup(<>) +sortedSprites dd NUM_SPRITES dup(0) + +rowDistTable dd 120 dup(0) +rngSeed3D dd 12345678h + +slotBet dd 50 +slotReel1 dd 0 +slotReel2 dd 1 +slotReel3 dd 2 +slotSpinState dd 0 +slotSpinTimer dd 0 +slotWinAmount dd 0 +slotWinMsg db 64 dup(0) + +bjState dd 0 +bjBet dd 100 +bjPlayerCards dd 10 dup(0) +bjPlayerCardCount dd 0 +bjPlayerScore dd 0 +bjDealerCards dd 10 dup(0) +bjDealerCardCount dd 0 +bjDealerScore dd 0 +bjDealerHideHole dd 1 +bjOutcomeMsg db 64 dup(0) + +roulState dd 0 +roulBetType dd 1 +roulBetAmount dd 100 +roulWheelAngle dd 0 +roulBallAngle dd 0 +roulSpinTimer dd 0 +roulWinningNum dd 0 +roulPayout dd 0 +roulOutcomeMsg db 64 dup(0) + +coinRxAnimTable db 26, 22, 16, 6, 16, 22, 26, 22, 16, 6 + +; --- Native 2.5D Coin Flip --- +coin3d_bet dd 50 +coin3d_choice dd 1 ; 1 = Îð¸ë, 2 = Ðåøêà +coin3d_state dd 0 ; 0 = Idle, 1 = Flipping, 2 = Result +coin3d_timer dd 0 +coin3d_result dd 1 ; 1 = Îð¸ë, 2 = Ðåøêà +coin3d_streak dd 0 +coin3d_win dd 0 + +textCoinTitle db "* * * Ç Î Ë Î Ò À ß Ì Î Í Å Ò À * * *",0 +textCoinHeads db "ÎШË",0 +textCoinTails db "ÐÅØÊÀ",0 +textCoinSide1 db "[1] ÎШË",0 +textCoinSide2 db "[2] ÐÅØÊÀ",0 +textCoinFlipping db "ÌÎÍÅÒÀ  ÏÎ˨ÒÅ...",0 +textCoinWin db "ÏÎÁÅÄÀ: +$",0 +textCoinLose db "ÍÅ ÓÃÀÄÀËÈ!",0 +textCoinStreakFmt db "ÑÅÐÈß ÏÎÁÅÄ: x",0 +textCoinSelected db "ÂÛÁÐÀÍÎ",0 +textCoinKey1 db "[1] ÎШË",0 +textCoinKey2 db "[2] ÐÅØÊÀ",0 +textCoinKeySpace db "[SPACE]",0 + +; --- Native 2.5D Dice Game --- +dice3d_bet dd 50 +dice3d_choice dd 1 ; 1 = ׸ò, 2 = Íå÷åò +dice3d_state dd 0 ; 0 = Idle, 1 = Rolling, 2 = Result +dice3d_timer dd 0 +dice3d_val1 dd 4 +dice3d_val2 dd 6 +dice3d_sum dd 10 +dice3d_win dd 0 + +textDiceTitle db 200,195,208,192,32,194,32,202,206,209,210,200,0 +textDiceEven db "[1] רÒ",0 +textDiceOdd db "[2] ÍÅ×ÅÒ",0 +textDiceEvenNums db "2 4 6 ...",0 +textDiceOddNums db "3 5 7 ...",0 +textDiceSumHdr db "ÑÓÌÌÀ: ",0 +textDicePlus db " + ",0 +textDiceEqual db " = ",0 +textDiceEvenResult db " (רÒ)",0 +textDiceOddResult db " (ÍÅ×ÅÒ)",0 +textDiceRolling db "ÊÎÑÒÈ ËÅÒßÒ ÏÎ ÑÓÊÍÓ...",0 +textDiceWin db "ÂÛÈÃÐÛØ: +$",0 +textDiceWinMult db "! (x2)",0 +textDiceLose db "ÏÐÎÈÃÐÛØ!",0 +textDiceKey1 db "[1] רÒ",0 +textDiceKey2 db "[2] ÍÅ×ÅÒ",0 +textDiceKeySpace db "[SPACE]",0 + +; --- Native 2.5D Skulls Game --- +skulls3d_bet dd 50 +skulls3d_state dd 0 ; 0 = Idle, 1 = Show ball, 2 = Shuffle, 3 = Pick, 4 = Reveal +skulls3d_timer dd 0 +skulls3d_ballPos dd 1 ; 0, 1, 2 +skulls3d_choice dd 1 ; 0, 1, 2 +skulls3d_win dd 0 +skulls3d_swapPair0 dd 0 +skulls3d_swapPair1 dd 1 +skulls3d_swapPair2 dd 2 +skulls3d_cup0 dd 0 +skulls3d_cup1 dd 1 +skulls3d_cup2 dd 2 + +textSkullsTitle db "* * * Í À Ï ¨ Ð Ñ Ò Ê È * * *",0 +textSkullsPhase0 db "ÄÅËÀÉ ÑÒÀÂÊÓ È ÆÌÈ [ÏÐÎÁÅË]",0 +textSkullsPhase1 db "ÑÌÎÒÐÈ, ÃÄÅ ÇÎËÎÒÎÉ ØÀÐ...",0 +textSkullsPhase2 db "ÊÐÓ×Ó, ÂÅÐ×Ó, ÇÀÏÓÒÀÒÜ ÕÎ×Ó...",0 +textSkullsPhase3 db "ÃÄÅ ØÀÐ? ÂÛÁÈÐÀÉ: [1], [2] ÈËÈ [3]!",0 +textSkullsWin db "ÂÛÈÃÐÛØ: +$",0 +textSkullsWinMult db "! (x3) ÂÛ ÓÃÀÄÀËÈ!",0 +textSkullsLose db "ÌÈÌÎ! ØÀÐ ÁÛË Â ÄÐÓÃÎÌ ÌÅÑÒÅ!",0 +textSkullsAgain db "[ÏÐÎÁÅË] - ÑÛÃÐÀÒÜ Å٨ ÐÀÇ",0 +textSkullsKey1 db "[1]",0 +textSkullsKey2 db "[2]",0 +textSkullsKey3 db "[3]",0 +textSkullsKeySpace db "[SPACE] ÑÒÀÐÒ",0 + +; --- Native 2.5D Skill Check (Dead by Daylight Survivor Check) --- +skill3d_bet dd 50 +skill3d_state dd 0 ; 0=Ready, 1=Active, 2=Hit Result, 3=Miss Result, 4=Escaped, 5=Defeated +skill3d_timer dd 0 +skill3d_needle dd 55 ; Needle X (52..268) +skill3d_speed dd 4 +skill3d_dir dd 1 ; 1=Right, -1=Left +skill3d_zone_start dd 140 +skill3d_zone_width dd 48 +skill3d_great_start dd 176 +skill3d_great_width dd 12 +skill3d_hits dd 0 +skill3d_misses dd 0 +skill3d_last_result dd 0 +skill3d_win_amount dd 0 + +textSkillTitle db 61,61,61,32,207,208,206,194,197,208,202,192,32,205,192,194,219,202,192,32,61,61,61,0 +textSkillHitsHdr db "ÕÈÒ: ",0 +textSkillMissHdr db "ÏÐÎÌÀÕ: ",0 +textSkillReadyMsg db "ÍÀÆÌÈÒÅ [ÏÐÎÁÅË] ÄËß ÑÒÀÐÒÀ",0 +textSkillPrompt db "ÍÀÆÌÈÒÅ [ÏÐÎÁÅË]  ÇÎÍÅ!",0 +textSkillHitMsg db "ÕÈÒ! ÒÎ×ÍÎÅ ÏÎÏÀÄÀÍÈÅ!",0 +textSkillGreatMsg db 206,210,203,200,215,205,206,33,32,43,193,206,205,211,209,33,0 +textSkillMissMsg db "ÏÐÎÌÀÕ! ÒÐÅÂÎÃÀ!",0 +textSkillEscape db "ÏÎÁÅà ÓÑÏÅØÅÍ! ÂÛÈÃÐÛØ: +$",0 +textSkillLost db "ÂÛ ÏÎÉÌÀÍÛ! ÏÐÎÈÃÐÛØ ÑÒÀÂÊÈ!",0 +textSkillKeySpace db "[SPACE] ÐÅÀÊÖÈß",0 +textSkillKeyBet db "[ÂÂÅÐÕ/ÂÍÈÇ]",0 + +; --- Shared UI Strings --- +textKeyEsc db "[ESC]",0 +textBankPrompt db "ÁÀÍÊ: $",0 +textBetPrompt db "ÑÒÀÂÊÀ: $",0 +textBetHint db " [W/S]",0 + +shopMsg db 128 dup(0) +atmMsg db 128 dup(0) + +strWin db "ÏÎÁÅÄÀ! +$",0 +strLose db "ÏÐÎÈÃÐÛØ",0 +strJackpot db "ÄÆÅÊÏÎÒ! +$",0 +strPush db 205,200,215,220,223,0 +strDealerBust db "ÄÈËÅÐ ÏÅÐÅÁÐÀË! ÏÎÁÅÄÀ! +$",0 +strPlayerBust db "ÏÅÐÅÁÎÐ (>21)! ÏÐÎÈÃÐÛØ",0 + +sym7 db " 777 ",0 +symBar db " BAR ",0 +symBell db 32,199,194,206,205,0 +symCherry db 194,200,216,205,223,0 +symClover db 202,203,197,194,197,208,0 +symGem db 192,203,204,192,199,0 +symCrown db 202,206,208,206,205,192,0 + +cardRankStr db "A ",0,"2 ",0,"3 ",0,"4 ",0,"5 ",0,"6 ",0,"7 ",0,"8 ",0,"9 ",0,"10",0,"J ",0,"Q ",0,"K ",0 + +.data? +ALIGN 4 +screenBuffer dd SCREEN_SIZE dup(?) +ALIGN 4 +zBuffer dd SCREEN_W dup(?) +ALIGN 4 +texturesBuffer dd (201 * 128 * 128) dup(?) + +hudNumBuffer db 32 dup(?) + +.code + +; --- 3D Window Procedure --- +Casino3DWndProc PROC hwnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD + invoke WindowEvents3D, hwnd, uMsg, wParam, lParam + ret +Casino3DWndProc ENDP + +; --- Random Generator --- +RandomRange3D PROC maxVal:DWORD + mov eax, rngSeed3D + imul eax, 1103515245 + add eax, 12345 + mov rngSeed3D, eax + shr eax, 16 + and eax, 7FFFh + xor edx, edx + div maxVal + mov eax, edx + ret +RandomRange3D ENDP + +; --- Copy String --- +CopyString3D PROC src:DWORD, dst:DWORD + push esi + push edi + mov esi, src + mov edi, dst +@@: + mov al, [esi] + mov [edi], al + test al, al + jz @F + inc esi + inc edi + jmp @B +@@: + pop edi + pop esi + ret +CopyString3D ENDP + +; --- Format Number to Decimal String --- +FormatNumber PROC num:DWORD, buf:DWORD + push ebx + push esi + push edi + mov eax, num + mov edi, buf + test eax, eax + jns fn_pos + mov BYTE PTR [edi], '-' + inc edi + neg eax +fn_pos: + mov ebx, 10 + push 0 +fn_div: + xor edx, edx + div ebx + add dl, '0' + push edx + test eax, eax + jnz fn_div +fn_pop: + pop eax + test al, al + jz fn_done + mov [edi], al + inc edi + jmp fn_pop +fn_done: + mov BYTE PTR [edi], 0 + pop edi + pop esi + pop ebx + ret +FormatNumber ENDP + +; --- Fast 2D Drawing Primitives --- +DrawBox PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD + +DrawPixel PROC x:DWORD, y:DWORD, color:DWORD + invoke DrawBox, x, y, 1, 1, color + ret +DrawPixel ENDP + +DrawBox PROC x:DWORD, y:DWORD, w:DWORD, h:DWORD, color:DWORD + shl x, 1 + shl y, 1 + shl w, 1 + shl h, 1 + push ebx + push esi + push edi + mov edi, y +box_row_loop: + mov eax, y + add eax, h + cmp edi, eax + jge box_done + cmp edi, 0 + jl next_box_row + cmp edi, SCREEN_H + jge box_done + + mov esi, x +box_col_loop: + mov eax, x + add eax, w + cmp esi, eax + jge next_box_row + cmp esi, 0 + jl next_box_col + cmp esi, SCREEN_W + jge next_box_row + + mov ecx, edi + imul ecx, SCREEN_W + add ecx, esi + mov edx, color + mov [screenBuffer + ecx*4], edx + +next_box_col: + inc esi + jmp box_col_loop + +next_box_row: + inc edi + jmp box_row_loop + +box_done: + pop edi + pop esi + pop ebx + ret +DrawBox ENDP + +DrawBoxBorder PROC uses ebx x:DWORD, y:DWORD, w:DWORD, h:DWORD, fillColor:DWORD, borderColor:DWORD, bWidth:DWORD + invoke DrawBox, x, y, w, h, borderColor + mov eax, x + add eax, bWidth + mov edx, y + add edx, bWidth + mov ecx, w + sub ecx, bWidth + sub ecx, bWidth + mov ebx, h + sub ebx, bWidth + sub ebx, bWidth + invoke DrawBox, eax, edx, ecx, ebx, fillColor + ret +DrawBoxBorder ENDP + +DrawCircle PROC cxVal:DWORD, cyVal:DWORD, radius:DWORD, color:DWORD + push ebx + push esi + push edi + mov eax, radius + neg eax + mov edi, eax +circ_y: + cmp edi, radius + jg circ_done + mov eax, radius + neg eax + mov esi, eax +circ_x: + cmp esi, radius + jg next_circ_y + + mov eax, esi + imul eax, eax + mov ebx, edi + imul ebx, ebx + add eax, ebx + mov edx, radius + imul edx, edx + cmp eax, edx + jg next_circ_x + + mov eax, cxVal + add eax, esi + mov ecx, cyVal + add ecx, edi + invoke DrawPixel, eax, ecx, color + +next_circ_x: + inc esi + jmp circ_x +next_circ_y: + inc edi + jmp circ_y +circ_done: + pop edi + pop esi + pop ebx + ret +DrawCircle ENDP + +DrawChar8x8 PROC uses ebx esi edi x:DWORD, y:DWORD, chVal:DWORD, color:DWORD + local column:DWORD + mov eax, chVal + and eax, 255 + lea esi, [font8x8 + eax*8] + xor edi, edi +glyph_row: + movzx ebx, BYTE PTR [esi+edi] + mov column, 0 +glyph_col: + test ebx, 80h + jz glyph_next + mov eax, x + add eax, column + mov edx, y + add edx, edi + invoke DrawPixel, eax, edx, color +glyph_next: + shl ebx, 1 + inc column + cmp column, 8 + jl glyph_col + inc edi + cmp edi, 8 + jl glyph_row + ret +DrawChar8x8 ENDP + +DrawString8x8 PROC x:DWORD, y:DWORD, strPtr:DWORD, color:DWORD + push ebx + push esi + mov esi, strPtr + mov ebx, x +str_loop: + movzx eax, BYTE PTR [esi] + test al, al + jz str_done + invoke DrawChar8x8, ebx, y, eax, color + add ebx, 8 + inc esi + jmp str_loop +str_done: + pop esi + pop ebx + ret +DrawString8x8 ENDP + +; --- True 3D Perspective Floor & Ceiling Rendering --- + +; --- DDA Raycasting Walls --- +RenderWallsRange PROC colStart:DWORD, colLimit:DWORD + local col:DWORD + local originalStart:DWORD + local camX:DWORD + local rayDirX:DWORD + local rayDirY:DWORD + local mapX:DWORD + local mapY:DWORD + local deltaDistX:DWORD + local deltaDistY:DWORD + local stepX:DWORD + local stepY:DWORD + local sideDistX:DWORD + local sideDistY:DWORD + local side:DWORD + local perpWallDist:DWORD + local lineH:DWORD + local drawStart:DWORD + local drawEnd:DWORD + local wallHit:DWORD + local texX:DWORD + local texXHD:DWORD + local pixelMaterial:DWORD + local texId:DWORD + local shade:DWORD + + push ebx + push esi + push edi + + mov eax, playerAngle + and eax, 511 + mov ebx, [tableCos + eax*4] + mov playerDirX, ebx + mov ebx, [tableSin + eax*4] + mov playerDirY, ebx + + mov eax, ebx + imul eax, -66 + cdq + mov ecx, 100 + idiv ecx + mov playerPlaneX, eax + + mov eax, playerDirX + imul eax, 66 + cdq + idiv ecx + mov playerPlaneY, eax + + mov eax, colStart + mov col, eax +col_loop: + mov eax, colLimit + cmp col, eax + jge walls_done + + mov eax, col + shl eax, 1 + sub eax, SCREEN_W + imul eax, FP_1 + cdq + mov ecx, SCREEN_W + idiv ecx + mov camX, eax + + mov eax, playerPlaneX + imul camX + shrd eax, edx, 16 + add eax, playerDirX + mov rayDirX, eax + + mov eax, playerPlaneY + imul camX + shrd eax, edx, 16 + add eax, playerDirY + mov rayDirY, eax + + mov eax, playerX + sar eax, 16 + mov mapX, eax + mov eax, playerY + sar eax, 16 + mov mapY, eax + + cmp portalRendering3D,0 + je wall_ray_start_ready + mov ebx,col + mov ecx,portalClipDepth3D[ebx*4] + test ecx,ecx + jnz @F + mov zBuffer[ebx*4],7FFFFFFFh + jmp next_col +@@: + ; Start DDA just inside the destination aperture, never in its rear wall. + add ecx,FP_1/100 + mov eax,rayDirX + imul ecx + shrd eax,edx,16 + add eax,playerX + sar eax,16 + mov mapX,eax + mov eax,rayDirY + imul ecx + shrd eax,edx,16 + add eax,playerY + sar eax,16 + mov mapY,eax +wall_ray_start_ready: + mov eax, rayDirX + test eax, eax + jnz calc_delta_x + mov deltaDistX, 7FFFFFFFh + jmp calc_delta_y +calc_delta_x: + test eax, eax + jns @F + neg eax +@@: + mov ebx, eax + cmp ebx, 4 + jbe delta_x_clamp + xor eax, eax + mov edx, 1 + div ebx + mov deltaDistX, eax + jmp calc_delta_y +delta_x_clamp: + mov deltaDistX, 7FFFFFFFh + +calc_delta_y: + mov eax, rayDirY + test eax, eax + jnz calc_delta_y_ok + mov deltaDistY, 7FFFFFFFh + jmp check_step +calc_delta_y_ok: + test eax, eax + jns @F + neg eax +@@: + mov ebx, eax + cmp ebx, 4 + jbe delta_y_clamp + xor eax, eax + mov edx, 1 + div ebx + mov deltaDistY, eax + jmp check_step +delta_y_clamp: + mov deltaDistY, 7FFFFFFFh + +check_step: + cmp rayDirX, 0 + jge step_x_pos + mov stepX, -1 + mov eax, playerX + mov edx, mapX + shl edx, 16 + sub eax, edx + imul deltaDistX + shrd eax, edx, 16 + mov sideDistX, eax + jmp check_step_y +step_x_pos: + mov stepX, 1 + mov eax, mapX + inc eax + shl eax, 16 + sub eax, playerX + imul deltaDistX + shrd eax, edx, 16 + mov sideDistX, eax + +check_step_y: + cmp rayDirY, 0 + jge step_y_pos + mov stepY, -1 + mov eax, playerY + mov edx, mapY + shl edx, 16 + sub eax, edx + imul deltaDistY + shrd eax, edx, 16 + mov sideDistY, eax + jmp dda_start +step_y_pos: + mov stepY, 1 + mov eax, mapY + inc eax + shl eax, 16 + sub eax, playerY + imul deltaDistY + shrd eax, edx, 16 + mov sideDistY, eax + +dda_start: + xor ecx, ecx +dda_step_loop: + inc ecx + cmp ecx, 64 + jge wall_map_boundary + + mov eax, sideDistX + cmp eax, sideDistY + jge step_in_y + + mov eax, deltaDistX + add sideDistX, eax + mov eax, stepX + add mapX, eax + mov side, 0 + jmp check_tile + +step_in_y: + mov eax, deltaDistY + add sideDistY, eax + mov eax, stepY + add mapY, eax + mov side, 1 + +check_tile: + cmp mapX, 0 + jl wall_map_boundary + cmp mapX, MAP_WIDTH + jge wall_map_boundary + cmp mapY, 0 + jl wall_map_boundary + cmp mapY, MAP_HEIGHT + jge wall_map_boundary + + mov eax, mapY + shl eax, 5 + add eax, mapX + mov edx, worldMap3D + movzx eax, BYTE PTR [edx + eax] + test eax, eax + jnz hit_wall + jmp dda_step_loop + +wall_map_boundary: + cmp outdoorRender3D, 0 + je hit_wall + mov eax, col + mov zBuffer[eax*4], 7FFFFFFFh + jmp next_col + +hit_wall: + cmp side, 0 + jne perp_y + mov eax, sideDistX + sub eax, deltaDistX + mov perpWallDist, eax + jmp perp_done +perp_y: + mov eax, sideDistY + sub eax, deltaDistY + mov perpWallDist, eax + +perp_done: + cmp perpWallDist, 2048 + jge @F + mov perpWallDist, 2048 +@@: + mov eax, col + mov edx, perpWallDist + mov [zBuffer + eax*4], edx + + ; Unit projection is shared by indoor room height and outdoor storeys. + mov eax, SCREEN_H + imul eax, FP_1 + cdq + idiv perpWallDist + mov lineH, eax + + mov eax, lineH + imul viewEye3D + shrd eax, edx, 16 + add eax, viewHorizon3D + mov drawEnd, eax + mov ebx, lineH + mov eax, viewCeiling3D + cmp outdoorRender3D, 0 + je @F + mov eax, CITY_STOREY_HEIGHT +@@: + imul ebx + shrd eax, edx, 16 + mov ebx, eax + mov lineH, ebx + mov eax, drawEnd + sub eax, ebx + mov drawStart, eax + cmp outdoorRender3D, 0 + je wall_store_original_start + ; Floor height is independent of storey height. + mov eax, drawEnd + sub eax, lineH + mov drawStart, eax + mov eax, mapY + shl eax, 5 + add eax, mapX + mov edx, worldMap3D + movzx eax, BYTE PTR [edx+eax] +wall_exterior_tall: + ; Roof projection and texture sampling use the same storey count. + mov eax, lineH + imul eax, CITY_BUILDING_STOREYS-1 + sub drawStart, eax + mov eax, lineH + imul eax, CITY_BUILDING_STOREYS + mov lineH, eax +wall_store_original_start: + mov eax, drawStart + mov originalStart, eax + + cmp side, 0 + jne hit_side_y + mov eax, perpWallDist + imul rayDirY + shrd eax, edx, 16 + add eax, playerY + mov wallHit, eax + jmp calc_tex_x +hit_side_y: + mov eax, perpWallDist + imul rayDirX + shrd eax, edx, 16 + add eax, playerX + mov wallHit, eax + +calc_tex_x: + ; MASK WITH 0FFFFh to prevent texture scrambling! + mov eax, wallHit + and eax, 0FFFFh + mov texXHD, eax + shr eax, 9 + and eax, 127 + mov texX, eax + + cmp side, 0 + jne @F + cmp rayDirX, 0 + jle @F + mov eax, 127 + sub eax, texX + mov texX, eax + xor texXHD, 0FFFFh +@@: + cmp side, 1 + jne select_tex + cmp rayDirY, 0 + jge select_tex + mov eax, 127 + sub eax, texX + mov texX, eax + xor texXHD, 0FFFFh + +select_tex: + mov eax, mapY + shl eax, 5 + add eax, mapX + mov edx, worldMap3D + movzx eax, BYTE PTR [edx + eax] + mov texId, eax + cmp texId, 0 + jne @F + mov texId, 1 +@@: + + mov eax, perpWallDist + shr eax, 13 + mov edx, 256 + sub edx, eax + cmp edx, 75 + jge @F + mov edx, 75 +@@: + cmp side, 1 + jne @F + imul edx, 3 + shr edx, 2 +@@: + mov shade, edx + + cmp drawStart, 0 + jge @F + mov drawStart, 0 +@@: + cmp drawEnd, SCREEN_H + jl @F + mov drawEnd, SCREEN_H - 1 +@@: + + mov eax, lineH + cmp eax, 1 + jge @F + mov eax, 1 + mov lineH, eax +@@: + + mov eax, 128 * FP_1 + cdq + idiv lineH + mov esi, eax ; stepY + + mov eax, drawStart + sub eax, originalStart + imul eax, esi + mov edi, eax ; texPos + + mov ecx, drawStart +draw_stripe_loop: + cmp ecx, drawEnd + jg next_col + + mov eax, edi + shr eax, 16 + and eax, 127 + mov edx, texId + cmp outdoorRender3D, 0 + je wall_sample_material + imul eax, CITY_BUILDING_STOREYS + cmp eax, 128*(CITY_BUILDING_STOREYS-1) + jae wall_lower_storey + push eax + shr eax, 7 + add eax, mapX + add eax, mapY + xor edx, edx + mov ebx, 3 + div ebx + add edx, 65 + pop eax + and eax, 127 + jmp wall_sample_material +wall_lower_storey: + sub eax, 128*(CITY_BUILDING_STOREYS-1) +wall_sample_material: + mov pixelMaterial, edx + cmp outdoorRender3D, 0 + je wall_sample_indoor_hd + cmp hallCityDetail3D.pixels, 0 + je wall_sample_standard + cmp edx, 57 + jb wall_sample_standard + cmp edx, 72 + ja wall_sample_standard + cmp perpWallDist, 6*FP_1 + ja wall_sample_standard + ; Preserve subtexel detail near facades; retain the 128px mip at distance. + push edx + mov eax, edi + shr eax, 15 + imul eax, CITY_BUILDING_STOREYS + and eax, 255 + shl eax, 8 + mov ebx, texXHD + shr ebx, 8 + add eax, ebx + pop edx + sub edx, 57 + shl edx, 16 + add eax, edx + mov ebx, hallCityDetail3D.pixels + mov eax, [ebx+eax*4] + jmp wall_shade_pixel +wall_sample_indoor_hd: + cmp edx,132 + jb wall_sample_other_hd + cmp edx,135 + ja wall_sample_other_hd + mov ebx,fortuneMaterialArt3D.pixels + test ebx,ebx + jz wall_fortune_material_missing + sub edx,132 + shl edx,18 + add ebx,edx + jmp wall_room_hd_coordinates +wall_fortune_material_missing: + mov edx,92 + mov eax,edi + shr eax,16 + and eax,127 + jmp wall_sample_standard +wall_sample_other_hd: + cmp edx,122 + jb wall_sample_existing_hd + cmp edx,125 + ja wall_sample_existing_hd + mov ebx,upperMaterialArt3D.pixels + test ebx,ebx + jz wall_upper_material_missing + sub edx,122 + shl edx,18 + add ebx,edx + jmp wall_room_hd_coordinates +wall_upper_material_missing: + mov edx,102 +wall_sample_existing_hd: + cmp edx, 80 + jb wall_sample_standard + cmp edx, 103 + ja wall_sample_standard + mov ebx, hallRoomHD3D.pixels + cmp edx, 92 + jb wall_sample_room_hd + mov ebx, hallArchitectureHD3D.pixels + sub edx, 12 +wall_sample_room_hd: + test ebx, ebx + jz wall_sample_standard_restore + sub edx, 80 + shl edx, 18 + add ebx, edx +wall_room_hd_coordinates: + mov eax, edi + shr eax, 15 + and eax, 255 + shl eax, 8 + mov edx, texXHD + shr edx, 8 + add eax, edx + mov eax, [ebx+eax*4] + jmp wall_shade_pixel +wall_sample_standard_restore: + mov edx, texId + mov eax, edi + shr eax, 16 + and eax, 127 +wall_sample_standard: + shl eax, 7 + add eax, texX + + shl edx, 14 + add eax, edx + mov eax, [texturesBuffer + eax*4] + + ; Shade wall pixel +wall_shade_pixel: + mov ebx, shade + cmp outdoorRender3D, 0 + je wall_ambient_shade + push eax + push ecx + invoke IsCityEmissive3D, eax, pixelMaterial + pop ecx + test eax, eax + pop eax + jz wall_ambient_shade + mov ebx, 256 +wall_ambient_shade: + cmp hallLevel3D, 0 + je @F + imul ebx, 7 + shr ebx, 3 +@@: + movzx edx, al + imul edx, ebx + shr edx, 8 + push edx + + movzx edx, ah + imul edx, ebx + shr edx, 8 + shl edx, 8 + + shr eax, 16 + movzx eax, al + imul eax, ebx + shr eax, 8 + shl eax, 16 + or eax, edx + pop edx + or eax, edx + + mov edx, ecx + imul edx, SCREEN_W + add edx, col + mov [screenBuffer + edx*4], eax + + add edi, esi + inc ecx + jmp draw_stripe_loop + +next_col: + inc col + jmp col_loop + +walls_done: + pop edi + pop esi + pop ebx + ret +RenderWallsRange ENDP + +; --- Raycasting Background Worker Thread --- +RaycastWorkerProc PROC uses ebx esi edi lpParam:DWORD +worker_loop: + invoke WaitForSingleObject, hRaycastStartEvent, 0FFFFFFFFh + cmp bRaycastQuit, 1 + je worker_exit + invoke RenderWallsRange, 320, 640 + invoke SetEvent, hRaycastDoneEvent + jmp worker_loop +worker_exit: + xor eax, eax + ret +RaycastWorkerProc ENDP + +; --- Multi-Threaded DDA Raycasting Walls Dispatcher --- +RenderWalls PROC + push ebx + push esi + push edi + + mov eax, playerAngle + and eax, 511 + mov ebx, [tableCos + eax*4] + mov playerDirX, ebx + mov ebx, [tableSin + eax*4] + mov playerDirY, ebx + + mov eax, ebx + imul eax, -66 + cdq + mov ecx, 100 + idiv ecx + mov playerPlaneX, eax + + mov eax, playerDirX + imul eax, 66 + cdq + idiv ecx + mov playerPlaneY, eax + + cmp hRaycastStartEvent, 0 + je single_thread_fallback + + ; Signal background worker to render columns [320..640) + invoke SetEvent, hRaycastStartEvent + + ; Main thread processes columns [0..320) in parallel + invoke RenderWallsRange, 0, 320 + + ; Synchronize with worker completion + invoke WaitForSingleObject, hRaycastDoneEvent, 0FFFFFFFFh + jmp walls_finished + +single_thread_fallback: + invoke RenderWallsRange, 0, SCREEN_W + +walls_finished: + pop edi + pop esi + pop ebx + ret +RenderWalls ENDP + +; --- Render 3D Billboard Sprites --- + +; --- HUD & Minimap Radar --- +RenderHUD PROC uses ebx esi edi + invoke DrawBox, 0, 0, 320, 16, 0014191Dh + invoke DrawString8x8, 8, 4, OFFSET textBank3D, 00D8BC6Ah + invoke FormatNumber, bankroll, OFFSET hudNumBuffer + invoke DrawString8x8, 64, 4, OFFSET hudNumBuffer, 00FFFFFFh + invoke DrawString8x8, 176, 4, OFFSET textWindowKeys3D, 00A8B6BBh + cmp securityHeat,0 + je @F + invoke DrawString8x8,8,18,OFFSET szSecHeatBar,005555FFh + invoke DrawNumber,88,18,securityHeat,005555FFh +@@: + cmp debtActive,0 + je @F + invoke DrawString8x8,136,18,OFFSET uwDebt,00E7CA88h + invoke DrawNumber,192,18,debtAmount,00FFFFFFh + invoke DrawNumber,280,18,debtRoundsLeft,00A8DDB9h + jmp hud_check_bankrupt_done +@@: + cmp bankroll,50 + jae hud_check_bankrupt_done + invoke DrawString8x8,8,18,OFFSET uwRoute,005555FFh +hud_check_bankrupt_done: + invoke DrawBox, 0, 226, 320, 14, 0014191Dh + invoke DrawString8x8, 12, 230, OFFSET textWalkKeys3D, 00A8B6BBh + invoke DrawBox, 159, 118, 2, 5, 00E7DFC8h + invoke DrawBox, 157, 120, 6, 1, 00E7DFC8h + cmp interactPromptPtr, 0 + je hud_charms_bottom + invoke DrawBoxBorder, 4, 199, 312, 18, 0014191Dh, 00D8BC6Ah, 1 + invoke DrawString8x8, 10, 204, interactPromptPtr, 00F5E2B0h + invoke DrawCharmsHUD, 8, 18 + jmp hud_charms_done +hud_charms_bottom: + invoke DrawCharmsHUD, 8, 214 +hud_charms_done: + cmp flashTimer, 0 + je hud_finished + dec flashTimer + invoke DrawBox, 4, 22, 312, 16, 0014191Dh + invoke DrawString8x8, 10, 26, OFFSET flashMessage, 00FFFFFFh +hud_finished: + ret +RenderHUD ENDP + +RenderMinimap PROC uses ebx esi edi + local radarX:DWORD + local radarY:DWORD + local radarSize:DWORD + + mov radarX, 320 - 48 + mov radarY, 20 + mov radarSize, 44 + + invoke DrawBoxBorder, radarX, radarY, radarSize, radarSize, 00101510h, 00FFD700h, 1 + + ; Draw Sprites on radar + cmp hallLevel3D, 0 + jne draw_player_radar + xor esi, esi +radar_spr_loop: + cmp esi, NUM_SPRITES + jge draw_player_radar + cmp esi,17 + je radar_skip_sprite + cmp esi,19 + je radar_skip_sprite + cmp esi,21 + je radar_skip_sprite + mov eax, esi + imul eax, SIZEOF SpriteObject + mov eax, [casinoSprites + eax].posX + sar eax, 16 + imul eax, radarSize + shr eax, 5 + add eax, radarX + mov ebx, eax + + mov eax, esi + imul eax, SIZEOF SpriteObject + mov eax, [casinoSprites + eax].posY + sar eax, 16 + imul eax, radarSize + shr eax, 5 + add eax, radarY + + invoke DrawPixel, ebx, eax, 00FFAA00h +radar_skip_sprite: + inc esi + jmp radar_spr_loop + +draw_player_radar: + mov eax, playerX + sar eax, 16 + imul eax, radarSize + shr eax, 5 + add eax, radarX + mov ebx, eax + + mov eax, playerY + sar eax, 16 + imul eax, radarSize + shr eax, 5 + add eax, radarY + + invoke DrawCircle, ebx, eax, 2, 00FF2020h + ret +RenderMinimap ENDP + +; ============================================================================== +; IN-ENGINE 2.5D MINI-GAME: SLOTS 777 +; ============================================================================== +HandleSlotsInput PROC + cmp slotSpinState, 1 + je slots_input_done + + invoke Pressed3D, 20h ; SPACE -> Spin + test ah, 80h + jz check_bet_adjust + mov eax, bankroll + cmp eax, slotBet + jl @F + sub eax, slotBet + mov bankroll, eax + mov slotSpinState, 1 + mov slotSpinTimer, 0 + mov slotWinAmount, 0 + invoke PlayCasinoSound3D, OFFSET soundSlotSpin, 0, 1 + jmp slots_input_done +@@: + invoke CopyString3D, OFFSET msgNeedMoney, OFFSET flashMessage + mov flashTimer, 60 + +check_bet_adjust: + invoke Pressed3D, 26h ; UP / W + test ah, 80h + jnz inc_bet + invoke Pressed3D, 57h + test ah, 80h + jz check_bet_down +inc_bet: + cmp slotBet, 500 + jge slots_input_done + cmp slotBet, 100 + jge @F + cmp slotBet, 50 + jge set_100 + mov slotBet, 50 + jmp slots_input_done +set_100: + mov slotBet, 100 + jmp slots_input_done +@@: + mov slotBet, 500 + jmp slots_input_done + +check_bet_down: + invoke Pressed3D, 28h ; DOWN / S + test ah, 80h + jnz dec_bet + invoke Pressed3D, 53h + test ah, 80h + jz slots_input_done +dec_bet: + cmp slotBet, 50 + jle set_10 + cmp slotBet, 100 + jle set_50 + mov slotBet, 100 + jmp slots_input_done +set_50: + mov slotBet, 50 + jmp slots_input_done +set_10: + mov slotBet, 10 + +slots_input_done: + ret +HandleSlotsInput ENDP + +RenderSlotsGame PROC uses ebx esi edi + ; Cabinet Background (Dark Cherry Wood & Gold) + invoke DrawBox, 0, 0, SCREEN_W, SCREEN_H, 00150A10h + invoke DrawBoxBorder, 10, 10, 300, 220, 00251015h, 00FFD700h, 3 + + ; Illuminated Top Marquee + invoke DrawBoxBorder, 25, 20, 270, 32, 000A0505h, 00FFFF00h, 2 + invoke DrawString8x8, 55, 32, OFFSET textSlots3D, 00FFD700h + + ; Spinning Animation Logic + cmp slotSpinState, 1 + jne draw_reels + inc slotSpinTimer + + cmp slotSpinTimer, 22 + jge @F + invoke RandomRange3D, 7 + mov slotReel1, eax +@@: + cmp slotSpinTimer, 36 + jge @F + invoke RandomRange3D, 7 + mov slotReel2, eax +@@: + cmp slotSpinTimer, 50 + jge @F + invoke RandomRange3D, 7 + mov slotReel3, eax +@@: + cmp slotSpinTimer, 50 + jl draw_reels + + ; Spin finished! Check outcome! + mov slotSpinState, 0 + mov eax, slotReel1 + cmp eax, slotReel2 + jne check_pairs + cmp eax, slotReel3 + jne check_pairs + + ; 3 Matching! + cmp eax, 0 ; 777! + jne @F + mov eax, slotBet + imul eax, 25 + mov slotWinAmount, eax + add bankroll, eax + invoke PlayCasinoSound3D, OFFSET soundJackpot, 0, 1 + jmp draw_reels +@@: + cmp eax, 6 ; CROWN! + jne @F + mov eax, slotBet + imul eax, 50 + mov slotWinAmount, eax + add bankroll, eax + invoke PlayCasinoSound3D, OFFSET soundJackpot, 0, 1 + jmp draw_reels +@@: + mov eax, slotBet + imul eax, 10 + mov slotWinAmount, eax + add bankroll, eax + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + jmp draw_reels + +check_pairs: + mov eax, slotReel1 + cmp eax, slotReel2 + je pair_win + mov eax, slotReel2 + cmp eax, slotReel3 + je pair_win + mov eax, slotReel1 + cmp eax, slotReel3 + je pair_win + jmp draw_reels +pair_win: + mov eax, slotBet + imul eax, 2 + mov slotWinAmount, eax + add bankroll, eax + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + +draw_reels: + ; Reels Window + invoke DrawBoxBorder, 30, 62, 260, 95, 000F0F12h, 0000A5FFh, 2 + + ; Reel 1 (45..105) + invoke DrawBoxBorder, 45, 68, 65, 82, 00F0F0F5h, 00505050h, 2 + mov eax, slotReel1 + call DrawReelSymbolAt1 + + ; Reel 2 (128..188) + invoke DrawBoxBorder, 128, 68, 65, 82, 00F0F0F5h, 00505050h, 2 + mov eax, slotReel2 + call DrawReelSymbolAt2 + + ; Reel 3 (210..270) + invoke DrawBoxBorder, 210, 68, 65, 82, 00F0F0F5h, 00505050h, 2 + mov eax, slotReel3 + call DrawReelSymbolAt3 + + ; Bottom Control Panel + invoke DrawBoxBorder, 20, 165, 280, 58, 00151515h, 00FFD700h, 1 + + invoke DrawString8x8, 28, 172, OFFSET textBank3D, 00FFD700h + invoke FormatNumber, bankroll, OFFSET hudNumBuffer + invoke DrawString8x8, 110, 172, OFFSET hudNumBuffer, 00FFFF00h + + invoke DrawString8x8, 175, 172, OFFSET textBet3D, 00FFD700h + invoke FormatNumber, slotBet, OFFSET hudNumBuffer + invoke DrawString8x8, 240, 172, OFFSET hudNumBuffer, 0050FF50h + + cmp slotWinAmount, 0 + jle draw_slot_ctrls + invoke DrawString8x8, 28, 187, OFFSET strWin, 00FFFF00h + invoke FormatNumber, slotWinAmount, OFFSET hudNumBuffer + invoke DrawString8x8, 110, 187, OFFSET hudNumBuffer, 00FFFF00h + +draw_slot_ctrls: + invoke DrawString8x8, 28, 204, OFFSET textSlotsKeys3D, 00A0A0A0h + ret +RenderSlotsGame ENDP + +DrawReelSymbolAt1 PROC + cmp eax, 0 + jne @F + invoke DrawString8x8, 52, 105, OFFSET sym7, 00FF2020h + ret +@@: + cmp eax, 1 + jne @F + invoke DrawString8x8, 52, 105, OFFSET symBar, 00FFAA00h + ret +@@: + cmp eax, 2 + jne @F + invoke DrawString8x8, 52, 105, OFFSET symBell, 00FFD700h + ret +@@: + cmp eax, 3 + jne @F + invoke DrawString8x8, 48, 105, OFFSET symCherry, 000000D0h + ret +@@: + cmp eax, 4 + jne @F + invoke DrawString8x8, 48, 105, OFFSET symClover, 0000A000h + ret +@@: + cmp eax, 5 + jne @F + invoke DrawString8x8, 52, 105, OFFSET symGem, 00FFFF00h + ret +@@: + invoke DrawString8x8, 52, 105, OFFSET symCrown, 00FFD700h + ret +DrawReelSymbolAt1 ENDP + +DrawReelSymbolAt2 PROC + cmp eax, 0 + jne @F + invoke DrawString8x8, 135, 105, OFFSET sym7, 00FF2020h + ret +@@: + cmp eax, 1 + jne @F + invoke DrawString8x8, 135, 105, OFFSET symBar, 00FFAA00h + ret +@@: + cmp eax, 2 + jne @F + invoke DrawString8x8, 135, 105, OFFSET symBell, 00FFD700h + ret +@@: + cmp eax, 3 + jne @F + invoke DrawString8x8, 131, 105, OFFSET symCherry, 000000D0h + ret +@@: + cmp eax, 4 + jne @F + invoke DrawString8x8, 131, 105, OFFSET symClover, 0000A000h + ret +@@: + cmp eax, 5 + jne @F + invoke DrawString8x8, 135, 105, OFFSET symGem, 00FFFF00h + ret +@@: + invoke DrawString8x8, 135, 105, OFFSET symCrown, 00FFD700h + ret +DrawReelSymbolAt2 ENDP + +DrawReelSymbolAt3 PROC + cmp eax, 0 + jne @F + invoke DrawString8x8, 218, 105, OFFSET sym7, 00FF2020h + ret +@@: + cmp eax, 1 + jne @F + invoke DrawString8x8, 218, 105, OFFSET symBar, 00FFAA00h + ret +@@: + cmp eax, 2 + jne @F + invoke DrawString8x8, 218, 105, OFFSET symBell, 00FFD700h + ret +@@: + cmp eax, 3 + jne @F + invoke DrawString8x8, 214, 105, OFFSET symCherry, 000000D0h + ret +@@: + cmp eax, 4 + jne @F + invoke DrawString8x8, 214, 105, OFFSET symClover, 0000A000h + ret +@@: + cmp eax, 5 + jne @F + invoke DrawString8x8, 218, 105, OFFSET symGem, 00FFFF00h + ret +@@: + invoke DrawString8x8, 218, 105, OFFSET symCrown, 00FFD700h + ret +DrawReelSymbolAt3 ENDP + +; ============================================================================== +; IN-ENGINE 2.5D MINI-GAME: BLACKJACK (21) +; ============================================================================== +HandleBlackjackInput PROC uses ebx + cmp bjState, 0 ; Need Deal + jne check_bj_player_turn + invoke Pressed3D, 20h ; SPACE -> Deal + test ah, 80h + jz check_bj_bet_change + mov eax, bankroll + cmp eax, bjBet + jl bj_need_cash + sub eax, bjBet + mov bankroll, eax + + ; Deal 2 cards to player, 2 cards to dealer + mov bjPlayerCardCount, 0 + mov bjDealerCardCount, 0 + mov bjDealerHideHole, 1 + + ; Player Card 1 + invoke RandomRange3D, 13 + inc eax + mov ebx, bjPlayerCardCount + mov [bjPlayerCards + ebx*4], eax + inc bjPlayerCardCount + + ; Dealer Card 1 + invoke RandomRange3D, 13 + inc eax + mov ebx, bjDealerCardCount + mov [bjDealerCards + ebx*4], eax + inc bjDealerCardCount + + ; Player Card 2 + invoke RandomRange3D, 13 + inc eax + mov ebx, bjPlayerCardCount + mov [bjPlayerCards + ebx*4], eax + inc bjPlayerCardCount + + ; Dealer Card 2 (Hole card) + invoke RandomRange3D, 13 + inc eax + mov ebx, bjDealerCardCount + mov [bjDealerCards + ebx*4], eax + inc bjDealerCardCount + + invoke PlayCasinoSound3D, OFFSET soundCards, 0, 1 + + ; Calc Player Score + call CalcPlayerBJScore + cmp bjPlayerScore, 21 + jne set_bj_turn + ; Instant Blackjack! + mov bjDealerHideHole, 0 + mov eax, bjBet + imul eax, 5 + shr eax, 1 + add bankroll, eax + invoke CopyString3D, OFFSET strWin, OFFSET bjOutcomeMsg + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + mov bjState, 2 + ret +set_bj_turn: + mov bjState, 1 + mov BYTE PTR [bjOutcomeMsg], 0 + ret + +bj_need_cash: + invoke CopyString3D, OFFSET msgNeedMoney, OFFSET flashMessage + mov flashTimer, 60 + ret + +check_bj_player_turn: + cmp bjState, 1 + jne check_bj_round_over + + invoke Pressed3D, 48h ; 'H' -> Hit + test ah, 80h + jz check_bj_stand + invoke RandomRange3D, 13 + inc eax + mov ebx, bjPlayerCardCount + cmp ebx, 8 + jge @F + mov [bjPlayerCards + ebx*4], eax + inc bjPlayerCardCount +@@: + invoke PlayCasinoSound3D, OFFSET soundCards, 0, 1 + call CalcPlayerBJScore + cmp bjPlayerScore, 21 + jle bj_input_done + ; Bust! + invoke CopyString3D, OFFSET strPlayerBust, OFFSET bjOutcomeMsg + mov bjDealerHideHole, 0 + mov bjState, 2 + ret + +check_bj_stand: + invoke Pressed3D, 53h ; 'S' -> Stand + test ah, 80h + jz bj_input_done + + ; Dealer Turn + mov bjDealerHideHole, 0 +dealer_loop: + call CalcDealerBJScore + cmp bjDealerScore, 17 + jge dealer_finished + invoke RandomRange3D, 13 + inc eax + mov ebx, bjDealerCardCount + cmp ebx, 8 + jge dealer_finished + mov [bjDealerCards + ebx*4], eax + inc bjDealerCardCount + jmp dealer_loop + +dealer_finished: + cmp bjDealerScore, 21 + jle compare_scores + ; Dealer Bust! + mov eax, bjBet + shl eax, 1 + add bankroll, eax + invoke CopyString3D, OFFSET strDealerBust, OFFSET bjOutcomeMsg + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + mov bjState, 2 + ret + +compare_scores: + mov eax, bjPlayerScore + cmp eax, bjDealerScore + jle check_dealer_won + ; Player Won! + mov eax, bjBet + shl eax, 1 + add bankroll, eax + invoke CopyString3D, OFFSET strWin, OFFSET bjOutcomeMsg + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + mov bjState, 2 + ret +check_dealer_won: + cmp eax, bjDealerScore + jl dealer_wins + ; Push (Tie) + mov eax, bjBet + add bankroll, eax + invoke CopyString3D, OFFSET strPush, OFFSET bjOutcomeMsg + mov bjState, 2 + ret +dealer_wins: + invoke CopyString3D, OFFSET strLose, OFFSET bjOutcomeMsg + mov bjState, 2 + ret + +check_bj_round_over: + invoke Pressed3D, 20h ; SPACE -> Next Hand + test ah, 80h + jz bj_input_done + mov bjState, 0 + ret + +check_bj_bet_change: + invoke Pressed3D, 26h ; UP + test ah, 80h + jz @F + cmp bjBet, 500 + jge bj_input_done + add bjBet, 50 + ret +@@: + invoke Pressed3D, 28h ; DOWN + test ah, 80h + jz bj_input_done + cmp bjBet, 50 + jle bj_input_done + sub bjBet, 50 + +bj_input_done: + ret +HandleBlackjackInput ENDP + +CalcPlayerBJScore PROC uses ebx esi + xor eax, eax + xor ebx, ebx + xor esi, esi +calc_p_loop: + cmp esi, bjPlayerCardCount + jge calc_p_done + mov edx, [bjPlayerCards + esi*4] + cmp edx, 10 + jle @F + mov edx, 10 +@@: + cmp edx, 1 + jne add_p_val + inc ebx ; count Aces + add eax, 11 + jmp next_p_card +add_p_val: + add eax, edx +next_p_card: + inc esi + jmp calc_p_loop +calc_p_done: + ; Soft Ace reduction +reduce_p_ace: + cmp eax, 21 + jle store_p_score + test ebx, ebx + jz store_p_score + sub eax, 10 + dec ebx + jmp reduce_p_ace +store_p_score: + mov bjPlayerScore, eax + ret +CalcPlayerBJScore ENDP + +CalcDealerBJScore PROC uses ebx esi + xor eax, eax + xor ebx, ebx + xor esi, esi +calc_d_loop: + cmp esi, bjDealerCardCount + jge calc_d_done + mov edx, [bjDealerCards + esi*4] + cmp edx, 10 + jle @F + mov edx, 10 +@@: + cmp edx, 1 + jne add_d_val + inc ebx + add eax, 11 + jmp next_d_card +add_d_val: + add eax, edx +next_d_card: + inc esi + jmp calc_d_loop +calc_d_done: +reduce_d_ace: + cmp eax, 21 + jle store_d_score + test ebx, ebx + jz store_d_score + sub eax, 10 + dec ebx + jmp reduce_d_ace +store_d_score: + mov bjDealerScore, eax + ret +CalcDealerBJScore ENDP + +RenderBlackjackGame PROC uses ebx esi edi + ; Emerald Felt Table Background + invoke DrawBox, 0, 0, SCREEN_W, SCREEN_H, 000A3015h + invoke DrawBoxBorder, 10, 10, 300, 220, 000D4018h, 00FFD700h, 3 + + ; Dealer Area Top + invoke DrawString8x8, 25, 20, OFFSET textBJ3D, 00FFD700h + invoke DrawString8x8, 25, 35, OFFSET textDealer3D, 00FFFFFFh + invoke FormatNumber, bjDealerScore, OFFSET hudNumBuffer + invoke DrawString8x8, 120, 35, OFFSET hudNumBuffer, 00FFFF00h + + ; Dealer Cards + xor esi, esi +draw_dealer_cards: + cmp esi, bjDealerCardCount + jge draw_player_bj_area + mov eax, esi + imul eax, 45 + add eax, 25 + mov ebx, eax + + cmp esi, 1 + jne draw_dealer_face + cmp bjDealerHideHole, 1 + jne draw_dealer_face + ; Face Down Card + mov eax, selectedBack3D + mov eax, cardBackColors3D[eax*4] + invoke DrawBoxBorder, ebx, 48, 38, 52, eax, 00FFFFFFh, 2 + jmp next_dealer_card_draw + +draw_dealer_face: + invoke DrawBoxBorder, ebx, 48, 38, 52, 00F0F0F5h, 00000000h, 2 + mov eax, [bjDealerCards + esi*4] + dec eax + imul eax, 3 + lea edx, [cardRankStr + eax] + mov eax, ebx + add eax, 8 + invoke DrawString8x8, eax, 68, edx, 00000000h + +next_dealer_card_draw: + inc esi + jmp draw_dealer_cards + +draw_player_bj_area: + ; Player Area Bottom + invoke DrawString8x8, 25, 110, OFFSET textPlayer3D, 00FFFFFFh + invoke FormatNumber, bjPlayerScore, OFFSET hudNumBuffer + invoke DrawString8x8, 120, 110, OFFSET hudNumBuffer, 0050FF50h + + ; Player Cards + xor esi, esi +draw_player_cards: + cmp esi, bjPlayerCardCount + jge draw_bj_footer + mov eax, esi + imul eax, 45 + add eax, 25 + mov ebx, eax + + invoke DrawBoxBorder, ebx, 124, 38, 52, 00F0F0F5h, 00000000h, 2 + mov eax, [bjPlayerCards + esi*4] + dec eax + imul eax, 3 + lea edx, [cardRankStr + eax] + mov eax, ebx + add eax, 8 + invoke DrawString8x8, eax, 144, edx, 00000000h + + inc esi + jmp draw_player_cards + +draw_bj_footer: + ; Footer Status & Controls + invoke DrawBoxBorder, 20, 182, 280, 42, 00102010h, 00FFD700h, 1 + cmp BYTE PTR [bjOutcomeMsg], 0 + je draw_bj_controls + invoke DrawString8x8, 28, 188, OFFSET bjOutcomeMsg, 00FFFF00h + invoke DrawString8x8, 28, 204, OFFSET textNext3D, 00A0A0A0h + ret + +draw_bj_controls: + invoke DrawString8x8, 28, 188, OFFSET textBJKeys3D, 00FFFFFFh + invoke DrawString8x8, 28, 204, OFFSET textDeal3D, 00A0A0A0h + ret +RenderBlackjackGame ENDP + +; ============================================================================== +; IN-ENGINE 2.5D MINI-GAME: ROULETTE +; ============================================================================== +HandleRouletteInput PROC uses ebx + cmp roulState, 1 + je roul_input_done + + invoke Pressed3D, 31h ; '1' -> RED + test ah, 80h + jz @F + mov roulBetType, 1 +@@: + invoke Pressed3D, 32h ; '2' -> BLACK + test ah, 80h + jz @F + mov roulBetType, 2 +@@: + invoke Pressed3D, 33h ; '3' -> ZERO (0) + test ah, 80h + jz @F + mov roulBetType, 3 +@@: + invoke Pressed3D, 34h ; '4' -> EVEN + test ah, 80h + jz @F + mov roulBetType, 4 +@@: + invoke Pressed3D, 35h ; '5' -> ODD + test ah, 80h + jz check_roul_spin + mov roulBetType, 5 + +check_roul_spin: + invoke Pressed3D, 20h ; SPACE -> Spin + test ah, 80h + jz roul_input_done + mov eax, bankroll + cmp eax, roulBetAmount + jl roul_no_cash + sub eax, roulBetAmount + mov bankroll, eax + mov roulState, 1 + mov roulSpinTimer, 50 + mov roulPayout, 0 + invoke PlayCasinoSound3D, OFFSET soundRoulette, 0, 1 + ret + +roul_no_cash: + invoke CopyString3D, OFFSET msgNeedMoney, OFFSET flashMessage + mov flashTimer, 60 + +roul_input_done: + ret +HandleRouletteInput ENDP + +RenderRouletteGame PROC uses ebx esi edi + ; Table felt background + invoke DrawBox, 0, 0, SCREEN_W, SCREEN_H, 00151525h + invoke DrawBoxBorder, 10, 10, 300, 220, 00201525h, 00FFD700h, 3 + + ; 2.5D Rotating Wheel on Left + invoke DrawCircle, 85, 110, 65, 00102550h + invoke DrawCircle, 85, 110, 60, 00FFD700h + invoke DrawCircle, 85, 110, 52, 00101010h + invoke DrawCircle, 85, 110, 22, 00FFD700h ; Center brass turret + + ; Spinning Wheel / Ball Logic + cmp roulState, 1 + jne draw_roul_ball + dec roulSpinTimer + add roulWheelAngle, 8 + sub roulBallAngle, 14 + cmp roulSpinTimer, 0 + jg draw_roul_ball + + ; Wheel stopped! Determine result! + mov roulState, 2 + invoke RandomRange3D, 37 + mov roulWinningNum, eax + + ; Check bet + cmp roulBetType, 1 ; RED + jne check_ro_black + call IsNumberRed + test eax, eax + jz ro_lost + mov eax, roulBetAmount + shl eax, 1 + mov roulPayout, eax + add bankroll, eax + invoke CopyString3D, OFFSET strWin, OFFSET roulOutcomeMsg + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + jmp draw_roul_ball + +check_ro_black: + cmp roulBetType, 2 ; BLACK + jne check_ro_zero + cmp roulWinningNum, 0 + je ro_lost + call IsNumberRed + test eax, eax + jnz ro_lost + mov eax, roulBetAmount + shl eax, 1 + mov roulPayout, eax + add bankroll, eax + invoke CopyString3D, OFFSET strWin, OFFSET roulOutcomeMsg + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + jmp draw_roul_ball + +check_ro_zero: + cmp roulBetType, 3 ; ZERO + jne check_ro_even + cmp roulWinningNum, 0 + jne ro_lost + mov eax, roulBetAmount + imul eax, 36 + mov roulPayout, eax + add bankroll, eax + invoke CopyString3D, OFFSET strJackpot, OFFSET roulOutcomeMsg + invoke PlayCasinoSound3D, OFFSET soundJackpot, 0, 1 + jmp draw_roul_ball + +check_ro_even: + cmp roulBetType, 4 ; EVEN + jne check_ro_odd + mov eax, roulWinningNum + test eax, eax + jz ro_lost + test al, 1 + jnz ro_lost + mov eax, roulBetAmount + shl eax, 1 + mov roulPayout, eax + add bankroll, eax + invoke CopyString3D, OFFSET strWin, OFFSET roulOutcomeMsg + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + jmp draw_roul_ball + +check_ro_odd: + mov eax, roulWinningNum + test eax, eax + jz ro_lost + test al, 1 + jz ro_lost + mov eax, roulBetAmount + shl eax, 1 + mov roulPayout, eax + add bankroll, eax + invoke CopyString3D, OFFSET strWin, OFFSET roulOutcomeMsg + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + jmp draw_roul_ball + +ro_lost: + invoke CopyString3D, OFFSET strLose, OFFSET roulOutcomeMsg + +draw_roul_ball: + ; Draw White Ball on Rim + mov eax, roulBallAngle + and eax, 511 + mov ebx, [tableCos + eax*4] + imul ebx, 42 + sar ebx, 16 + add ebx, 85 + + mov eax, roulBallAngle + and eax, 511 + mov edx, [tableSin + eax*4] + imul edx, 42 + sar edx, 16 + add edx, 110 + invoke DrawCircle, ebx, edx, 3, 00FFFFFFh + + ; Right Betting Board + invoke DrawBoxBorder, 175, 25, 125, 28, 001010C0h, 00FFFFFFh, 2 ; [1] RED + invoke DrawString8x8, 190, 35, OFFSET textRed3D, 00FFFFFFh + + invoke DrawBoxBorder, 175, 60, 125, 28, 00151515h, 00FFFFFFh, 2 ; [2] BLACK + invoke DrawString8x8, 190, 70, OFFSET textBlack3D, 00FFFFFFh + + invoke DrawBoxBorder, 175, 95, 125, 28, 00106010h, 00FFFFFFh, 2 ; [3] ZERO + invoke DrawString8x8, 190, 105, OFFSET textZero3D, 00FFFFFFh + + invoke DrawBoxBorder, 175, 130, 60, 26, 00302020h, 00FFFFFFh, 1 ; [4] EVEN + invoke DrawString8x8, 185, 139, OFFSET textEven3D, 00FFFFFFh + + invoke DrawBoxBorder, 240, 130, 60, 26, 00302020h, 00FFFFFFh, 1 ; [5] ODD + invoke DrawString8x8, 250, 139, OFFSET textOdd3D, 00FFFFFFh + + ; Highlight Active Bet + cmp roulBetType, 1 + jne @F + invoke DrawBoxBorder, 173, 23, 129, 32, 0, 00FFFF00h, 2 +@@: + cmp roulBetType, 2 + jne @F + invoke DrawBoxBorder, 173, 58, 129, 32, 0, 00FFFF00h, 2 +@@: + cmp roulBetType, 3 + jne @F + invoke DrawBoxBorder, 173, 93, 129, 32, 0, 00FFFF00h, 2 +@@: + cmp roulBetType, 4 + jne @F + invoke DrawBoxBorder, 173, 128, 64, 30, 0, 00FFFF00h, 2 +@@: + cmp roulBetType, 5 + jne draw_ro_footer + invoke DrawBoxBorder, 238, 128, 64, 30, 0, 00FFFF00h, 2 + +draw_ro_footer: + invoke DrawBoxBorder, 20, 180, 280, 42, 00101015h, 00FFD700h, 1 + + cmp roulState, 2 + jne @F + invoke DrawString8x8, 28, 186, OFFSET textResult3D, 00FFD700h + invoke FormatNumber, roulWinningNum, OFFSET hudNumBuffer + invoke DrawString8x8, 85, 186, OFFSET hudNumBuffer, 00FFFF00h + invoke DrawString8x8, 130, 186, OFFSET roulOutcomeMsg, 0050FF50h +@@: + invoke DrawString8x8, 28, 202, OFFSET textSpin3D, 00A0A0A0h + ret +RenderRouletteGame ENDP + +IsNumberRed PROC + mov eax, roulWinningNum + cmp eax, 1 + je red_yes + cmp eax, 3 + je red_yes + cmp eax, 5 + je red_yes + cmp eax, 7 + je red_yes + cmp eax, 9 + je red_yes + cmp eax, 12 + je red_yes + cmp eax, 14 + je red_yes + cmp eax, 16 + je red_yes + cmp eax, 18 + je red_yes + cmp eax, 19 + je red_yes + cmp eax, 21 + je red_yes + cmp eax, 23 + je red_yes + cmp eax, 25 + je red_yes + cmp eax, 27 + je red_yes + cmp eax, 30 + je red_yes + cmp eax, 32 + je red_yes + cmp eax, 34 + je red_yes + cmp eax, 36 + je red_yes + xor eax, eax + ret +red_yes: + mov eax, 1 + ret +IsNumberRed ENDP + +; ============================================================================== +; IN-ENGINE 2.5D MINI-GAME: BAR & SHOP +; ============================================================================== +HandleShopInput PROC uses ebx esi + xor esi, esi +shop_choice: + inc esi + lea eax, [esi+30h] + invoke Pressed3D, eax + test eax, eax + jnz shop_chosen + cmp esi, 3 + jb shop_choice + ret +shop_chosen: + bt ownedBacks3D, esi + jc shop_equip + mov ebx, 1500 + cmp esi, 1 + jne @F + mov ebx, 1000 +@@: + cmp bankroll, ebx + jb shop_no_money + sub bankroll, ebx + bts ownedBacks3D, esi +shop_equip: + mov selectedBack3D, esi + invoke CopyString3D, OFFSET textBought3D, OFFSET shopMsg + call SaveProgress3D + ret +shop_no_money: + invoke CopyString3D, OFFSET textNoCash3D, OFFSET shopMsg + ret +HandleShopInput ENDP + +RenderShopGame PROC + invoke DrawBox, 0, 0, SCREEN_W, SCREEN_H, 00150A0Ah + invoke DrawBoxBorder, 10, 10, 300, 220, 00251515h, 00FFD700h, 3 + invoke DrawString8x8, 25, 20, OFFSET textShop3D, 00FFD700h + + invoke DrawBoxBorder, 20, 40, 280, 32, 001A1010h, 00FFFFFFh, 1 + invoke DrawString8x8, 28, 46, OFFSET textItem1_3D, 00FFFF00h + invoke DrawString8x8, 28, 58, OFFSET textShopHint3D, 00A0A0A0h + + invoke DrawBoxBorder, 20, 80, 280, 32, 001A1010h, 00FFFFFFh, 1 + invoke DrawString8x8, 28, 86, OFFSET textItem2_3D, 00FFFF00h + invoke DrawString8x8, 28, 98, OFFSET textShopHint3D, 00A0A0A0h + + invoke DrawBoxBorder, 20, 120, 280, 32, 001A1010h, 00FFFFFFh, 1 + invoke DrawString8x8, 28, 126, OFFSET textItem3_3D, 00FFFF00h + invoke DrawString8x8, 28, 138, OFFSET textShopHint3D, 00A0A0A0h + + invoke DrawBoxBorder, 20, 165, 280, 55, 00100A0Ah, 00FFD700h, 1 + invoke DrawString8x8, 28, 172, OFFSET textBank3D, 00FFD700h + invoke FormatNumber, bankroll, OFFSET hudNumBuffer + invoke DrawString8x8, 110, 172, OFFSET hudNumBuffer, 00FFFF00h + + cmp BYTE PTR [shopMsg], 0 + je @F + invoke DrawString8x8, 28, 188, OFFSET shopMsg, 0050FF50h +@@: + invoke DrawString8x8, 28, 204, OFFSET textBack3D, 00A0A0A0h + ret +RenderShopGame ENDP + +; ============================================================================== +; IN-ENGINE 2.5D MINI-GAME: ATM TERMINAL +; ============================================================================== +HandleATMInput PROC + call HandleTerminal3D + ret +HandleATMInput ENDP + +RenderATMGame PROC + call RenderTerminal3D + ret +RenderATMGame ENDP + +; ============================================================================== +; ============================================================================== +; ============================================================================== +; SHARED RICH UI PROCEDURES +; ============================================================================== +DrawKeycap3D PROC uses ebx esi edi, x:DWORD, y:DWORD, strPtr:DWORD, isActive:DWORD + local keyW:DWORD + mov esi, strPtr + xor ecx, ecx +keycap_len: + mov al, [esi+ecx] + test al, al + jz keycap_len_done + inc ecx + jmp keycap_len +keycap_len_done: + shl ecx, 3 + add ecx, 8 + mov keyW, ecx + + ; Drop shadow + mov eax, y + add eax, 2 + invoke DrawBox, x, eax, keyW, 13, 0008080Ch + + ; Border and Fill + cmp isActive, 0 + je keycap_inactive + mov eax, 00FFFF00h ; Bright Yellow active border + mov edx, 001B4B22h ; Casino Green active fill + mov ebx, 00FFFF00h ; Bright Yellow active text + jmp keycap_draw_box +keycap_inactive: + mov eax, 00606870h ; Slate inactive border + mov edx, 001A1C22h ; Charcoal inactive fill + mov ebx, 00D0D8E0h ; Silver inactive text + +keycap_draw_box: + push ebx + invoke DrawBoxBorder, x, y, keyW, 13, edx, eax, 1 + pop ebx + + ; Text label + mov eax, x + add eax, 4 + mov edx, y + add edx, 3 + invoke DrawString8x8, eax, edx, strPtr, ebx + + mov eax, keyW + add eax, 4 + ret +DrawKeycap3D ENDP + +DrawChipStack PROC uses ebx esi edi, x:DWORD, y:DWORD, chipCount:DWORD + mov edi, chipCount + xor esi, esi +chip_loop: + cmp esi, edi + jge chip_done + mov eax, esi + shl eax, 2 + mov edx, y + sub edx, eax + + ; Shadow + mov eax, x + add eax, 2 + mov ecx, edx + add ecx, 5 + invoke DrawBox, eax, ecx, 20, 2, 00061004h + + ; Red Clay Chip body with white rim + invoke DrawBoxBorder, x, edx, 24, 6, 00B81515h, 00FFFFFFh, 1 + + ; White stripe inlays + mov eax, x + add eax, 4 + mov ecx, edx + add ecx, 1 + invoke DrawBox, eax, ecx, 3, 4, 00FFFFFFh + + mov eax, x + add eax, 17 + mov ecx, edx + add ecx, 1 + invoke DrawBox, eax, ecx, 3, 4, 00FFFFFFh + + inc esi + jmp chip_loop +chip_done: + ret +DrawChipStack ENDP + +DrawDetailedCoin PROC uses ebx esi edi, cxVal:DWORD, cyVal:DWORD, rxVal:DWORD, ryVal:DWORD, outerColor:DWORD, innerColor:DWORD, reliefType:DWORD + local rxSq:DWORD + local rySq:DWORD + local rxRySq:DWORD + local threshSq:DWORD + local curDy:DWORD + local curDx:DWORD + local curX:DWORD + local curY:DWORD + + mov eax, rxVal + cmp eax, 0 + jle coin_draw_done + mov eax, ryVal + cmp eax, 0 + jle coin_draw_done + + mov eax, rxVal + imul eax, rxVal + mov rxSq, eax + + mov eax, ryVal + imul eax, ryVal + mov rySq, eax + + imul eax, rxSq + mov rxRySq, eax + + ; 3/4 threshold for rim bevel + mov ecx, 3 + imul eax, ecx + shr eax, 2 + mov threshSq, eax + + ; Scan rows + mov eax, ryVal + neg eax + mov curDy, eax +coin_row_loop: + mov eax, curDy + cmp eax, ryVal + jg coin_relief_check + + mov edx, cyVal + add edx, curDy + mov curY, edx + + ; Scan columns + mov eax, rxVal + neg eax + mov curDx, eax +coin_col_loop: + mov eax, curDx + cmp eax, rxVal + jg coin_col_next_row + + mov ecx, cxVal + add ecx, curDx + mov curX, ecx + + ; val = dx*dx*rySq + dy*dy*rxSq + mov eax, curDx + imul eax, curDx + imul eax, rySq + mov ebx, eax + + mov eax, curDy + imul eax, curDy + imul eax, rxSq + add eax, ebx + + cmp eax, rxRySq + ja coin_pixel_outside + + cmp eax, threshSq + jb coin_draw_inner + invoke DrawPixel, curX, curY, outerColor + jmp coin_pixel_outside +coin_draw_inner: + invoke DrawPixel, curX, curY, innerColor + +coin_pixel_outside: + inc curDx + jmp coin_col_loop + +coin_col_next_row: + inc curDy + jmp coin_row_loop + +coin_relief_check: + cmp rxVal, 14 + jl coin_draw_done + + cmp reliefType, 1 + je coin_draw_eagle + cmp reliefType, 2 + je coin_draw_numeral + jmp coin_draw_done + +coin_draw_eagle: + ; Imperial Eagle relief (Dark Gold 009A7A00h / Bright 00FFD700h) + mov eax, cxVal + sub eax, 3 + mov edx, cyVal + sub edx, 14 + invoke DrawBox, eax, edx, 7, 2, 009A7A00h + + mov eax, cxVal + sub eax, 4 + mov edx, cyVal + sub edx, 12 + invoke DrawBox, eax, edx, 9, 2, 009A7A00h + + mov eax, cxVal + sub eax, 2 + mov edx, cyVal + sub edx, 9 + invoke DrawBox, eax, edx, 5, 12, 009A7A00h + + mov eax, cxVal + sub eax, 1 + mov edx, cyVal + sub edx, 8 + invoke DrawBox, eax, edx, 3, 10, 00FFD700h + + mov eax, cxVal + sub eax, 10 + mov edx, cyVal + sub edx, 8 + invoke DrawBox, eax, edx, 7, 3, 009A7A00h + + mov eax, cxVal + sub eax, 13 + mov edx, cyVal + sub edx, 5 + invoke DrawBox, eax, edx, 10, 3, 009A7A00h + + mov eax, cxVal + sub eax, 11 + mov edx, cyVal + sub edx, 2 + invoke DrawBox, eax, edx, 7, 3, 009A7A00h + + mov eax, cxVal + add eax, 4 + mov edx, cyVal + sub edx, 8 + invoke DrawBox, eax, edx, 7, 3, 009A7A00h + + mov eax, cxVal + add eax, 4 + mov edx, cyVal + sub edx, 5 + invoke DrawBox, eax, edx, 10, 3, 009A7A00h + + mov eax, cxVal + add eax, 5 + mov edx, cyVal + sub edx, 2 + invoke DrawBox, eax, edx, 7, 3, 009A7A00h + + mov eax, cxVal + sub eax, 4 + mov edx, cyVal + add edx, 4 + invoke DrawBox, eax, edx, 9, 3, 009A7A00h + + mov eax, cxVal + sub eax, 3 + mov edx, cyVal + add edx, 7 + invoke DrawBox, eax, edx, 7, 3, 009A7A00h + jmp coin_draw_done + +coin_draw_numeral: + ; Roman numeral 'I' & laurel + mov eax, cxVal + sub eax, 5 + mov edx, cyVal + sub edx, 10 + invoke DrawBox, eax, edx, 11, 3, 009A7A00h + + mov eax, cxVal + sub eax, 2 + mov edx, cyVal + sub edx, 7 + invoke DrawBox, eax, edx, 5, 14, 009A7A00h + + mov eax, cxVal + sub eax, 1 + mov edx, cyVal + sub edx, 6 + invoke DrawBox, eax, edx, 3, 12, 00FFD700h + + mov eax, cxVal + sub eax, 6 + mov edx, cyVal + add edx, 7 + invoke DrawBox, eax, edx, 13, 3, 009A7A00h + + ; Laurel dots + mov eax, cxVal + sub eax, 12 + mov edx, cyVal + sub edx, 8 + invoke DrawBox, eax, edx, 2, 2, 009A7A00h + + mov eax, cxVal + add eax, 11 + mov edx, cyVal + sub edx, 8 + invoke DrawBox, eax, edx, 2, 2, 009A7A00h + + mov eax, cxVal + sub eax, 12 + mov edx, cyVal + invoke DrawBox, eax, edx, 2, 2, 009A7A00h + + mov eax, cxVal + add eax, 11 + mov edx, cyVal + invoke DrawBox, eax, edx, 2, 2, 009A7A00h + + mov eax, cxVal + sub eax, 12 + mov edx, cyVal + add edx, 8 + invoke DrawBox, eax, edx, 2, 2, 009A7A00h + + mov eax, cxVal + add eax, 11 + mov edx, cyVal + add edx, 8 + invoke DrawBox, eax, edx, 2, 2, 009A7A00h + +coin_draw_done: + ret +DrawDetailedCoin ENDP + +; ============================================================================== +; IN-ENGINE 2.5D MINI-GAME: COIN FLIP +; ============================================================================== +InitCoinGame PROC + call InitNativeCoin3D + ret +InitCoinGame ENDP + +HandleCoinInput PROC + call HandleNativeCoin3D + ret +; Retained legacy frame-count prototype, excluded from the executable. +IF 0 + cmp coin3d_state, 0 + je coin_handle_idle + cmp coin3d_state, 1 + je coin_handle_flipping + cmp coin3d_state, 2 + je coin_handle_result + ret + +coin_handle_idle: + invoke Pressed3D, 26h ; UP + test eax, eax + jnz coin_bet_up + invoke Pressed3D, 57h ; 'W' + test eax, eax + jnz coin_bet_up + invoke Pressed3D, 28h ; DOWN + test eax, eax + jnz coin_bet_down + invoke Pressed3D, 53h ; 'S' + test eax, eax + jnz coin_bet_down + invoke Pressed3D, 31h ; '1' + test eax, eax + jnz coin_pick_1 + invoke Pressed3D, 32h ; '2' + test eax, eax + jnz coin_pick_2 + invoke Pressed3D, 20h ; SPACE + test eax, eax + jnz coin_start_flip + ret + +coin_bet_up: + mov eax, coin3d_bet + add eax, 50 + cmp eax, bankroll + jle @F + mov eax, bankroll +@@: + cmp eax, 5000 + jle @F + mov eax, 5000 +@@: + mov coin3d_bet, eax + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +coin_bet_down: + mov eax, coin3d_bet + sub eax, 50 + cmp eax, 50 + jge @F + mov eax, 50 +@@: + mov coin3d_bet, eax + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +coin_pick_1: + mov coin3d_choice, 1 + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +coin_pick_2: + mov coin3d_choice, 2 + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +coin_start_flip: + mov eax, coin3d_bet + cmp eax, bankroll + jle @F + mov eax, bankroll + mov coin3d_bet, eax + test eax, eax + jz coin_done +@@: + mov eax, coin3d_bet + sub bankroll, eax + mov coin3d_state, 1 + mov coin3d_timer, 40 + invoke PlayCasinoSound3D, OFFSET soundCoin, 0, 1 + ret + +coin_handle_flipping: + dec coin3d_timer + cmp coin3d_timer, 0 + jg coin_done + invoke RandomRange3D, 2 + inc eax + mov coin3d_result, eax + mov edx, coin3d_choice + cmp eax, edx + jne coin_flip_lost + + ; Won! + inc coin3d_streak + mov eax, coin3d_bet + shl eax, 1 + add bankroll, eax + mov coin3d_win, eax + mov coin3d_state, 2 + invoke PlayCasinoSound3D, OFFSET soundCoinDing, 0, 1 + ret + +coin_flip_lost: + mov coin3d_streak, 0 + mov coin3d_win, 0 + mov coin3d_state, 2 + invoke PlayCasinoSound3D, OFFSET soundLose, 0, 1 + ret + +coin_handle_result: + invoke Pressed3D, 20h + test eax, eax + jz coin_done + mov coin3d_state, 0 + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 +coin_done: + ret +ENDIF +HandleCoinInput ENDP + +RenderCoinGame PROC uses ebx esi edi + local cyVal:DWORD + local rxVal:DWORD + local kx:DWORD + + call RenderNativeCoin3D + ret +IF 0 + ; Background & Cabinet border + invoke DrawBox, 0, 0, 320, 240, 00140906h + invoke DrawBoxBorder, 6, 6, 308, 228, 0022150Fh, 00482E1Bh, 3 + + ; Header + invoke DrawBoxBorder, 20, 12, 280, 26, 001C100Ah, 00FFD700h, 2 + invoke DrawString8x8, 44, 21, OFFSET textCoinTitle, 00FFFF00h + + ; Corner rivets + invoke DrawBox, 12, 12, 3, 3, 00FFD700h + invoke DrawBox, 306, 12, 3, 3, 00FFD700h + invoke DrawBox, 12, 226, 3, 3, 00FFD700h + invoke DrawBox, 306, 226, 3, 3, 00FFD700h + + ; Status meters + invoke DrawBoxBorder, 20, 44, 110, 18, 000E1A0Ah, 00224B1Ah, 1 + invoke DrawString8x8, 24, 49, OFFSET textBankPrompt, 003CFF3Ch + invoke FormatNumber, bankroll, OFFSET hudNumBuffer + invoke DrawString8x8, 72, 49, OFFSET hudNumBuffer, 003CFF3Ch + + invoke DrawBoxBorder, 190, 44, 110, 18, 001A100Ah, 003A2814h, 1 + invoke DrawString8x8, 194, 49, OFFSET textBetPrompt, 00FFD700h + invoke FormatNumber, coin3d_bet, OFFSET hudNumBuffer + invoke DrawString8x8, 254, 49, OFFSET hudNumBuffer, 00FFD700h + + ; Left: Heads + cmp coin3d_choice, 1 + jne coin_left_inactive + invoke DrawBoxBorder, 20, 72, 76, 68, 00101828h, 00FFFF00h, 2 + invoke DrawString8x8, 30, 78, OFFSET textCoinSide1, 00FFFF00h + invoke DrawDetailedCoin, 58, 106, 14, 14, 00D0A000h, 00FFD700h, 1 + invoke DrawString8x8, 24, 126, OFFSET textCoinSelected, 003CFF3Ch + jmp coin_right_side +coin_left_inactive: + invoke DrawBoxBorder, 20, 72, 76, 68, 000A101Ch, 00404855h, 1 + invoke DrawString8x8, 30, 78, OFFSET textCoinSide1, 00D0D8E0h + invoke DrawDetailedCoin, 58, 106, 14, 14, 009A7A00h, 00D0A000h, 1 + +coin_right_side: + ; Right: Tails + cmp coin3d_choice, 2 + jne coin_right_inactive + invoke DrawBoxBorder, 224, 72, 76, 68, 00101828h, 00FFFF00h, 2 + invoke DrawString8x8, 234, 78, OFFSET textCoinSide2, 00FFFF00h + invoke DrawDetailedCoin, 262, 106, 14, 14, 00D0A000h, 00FFD700h, 2 + invoke DrawString8x8, 228, 126, OFFSET textCoinSelected, 003CFF3Ch + jmp coin_center_area +coin_right_inactive: + invoke DrawBoxBorder, 224, 72, 76, 68, 000A101Ch, 00404855h, 1 + invoke DrawString8x8, 234, 78, OFFSET textCoinSide2, 00D0D8E0h + invoke DrawDetailedCoin, 262, 106, 14, 14, 009A7A00h, 00D0A000h, 2 + +coin_center_area: + ; Center spotlight + invoke DrawCircle, 160, 110, 48, 00121620h + invoke DrawCircle, 160, 110, 44, 00FFD700h + invoke DrawCircle, 160, 110, 42, 000E141Eh + + cmp coin3d_state, 1 + je coin_render_flipping + cmp coin3d_state, 2 + je coin_render_result + + ; Idle coin + invoke DrawDetailedCoin, 160, 110, 26, 26, 00D0A000h, 00FFD700h, coin3d_choice + jmp coin_render_keys + +coin_render_flipping: + mov eax, coin3d_timer + and eax, 7 + movzx eax, byte ptr [coinRxAnimTable + eax] + mov rxVal, eax + invoke DrawDetailedCoin, 160, 110, rxVal, 26, 00D0A000h, 00FFD700h, 0 + invoke DrawString8x8, 88, 160, OFFSET textCoinFlipping, 00FFFF00h + jmp coin_render_keys + +coin_render_result: + invoke DrawDetailedCoin, 160, 110, 26, 26, 00D0A000h, 00FFD700h, coin3d_result + mov eax, coin3d_result + cmp eax, coin3d_choice + jne coin_render_loss_msg + + ; Win banner + invoke DrawBoxBorder, 44, 154, 232, 22, 000E141Eh, 003CFF3Ch, 1 + invoke DrawString8x8, 64, 161, OFFSET textCoinWin, 003CFF3Ch + invoke FormatNumber, coin3d_win, OFFSET hudNumBuffer + invoke DrawString8x8, 152, 161, OFFSET hudNumBuffer, 003CFF3Ch + jmp coin_render_keys + +coin_render_loss_msg: + invoke DrawBoxBorder, 44, 154, 232, 22, 000E141Eh, 00C81414h, 1 + invoke DrawString8x8, 114, 161, OFFSET textCoinLose, 00FF6464h + +coin_render_keys: + mov kx, 16 + xor eax, eax + cmp coin3d_choice, 1 + sete al + invoke DrawKeycap3D, kx, 192, OFFSET textCoinKey1, eax + add kx, eax + + xor eax, eax + cmp coin3d_choice, 2 + sete al + invoke DrawKeycap3D, kx, 192, OFFSET textCoinKey2, eax + add kx, eax + + invoke DrawKeycap3D, kx, 192, OFFSET textCoinKeySpace, 1 + add kx, eax + + invoke DrawKeycap3D, kx, 192, OFFSET textKeyEsc, 0 + ret +ENDIF +RenderCoinGame ENDP + +; ============================================================================== +; IN-ENGINE 2.5D MINI-GAME: CRAPS / DICE +; ============================================================================== +DrawCrapsDie PROC uses ebx esi edi, x:DWORD, y:DWORD, sizeVal:DWORD, valNum:DWORD + ; Drop shadow + mov eax, x + add eax, 3 + mov edx, y + add edx, sizeVal + invoke DrawBox, eax, edx, sizeVal, 3, 00081403h + + mov eax, x + add eax, sizeVal + mov edx, y + add edx, 3 + invoke DrawBox, eax, edx, 3, sizeVal, 00081403h + + ; Ivory body & bevel + invoke DrawBoxBorder, x, y, sizeVal, sizeVal, 00FAF4F0h, 00403535h, 1 + mov eax, x + inc eax + mov edx, y + inc edx + mov ecx, sizeVal + sub ecx, 2 + invoke DrawBox, eax, edx, ecx, 1, 00FFFFFFh + invoke DrawBox, eax, edx, 1, ecx, 00FFFFFFh + + ; Ruby pips (00C81515h) + mov eax, valNum + test al, 1 + jz @F + ; Center pip + mov eax, x + add eax, 18 + mov edx, y + add edx, 18 + invoke DrawCircle, eax, edx, 3, 00C81515h + dec eax + dec edx + invoke DrawPixel, eax, edx, 00FFFFFFh +@@: + cmp valNum, 2 + jl die_pips_done + mov eax, x + add eax, 9 + mov edx, y + add edx, 9 + invoke DrawCircle, eax, edx, 3, 00C81515h + mov eax, x + add eax, 27 + mov edx, y + add edx, 27 + invoke DrawCircle, eax, edx, 3, 00C81515h + + cmp valNum, 4 + jl die_pips_done + mov eax, x + add eax, 27 + mov edx, y + add edx, 9 + invoke DrawCircle, eax, edx, 3, 00C81515h + mov eax, x + add eax, 9 + mov edx, y + add edx, 27 + invoke DrawCircle, eax, edx, 3, 00C81515h + + cmp valNum, 6 + jl die_pips_done + mov eax, x + add eax, 9 + mov edx, y + add edx, 18 + invoke DrawCircle, eax, edx, 3, 00C81515h + mov eax, x + add eax, 27 + mov edx, y + add edx, 18 + invoke DrawCircle, eax, edx, 3, 00C81515h + +die_pips_done: + ret +DrawCrapsDie ENDP + +InitDiceGame PROC + call LoadNativeDiceArt3D + mov diceExitQueued3D,0 + mov dice3d_state, 0 + mov dice3d_timer, 0 + mov dice3d_win, 0 + ret +InitDiceGame ENDP + +HandleDiceRules3D PROC + cmp dice3d_state, 0 + je dice_handle_idle + cmp dice3d_state, 1 + je dice_handle_rolling + cmp dice3d_state, 2 + je dice_handle_result + ret + +dice_handle_idle: + invoke Pressed3D, 26h ; UP + test eax, eax + jnz dice_bet_up + invoke Pressed3D, 57h ; 'W' + test eax, eax + jnz dice_bet_up + invoke Pressed3D, 28h ; DOWN + test eax, eax + jnz dice_bet_down + invoke Pressed3D, 53h ; 'S' + test eax, eax + jnz dice_bet_down + invoke Pressed3D, 31h ; '1' + test eax, eax + jnz dice_pick_1 + invoke Pressed3D, 32h ; '2' + test eax, eax + jnz dice_pick_2 + invoke Pressed3D, 20h ; SPACE + test eax, eax + jnz dice_start_roll + ret + +dice_bet_up: + mov eax, dice3d_bet + add eax, 50 + cmp eax, bankroll + jle @F + mov eax, bankroll +@@: + cmp eax, 5000 + jle @F + mov eax, 5000 +@@: + mov dice3d_bet, eax + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +dice_bet_down: + mov eax, dice3d_bet + sub eax, 50 + cmp eax, 50 + jge @F + mov eax, 50 +@@: + mov dice3d_bet, eax + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +dice_pick_1: + mov dice3d_choice, 1 + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +dice_pick_2: + mov dice3d_choice, 2 + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +dice_start_roll: + mov eax, dice3d_bet + cmp eax, bankroll + jle @F + mov eax, bankroll + mov dice3d_bet, eax + test eax, eax + jz dice_done +@@: + mov eax, dice3d_bet + test eax, eax + jle dice_done + sub bankroll, eax + mov dice3d_state, 1 + mov dice3d_timer, 0 + invoke RandomRange3D, 6 + inc eax + mov dice3d_val1, eax + invoke RandomRange3D, 6 + inc eax + mov dice3d_val2, eax + call BackroomsLuck3D + cmp eax,-1 + je br_dice_fixed + xor eax,1 + mov ecx,dice3d_choice + dec ecx + xor eax,ecx + mov edx,dice3d_val1 + add edx,dice3d_val2 + and edx,1 + cmp eax,edx + je br_dice_fixed + xor edx,edx + mov eax,dice3d_val2 + mov ecx,6 + div ecx + inc edx + mov dice3d_val2,edx +br_dice_fixed: + invoke PlayCasinoSound3D, OFFSET soundDiceRoll, 0, 1 + call SaveProgress3D + ret + +dice_handle_rolling: + mov eax, deltaTime3D + add dice3d_timer, eax + cmp dice3d_timer, 1600 + jb dice_done + mov dice3d_timer, 1600 + mov eax, dice3d_val2 + mov edx, dice3d_val1 + add edx, eax + mov dice3d_sum, edx + + ; Parity check + mov eax, edx + and eax, 1 + jnz dice_sum_is_odd + ; Even + mov eax, 1 + jmp dice_check_win +dice_sum_is_odd: + mov eax, 2 + +dice_check_win: + cmp eax, dice3d_choice + jne dice_roll_lost + + ; Won! + mov eax, dice3d_bet + shl eax, 1 + add bankroll, eax + mov dice3d_win, eax + invoke TriggerCharmWinBonus,dice3d_bet + mov dice3d_state, 2 + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + invoke NpcRecordRound3D,8,1 + call SaveProgress3D + ret + +dice_roll_lost: + mov dice3d_win, 0 + mov dice3d_state, 2 + invoke TriggerCharmLossProtection, dice3d_bet + test eax, eax + jnz @F + invoke PlayCasinoSound3D, OFFSET soundLose, 0, 1 +@@: + invoke NpcRecordRound3D,8,0 + call SaveProgress3D + ret + +dice_handle_result: + cmp tournamentMode, 1 + jne @F + invoke Pressed3D, 20h + test eax, eax + jnz dice_tourney_report + invoke Pressed3D, 0Dh + test eax, eax + jnz dice_tourney_report + ret +dice_tourney_report: + cmp dice3d_win, 0 + je dice_tourney_loss + invoke TowerReportRoundOutcome, 1 + ret +dice_tourney_loss: + invoke TowerReportRoundOutcome, 2 + ret +@@: + invoke Pressed3D, 20h + test eax, eax + jz dice_done + mov dice3d_state, 0 + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 +dice_done: + ret +HandleDiceRules3D ENDP + +RenderDiceGame PROC + call RenderNativeDice3D + ret +RenderDiceGame ENDP + +; ============================================================================== +; IN-ENGINE 2.5D MINI-GAME: SKULLS & CUPS (ÍÀϨÐÑÒÊÈ) +; ============================================================================== +DrawGlowingOrb PROC uses ebx esi edi, cxVal:DWORD, cyVal:DWORD + invoke DrawCircle, cxVal, cyVal, 14, 002E1E08h + invoke DrawCircle, cxVal, cyVal, 11, 00583A10h + invoke DrawCircle, cxVal, cyVal, 8, 008A581Ah + invoke DrawCircle, cxVal, cyVal, 6, 00D0B000h + invoke DrawCircle, cxVal, cyVal, 4, 00FFE000h + mov eax, cxVal + dec eax + mov edx, cyVal + dec edx + invoke DrawCircle, eax, edx, 2, 00FFFF80h + dec eax + dec edx + invoke DrawPixel, eax, edx, 00FFFFFFh + ret +DrawGlowingOrb ENDP + +DrawGothicCup PROC uses ebx esi edi, x:DWORD, y:DWORD, cupId:DWORD, isLifted:DWORD, hasBall:DWORD + local liftY:DWORD + + mov eax, y + cmp isLifted, 0 + je @F + sub eax, 36 +@@: + mov liftY, eax + + ; Drop shadow + cmp isLifted, 0 + jne cup_shadow_lifted + mov eax, x + add eax, 6 + mov edx, y + add edx, 42 + invoke DrawBox, eax, edx, 36, 4, 0010040Ah + jmp cup_ball_check +cup_shadow_lifted: + mov eax, x + add eax, 10 + mov edx, y + add edx, 42 + invoke DrawBox, eax, edx, 28, 2, 001A0612h + +cup_ball_check: + cmp isLifted, 0 + je cup_body_draw + cmp hasBall, 0 + je cup_body_draw + mov eax, x + add eax, 24 + mov edx, y + add edx, 26 + invoke DrawGlowingOrb, eax, edx + +cup_body_draw: + ; Base pedestal + mov eax, x + add eax, 6 + mov edx, liftY + add edx, 36 + invoke DrawBoxBorder, eax, edx, 36, 6, 00301A22h, 00D0B000h, 1 + + ; Stem + mov eax, x + add eax, 18 + mov edx, liftY + add edx, 28 + invoke DrawBox, eax, edx, 12, 8, 00452533h + mov eax, x + add eax, 22 + invoke DrawBox, eax, edx, 4, 8, 006E4055h + + ; Goblet Bowl + mov eax, x + add eax, 8 + mov edx, liftY + add edx, 8 + invoke DrawBoxBorder, eax, edx, 32, 20, 00401E2Dh, 00FFD700h, 1 + + mov eax, x + add eax, 14 + mov edx, liftY + add edx, 10 + invoke DrawBox, eax, edx, 6, 16, 00703550h + mov eax, x + add eax, 17 + invoke DrawBox, eax, edx, 3, 16, 00A05078h + + ; Golden Rim + mov eax, x + add eax, 4 + mov edx, liftY + add edx, 2 + invoke DrawBoxBorder, eax, edx, 40, 7, 00200A15h, 00FFFF00h, 1 + mov eax, x + add eax, 12 + mov edx, liftY + add edx, 4 + invoke DrawBox, eax, edx, 16, 2, 00FFFF00h + + ; Skull face emblem + mov eax, x + add eax, 21 + mov edx, liftY + add edx, 12 + invoke DrawBox, eax, edx, 6, 5, 00FFD700h + mov eax, x + add eax, 22 + mov edx, liftY + add edx, 17 + invoke DrawBox, eax, edx, 4, 3, 00FFD700h + mov eax, x + add eax, 22 + mov edx, liftY + add edx, 14 + invoke DrawPixel, eax, edx, 00200A15h + mov eax, x + add eax, 24 + invoke DrawPixel, eax, edx, 00200A15h + + ; Cup number label + mov eax, x + add eax, 21 + mov edx, liftY + add edx, 24 + mov ecx, cupId + add ecx, '1' + invoke DrawChar8x8, eax, edx, ecx, 00FFFF00h + ret +DrawGothicCup ENDP + +InitSkullsGame PROC + mov skulls3d_state, 0 + mov skulls3d_timer, 0 + mov skulls3d_win, 0 + mov skulls3d_choice, 1 + mov skulls3d_cup0, 0 + mov skulls3d_cup1, 1 + mov skulls3d_cup2, 2 + invoke RandomRange3D, 3 + mov skulls3d_ballPos, eax + ret +InitSkullsGame ENDP + +FinalizeSkullsGuess PROC uses ebx + cmp skulls3d_state,3 + jne skulls_guess_done + cmp brSkullsLuck3D,-1 + je br_skulls_fixed + mov eax,skulls3d_choice + cmp brSkullsLuck3D,1 + je @F + inc eax + xor edx,edx + mov ecx,3 + div ecx + mov eax,edx +@@: + mov skulls3d_ballPos,eax + ; Reality distortion explicitly covers relocation before the reveal. + mov skulls3d_timer,0 +br_skulls_fixed: + mov eax, skulls3d_choice + cmp eax, skulls3d_ballPos + jne skulls_guess_wrong + + ; Correct! 3x payout + mov eax, skulls3d_bet + imul eax, 3 + add bankroll, eax + mov skulls3d_win, eax + mov skulls3d_state, 4 + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + invoke NpcRecordRound3D,9,1 + call SaveProgress3D + ret + +skulls_guess_wrong: + mov skulls3d_win, 0 + mov skulls3d_state, 4 + invoke PlayCasinoSound3D, OFFSET soundLose, 0, 1 + invoke NpcRecordRound3D,9,0 + call SaveProgress3D +skulls_guess_done: + ret +FinalizeSkullsGuess ENDP + +HandleSkullsInput PROC + cmp skulls3d_state, 0 + je skulls_handle_idle + cmp skulls3d_state, 1 + je skulls_handle_show + cmp skulls3d_state, 2 + je skulls_handle_shuffle + cmp skulls3d_state, 3 + je skulls_handle_pick + cmp skulls3d_state, 4 + je skulls_handle_reveal + ret + +skulls_handle_idle: + invoke Pressed3D, 26h ; UP + test eax, eax + jnz skulls_bet_up + invoke Pressed3D, 57h ; 'W' + test eax, eax + jnz skulls_bet_up + invoke Pressed3D, 28h ; DOWN + test eax, eax + jnz skulls_bet_down + invoke Pressed3D, 53h ; 'S' + test eax, eax + jnz skulls_bet_down + invoke Pressed3D, 20h ; SPACE + test eax, eax + jnz skulls_start_game + ret + +skulls_bet_up: + mov eax, skulls3d_bet + add eax, 50 + cmp eax, bankroll + jle @F + mov eax, bankroll +@@: + cmp eax, 5000 + jle @F + mov eax, 5000 +@@: + mov skulls3d_bet, eax + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +skulls_bet_down: + mov eax, skulls3d_bet + sub eax, 50 + cmp eax, 50 + jge @F + mov eax, 50 +@@: + mov skulls3d_bet, eax + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +skulls_start_game: + call BackroomsLuck3D + mov brSkullsLuck3D,eax + mov eax, skulls3d_bet + cmp eax, bankroll + jle @F + mov eax, bankroll + mov skulls3d_bet, eax + test eax, eax + jz skulls_input_done +@@: + mov eax, skulls3d_bet + sub bankroll, eax + invoke RandomRange3D, 3 + mov skulls3d_ballPos, eax + mov skulls3d_cup0, 0 + mov skulls3d_cup1, 1 + mov skulls3d_cup2, 2 + + ; Pre-generate 3 dynamic swap pairs + invoke RandomRange3D, 3 + mov skulls3d_swapPair0, eax + invoke RandomRange3D, 3 + mov skulls3d_swapPair1, eax + invoke RandomRange3D, 3 + mov skulls3d_swapPair2, eax + + mov skulls3d_state, 1 + mov skulls3d_timer, 0 + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +skulls_handle_show: + inc skulls3d_timer + cmp skulls3d_timer, 45 + jl skulls_input_done + ; Transition to Phase 2: Active Shuffle Animation + mov skulls3d_state, 2 + mov skulls3d_timer, 0 + invoke PlayCasinoSound3D, OFFSET soundShuffle, 0, 1 + ret + +skulls_handle_shuffle: + inc skulls3d_timer + cmp skulls3d_timer, 60 + jl skulls_input_done + ; Transition to Phase 3: Pick cup + mov skulls3d_state, 3 + mov skulls3d_timer, 0 + ret + +skulls_handle_pick: + invoke Pressed3D, 31h ; '1' + test eax, eax + jnz skulls_pick_1 + invoke Pressed3D, 32h ; '2' + test eax, eax + jnz skulls_pick_2 + invoke Pressed3D, 33h ; '3' + test eax, eax + jnz skulls_pick_3 + ret + +skulls_pick_1: + mov skulls3d_choice, 0 + call FinalizeSkullsGuess + ret + +skulls_pick_2: + mov skulls3d_choice, 1 + call FinalizeSkullsGuess + ret + +skulls_pick_3: + mov skulls3d_choice, 2 + call FinalizeSkullsGuess + ret + +skulls_handle_reveal: + cmp tournamentMode, 1 + jne @F + invoke Pressed3D, 20h + test eax, eax + jnz skulls_tourney_report + invoke Pressed3D, 0Dh + test eax, eax + jnz skulls_tourney_report + ret +skulls_tourney_report: + cmp skulls3d_win, 0 + je skulls_tourney_loss + invoke TowerReportRoundOutcome, 1 + ret +skulls_tourney_loss: + invoke TowerReportRoundOutcome, 2 + ret +@@: + invoke Pressed3D, 20h + test eax, eax + jz skulls_input_done + mov skulls3d_state, 0 + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 +skulls_input_done: + ret +HandleSkullsInput ENDP + +RenderSkullsGame PROC uses ebx esi edi + local kx:DWORD + local passTick:DWORD, curPair:DWORD, swapSlotA:DWORD, swapSlotB:DWORD + local xA:DWORD, xB:DWORD, curXA:DWORD, curXB:DWORD, curYA:DWORD, curYB:DWORD + local distX:DWORD, dxVal:DWORD, archY:DWORD + + ; Mahogany & Gothic Purple table + invoke DrawBox, 0, 0, 320, 240, 00140906h + invoke DrawBoxBorder, 6, 6, 308, 228, 00300F22h, 00FFD700h, 2 + + ; Header + invoke DrawBoxBorder, 20, 12, 280, 26, 001A0812h, 00FFD700h, 2 + invoke DrawString8x8, 44, 21, OFFSET textSkullsTitle, 00FFFF00h + + ; Status + invoke DrawBoxBorder, 20, 44, 110, 18, 001A0812h, 00452033h, 1 + invoke DrawString8x8, 24, 49, OFFSET textBankPrompt, 003CFF3Ch + invoke FormatNumber, bankroll, OFFSET hudNumBuffer + invoke DrawString8x8, 72, 49, OFFSET hudNumBuffer, 003CFF3Ch + + invoke DrawBoxBorder, 190, 44, 110, 18, 001A0812h, 00452033h, 1 + invoke DrawString8x8, 194, 49, OFFSET textBetPrompt, 00FFD700h + invoke FormatNumber, skulls3d_bet, OFFSET hudNumBuffer + invoke DrawString8x8, 254, 49, OFFSET hudNumBuffer, 00FFD700h + + ; Phase Prompts + cmp skulls3d_state, 0 + jne @F + invoke DrawString8x8, 56, 62, OFFSET textSkullsPhase0, 00FFD700h + jmp skulls_draw_idle_cups +@@: + cmp skulls3d_state, 1 + jne @F + invoke DrawString8x8, 56, 62, OFFSET textSkullsPhase1, 00FFFF00h + jmp skulls_draw_phase1_cups +@@: + cmp skulls3d_state, 2 + jne @F + invoke DrawString8x8, 44, 62, OFFSET textSkullsPhase2, 00FFFF00h + jmp skulls_draw_animated_cups +@@: + cmp skulls3d_state, 3 + jne @F + invoke DrawString8x8, 28, 62, OFFSET textSkullsPhase3, 00FFFF00h + jmp skulls_draw_idle_cups +@@: + ; Short artifact glitch, then reveal the actual ball and matching payout. + cmp brSkullsLuck3D,-1 + je @F + cmp skulls3d_timer,12 + jae @F + inc skulls3d_timer + invoke DrawBox,8,76,304,122,00130F20h + invoke DrawString8x8,108,128,OFFSET brRealityGlitch3D,00FF88CCh + jmp skulls_render_controls +@@: + ; Phase 4: Reveal outcome + mov eax, skulls3d_win + test eax, eax + jz skulls_reveal_loss_text + invoke DrawString8x8, 40, 62, OFFSET textSkullsWin, 003CFF3Ch + invoke FormatNumber, skulls3d_win, OFFSET hudNumBuffer + invoke DrawString8x8, 136, 62, OFFSET hudNumBuffer, 003CFF3Ch + invoke DrawString8x8, 168, 62, OFFSET textSkullsWinMult, 003CFF3Ch + jmp skulls_draw_reveal_cups + +skulls_reveal_loss_text: + invoke DrawString8x8, 40, 62, OFFSET textSkullsLose, 00FF6464h + jmp skulls_draw_reveal_cups + +skulls_draw_idle_cups: + ; Draw resting cups at static slots: Slot 0 (X=36), Slot 1 (X=136), Slot 2 (X=236) + invoke DrawGothicCup, 36, 114, skulls3d_cup0, 0, 0 + invoke DrawGothicCup, 136, 114, skulls3d_cup1, 0, 0 + invoke DrawGothicCup, 236, 114, skulls3d_cup2, 0, 0 + jmp skulls_render_controls + +skulls_draw_phase1_cups: + ; Draw with golden ball showing under starting cup + mov ebx, 0 + mov edx, 0 + cmp skulls3d_ballPos, 0 + jne @F + mov ebx, 1 + mov edx, 1 +@@: + invoke DrawGothicCup, 36, 114, skulls3d_cup0, ebx, edx + + mov ebx, 0 + mov edx, 0 + cmp skulls3d_ballPos, 1 + jne @F + mov ebx, 1 + mov edx, 1 +@@: + invoke DrawGothicCup, 136, 114, skulls3d_cup1, ebx, edx + + mov ebx, 0 + mov edx, 0 + cmp skulls3d_ballPos, 2 + jne @F + mov ebx, 1 + mov edx, 1 +@@: + invoke DrawGothicCup, 236, 114, skulls3d_cup2, ebx, edx + jmp skulls_render_controls + +skulls_draw_animated_cups: + ; 60 frames = 3 passes of 20 frames + mov eax, skulls3d_timer + cmp eax, 20 + jbe pass_0 + cmp eax, 40 + jbe pass_1 + sub eax, 41 + mov passTick, eax + mov eax, skulls3d_swapPair2 + mov curPair, eax + jmp setup_pass + +pass_0: + dec eax + mov passTick, eax + mov eax, skulls3d_swapPair0 + mov curPair, eax + jmp setup_pass + +pass_1: + sub eax, 21 + mov passTick, eax + mov eax, skulls3d_swapPair1 + mov curPair, eax + +setup_pass: + ; curPair determines swap pair: + ; 0: swap slot 0 (X=36) and slot 1 (X=136) + ; 1: swap slot 1 (X=136) and slot 2 (X=236) + ; 2: swap slot 0 (X=36) and slot 2 (X=236) + cmp curPair, 1 + je pair_1 + cmp curPair, 2 + je pair_2 + mov swapSlotA, 0 + mov swapSlotB, 1 + mov xA, 36 + mov xB, 136 + jmp calc_coords +pair_1: + mov swapSlotA, 1 + mov swapSlotB, 2 + mov xA, 136 + mov xB, 236 + jmp calc_coords +pair_2: + mov swapSlotA, 0 + mov swapSlotB, 2 + mov xA, 36 + mov xB, 236 + +calc_coords: + ; distX = xB - xA + mov eax, xB + sub eax, xA + mov distX, eax + + ; dxVal = (distX * passTick) / 20 + mov eax, distX + imul eax, passTick + xor edx, edx + mov ecx, 20 + div ecx + mov dxVal, eax + + ; curXA = xA + dxVal + mov eax, xA + add eax, dxVal + mov curXA, eax + + ; curXB = xB - dxVal + mov eax, xB + sub eax, dxVal + mov curXB, eax + + ; archY = (passTick * (20 - passTick)) / 10 + mov eax, passTick + mov ecx, 20 + sub ecx, eax + imul eax, ecx + xor edx, edx + mov ecx, 10 + div ecx + mov archY, eax + + ; Cup A hops UP: 114 - archY + mov eax, 114 + sub eax, archY + mov curYA, eax + + ; Cup B hops DOWN: 114 + archY + mov eax, 114 + add eax, archY + mov curYB, eax + + ; Check if pass ended (frame 19): swap ball position and cups + cmp passTick, 19 + jne draw_active_shuffle + + ; Swap ball position if involved + mov eax, skulls3d_ballPos + cmp eax, swapSlotA + jne check_ball_b + mov edx, swapSlotB + mov skulls3d_ballPos, edx + jmp swap_slot_identities +check_ball_b: + cmp eax, swapSlotB + jne swap_slot_identities + mov edx, swapSlotA + mov skulls3d_ballPos, edx + +swap_slot_identities: + cmp curPair, 1 + je swap_ids_1_2 + cmp curPair, 2 + je swap_ids_0_2 + ; swap 0 and 1 + mov eax, skulls3d_cup0 + xchg eax, skulls3d_cup1 + mov skulls3d_cup0, eax + jmp swap_sound_tick +swap_ids_1_2: + mov eax, skulls3d_cup1 + xchg eax, skulls3d_cup2 + mov skulls3d_cup1, eax + jmp swap_sound_tick +swap_ids_0_2: + mov eax, skulls3d_cup0 + xchg eax, skulls3d_cup2 + mov skulls3d_cup0, eax + +swap_sound_tick: + invoke PlayCasinoSound3D, OFFSET soundShuffle, 0, 1 + +draw_active_shuffle: + ; Draw stationary cup + cmp curPair, 1 + je draw_stat_cup0 + cmp curPair, 2 + je draw_stat_cup1 + ; Stationary cup is slot 2 (X=236) + invoke DrawGothicCup, 236, 114, skulls3d_cup2, 0, 0 + jmp draw_moving_cups +draw_stat_cup0: + ; Stationary cup is slot 0 (X=36) + invoke DrawGothicCup, 36, 114, skulls3d_cup0, 0, 0 + jmp draw_moving_cups +draw_stat_cup1: + ; Stationary cup is slot 1 (X=136) + invoke DrawGothicCup, 136, 114, skulls3d_cup1, 0, 0 + +draw_moving_cups: + ; Moving Cup A and Moving Cup B + cmp curPair, 1 + je ids_pair_1 + cmp curPair, 2 + je ids_pair_2 + mov eax, skulls3d_cup0 + mov ebx, skulls3d_cup1 + jmp draw_the_pair +ids_pair_1: + mov eax, skulls3d_cup1 + mov ebx, skulls3d_cup2 + jmp draw_the_pair +ids_pair_2: + mov eax, skulls3d_cup0 + mov ebx, skulls3d_cup2 + +draw_the_pair: + push ebx + invoke DrawGothicCup, curXA, curYA, eax, 0, 0 + pop ebx + invoke DrawGothicCup, curXB, curYB, ebx, 0, 0 + jmp skulls_render_controls + +skulls_draw_reveal_cups: + ; Reveal Phase: lift chosen cup and lift actual ball cup if different + ; Slot 0 + mov ebx, 0 + mov edx, 0 + cmp skulls3d_choice, 0 + je slot0_is_lifted + cmp skulls3d_ballPos, 0 + jne @F +slot0_is_lifted: + mov ebx, 1 + cmp skulls3d_ballPos, 0 + sete dl +@@: + invoke DrawGothicCup, 36, 114, skulls3d_cup0, ebx, edx + + ; Slot 1 + mov ebx, 0 + mov edx, 0 + cmp skulls3d_choice, 1 + je slot1_is_lifted + cmp skulls3d_ballPos, 1 + jne @F +slot1_is_lifted: + mov ebx, 1 + cmp skulls3d_ballPos, 1 + sete dl +@@: + invoke DrawGothicCup, 136, 114, skulls3d_cup1, ebx, edx + + ; Slot 2 + mov ebx, 0 + mov edx, 0 + cmp skulls3d_choice, 2 + je slot2_is_lifted + cmp skulls3d_ballPos, 2 + jne @F +slot2_is_lifted: + mov ebx, 1 + cmp skulls3d_ballPos, 2 + sete dl +@@: + invoke DrawGothicCup, 236, 114, skulls3d_cup2, ebx, edx + +skulls_render_controls: + ; Cup selection slot labels [1], [2], [3] + invoke DrawString8x8, 54, 168, OFFSET textSkullsKey1, 00D0D8E0h + invoke DrawString8x8, 150, 168, OFFSET textSkullsKey2, 00D0D8E0h + invoke DrawString8x8, 250, 168, OFFSET textSkullsKey3, 00D0D8E0h + + ; Keycaps + mov kx, 16 + xor eax, eax + cmp skulls3d_state, 3 + je key1_active + cmp skulls3d_choice, 0 + sete al + jmp draw_key1 +key1_active: + mov eax, 1 +draw_key1: + invoke DrawKeycap3D, kx, 192, OFFSET textSkullsKey1, eax + add kx, eax + + xor eax, eax + cmp skulls3d_state, 3 + je key2_active + cmp skulls3d_choice, 1 + sete al + jmp draw_key2 +key2_active: + mov eax, 1 +draw_key2: + invoke DrawKeycap3D, kx, 192, OFFSET textSkullsKey2, eax + add kx, eax + + xor eax, eax + cmp skulls3d_state, 3 + je key3_active + cmp skulls3d_choice, 2 + sete al + jmp draw_key3 +key3_active: + mov eax, 1 +draw_key3: + invoke DrawKeycap3D, kx, 192, OFFSET textSkullsKey3, eax + add kx, eax + + xor eax, eax + cmp skulls3d_state, 0 + je start_active + cmp skulls3d_state, 4 + je start_active + jmp draw_start_key +start_active: + mov eax, 1 +draw_start_key: + invoke DrawKeycap3D, kx, 192, OFFSET textSkullsKeySpace, eax + add kx, eax + + invoke DrawKeycap3D, kx, 192, OFFSET textKeyEsc, 0 + ret +RenderSkullsGame ENDP + +InitSkillGame PROC + mov skill3d_state, 0 + mov skill3d_timer, 0 + mov skill3d_hits, 0 + mov skill3d_misses, 0 + mov skill3d_needle, 55 + mov skill3d_speed, 4 + mov skill3d_dir, 1 + mov skill3d_last_result, 0 + mov skill3d_win_amount, 0 + + ; Randomize initial zone: 80 + RandomRange(90) -> 80..170 + invoke RandomRange3D, 90 + add eax, 80 + mov skill3d_zone_start, eax + + ; Great zone: start + 20 + RandomRange(12) + invoke RandomRange3D, 12 + add eax, skill3d_zone_start + add eax, 20 + mov skill3d_great_start, eax + ret +InitSkillGame ENDP + +HandleSkillInput PROC uses ebx esi + mov eax, skill3d_state + cmp eax, 0 + je skill_handle_ready + cmp eax, 1 + je skill_handle_active + cmp eax, 2 + je skill_handle_round_wait + cmp eax, 3 + je skill_handle_round_wait + cmp eax, 4 + je skill_handle_end_wait + cmp eax, 5 + je skill_handle_end_wait + ret + +skill_handle_ready: + invoke Pressed3D, 26h ; UP + test eax, eax + jnz skill_bet_up + invoke Pressed3D, 57h ; 'W' + test eax, eax + jnz skill_bet_up + invoke Pressed3D, 28h ; DOWN + test eax, eax + jnz skill_bet_down + invoke Pressed3D, 53h ; 'S' + test eax, eax + jnz skill_bet_down + jmp skill_check_start + +skill_bet_up: + mov eax, skill3d_bet + add eax, 50 + cmp eax, bankroll + jle @F + mov eax, bankroll +@@: + cmp eax, 5000 + jle @F + mov eax, 5000 +@@: + mov skill3d_bet, eax + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +skill_bet_down: + mov eax, skill3d_bet + sub eax, 50 + cmp eax, 50 + jge @F + mov eax, 50 +@@: + mov skill3d_bet, eax + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +skill_check_start: + invoke Pressed3D, 20h ; SPACE + test eax, eax + jz skill_input_done + + ; Deduct bet on game start if beginning of run + mov eax, skill3d_hits + or eax, skill3d_misses + jnz @F + mov eax, skill3d_bet + cmp eax, bankroll + jle skill_has_funds + mov eax, bankroll + mov skill3d_bet, eax + test eax, eax + jz skill_input_done +skill_has_funds: + mov eax, skill3d_bet + sub bankroll, eax +@@: + mov skill3d_state, 1 + mov skill3d_needle, 55 + mov skill3d_dir, 1 + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret + +skill_handle_active: + ; Move needle smoothly + mov eax, skill3d_needle + mov edx, skill3d_speed + cmp skill3d_dir, 1 + je skill_move_right + sub eax, edx + cmp eax, 52 + jge skill_update_needle + mov eax, 52 + mov skill3d_dir, 1 + jmp skill_update_needle +skill_move_right: + add eax, edx + cmp eax, 268 + jle skill_update_needle + mov eax, 268 + mov skill3d_dir, -1 +skill_update_needle: + mov skill3d_needle, eax + + ; Check SPACE pressed (Reaction Hit Attempt!) + invoke Pressed3D, 20h + test eax, eax + jz skill_input_done + + ; Is needle in Great Sweet Spot? + mov eax, skill3d_needle + mov edx, skill3d_great_start + cmp eax, edx + jl check_success_zone + add edx, skill3d_great_width + cmp eax, edx + jg check_success_zone + + ; GREAT HIT! + mov skill3d_last_result, 2 + add skill3d_hits, 2 + mov skill3d_state, 2 + mov skill3d_timer, 40 + invoke PlayCasinoSound3D, OFFSET soundSkillPerfect, 0, 1 + jmp skill_check_finish_round + +check_success_zone: + mov eax, skill3d_needle + mov edx, skill3d_zone_start + cmp eax, edx + jl skill_was_miss + add edx, skill3d_zone_width + cmp eax, edx + jg skill_was_miss + + ; NORMAL HIT! + mov skill3d_last_result, 1 + inc skill3d_hits + mov skill3d_state, 2 + mov skill3d_timer, 40 + invoke PlayCasinoSound3D, OFFSET soundSkillHit, 0, 1 + jmp skill_check_finish_round + +skill_was_miss: + ; MISS! + mov skill3d_last_result, 0 + inc skill3d_misses + mov skill3d_state, 3 + mov skill3d_timer, 45 + invoke PlayCasinoSound3D, OFFSET soundSkillMiss, 0, 1 + +skill_check_finish_round: + cmp skill3d_hits, 5 + jge skill_game_escaped + cmp skill3d_misses, 3 + jge skill_game_lost + ret + +skill_game_escaped: + mov skill3d_state, 4 + mov skill3d_timer, 0 + ; Payout: 3x total return (+$2x bet profit) + mov eax, skill3d_bet + imul eax, 3 + add bankroll, eax + mov eax, skill3d_bet + shl eax, 1 + mov skill3d_win_amount, eax + invoke NpcRecordRound3D,10,1 + call SaveProgress3D + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + ret + +skill_game_lost: + mov skill3d_state, 5 + mov skill3d_timer, 0 + invoke NpcRecordRound3D,10,0 + call SaveProgress3D + invoke PlayCasinoSound3D, OFFSET soundLose, 0, 1 + ret + +skill_handle_round_wait: + dec skill3d_timer + cmp skill3d_timer, 0 + jg skill_input_done + + ; Next round setup + invoke RandomRange3D, 90 + add eax, 80 + mov skill3d_zone_start, eax + + invoke RandomRange3D, 12 + add eax, skill3d_zone_start + add eax, 20 + mov skill3d_great_start, eax + + mov eax, skill3d_hits + shr eax, 1 + add eax, 4 + mov skill3d_speed, eax + mov skill3d_state, 1 + ret + +skill_handle_end_wait: + cmp tournamentMode, 1 + jne @F + invoke Pressed3D, 20h + test eax, eax + jnz skill_tourney_report + invoke Pressed3D, 0Dh + test eax, eax + jnz skill_tourney_report + ret +skill_tourney_report: + cmp skill3d_state, 4 + jne skill_tourney_loss + invoke TowerReportRoundOutcome, 1 + ret +skill_tourney_loss: + invoke TowerReportRoundOutcome, 2 + ret +@@: + invoke Pressed3D, 20h + test eax, eax + jz skill_input_done + call InitSkillGame + ret + +skill_input_done: + ret +HandleSkillInput ENDP + +RenderSkillGame PROC uses ebx esi edi + local kx:DWORD + local tx:DWORD + + ; Industrial Steel bezel + invoke DrawBox, 0, 0, 320, 240, 00121416h + invoke DrawBoxBorder, 6, 6, 308, 228, 001A1D20h, 00FFD700h, 2 + + ; Header + invoke DrawBoxBorder, 20, 12, 280, 26, 00121418h, 00FFD700h, 2 + invoke DrawString8x8, 40, 21, OFFSET textSkillTitle, 00FFFF00h + + ; Status + invoke DrawBoxBorder, 20, 44, 110, 18, 00121418h, 002A3540h, 1 + invoke DrawString8x8, 24, 49, OFFSET textBankPrompt, 003CFF3Ch + invoke FormatNumber, bankroll, OFFSET hudNumBuffer + invoke DrawString8x8, 72, 49, OFFSET hudNumBuffer, 003CFF3Ch + + invoke DrawBoxBorder, 190, 44, 110, 18, 00121418h, 002A3540h, 1 + invoke DrawString8x8, 194, 49, OFFSET textBetPrompt, 00FFD700h + invoke FormatNumber, skill3d_bet, OFFSET hudNumBuffer + invoke DrawString8x8, 254, 49, OFFSET hudNumBuffer, 00FFD700h + + ; Survivor Progress + invoke DrawString8x8, 24, 70, OFFSET textSkillHitsHdr, 003CFF3Ch + invoke FormatNumber, skill3d_hits, OFFSET hudNumBuffer + invoke DrawString8x8, 64, 70, OFFSET hudNumBuffer, 003CFF3Ch + + invoke DrawString8x8, 180, 70, OFFSET textSkillMissHdr, 00FF6464h + invoke FormatNumber, skill3d_misses, OFFSET hudNumBuffer + invoke DrawString8x8, 240, 70, OFFSET hudNumBuffer, 00FF6464h + + ; Dial Frame (Track: X=50..270, Y=102..134) + invoke DrawBoxBorder, 50, 102, 220, 32, 000F1114h, 00404855h, 2 + + ; Calibrated ticks + mov tx, 60 +skill_ticks_loop: + cmp tx, 260 + jge skill_draw_zones + invoke DrawBox, tx, 104, 1, 6, 00303845h + invoke DrawBox, tx, 126, 1, 6, 00303845h + add tx, 12 + jmp skill_ticks_loop + +skill_draw_zones: + ; Normal Success Zone (Green) + invoke DrawBoxBorder, skill3d_zone_start, 106, skill3d_zone_width, 24, 00155020h, 003CFF3Ch, 1 + + ; Great Zone (Gold) + invoke DrawBoxBorder, skill3d_great_start, 106, skill3d_great_width, 24, 00FFD700h, 00FFFF00h, 1 + + ; Pointer / Needle at skill3d_needle + mov eax, skill3d_needle + dec eax + invoke DrawBox, eax, 98, 3, 40, 00FFFFFFh + mov eax, skill3d_needle + sub eax, 2 + invoke DrawBox, eax, 96, 5, 2, 00FF3030h + invoke DrawBox, eax, 138, 5, 2, 00FF3030h + + ; Center prompts / outcome + cmp skill3d_state, 0 + jne @F + invoke DrawString8x8, 52, 150, OFFSET textSkillReadyMsg, 00FFD700h + invoke DrawString8x8, 76, 166, OFFSET textSkillPrompt, 00D0D8E0h + jmp skill_render_keys +@@: + cmp skill3d_state, 1 + jne @F + invoke DrawString8x8, 76, 150, OFFSET textSkillPrompt, 00FFFF00h + jmp skill_render_keys +@@: + cmp skill3d_state, 2 + jne @F + cmp skill3d_last_result, 2 + jne skill_normal_hit_text + invoke DrawString8x8, 36, 150, OFFSET textSkillGreatMsg, 00FFFF00h + jmp skill_render_keys +skill_normal_hit_text: + invoke DrawString8x8, 64, 150, OFFSET textSkillHitMsg, 003CFF3Ch + jmp skill_render_keys +@@: + cmp skill3d_state, 3 + jne @F + invoke DrawString8x8, 88, 150, OFFSET textSkillMissMsg, 00FF6464h + jmp skill_render_keys +@@: + cmp skill3d_state, 4 + jne @F + invoke DrawString8x8, 48, 150, OFFSET textSkillEscape, 003CFF3Ch + invoke FormatNumber, skill3d_win_amount, OFFSET hudNumBuffer + invoke DrawString8x8, 240, 150, OFFSET hudNumBuffer, 003CFF3Ch + invoke DrawString8x8, 64, 166, OFFSET textSkullsAgain, 00FFD700h + jmp skill_render_keys +@@: + invoke DrawString8x8, 44, 150, OFFSET textSkillLost, 00FF6464h + invoke DrawString8x8, 64, 166, OFFSET textSkullsAgain, 00FFD700h + +skill_render_keys: + mov kx, 16 + invoke DrawKeycap3D, kx, 192, OFFSET textSkillKeySpace, 1 + add kx, eax + + invoke DrawKeycap3D, kx, 192, OFFSET textSkillKeyBet, 0 + add kx, eax + + invoke DrawKeycap3D, kx, 192, OFFSET textKeyEsc, 0 + ret +RenderSkillGame ENDP + +; --- Mouse Lock & Unlock Routines for Free Camera Look --- +LockMouse3D PROC + LOCAL rcClient[16]:BYTE + LOCAL ptCenter:C3D_POINT + cmp mouseLocked3D, 1 + je lock_done + mov mouseLocked3D, 1 + invoke ShowCursor, 0 + lea eax, rcClient + invoke GetClientRect, h3DWnd, eax + mov eax, dword ptr rcClient[8] + shr eax, 1 + mov ptCenter.x, eax + mov eax, dword ptr rcClient[12] + shr eax, 1 + mov ptCenter.y, eax + lea eax, ptCenter + invoke ClientToScreen, h3DWnd, eax + invoke SetCursorPos, ptCenter.x, ptCenter.y +lock_done: + ret +LockMouse3D ENDP + +UnlockMouse3D PROC + cmp mouseLocked3D, 0 + je unlock_done + mov mouseLocked3D, 0 + invoke ShowCursor, 1 +unlock_done: + ret +UnlockMouse3D ENDP + +UpdateMouseLockState PROC + cmp welcomeActive3D,0 + jne unlock_it + cmp engineMode,MODE_HEIST + jne @F + cmp hqActive,1 + jne unlock_it + cmp heistPhase,7 + je lock_interior_check + jmp unlock_it +@@: cmp engineMode,MODE_HELL_FPS je lock_interior_check - cmp engineMode,MODE_STAIRS - je lock_interior_check - cmp engineMode, MODE_WALK - jne unlock_it -lock_interior_check: - cmp paused3D, 0 - jne unlock_it - invoke GetForegroundWindow - cmp eax, h3DWnd - jne unlock_it - invoke IsIconic, h3DWnd - test eax, eax - jnz unlock_it - call LockMouse3D - ret -unlock_it: - call UnlockMouse3D - ret -UpdateMouseLockState ENDP - -HandlePlayerInput PROC uses ebx esi edi - local speed:DWORD - local nextX:DWORD - local nextY:DWORD - local fwdDir:DWORD - local strafeDir:DWORD - local deltaMoveX:DWORD - local deltaMoveY:DWORD - local rcClient[16]:BYTE - local ptCenter:C3D_POINT - local ptCursor:C3D_POINT - - ; --- Mouse Look Camera Rotation --- - cmp mouseLocked3D, 1 - jne skip_mouse_look - lea eax, rcClient - invoke GetClientRect, h3DWnd, eax - mov eax, dword ptr rcClient[8] - shr eax, 1 - mov ptCenter.x, eax - mov eax, dword ptr rcClient[12] - shr eax, 1 - mov ptCenter.y, eax - lea eax, ptCenter - invoke ClientToScreen, h3DWnd, eax - lea eax, ptCursor - invoke GetCursorPos, eax - mov eax, ptCursor.x - sub eax, ptCenter.x - test eax, eax - jz mouse_recenter - cmp eax, 64 - jle @F - mov eax, 64 -@@: - cmp eax, -64 - jge @F - mov eax, -64 -@@: - add playerAngle, eax -mouse_recenter: - invoke SetCursorPos, ptCenter.x, ptCenter.y -skip_mouse_look: - - ; Movement speed with sprint (Shift = 10h) - mov eax, deltaTime3D - cmp eax,50 - jbe @F - mov eax,50 -@@: - imul eax, 200 + cmp engineMode,MODE_STAIRS + je lock_interior_check + cmp engineMode, MODE_WALK + jne unlock_it +lock_interior_check: + cmp paused3D, 0 + jne unlock_it + invoke GetForegroundWindow + cmp eax, h3DWnd + jne unlock_it + invoke IsIconic, h3DWnd + test eax, eax + jnz unlock_it + call LockMouse3D + ret +unlock_it: + call UnlockMouse3D + ret +UpdateMouseLockState ENDP + +HandlePlayerInput PROC uses ebx esi edi + local speed:DWORD + local nextX:DWORD + local nextY:DWORD + local fwdDir:DWORD + local strafeDir:DWORD + local deltaMoveX:DWORD + local deltaMoveY:DWORD + local rcClient[16]:BYTE + local ptCenter:C3D_POINT + local ptCursor:C3D_POINT + + ; --- Mouse Look Camera Rotation --- + cmp mouseLocked3D, 1 + jne skip_mouse_look + lea eax, rcClient + invoke GetClientRect, h3DWnd, eax + mov eax, dword ptr rcClient[8] + shr eax, 1 + mov ptCenter.x, eax + mov eax, dword ptr rcClient[12] + shr eax, 1 + mov ptCenter.y, eax + lea eax, ptCenter + invoke ClientToScreen, h3DWnd, eax + lea eax, ptCursor + invoke GetCursorPos, eax + mov eax, ptCursor.x + sub eax, ptCenter.x + test eax, eax + jz mouse_recenter + cmp eax, 64 + jle @F + mov eax, 64 +@@: + cmp eax, -64 + jge @F + mov eax, -64 +@@: + add playerAngle, eax +mouse_recenter: + invoke SetCursorPos, ptCenter.x, ptCenter.y +skip_mouse_look: + + ; Movement speed with sprint (Shift = 10h) + mov eax, deltaTime3D + cmp eax,50 + jbe @F + mov eax,50 +@@: + imul eax, 200 cmp engineMode,MODE_HELL_FPS jne @F imul eax,2 @@: - mov speed, eax - cmp keys3D[10h], 0 - je @F - shl speed, 1 -@@: - - ; --- Keyboard Arrow Turning (VK_LEFT = 25h, VK_RIGHT = 27h) --- - mov eax, deltaTime3D - shr eax, 2 - inc eax - cmp keys3D[25h], 0 - je @F - sub playerAngle, eax -@@: - cmp keys3D[27h], 0 - je @F - add playerAngle, eax -@@: - and playerAngle, 511 - call UpdateCamera3D - - ; --- Forward / Backward Direction (W / Up / S / Down) --- - mov fwdDir, 0 - cmp keys3D[57h], 0 - jne @F - cmp keys3D[26h], 0 - je check_back_key -@@: - inc fwdDir -check_back_key: - cmp keys3D[53h], 0 - jne @F - cmp keys3D[28h], 0 - je check_strafe_keys -@@: - dec fwdDir - -check_strafe_keys: - ; --- Strafe Direction (A = Left, D = Right) --- - mov strafeDir, 0 - cmp keys3D[44h], 0 - je @F - inc strafeDir -@@: - cmp keys3D[41h], 0 - je @F - dec strafeDir -@@: - - ; --- Movement Calculation --- - mov deltaMoveX, 0 - mov deltaMoveY, 0 - - ; Forward / Backward component - mov edi, fwdDir - test edi, edi - jz calc_strafe_comp - - imul edi, speed - mov eax, playerDirX - imul edi - shrd eax, edx, 16 - add deltaMoveX, eax - - mov eax, playerDirY - imul edi - shrd eax, edx, 16 - add deltaMoveY, eax - -calc_strafe_comp: - ; Strafe Left / Right component: Right vector is (-playerDirY, playerDirX) - mov edi, strafeDir - test edi, edi - jz check_total_movement - - imul edi, speed - mov eax, playerDirY - neg eax - imul edi - shrd eax, edx, 16 - add deltaMoveX, eax - - mov eax, playerDirX - imul edi - shrd eax, edx, 16 - add deltaMoveY, eax - -check_total_movement: - mov eax, deltaMoveX - or eax, deltaMoveY - jz input_action - - mov eax, playerX - add eax, deltaMoveX - mov nextX, eax - - mov eax, playerY - add eax, deltaMoveY - mov nextY, eax - + mov speed, eax + cmp hqActive,1 + jne @F + cmp keys3D[11h],0 + je @F + shr speed,1 +@@: + cmp keys3D[10h], 0 + je @F + shl speed, 1 +@@: + cmp barBuffSpeedTimer, 0 + jbe @F + mov eax, speed + shr eax, 1 + add speed, eax +@@: + + ; --- Keyboard Arrow Turning (VK_LEFT = 25h, VK_RIGHT = 27h) --- + mov eax, deltaTime3D + shr eax, 2 + inc eax + cmp keys3D[25h], 0 + je @F + sub playerAngle, eax +@@: + cmp keys3D[27h], 0 + je @F + add playerAngle, eax +@@: + and playerAngle, 511 + call UpdateCamera3D + + ; --- Forward / Backward Direction (W / Up / S / Down) --- + mov fwdDir, 0 + cmp keys3D[57h], 0 + jne @F + cmp keys3D[26h], 0 + je check_back_key +@@: + inc fwdDir +check_back_key: + cmp keys3D[53h], 0 + jne @F + cmp keys3D[28h], 0 + je check_strafe_keys +@@: + dec fwdDir + +check_strafe_keys: + ; --- Strafe Direction (A = Left, D = Right) --- + mov strafeDir, 0 + cmp keys3D[44h], 0 + je @F + inc strafeDir +@@: + cmp keys3D[41h], 0 + je @F + dec strafeDir +@@: + + ; --- Movement Calculation --- + mov deltaMoveX, 0 + mov deltaMoveY, 0 + + ; Forward / Backward component + mov edi, fwdDir + test edi, edi + jz calc_strafe_comp + + imul edi, speed + mov eax, playerDirX + imul edi + shrd eax, edx, 16 + add deltaMoveX, eax + + mov eax, playerDirY + imul edi + shrd eax, edx, 16 + add deltaMoveY, eax + +calc_strafe_comp: + ; Strafe Left / Right component: Right vector is (-playerDirY, playerDirX) + mov edi, strafeDir + test edi, edi + jz check_total_movement + + imul edi, speed + mov eax, playerDirY + neg eax + imul edi + shrd eax, edx, 16 + add deltaMoveX, eax + + mov eax, playerDirX + imul edi + shrd eax, edx, 16 + add deltaMoveY, eax + +check_total_movement: + mov eax, deltaMoveX + or eax, deltaMoveY + jz input_action + + mov eax, playerX + add eax, deltaMoveX + mov nextX, eax + + mov eax, playerY + add eax, deltaMoveY + mov nextY, eax + cmp engineMode,MODE_HELL_FPS jne hf_move_regular_x invoke HFPlayerCanWalk,nextX,playerY jmp hf_move_check_x hf_move_regular_x: - invoke CanWalk3D, nextX, playerY + invoke CanWalk3D, nextX, playerY hf_move_check_x: - test eax, eax - jz @F - mov eax, nextX - mov playerX, eax -@@: + test eax, eax + jz @F + mov eax, nextX + mov playerX, eax +@@: cmp engineMode,MODE_HELL_FPS jne hf_move_regular_y invoke HFPlayerCanWalk,playerX,nextY jmp hf_move_check_y hf_move_regular_y: - invoke CanWalk3D, playerX, nextY + invoke CanWalk3D, playerX, nextY hf_move_check_y: - test eax, eax - jz input_action - mov eax, nextY - mov playerY, eax - -input_action: + test eax, eax + jz input_action + mov eax, nextY + mov playerY, eax + +input_action: + cmp hqActive,1 + je player_input_complete cmp engineMode,MODE_HELL_FPS je player_input_complete - cmp brActive3D,0 - jne player_input_complete - cmp engineMode,MODE_STAIRS - je player_input_complete - invoke Pressed3D, 45h - test eax, eax - jz @F - call Trigger3DInteraction -@@: -player_input_complete: - ret -HandlePlayerInput ENDP - -CheckInteractions PROC uses ebx esi edi - local nearest:DWORD - mov nearest, 262144 - mov interactTargetId, 0 - mov interactPromptPtr, 0 - cmp hallLevel3D,0 - jne interaction_done - xor esi, esi -interaction_scan: - cmp esi, NUM_SPRITES - jge interaction_done - cmp esi,3 - jb interaction_next - cmp esi,17 - je interaction_next - cmp esi,19 - je interaction_next - cmp esi,21 - je interaction_next - imul edi, esi, SIZEOF SpriteObject - cmp [casinoSprites+edi].interactId, 0 - je interaction_next - mov eax, [casinoSprites+edi].posX - sub eax, playerX - sar eax, 8 - mov ebx, eax - imul eax, eax - mov ecx, eax - mov eax, [casinoSprites+edi].posY - sub eax, playerY - sar eax, 8 - mov edx, eax - imul eax, eax - add ecx, eax - cmp ecx, nearest - jae interaction_next - ; Only target objects in front of the camera. - mov eax, playerDirX - sar eax, 8 - imul eax, ebx - mov ebx, playerDirY - sar ebx, 8 - imul ebx, edx - add eax, ebx - cmp eax, 18000 - jl interaction_next - mov nearest, ecx - mov eax, [casinoSprites+edi].interactId - mov interactTargetId, eax - mov eax, [casinoSprites+edi].promptPtr - mov interactPromptPtr, eax -interaction_next: - inc esi - jmp interaction_scan -interaction_done: - call CheckHallInteractions3D - ret -CheckInteractions ENDP - -; (Legacy console arcade bezel bridge removed) - -Trigger3DInteraction PROC - cmp brActive3D,0 - jne trigger_backrooms_station - call TriggerHallInteraction3D - test eax, eax - jnz trigger_done -trigger_backrooms_station: - mov eax, interactTargetId - test eax, eax - jz trigger_done - - cmp eax, INTERACT_DANCER - jne check_target_bj - cmp bankroll, 100 - jl dancer_no_cash - sub bankroll, 100 - inc dancerLuckBuff - invoke CopyString3D, OFFSET textTips3D, OFFSET flashMessage - mov flashTimer, 100 - invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 - ret -dancer_no_cash: - invoke CopyString3D, OFFSET msgNeedMoney, OFFSET flashMessage - mov flashTimer, 60 - ret - -check_target_bj: - cmp eax, INTERACT_BLACKJACK - jne check_target_poker - call InitNativeBlackjack3D - mov engineMode, MODE_BLACKJACK - ret - -check_target_poker: - cmp eax, INTERACT_POKER - jne check_target_durak - call InitNativePoker3D - test eax, eax - jz target_unported - mov engineMode, MODE_POKER - ret - -check_target_durak: - cmp eax, INTERACT_DURAK - jne check_target_slots777 - call InitNativeDurak3D - mov engineMode, MODE_DURAK - ret - -check_target_slots777: - cmp eax, INTERACT_SLOTS_777 - jne check_target_slots_clover - call InitNativeSlots3D - test eax,eax - jz target_unported - mov engineMode,MODE_SLOTS - ret - -check_target_slots_clover: - cmp eax, INTERACT_SLOTS_CLOVER - jne check_target_roulette - call InitNativeClover3D - test eax,eax - jz target_unported - mov engineMode,MODE_CLOVER - ret - -check_target_roulette: - cmp eax, INTERACT_ROULETTE - jne check_target_dice - call InitNativeWheel3D - mov engineMode, MODE_ROULETTE - ret - -check_target_dice: - cmp eax, INTERACT_DICE - jne check_target_skulls - call InitDiceGame - mov engineMode, MODE_DICE - ret - -check_target_skulls: - cmp eax, INTERACT_SKULLS - jne check_target_coin - call InitSkullsGame - mov engineMode, MODE_SKULLS - ret - -check_target_coin: - cmp eax, INTERACT_COIN - jne check_target_skill - call InitCoinGame - mov engineMode, MODE_COIN - ret - -check_target_skill: - cmp eax, INTERACT_SKILL_CHECK - jne check_target_buckshot - call InitSkillGame - mov engineMode, MODE_SKILL - ret - -check_target_buckshot: - cmp eax, INTERACT_BUCKSHOT - jne check_target_rr - call InitBuckshot3D - mov engineMode, MODE_BUCKSHOT - ret - -check_target_rr: - cmp eax, INTERACT_RUSSIAN_ROULETTE - jne check_target_online_rr - call InitRussianGame3D - test eax, eax - jz @F - mov engineMode, MODE_RUSSIAN -@@: - ret - -check_target_online_rr: - cmp eax, INTERACT_ONLINE_RR - jne check_target_umamusume - call BeginUnavailable3D - ret - -check_target_umamusume: - cmp eax, INTERACT_UMAMUSUME - jne check_target_hell - call BeginUnavailable3D - ret - -check_target_hell: - cmp eax, INTERACT_HELL_TOWER - jne check_target_shop - call InitHellTower3D - ret - -check_target_shop: - cmp eax, INTERACT_SHOP - jne check_target_atm - call BeginMerchant3D - ret - -check_target_atm: - cmp eax, INTERACT_ATM - jne check_target_terminal - invoke BeginTerminal3D,0 - ret - -check_target_terminal: - cmp eax, INTERACT_TERMINAL - jne check_target_observer - invoke BeginTerminal3D,1 - ret - -check_target_observer: - cmp eax, INTERACT_OBSERVER - jne target_unported - call BeginObserver3D - ret - -target_unported: - call BeginUnavailable3D -trigger_done: - ret -Trigger3DInteraction ENDP - -; --- Engine Initialization --- -Init3DEngine PROC - local screenCX:DWORD - local screenCY:DWORD - local posX:DWORD - local posY:DWORD - local bytesRead:DWORD - - push ebx - push esi - push edi - - invoke timeBeginPeriod, 1 - call LoadDisplaySettings3D - call Create3DWindow - test eax, eax - jz init_failed - call LoadTextures3D - test eax, eax - jz init_failed - - call InitializeCasinoSprites3D - - ; Initialize raycasting worker thread and sync events - invoke CreateEventA, 0, 0, 0, 0 - mov hRaycastStartEvent, eax - invoke CreateEventA, 0, 0, 0, 0 - mov hRaycastDoneEvent, eax - mov bRaycastQuit, 0 - invoke CreateThread, 0, 65536, OFFSET RaycastWorkerProc, 0, 0, ADDR raycastThreadId - mov hRaycastThread, eax - - call InitHall3D - call BeginStartup3D - call RenderStartup3D - invoke ShowWindow, h3DWnd, SW_SHOW - invoke UpdateWindow, h3DWnd - invoke SetForegroundWindow, h3DWnd - mov eax, 1 - jmp init_return -init_failed: - xor eax, eax -init_return: - pop edi - pop esi - pop ebx - ret -Init3DEngine ENDP - -InitializeCasinoSprites3D PROC -init_sprites_table: - ; Sprite 0: VIP Dancer 1 (Stage Left) - mov casinoSprites[0*SIZEOF SpriteObject].posX, (13 * FP_1 + FP_HALF) - mov casinoSprites[0*SIZEOF SpriteObject].posY, (4 * FP_1) - mov casinoSprites[0*SIZEOF SpriteObject].baseTexId, 10 - mov casinoSprites[0*SIZEOF SpriteObject].frameCount, 12 - mov casinoSprites[0*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[0*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[0*SIZEOF SpriteObject].animSpeed, 5 - mov casinoSprites[0*SIZEOF SpriteObject].interactId, INTERACT_DANCER - mov casinoSprites[0*SIZEOF SpriteObject].promptPtr, OFFSET promptDancer - - ; Sprite 1: VIP Dancer 2 (Center Stage Star) - mov casinoSprites[1*SIZEOF SpriteObject].posX, (16 * FP_1 + FP_HALF) - mov casinoSprites[1*SIZEOF SpriteObject].posY, (3 * FP_1 + FP_HALF) - mov casinoSprites[1*SIZEOF SpriteObject].baseTexId, 10 - mov casinoSprites[1*SIZEOF SpriteObject].frameCount, 12 - mov casinoSprites[1*SIZEOF SpriteObject].curFrame, 2 - mov casinoSprites[1*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[1*SIZEOF SpriteObject].animSpeed, 5 - mov casinoSprites[1*SIZEOF SpriteObject].interactId, INTERACT_DANCER - mov casinoSprites[1*SIZEOF SpriteObject].promptPtr, OFFSET promptDancer - - ; Sprite 2: VIP Dancer 3 (Stage Right) - mov casinoSprites[2*SIZEOF SpriteObject].posX, (19 * FP_1 + FP_HALF) - mov casinoSprites[2*SIZEOF SpriteObject].posY, (4 * FP_1) - mov casinoSprites[2*SIZEOF SpriteObject].baseTexId, 10 - mov casinoSprites[2*SIZEOF SpriteObject].frameCount, 12 - mov casinoSprites[2*SIZEOF SpriteObject].curFrame, 1 - mov casinoSprites[2*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[2*SIZEOF SpriteObject].animSpeed, 5 - mov casinoSprites[2*SIZEOF SpriteObject].interactId, INTERACT_DANCER - mov casinoSprites[2*SIZEOF SpriteObject].promptPtr, OFFSET promptDancer - - ; Sprite 3: VIP Blackjack (Front Center Left) - mov casinoSprites[3*SIZEOF SpriteObject].posX, (12 * FP_1 + FP_HALF) - mov casinoSprites[3*SIZEOF SpriteObject].posY, (8 * FP_1) - mov casinoSprites[3*SIZEOF SpriteObject].baseTexId, 30 - mov casinoSprites[3*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[3*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[3*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[3*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[3*SIZEOF SpriteObject].interactId, INTERACT_BLACKJACK - mov casinoSprites[3*SIZEOF SpriteObject].promptPtr, OFFSET promptBlackjack - - ; Sprite 4: European Roulette Table (Front Center) - mov casinoSprites[4*SIZEOF SpriteObject].posX, (16 * FP_1 + FP_HALF) - mov casinoSprites[4*SIZEOF SpriteObject].posY, (10 * FP_1) - mov casinoSprites[4*SIZEOF SpriteObject].baseTexId, 31 - mov casinoSprites[4*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[4*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[4*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[4*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[4*SIZEOF SpriteObject].interactId, INTERACT_ROULETTE - mov casinoSprites[4*SIZEOF SpriteObject].promptPtr, OFFSET promptCasinoRoulette - - ; Sprite 5: Texas Hold'em Poker Table (Front Center Right) - mov casinoSprites[5*SIZEOF SpriteObject].posX, (20 * FP_1 + FP_HALF) - mov casinoSprites[5*SIZEOF SpriteObject].posY, (8 * FP_1) - mov casinoSprites[5*SIZEOF SpriteObject].baseTexId, 30 - mov casinoSprites[5*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[5*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[5*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[5*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[5*SIZEOF SpriteObject].interactId, INTERACT_POKER - mov casinoSprites[5*SIZEOF SpriteObject].promptPtr, OFFSET promptPoker - - ; Sprite 6: Podkidnoy Durak Card Table - mov casinoSprites[6*SIZEOF SpriteObject].posX, (24 * FP_1 + FP_HALF) - mov casinoSprites[6*SIZEOF SpriteObject].posY, (8 * FP_1) - mov casinoSprites[6*SIZEOF SpriteObject].baseTexId, 30 - mov casinoSprites[6*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[6*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[6*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[6*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[6*SIZEOF SpriteObject].interactId, INTERACT_DURAK - mov casinoSprites[6*SIZEOF SpriteObject].promptPtr, OFFSET promptDurak - - ; Sprite 7: Classic Slots 777 (West Arcade 1) - mov casinoSprites[7*SIZEOF SpriteObject].posX, (6 * FP_1) - mov casinoSprites[7*SIZEOF SpriteObject].posY, (8 * FP_1) - mov casinoSprites[7*SIZEOF SpriteObject].baseTexId, 24 - mov casinoSprites[7*SIZEOF SpriteObject].frameCount, 3 - mov casinoSprites[7*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[7*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[7*SIZEOF SpriteObject].animSpeed, 8 - mov casinoSprites[7*SIZEOF SpriteObject].interactId, INTERACT_SLOTS_777 - mov casinoSprites[7*SIZEOF SpriteObject].promptPtr, OFFSET promptClassicSlot - - ; Sprite 8: CloverPit Slots 5x3 (West Arcade 2) - mov casinoSprites[8*SIZEOF SpriteObject].posX, (6 * FP_1) - mov casinoSprites[8*SIZEOF SpriteObject].posY, (11 * FP_1) - mov casinoSprites[8*SIZEOF SpriteObject].baseTexId, 24 - mov casinoSprites[8*SIZEOF SpriteObject].frameCount, 3 - mov casinoSprites[8*SIZEOF SpriteObject].curFrame, 1 - mov casinoSprites[8*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[8*SIZEOF SpriteObject].animSpeed, 8 - mov casinoSprites[8*SIZEOF SpriteObject].interactId, INTERACT_SLOTS_CLOVER - mov casinoSprites[8*SIZEOF SpriteObject].promptPtr, OFFSET promptCloverSlot - - ; Sprite 9: Craps & Dice Table (West Arcade 3) - mov casinoSprites[9*SIZEOF SpriteObject].posX, (6 * FP_1) - mov casinoSprites[9*SIZEOF SpriteObject].posY, (14 * FP_1) - mov casinoSprites[9*SIZEOF SpriteObject].baseTexId, 30 - mov casinoSprites[9*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[9*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[9*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[9*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[9*SIZEOF SpriteObject].interactId, INTERACT_DICE - mov casinoSprites[9*SIZEOF SpriteObject].promptPtr, OFFSET promptDice - - ; Sprite 10: Skulls & Cups Table - mov casinoSprites[10*SIZEOF SpriteObject].posX, (10 * FP_1) - mov casinoSprites[10*SIZEOF SpriteObject].posY, (15 * FP_1) - mov casinoSprites[10*SIZEOF SpriteObject].baseTexId, 30 - mov casinoSprites[10*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[10*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[10*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[10*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[10*SIZEOF SpriteObject].interactId, INTERACT_SKULLS - mov casinoSprites[10*SIZEOF SpriteObject].promptPtr, OFFSET promptSkulls - - ; Sprite 11: Coin Toss Stand - mov casinoSprites[11*SIZEOF SpriteObject].posX, (14 * FP_1) - mov casinoSprites[11*SIZEOF SpriteObject].posY, (15 * FP_1) - mov casinoSprites[11*SIZEOF SpriteObject].baseTexId, 30 - mov casinoSprites[11*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[11*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[11*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[11*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[11*SIZEOF SpriteObject].interactId, INTERACT_COIN - mov casinoSprites[11*SIZEOF SpriteObject].promptPtr, OFFSET promptCoin - - ; Sprite 12: Skill Check Stand - mov casinoSprites[12*SIZEOF SpriteObject].posX, (18 * FP_1) - mov casinoSprites[12*SIZEOF SpriteObject].posY, (15 * FP_1) - mov casinoSprites[12*SIZEOF SpriteObject].baseTexId, 30 - mov casinoSprites[12*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[12*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[12*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[12*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[12*SIZEOF SpriteObject].interactId, INTERACT_SKILL_CHECK - mov casinoSprites[12*SIZEOF SpriteObject].promptPtr, OFFSET promptSkillCheck - - ; Sprite 13: Umamusume Derby Lounge - mov casinoSprites[13*SIZEOF SpriteObject].posX, (22 * FP_1) - mov casinoSprites[13*SIZEOF SpriteObject].posY, (15 * FP_1) - mov casinoSprites[13*SIZEOF SpriteObject].baseTexId, 30 - mov casinoSprites[13*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[13*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[13*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[13*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[13*SIZEOF SpriteObject].interactId, INTERACT_UMAMUSUME - mov casinoSprites[13*SIZEOF SpriteObject].promptPtr, OFFSET promptUmamusume - - ; Sprite 14: Boutique & Shop (East Wing) - mov casinoSprites[14*SIZEOF SpriteObject].posX, (26 * FP_1) - mov casinoSprites[14*SIZEOF SpriteObject].posY, (12 * FP_1) - mov casinoSprites[14*SIZEOF SpriteObject].baseTexId, 32 - mov casinoSprites[14*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[14*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[14*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[14*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[14*SIZEOF SpriteObject].interactId, INTERACT_SHOP - mov casinoSprites[14*SIZEOF SpriteObject].promptPtr, OFFSET promptShop - - ; Sprite 15: Cashier & ATM (East Wing) - mov casinoSprites[15*SIZEOF SpriteObject].posX, (26 * FP_1) - mov casinoSprites[15*SIZEOF SpriteObject].posY, (16 * FP_1) - mov casinoSprites[15*SIZEOF SpriteObject].baseTexId, 33 - mov casinoSprites[15*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[15*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[15*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[15*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[15*SIZEOF SpriteObject].interactId, INTERACT_ATM - mov casinoSprites[15*SIZEOF SpriteObject].promptPtr, OFFSET promptATM - - ; Sprite 16: Player Terminal (East Wing) - mov casinoSprites[16*SIZEOF SpriteObject].posX, (26 * FP_1) - mov casinoSprites[16*SIZEOF SpriteObject].posY, (20 * FP_1) - mov casinoSprites[16*SIZEOF SpriteObject].baseTexId, 33 - mov casinoSprites[16*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[16*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[16*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[16*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[16*SIZEOF SpriteObject].interactId, INTERACT_TERMINAL - mov casinoSprites[16*SIZEOF SpriteObject].promptPtr, OFFSET promptPlayerTerminal - - ; Sprite 17: Buckshot Roulette (South-West) - mov casinoSprites[17*SIZEOF SpriteObject].posX, (12 * FP_1) - mov casinoSprites[17*SIZEOF SpriteObject].posY, (22 * FP_1) - mov casinoSprites[17*SIZEOF SpriteObject].baseTexId, 30 - mov casinoSprites[17*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[17*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[17*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[17*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[17*SIZEOF SpriteObject].interactId, INTERACT_BUCKSHOT - mov casinoSprites[17*SIZEOF SpriteObject].promptPtr, OFFSET promptBuckshot - - ; Sprite 18: Observer Lounge (South-East) - mov casinoSprites[18*SIZEOF SpriteObject].posX, (20 * FP_1) - mov casinoSprites[18*SIZEOF SpriteObject].posY, (22 * FP_1) - mov casinoSprites[18*SIZEOF SpriteObject].baseTexId, 30 - mov casinoSprites[18*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[18*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[18*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[18*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[18*SIZEOF SpriteObject].interactId, INTERACT_OBSERVER - mov casinoSprites[18*SIZEOF SpriteObject].promptPtr, OFFSET promptObserver - - ; Sprite 19: Russian Roulette (Backroom Entrance) - mov casinoSprites[19*SIZEOF SpriteObject].posX, (16 * FP_1) - mov casinoSprites[19*SIZEOF SpriteObject].posY, (25 * FP_1) - mov casinoSprites[19*SIZEOF SpriteObject].baseTexId, 34 - mov casinoSprites[19*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[19*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[19*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[19*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[19*SIZEOF SpriteObject].interactId, INTERACT_RUSSIAN_ROULETTE - mov casinoSprites[19*SIZEOF SpriteObject].promptPtr, OFFSET promptRussianRoulette - - ; Sprite 20: Online Russian Roulette (Backroom Secret Terminal) - mov casinoSprites[20*SIZEOF SpriteObject].posX, (18 * FP_1) - mov casinoSprites[20*SIZEOF SpriteObject].posY, (25 * FP_1) - mov casinoSprites[20*SIZEOF SpriteObject].baseTexId, 34 - mov casinoSprites[20*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[20*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[20*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[20*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[20*SIZEOF SpriteObject].interactId, INTERACT_ONLINE_RR - mov casinoSprites[20*SIZEOF SpriteObject].promptPtr, OFFSET promptOnlineRR - - ; Sprite 21: Hell Tower Portal (South Wing Deep End) - mov casinoSprites[21*SIZEOF SpriteObject].posX, (16 * FP_1 + FP_HALF) - mov casinoSprites[21*SIZEOF SpriteObject].posY, (29 * FP_1) - mov casinoSprites[21*SIZEOF SpriteObject].baseTexId, 4 - mov casinoSprites[21*SIZEOF SpriteObject].frameCount, 1 - mov casinoSprites[21*SIZEOF SpriteObject].curFrame, 0 - mov casinoSprites[21*SIZEOF SpriteObject].animTimer, 0 - mov casinoSprites[21*SIZEOF SpriteObject].animSpeed, 1 - mov casinoSprites[21*SIZEOF SpriteObject].interactId, INTERACT_HELL_TOWER - mov casinoSprites[21*SIZEOF SpriteObject].promptPtr, OFFSET promptHellTower - ret -InitializeCasinoSprites3D ENDP - -include src_graphics\audio_code.inc -include src_graphics\dice_animation.inc -include src_graphics\russian_roulette.inc -include src_graphics\startup_code.inc -include src_graphics\presentation_code.inc -include src_graphics\card_table_assets.inc -include src_graphics\poker_evaluator.inc -include src_graphics\native_poker.inc -include src_graphics\native_blackjack.inc -include src_graphics\native_durak.inc -include src_graphics\card_tables_render.inc -include src_graphics\durak_render.inc -include src_graphics\card_table_input.inc -include src_graphics\scene_animation.inc -include src_graphics\native_slots.inc -include src_graphics\native_clover.inc -include src_graphics\native_coin.inc -include src_graphics\native_dice.inc -include src_graphics\scratch.inc -include src_graphics\graphic_profiles.inc -include src_graphics\city_arrival_scene.inc -include src_graphics\arrival_scene.inc -include src_graphics\merchant_scene.inc -include src_graphics\hall_scene.inc -include src_graphics\npc_mind.inc -include src_graphics\npc_life.inc -include src_graphics\npc_contracts.inc -include src_graphics\native_wheel.inc -include src_graphics\billiards.inc -include src_graphics\buckshot.inc -include src_graphics\russian_table.inc -include src_graphics\unavailable.inc -include src_graphics\fortune_dialog.inc -include src_graphics\hell_tower.inc -include src_graphics\charms.inc -include src_graphics\observer.inc -include src_graphics\darts.inc + cmp brActive3D,0 + jne player_input_complete + cmp engineMode,MODE_STAIRS + je player_input_complete + invoke Pressed3D, 45h + test eax, eax + jz @F + call Trigger3DInteraction +@@: +player_input_complete: + ret +HandlePlayerInput ENDP + +CheckInteractions PROC uses ebx esi edi + local nearest:DWORD + mov nearest, 262144 + mov interactTargetId, 0 + mov interactPromptPtr, 0 + cmp hallLevel3D,0 + jne interaction_done + xor esi, esi +interaction_scan: + cmp esi, NUM_SPRITES + jge interaction_done + cmp esi,3 + jb interaction_next + cmp esi,17 + je interaction_next + cmp esi,19 + je interaction_next + cmp esi,21 + je interaction_next + imul edi, esi, SIZEOF SpriteObject + cmp [casinoSprites+edi].interactId, 0 + je interaction_next + mov eax, [casinoSprites+edi].posX + sub eax, playerX + sar eax, 8 + mov ebx, eax + imul eax, eax + mov ecx, eax + mov eax, [casinoSprites+edi].posY + sub eax, playerY + sar eax, 8 + mov edx, eax + imul eax, eax + add ecx, eax + cmp ecx, nearest + jae interaction_next + ; Only target objects in front of the camera. + mov eax, playerDirX + sar eax, 8 + imul eax, ebx + mov ebx, playerDirY + sar ebx, 8 + imul ebx, edx + add eax, ebx + cmp eax, 18000 + jl interaction_next + mov nearest, ecx + mov eax, [casinoSprites+edi].interactId + mov interactTargetId, eax + mov eax, [casinoSprites+edi].promptPtr + mov interactPromptPtr, eax +interaction_next: + inc esi + jmp interaction_scan +interaction_done: + call CheckHallInteractions3D + ret +CheckInteractions ENDP + +; (Legacy console arcade bezel bridge removed) + +Trigger3DInteraction PROC + cmp brActive3D,0 + jne trigger_backrooms_station + call TriggerHallInteraction3D + test eax, eax + jnz trigger_done +trigger_backrooms_station: + mov eax, interactTargetId + test eax, eax + jz trigger_done + + cmp eax, INTERACT_DANCER + jne check_target_bj + cmp bankroll, 100 + jl dancer_no_cash + sub bankroll, 100 + inc dancerLuckBuff + invoke CopyString3D, OFFSET textTips3D, OFFSET flashMessage + mov flashTimer, 100 + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + ret +dancer_no_cash: + invoke CopyString3D, OFFSET msgNeedMoney, OFFSET flashMessage + mov flashTimer, 60 + ret + +check_target_bj: + cmp eax, INTERACT_BLACKJACK + jne check_target_poker + call InitNativeBlackjack3D + mov engineMode, MODE_BLACKJACK + ret + +check_target_poker: + cmp eax, INTERACT_POKER + jne check_target_durak + call InitNativePoker3D + test eax, eax + jz target_unported + mov engineMode, MODE_POKER + ret + +check_target_durak: + cmp eax, INTERACT_DURAK + jne check_target_slots777 + call InitNativeDurak3D + mov engineMode, MODE_DURAK + ret + +check_target_slots777: + cmp eax, INTERACT_SLOTS_777 + jne check_target_slots_clover + call InitNativeSlots3D + test eax,eax + jz target_unported + mov engineMode,MODE_SLOTS + ret + +check_target_slots_clover: + cmp eax, INTERACT_SLOTS_CLOVER + jne check_target_roulette + call InitNativeClover3D + test eax,eax + jz target_unported + mov engineMode,MODE_CLOVER + ret + +check_target_roulette: + cmp eax, INTERACT_ROULETTE + jne check_target_dice + call InitNativeWheel3D + mov engineMode, MODE_ROULETTE + ret + +check_target_dice: + cmp eax, INTERACT_DICE + jne check_target_skulls + call InitDiceGame + mov engineMode, MODE_DICE + ret + +check_target_skulls: + cmp eax, INTERACT_SKULLS + jne check_target_coin + call InitSkullsGame + mov engineMode, MODE_SKULLS + ret + +check_target_coin: + cmp eax, INTERACT_COIN + jne check_target_skill + call InitCoinGame + mov engineMode, MODE_COIN + ret + +check_target_skill: + cmp eax, INTERACT_SKILL_CHECK + jne check_target_buckshot + call InitSkillGame + mov engineMode, MODE_SKILL + ret + +check_target_buckshot: + cmp eax, INTERACT_BUCKSHOT + jne check_target_rr + call InitBuckshot3D + mov engineMode, MODE_BUCKSHOT + ret + +check_target_rr: + cmp eax, INTERACT_RUSSIAN_ROULETTE + jne check_target_online_rr + call InitRussianGame3D + test eax, eax + jz @F + mov engineMode, MODE_RUSSIAN +@@: + ret + +check_target_online_rr: + cmp eax, INTERACT_ONLINE_RR + jne check_target_umamusume + call BeginUnavailable3D + ret + +check_target_umamusume: + cmp eax, INTERACT_UMAMUSUME + jne check_target_hell + call BeginUnavailable3D + ret + +check_target_hell: + cmp eax, INTERACT_HELL_TOWER + jne check_target_shop + call InitHellTower3D + ret + +check_target_shop: + cmp eax, INTERACT_SHOP + jne check_target_atm + call BeginMerchant3D + ret + +check_target_atm: + cmp eax, INTERACT_ATM + jne check_target_terminal + invoke BeginTerminal3D,0 + ret + +check_target_terminal: + cmp eax, INTERACT_TERMINAL + jne check_target_observer + invoke BeginTerminal3D,1 + ret + +check_target_observer: + cmp eax, INTERACT_OBSERVER + jne target_unported + call BeginObserver3D + ret + +target_unported: + call BeginUnavailable3D +trigger_done: + ret +Trigger3DInteraction ENDP + +; --- Engine Initialization --- +Init3DEngine PROC + local screenCX:DWORD + local screenCY:DWORD + local posX:DWORD + local posY:DWORD + local bytesRead:DWORD + + push ebx + push esi + push edi + + invoke timeBeginPeriod, 1 + call LoadDisplaySettings3D + call Create3DWindow + test eax, eax + jz init_failed + call LoadTextures3D + test eax, eax + jz init_failed + + call InitializeCasinoSprites3D + + ; Initialize raycasting worker thread and sync events + invoke CreateEventA, 0, 0, 0, 0 + mov hRaycastStartEvent, eax + invoke CreateEventA, 0, 0, 0, 0 + mov hRaycastDoneEvent, eax + mov bRaycastQuit, 0 + invoke CreateThread, 0, 65536, OFFSET RaycastWorkerProc, 0, 0, ADDR raycastThreadId + mov hRaycastThread, eax + + call InitHall3D + call BeginStartup3D + call RenderStartup3D + invoke ShowWindow, h3DWnd, SW_SHOW + invoke UpdateWindow, h3DWnd + invoke SetForegroundWindow, h3DWnd + mov eax, 1 + jmp init_return +init_failed: + xor eax, eax +init_return: + pop edi + pop esi + pop ebx + ret +Init3DEngine ENDP + +InitializeCasinoSprites3D PROC +init_sprites_table: + ; Sprite 0: VIP Dancer 1 (Stage Left) + mov casinoSprites[0*SIZEOF SpriteObject].posX, (13 * FP_1 + FP_HALF) + mov casinoSprites[0*SIZEOF SpriteObject].posY, (4 * FP_1) + mov casinoSprites[0*SIZEOF SpriteObject].baseTexId, 10 + mov casinoSprites[0*SIZEOF SpriteObject].frameCount, 12 + mov casinoSprites[0*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[0*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[0*SIZEOF SpriteObject].animSpeed, 5 + mov casinoSprites[0*SIZEOF SpriteObject].interactId, INTERACT_DANCER + mov casinoSprites[0*SIZEOF SpriteObject].promptPtr, OFFSET promptDancer + + ; Sprite 1: VIP Dancer 2 (Center Stage Star) + mov casinoSprites[1*SIZEOF SpriteObject].posX, (16 * FP_1 + FP_HALF) + mov casinoSprites[1*SIZEOF SpriteObject].posY, (3 * FP_1 + FP_HALF) + mov casinoSprites[1*SIZEOF SpriteObject].baseTexId, 10 + mov casinoSprites[1*SIZEOF SpriteObject].frameCount, 12 + mov casinoSprites[1*SIZEOF SpriteObject].curFrame, 2 + mov casinoSprites[1*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[1*SIZEOF SpriteObject].animSpeed, 5 + mov casinoSprites[1*SIZEOF SpriteObject].interactId, INTERACT_DANCER + mov casinoSprites[1*SIZEOF SpriteObject].promptPtr, OFFSET promptDancer + + ; Sprite 2: VIP Dancer 3 (Stage Right) + mov casinoSprites[2*SIZEOF SpriteObject].posX, (19 * FP_1 + FP_HALF) + mov casinoSprites[2*SIZEOF SpriteObject].posY, (4 * FP_1) + mov casinoSprites[2*SIZEOF SpriteObject].baseTexId, 10 + mov casinoSprites[2*SIZEOF SpriteObject].frameCount, 12 + mov casinoSprites[2*SIZEOF SpriteObject].curFrame, 1 + mov casinoSprites[2*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[2*SIZEOF SpriteObject].animSpeed, 5 + mov casinoSprites[2*SIZEOF SpriteObject].interactId, INTERACT_DANCER + mov casinoSprites[2*SIZEOF SpriteObject].promptPtr, OFFSET promptDancer + + ; Sprite 3: VIP Blackjack (Front Center Left) + mov casinoSprites[3*SIZEOF SpriteObject].posX, (12 * FP_1 + FP_HALF) + mov casinoSprites[3*SIZEOF SpriteObject].posY, (8 * FP_1) + mov casinoSprites[3*SIZEOF SpriteObject].baseTexId, 30 + mov casinoSprites[3*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[3*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[3*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[3*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[3*SIZEOF SpriteObject].interactId, INTERACT_BLACKJACK + mov casinoSprites[3*SIZEOF SpriteObject].promptPtr, OFFSET promptBlackjack + + ; Sprite 4: European Roulette Table (Front Center) + mov casinoSprites[4*SIZEOF SpriteObject].posX, (16 * FP_1 + FP_HALF) + mov casinoSprites[4*SIZEOF SpriteObject].posY, (10 * FP_1) + mov casinoSprites[4*SIZEOF SpriteObject].baseTexId, 31 + mov casinoSprites[4*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[4*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[4*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[4*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[4*SIZEOF SpriteObject].interactId, INTERACT_ROULETTE + mov casinoSprites[4*SIZEOF SpriteObject].promptPtr, OFFSET promptCasinoRoulette + + ; Sprite 5: Texas Hold'em Poker Table (Front Center Right) + mov casinoSprites[5*SIZEOF SpriteObject].posX, (20 * FP_1 + FP_HALF) + mov casinoSprites[5*SIZEOF SpriteObject].posY, (8 * FP_1) + mov casinoSprites[5*SIZEOF SpriteObject].baseTexId, 30 + mov casinoSprites[5*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[5*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[5*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[5*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[5*SIZEOF SpriteObject].interactId, INTERACT_POKER + mov casinoSprites[5*SIZEOF SpriteObject].promptPtr, OFFSET promptPoker + + ; Sprite 6: Podkidnoy Durak Card Table + mov casinoSprites[6*SIZEOF SpriteObject].posX, (24 * FP_1 + FP_HALF) + mov casinoSprites[6*SIZEOF SpriteObject].posY, (8 * FP_1) + mov casinoSprites[6*SIZEOF SpriteObject].baseTexId, 30 + mov casinoSprites[6*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[6*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[6*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[6*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[6*SIZEOF SpriteObject].interactId, INTERACT_DURAK + mov casinoSprites[6*SIZEOF SpriteObject].promptPtr, OFFSET promptDurak + + ; Sprite 7: Classic Slots 777 (West Arcade 1) + mov casinoSprites[7*SIZEOF SpriteObject].posX, (6 * FP_1) + mov casinoSprites[7*SIZEOF SpriteObject].posY, (8 * FP_1) + mov casinoSprites[7*SIZEOF SpriteObject].baseTexId, 24 + mov casinoSprites[7*SIZEOF SpriteObject].frameCount, 3 + mov casinoSprites[7*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[7*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[7*SIZEOF SpriteObject].animSpeed, 8 + mov casinoSprites[7*SIZEOF SpriteObject].interactId, INTERACT_SLOTS_777 + mov casinoSprites[7*SIZEOF SpriteObject].promptPtr, OFFSET promptClassicSlot + + ; Sprite 8: CloverPit Slots 5x3 (West Arcade 2) + mov casinoSprites[8*SIZEOF SpriteObject].posX, (6 * FP_1) + mov casinoSprites[8*SIZEOF SpriteObject].posY, (11 * FP_1) + mov casinoSprites[8*SIZEOF SpriteObject].baseTexId, 24 + mov casinoSprites[8*SIZEOF SpriteObject].frameCount, 3 + mov casinoSprites[8*SIZEOF SpriteObject].curFrame, 1 + mov casinoSprites[8*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[8*SIZEOF SpriteObject].animSpeed, 8 + mov casinoSprites[8*SIZEOF SpriteObject].interactId, INTERACT_SLOTS_CLOVER + mov casinoSprites[8*SIZEOF SpriteObject].promptPtr, OFFSET promptCloverSlot + + ; Sprite 9: Craps & Dice Table (West Arcade 3) + mov casinoSprites[9*SIZEOF SpriteObject].posX, (6 * FP_1) + mov casinoSprites[9*SIZEOF SpriteObject].posY, (14 * FP_1) + mov casinoSprites[9*SIZEOF SpriteObject].baseTexId, 30 + mov casinoSprites[9*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[9*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[9*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[9*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[9*SIZEOF SpriteObject].interactId, INTERACT_DICE + mov casinoSprites[9*SIZEOF SpriteObject].promptPtr, OFFSET promptDice + + ; Sprite 10: Skulls & Cups Table + mov casinoSprites[10*SIZEOF SpriteObject].posX, (10 * FP_1) + mov casinoSprites[10*SIZEOF SpriteObject].posY, (15 * FP_1) + mov casinoSprites[10*SIZEOF SpriteObject].baseTexId, 30 + mov casinoSprites[10*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[10*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[10*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[10*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[10*SIZEOF SpriteObject].interactId, INTERACT_SKULLS + mov casinoSprites[10*SIZEOF SpriteObject].promptPtr, OFFSET promptSkulls + + ; Sprite 11: Coin Toss Stand + mov casinoSprites[11*SIZEOF SpriteObject].posX, (14 * FP_1) + mov casinoSprites[11*SIZEOF SpriteObject].posY, (15 * FP_1) + mov casinoSprites[11*SIZEOF SpriteObject].baseTexId, 30 + mov casinoSprites[11*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[11*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[11*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[11*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[11*SIZEOF SpriteObject].interactId, INTERACT_COIN + mov casinoSprites[11*SIZEOF SpriteObject].promptPtr, OFFSET promptCoin + + ; Sprite 12: Skill Check Stand + mov casinoSprites[12*SIZEOF SpriteObject].posX, (18 * FP_1) + mov casinoSprites[12*SIZEOF SpriteObject].posY, (15 * FP_1) + mov casinoSprites[12*SIZEOF SpriteObject].baseTexId, 30 + mov casinoSprites[12*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[12*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[12*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[12*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[12*SIZEOF SpriteObject].interactId, INTERACT_SKILL_CHECK + mov casinoSprites[12*SIZEOF SpriteObject].promptPtr, OFFSET promptSkillCheck + + ; Sprite 13: Umamusume Derby Lounge + mov casinoSprites[13*SIZEOF SpriteObject].posX, (22 * FP_1) + mov casinoSprites[13*SIZEOF SpriteObject].posY, (15 * FP_1) + mov casinoSprites[13*SIZEOF SpriteObject].baseTexId, 30 + mov casinoSprites[13*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[13*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[13*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[13*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[13*SIZEOF SpriteObject].interactId, INTERACT_UMAMUSUME + mov casinoSprites[13*SIZEOF SpriteObject].promptPtr, OFFSET promptUmamusume + + ; Sprite 14: Boutique & Shop (East Wing) + mov casinoSprites[14*SIZEOF SpriteObject].posX, (26 * FP_1) + mov casinoSprites[14*SIZEOF SpriteObject].posY, (12 * FP_1) + mov casinoSprites[14*SIZEOF SpriteObject].baseTexId, 32 + mov casinoSprites[14*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[14*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[14*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[14*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[14*SIZEOF SpriteObject].interactId, INTERACT_SHOP + mov casinoSprites[14*SIZEOF SpriteObject].promptPtr, OFFSET promptShop + + ; Sprite 15: Cashier & ATM (East Wing) + mov casinoSprites[15*SIZEOF SpriteObject].posX, (26 * FP_1) + mov casinoSprites[15*SIZEOF SpriteObject].posY, (16 * FP_1) + mov casinoSprites[15*SIZEOF SpriteObject].baseTexId, 33 + mov casinoSprites[15*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[15*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[15*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[15*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[15*SIZEOF SpriteObject].interactId, INTERACT_ATM + mov casinoSprites[15*SIZEOF SpriteObject].promptPtr, OFFSET promptATM + + ; Sprite 16: Player Terminal (East Wing) + mov casinoSprites[16*SIZEOF SpriteObject].posX, (26 * FP_1) + mov casinoSprites[16*SIZEOF SpriteObject].posY, (20 * FP_1) + mov casinoSprites[16*SIZEOF SpriteObject].baseTexId, 33 + mov casinoSprites[16*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[16*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[16*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[16*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[16*SIZEOF SpriteObject].interactId, INTERACT_TERMINAL + mov casinoSprites[16*SIZEOF SpriteObject].promptPtr, OFFSET promptPlayerTerminal + + ; Sprite 17: Buckshot Roulette (South-West) + mov casinoSprites[17*SIZEOF SpriteObject].posX, (12 * FP_1) + mov casinoSprites[17*SIZEOF SpriteObject].posY, (22 * FP_1) + mov casinoSprites[17*SIZEOF SpriteObject].baseTexId, 30 + mov casinoSprites[17*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[17*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[17*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[17*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[17*SIZEOF SpriteObject].interactId, INTERACT_BUCKSHOT + mov casinoSprites[17*SIZEOF SpriteObject].promptPtr, OFFSET promptBuckshot + + ; Sprite 18: Observer Lounge (South-East) + mov casinoSprites[18*SIZEOF SpriteObject].posX, (20 * FP_1) + mov casinoSprites[18*SIZEOF SpriteObject].posY, (22 * FP_1) + mov casinoSprites[18*SIZEOF SpriteObject].baseTexId, 30 + mov casinoSprites[18*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[18*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[18*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[18*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[18*SIZEOF SpriteObject].interactId, INTERACT_OBSERVER + mov casinoSprites[18*SIZEOF SpriteObject].promptPtr, OFFSET promptObserver + + ; Sprite 19: Russian Roulette (Backroom Entrance) + mov casinoSprites[19*SIZEOF SpriteObject].posX, (16 * FP_1) + mov casinoSprites[19*SIZEOF SpriteObject].posY, (25 * FP_1) + mov casinoSprites[19*SIZEOF SpriteObject].baseTexId, 34 + mov casinoSprites[19*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[19*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[19*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[19*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[19*SIZEOF SpriteObject].interactId, INTERACT_RUSSIAN_ROULETTE + mov casinoSprites[19*SIZEOF SpriteObject].promptPtr, OFFSET promptRussianRoulette + + ; Sprite 20: Online Russian Roulette (Backroom Secret Terminal) + mov casinoSprites[20*SIZEOF SpriteObject].posX, (18 * FP_1) + mov casinoSprites[20*SIZEOF SpriteObject].posY, (25 * FP_1) + mov casinoSprites[20*SIZEOF SpriteObject].baseTexId, 34 + mov casinoSprites[20*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[20*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[20*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[20*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[20*SIZEOF SpriteObject].interactId, INTERACT_ONLINE_RR + mov casinoSprites[20*SIZEOF SpriteObject].promptPtr, OFFSET promptOnlineRR + + ; Sprite 21: Hell Tower Portal (South Wing Deep End) + mov casinoSprites[21*SIZEOF SpriteObject].posX, (16 * FP_1 + FP_HALF) + mov casinoSprites[21*SIZEOF SpriteObject].posY, (29 * FP_1) + mov casinoSprites[21*SIZEOF SpriteObject].baseTexId, 4 + mov casinoSprites[21*SIZEOF SpriteObject].frameCount, 1 + mov casinoSprites[21*SIZEOF SpriteObject].curFrame, 0 + mov casinoSprites[21*SIZEOF SpriteObject].animTimer, 0 + mov casinoSprites[21*SIZEOF SpriteObject].animSpeed, 1 + mov casinoSprites[21*SIZEOF SpriteObject].interactId, INTERACT_HELL_TOWER + mov casinoSprites[21*SIZEOF SpriteObject].promptPtr, OFFSET promptHellTower + ret +InitializeCasinoSprites3D ENDP + +include src_graphics\audio_code.inc +include src_graphics\dice_animation.inc +include src_graphics\russian_roulette.inc +include src_graphics\startup_code.inc +include src_graphics\presentation_code.inc +include src_graphics\card_table_assets.inc +include src_graphics\poker_evaluator.inc +include src_graphics\native_poker.inc +include src_graphics\native_blackjack.inc +include src_graphics\native_durak.inc +include src_graphics\card_tables_render.inc +include src_graphics\durak_render.inc +include src_graphics\card_table_input.inc +include src_graphics\scene_animation.inc +include src_graphics\native_slots.inc +include src_graphics\native_clover.inc +include src_graphics\native_coin.inc +include src_graphics\native_dice.inc +include src_graphics\scratch.inc +include src_graphics\graphic_profiles.inc +include src_graphics\city_arrival_scene.inc +include src_graphics\arrival_scene.inc +include src_graphics\merchant_scene.inc +include src_graphics\hall_scene.inc +include src_graphics\npc_mind.inc +include src_graphics\npc_life.inc +include src_graphics\npc_contracts.inc +include src_graphics\native_wheel.inc +include src_graphics\billiards.inc +include src_graphics\buckshot.inc +include src_graphics\russian_table.inc +include src_graphics\unavailable.inc +include src_graphics\fortune_dialog.inc +include src_graphics\hell_tower.inc +include src_graphics\charms.inc +include src_graphics\observer.inc +include src_graphics\darts.inc include src_graphics\jackbox.inc -include src_graphics\backrooms.inc +include src_graphics\backrooms.inc include src_graphics\hell_fps.inc include src_graphics\hell_fps_combat.inc include src_graphics\hell_fps_render.inc - -; --- Main Loop of the 3D Casino Engine --- -StartHellTower3D PROC uses ebx esi edi - mov startInHellTower, 1 - call StartCasino3D - ret -StartHellTower3D ENDP - -StartCasino3D PROC uses ebx esi edi - call Init3DEngine - test eax, eax - jz engine_shutdown - invoke timeGetTime - mov rngSeed3D, eax - mov previousTick3D, eax - cmp startInHellTower, 1 - jne engine_loop - mov startInHellTower, 0 - call InitHellTower3D -engine_loop: - invoke PeekMessageA, OFFSET msg3D, 0, 0, 0, PM_REMOVE - test eax, eax - jz dispatch_frame - cmp msg3D.message, WM_QUIT - je engine_shutdown - invoke TranslateMessage, OFFSET msg3D - invoke DispatchMessageA, OFFSET msg3D - jmp engine_loop - -dispatch_frame: - invoke timeGetTime - mov frameStart3D, eax - sub eax, previousTick3D - cmp eax, 50 - jbe @F - mov eax, 50 -@@: - mov deltaTime3D, eax - mov eax, frameStart3D - mov previousTick3D, eax - invoke GetForegroundWindow - cmp eax, h3DWnd - jne engine_idle - invoke IsIconic, h3DWnd - test eax, eax - jnz engine_idle - invoke Pressed3D, 7Ah - test eax, eax - jz @F - call ToggleFullscreen3D -@@: - cmp obsActive3D,0 - jne engine_observer_frame - cmp engineMode,MODE_OBSERVER - jne engine_observer_skip -engine_observer_frame: - call UpdateMouseLockState - call ObserverFrame3D - jmp present_frame -engine_observer_skip: - invoke Pressed3D, 1Bh - test eax, eax - jz engine_tick +include src_graphics\underworld.inc +include src_graphics\underworld_analysis.inc +include src_graphics\security_scene.inc +include src_graphics\debt_scene.inc +include src_graphics\rat_race.inc +include src_graphics\heist_hq.inc +include src_graphics\heist_hq_render.inc +include src_graphics\heist_mission.inc + +; --- Main Loop of the 3D Casino Engine --- +StartHellTower3D PROC uses ebx esi edi + mov startInHellTower, 1 + call StartCasino3D + ret +StartHellTower3D ENDP + +StartCasino3D PROC uses ebx esi edi + call Init3DEngine + test eax, eax + jz engine_shutdown + invoke timeGetTime + mov rngSeed3D, eax + mov previousTick3D, eax + cmp startInHellTower, 1 + jne engine_loop + mov startInHellTower, 0 + call InitHellTower3D +engine_loop: + invoke PeekMessageA, OFFSET msg3D, 0, 0, 0, PM_REMOVE + test eax, eax + jz dispatch_frame + cmp msg3D.message, WM_QUIT + je engine_shutdown + invoke TranslateMessage, OFFSET msg3D + invoke DispatchMessageA, OFFSET msg3D + jmp engine_loop + +dispatch_frame: + invoke timeGetTime + mov frameStart3D, eax + sub eax, previousTick3D + cmp eax, 50 + jbe @F + mov eax, 50 +@@: + mov deltaTime3D, eax + mov eax, frameStart3D + mov previousTick3D, eax + invoke GetForegroundWindow + cmp eax, h3DWnd + jne engine_idle + invoke IsIconic, h3DWnd + test eax, eax + jnz engine_idle + invoke Pressed3D, 7Ah + test eax, eax + jz @F + call ToggleFullscreen3D +@@: + cmp obsActive3D,0 + jne engine_observer_frame + cmp engineMode,MODE_OBSERVER + jne engine_observer_skip +engine_observer_frame: + call UpdateMouseLockState + call ObserverFrame3D + jmp present_frame +engine_observer_skip: + invoke Pressed3D, 1Bh + test eax, eax + jz engine_tick cmp welcomeActive3D,0 je @F call CloseWelcome3D jmp engine_tick @@: + cmp engineMode,MODE_HEIST + jne hq_escape_other + cmp hqActive,1 + jne hq_escape_other + cmp heistPhase,2 + jne hq_escape_abort + mov heistPhase,7 + mov hqFireHeld,0 + call ClearKeys3D + jmp engine_tick +hq_escape_abort: + call HQLeave3D + jmp engine_tick +hq_escape_other: cmp engineMode,MODE_HELL_FPS jne @F call LeaveHellFPS3D jmp engine_tick @@: - cmp engineMode, MODE_INTRO - jne @F - call FinishStartup3D - jmp engine_tick -@@: - cmp engineMode, MODE_ARRIVAL - jne @F - call ArrivalEscape3D - jmp engine_tick -@@: - cmp engineMode,MODE_STAIRS - je pause_interior_walk - cmp engineMode, MODE_WALK - jne leave_table -pause_interior_walk: - cmp brCutscene3D,0 - jne engine_tick - mov brEntryHold3D,0 - xor paused3D, 1 - jmp engine_tick -leave_table: - cmp engineMode,MODE_BOWLING - jne @F - call LeaveBowlingPlay3D - jmp engine_tick -@@: - cmp engineMode,MODE_FORTUNE - jne @F - call StopFortuneWorker3D - mov engineMode,MODE_WALK - mov paused3D,0 - call ClearKeys3D - jmp engine_tick -@@: - cmp engineMode,MODE_SCRATCH - jne @F - call LeaveScratch3D - jmp engine_tick -@@: - cmp engineMode,MODE_DICE - jne @F - call DiceEscape3D - jmp engine_tick -@@: - call CardTableEscape3D - test eax, eax - jnz engine_tick - call TableBusy3D - test eax, eax - jz leave_idle_table - xor paused3D, 1 - call ClearKeys3D - jmp engine_tick -leave_idle_table: - mov paused3D, 0 - cmp tournamentMode, 1 - jne @F - call TowerExitToHall - jmp engine_tick -@@: - mov engineMode, MODE_WALK - call ClearKeys3D - invoke PlayCasinoSound3D, 0, 0, 0 -engine_tick: - call UpdateMouseLockState - cmp paused3D, 0 - jne draw_pause - mov eax, deltaTime3D - add animationClock3D, eax - cmp engineMode, MODE_INTRO - jne check_arrival_mode - call HandleStartupInput3D - cmp engineMode, MODE_INTRO - jne check_arrival_mode - call RenderStartup3D - jmp present_frame -check_arrival_mode: - cmp engineMode, MODE_ARRIVAL - jne check_walk_mode - call HandleArrival3D - cmp engineMode, MODE_WALK - je check_walk_mode - call RenderArrival3D - jmp present_frame -check_walk_mode: + cmp engineMode, MODE_INTRO + jne @F + call FinishStartup3D + jmp engine_tick +@@: + cmp engineMode, MODE_ARRIVAL + jne @F + call ArrivalEscape3D + jmp engine_tick +@@: + cmp engineMode,MODE_STAIRS + je pause_interior_walk + cmp engineMode, MODE_WALK + jne leave_table +pause_interior_walk: + cmp brCutscene3D,0 + jne engine_tick + mov brEntryHold3D,0 + xor paused3D, 1 + jmp engine_tick +leave_table: + cmp engineMode,MODE_BOWLING + jne @F + call LeaveBowlingPlay3D + jmp engine_tick +@@: + cmp engineMode,MODE_FORTUNE + jne @F + call StopFortuneWorker3D + mov engineMode,MODE_WALK + mov paused3D,0 + call ClearKeys3D + jmp engine_tick +@@: + cmp engineMode,MODE_SCRATCH + jne @F + call LeaveScratch3D + jmp engine_tick +@@: + cmp engineMode,MODE_DICE + jne @F + call DiceEscape3D + jmp engine_tick +@@: + call CardTableEscape3D + test eax, eax + jnz engine_tick + call TableBusy3D + test eax, eax + jz leave_idle_table + xor paused3D, 1 + call ClearKeys3D + jmp engine_tick +leave_idle_table: + mov paused3D, 0 + cmp tournamentMode, 1 + jne @F + call TowerExitToHall + jmp engine_tick +@@: + mov engineMode, MODE_WALK + call ClearKeys3D + invoke PlayCasinoSound3D, 0, 0, 0 +engine_tick: + call UpdateMouseLockState + cmp paused3D, 0 + jne draw_pause + mov eax, deltaTime3D + add animationClock3D, eax + call UpdateBarBuffTimers3D + call UpdateUnderworld3D + cmp engineMode, MODE_INTRO + jne check_arrival_mode + call HandleStartupInput3D + cmp engineMode, MODE_INTRO + jne check_arrival_mode + call RenderStartup3D + jmp present_frame +check_arrival_mode: + cmp engineMode, MODE_ARRIVAL + jne check_walk_mode + call HandleArrival3D + cmp engineMode, MODE_WALK + je check_walk_mode + call RenderArrival3D + jmp present_frame +check_walk_mode: cmp engineMode,MODE_HELL_FPS jne @F call HandleHellFPS3D @@ -5449,415 +5518,439 @@ check_walk_mode: call RenderHellFPS3D jmp present_frame @@: - cmp engineMode, MODE_WALK - jne check_slots_mode - cmp welcomeActive3D,0 - je welcome_walk_ready - call HandleWelcome3D - call RenderWelcomeScene3D - jmp present_frame -welcome_walk_ready: - cmp brActive3D,0 - jne engine_backrooms - call UpdateHall3D - call UpdateCamera3D - call CheckInteractions - call HandlePlayerInput + cmp engineMode, MODE_WALK + jne check_slots_mode + cmp welcomeActive3D,0 + je welcome_walk_ready + call HandleWelcome3D + call RenderWelcomeScene3D + jmp present_frame +welcome_walk_ready: + cmp brActive3D,0 + jne engine_backrooms + call UpdateHall3D + call UpdateCamera3D + call CheckInteractions + call HandlePlayerInput cmp engineMode,MODE_HELL_FPS je check_walk_mode - call BackroomsEntry3D - cmp brActive3D,0 - jne engine_backrooms - call HandleJukeboxKeys3D - call UpdateInteriorTravel3D - call UpdateInteriorEye3D - call UpdateCamera3D - ; The roof owns all planes/depth; an indoor prepass would be discarded. - cmp hallLevel3D,HALL_ROOF - je walk_world_ready - cmp hallLevel3D,HALL_BOWLING - je walk_world_ready - call RenderCeilingAndFloor - call RenderWalls - call PrepareCityDepth3D - call RenderSprites -walk_world_ready: - call RenderHall3D - call RenderHUD - call RenderMinimap - jmp present_frame -engine_backrooms: - call HandleBackrooms3D - cmp brActive3D,0 - je check_walk_mode - cmp engineMode,MODE_WALK - jne check_slots_mode - call RenderBackrooms3D - jmp present_frame -check_slots_mode: - cmp engineMode,MODE_BOWLING - jne @F - call HandleBowlingPlay3D - cmp engineMode,MODE_WALK - je check_walk_mode - call RenderBowlingPlay3D - jmp present_frame -@@: - cmp engineMode,MODE_JACKBOX - jne check_jackbox_done - call HandleJackbox3D - cmp engineMode,MODE_WALK - je check_walk_mode - call RenderJackbox3D - jmp present_frame -check_jackbox_done: - cmp engineMode,MODE_DARTS - jne check_darts_done - call HandleDarts3D - call RenderDarts3D - jmp present_frame -check_darts_done: - cmp engineMode,MODE_FORTUNE - jne @F - call HandleFortuneDialog3D - cmp engineMode,MODE_WALK - je check_walk_mode - call RenderFortuneDialog3D - jmp present_frame -@@: - cmp engineMode,MODE_CABARET - jne @F - call HandleCabaret3D - call RenderCabaret3D - jmp present_frame -@@: - cmp engineMode,MODE_SCRATCH - jne @F - call HandleScratch3D - cmp engineMode,MODE_WALK - je check_walk_mode - call RenderScratch3D - jmp present_frame -@@: - cmp engineMode, MODE_HELL_TOWER - jne @F - call HandleHellTowerInput - call RenderHellTower3D - jmp present_frame -@@: - cmp engineMode,MODE_CLOVER - jne @F - call HandleNativeClover3D - call RenderNativeClover3D - jmp present_frame -@@: - cmp engineMode,MODE_NPC_DIALOG - jne @F - call HandleNpcDialog3D - call RenderNpcDialog3D - jmp present_frame -@@: - cmp engineMode, MODE_UNAVAILABLE - jne @F - call HandleUnavailable3D - call RenderUnavailable3D - jmp present_frame -@@: - cmp engineMode, MODE_POOL - jne @F - call HandlePool3D - call RenderPool3D - jmp present_frame -@@: - cmp engineMode, MODE_BAR - jne @F - call HandleBar3D - call RenderBar3D - jmp present_frame -@@: - cmp engineMode, MODE_STAIRS - jne @F - call HandleStairs3D - call HandleJukeboxKeys3D - call RenderStairs3D - jmp present_frame -@@: - cmp engineMode, MODE_SLOTS - jne check_bj_mode - call HandleNativeSlots3D - cmp engineMode,MODE_WALK - je check_walk_mode - call RenderNativeSlots3D - jmp present_frame -check_bj_mode: - cmp engineMode, MODE_BLACKJACK - jne check_poker_mode - call HandleNativeBlackjack3D - cmp engineMode, MODE_WALK - je check_walk_mode - call RenderNativeBlackjack3D - jmp present_frame -check_poker_mode: - cmp engineMode, MODE_POKER - jne check_durak_mode - call HandleNativePoker3D - cmp engineMode, MODE_WALK - je check_walk_mode - call RenderNativePoker3D - jmp present_frame -check_durak_mode: - cmp engineMode, MODE_DURAK - jne check_roul_mode - call HandleNativeDurak3D - cmp engineMode, MODE_WALK - je check_walk_mode - call RenderNativeDurak3D - jmp present_frame -check_roul_mode: - cmp engineMode, MODE_ROULETTE - jne check_shop_mode - call HandleNativeWheel3D - call RenderNativeWheel3D - jmp present_frame -check_shop_mode: - cmp engineMode, MODE_SHOP - jne check_atm_mode - call HandleMerchant3D - call RenderMerchant3D - jmp present_frame -check_atm_mode: - cmp engineMode, MODE_ATM - jne check_coin_mode - call HandleATMInput - call RenderATMGame - jmp present_frame -check_coin_mode: - cmp engineMode, MODE_COIN - jne check_dice_mode - call HandleCoinInput - call RenderCoinGame - jmp present_frame -check_dice_mode: - cmp engineMode, MODE_DICE - jne check_skulls_mode - call HandleDiceInput - call RenderDiceGame - jmp present_frame -check_skulls_mode: - cmp engineMode, MODE_SKULLS - jne check_skill_mode - call HandleSkullsInput - call RenderSkullsGame - jmp present_frame -check_skill_mode: - cmp engineMode, MODE_SKILL - jne check_buckshot_mode - call HandleSkillInput - call RenderSkillGame - jmp present_frame -check_buckshot_mode: - cmp engineMode, MODE_BUCKSHOT - jne check_russian_mode - call HandleBuckshot3D - call RenderBuckshot3D - jmp present_frame -check_russian_mode: - cmp engineMode, MODE_RUSSIAN - jne present_frame - call HandleRussianInput3D - call RenderRussianGame3D - jmp present_frame -draw_pause: - mov brEntryHold3D,0 - invoke DrawBoxBorder, 28, 36, 264, 168, 00151C21h, 00D8BC6Ah, 2 - invoke DrawString8x8, 44, 48, OFFSET textPause3D, 00FFFFFFh - cmp displayFill3D, 0 - je @F - invoke DrawString8x8, 44, 72, OFFSET textDisplayFill3D, 00D8BC6Ah - jmp pause_draw_quality -@@: - invoke DrawString8x8, 44, 72, OFFSET textDisplayFit3D, 00D8BC6Ah -pause_draw_quality: - invoke DrawString8x8, 44, 92, OFFSET textLowSpec3D, 00D8BC6Ah - mov eax, settingsLowSpec - cmp eax, 0 - jne @F - mov edx, OFFSET textLowSpecOff3D - jmp pause_draw_quality_value -@@: - cmp eax, 1 - jne @F - mov edx, OFFSET textLowSpecEco3D - jmp pause_draw_quality_value -@@: - mov edx, OFFSET textLowSpecQuiet3D -pause_draw_quality_value: - invoke DrawString8x8, 208, 92, edx, 00FFFFFFh - invoke DrawString8x8, 44, 112, OFFSET textVolumeKeys3D, 00D8BC6Ah - invoke DrawString8x8, 44, 130, OFFSET textSoundLevel3D, 00BBBBBBh - invoke FormatNumber, settingsVolume, OFFSET hudNumBuffer - invoke DrawString8x8, 124, 130, OFFSET hudNumBuffer, 00FFFFFFh + call BackroomsEntry3D + cmp brActive3D,0 + jne engine_backrooms + call HandleJukeboxKeys3D + call UpdateInteriorTravel3D + call UpdateInteriorEye3D + call UpdateCamera3D + ; The roof owns all planes/depth; an indoor prepass would be discarded. + cmp hallLevel3D,HALL_ROOF + je walk_world_ready + cmp hallLevel3D,HALL_BOWLING + je walk_world_ready + call RenderCeilingAndFloor + call RenderWalls + call PrepareCityDepth3D + call RenderSprites +walk_world_ready: + call RenderHall3D + call RenderHUD + call RenderMinimap + jmp present_frame +engine_backrooms: + call HandleBackrooms3D + cmp brActive3D,0 + je check_walk_mode + cmp engineMode,MODE_WALK + jne check_slots_mode + call RenderBackrooms3D + jmp present_frame +check_slots_mode: + cmp engineMode,MODE_BOWLING + jne @F + call HandleBowlingPlay3D + cmp engineMode,MODE_WALK + je check_walk_mode + call RenderBowlingPlay3D + jmp present_frame +@@: + cmp engineMode,MODE_JACKBOX + jne check_jackbox_done + call HandleJackbox3D + cmp engineMode,MODE_WALK + je check_walk_mode + call RenderJackbox3D + jmp present_frame +check_jackbox_done: + cmp engineMode,MODE_DARTS + jne check_darts_done + call HandleDarts3D + call RenderDarts3D + jmp present_frame +check_darts_done: + cmp engineMode,MODE_FORTUNE + jne @F + call HandleFortuneDialog3D + cmp engineMode,MODE_WALK + je check_walk_mode + call RenderFortuneDialog3D + jmp present_frame +@@: + cmp engineMode,MODE_CABARET + jne @F + call HandleCabaret3D + call RenderCabaret3D + jmp present_frame +@@: + cmp engineMode,MODE_SCRATCH + jne @F + call HandleScratch3D + cmp engineMode,MODE_WALK + je check_walk_mode + call RenderScratch3D + jmp present_frame +@@: + cmp engineMode, MODE_HELL_TOWER + jne @F + call HandleHellTowerInput + call RenderHellTower3D + jmp present_frame +@@: + cmp engineMode,MODE_CLOVER + jne @F + call HandleNativeClover3D + call RenderNativeClover3D + jmp present_frame +@@: + cmp engineMode,MODE_NPC_DIALOG + jne @F + call HandleNpcDialog3D + call RenderNpcDialog3D + jmp present_frame +@@: + cmp engineMode, MODE_UNAVAILABLE + jne @F + call HandleUnavailable3D + call RenderUnavailable3D + jmp present_frame +@@: + cmp engineMode, MODE_POOL + jne @F + call HandlePool3D + call RenderPool3D + jmp present_frame +@@: + cmp engineMode, MODE_BAR + jne @F + call HandleBar3D + call RenderBar3D + jmp present_frame +@@: + cmp engineMode, MODE_STAIRS + jne @F + call HandleStairs3D + call HandleJukeboxKeys3D + call RenderStairs3D + jmp present_frame +@@: + cmp engineMode, MODE_SLOTS + jne check_bj_mode + call HandleNativeSlots3D + cmp engineMode,MODE_WALK + je check_walk_mode + call RenderNativeSlots3D + jmp present_frame +check_bj_mode: + cmp engineMode, MODE_BLACKJACK + jne check_poker_mode + call HandleNativeBlackjack3D + cmp engineMode, MODE_WALK + je check_walk_mode + call RenderNativeBlackjack3D + jmp present_frame +check_poker_mode: + cmp engineMode, MODE_POKER + jne check_durak_mode + call HandleNativePoker3D + cmp engineMode, MODE_WALK + je check_walk_mode + call RenderNativePoker3D + jmp present_frame +check_durak_mode: + cmp engineMode, MODE_DURAK + jne check_roul_mode + call HandleNativeDurak3D + cmp engineMode, MODE_WALK + je check_walk_mode + call RenderNativeDurak3D + jmp present_frame +check_roul_mode: + cmp engineMode, MODE_ROULETTE + jne check_shop_mode + call HandleNativeWheel3D + call RenderNativeWheel3D + jmp present_frame +check_shop_mode: + cmp engineMode, MODE_SHOP + jne check_atm_mode + call HandleMerchant3D + call RenderMerchant3D + jmp present_frame +check_atm_mode: + cmp engineMode, MODE_ATM + jne check_coin_mode + call HandleATMInput + call RenderATMGame + jmp present_frame +check_coin_mode: + cmp engineMode, MODE_COIN + jne check_dice_mode + call HandleCoinInput + call RenderCoinGame + jmp present_frame +check_dice_mode: + cmp engineMode, MODE_DICE + jne check_skulls_mode + call HandleDiceInput + call RenderDiceGame + jmp present_frame +check_skulls_mode: + cmp engineMode, MODE_SKULLS + jne check_skill_mode + call HandleSkullsInput + call RenderSkullsGame + jmp present_frame +check_skill_mode: + cmp engineMode, MODE_SKILL + jne check_buckshot_mode + call HandleSkillInput + call RenderSkillGame + jmp present_frame +check_buckshot_mode: + cmp engineMode, MODE_BUCKSHOT + jne check_russian_mode + call HandleBuckshot3D + call RenderBuckshot3D + jmp present_frame +check_russian_mode: + cmp engineMode, MODE_RUSSIAN + jne check_security_mode + call HandleRussianInput3D + call RenderRussianGame3D + jmp present_frame +check_security_mode: + cmp engineMode, MODE_SECURITY + jne check_debt_mode + call HandleSecurity3D + call RenderSecurity3D + jmp present_frame +check_debt_mode: + cmp engineMode, MODE_DEBT + jne check_rat_mode + call HandleDebt3D + call RenderDebt3D + jmp present_frame +check_rat_mode: + cmp engineMode, MODE_RAT_RACE + jne check_heist_mode + call HandleRatRace3D + call RenderRatRace3D + jmp present_frame +check_heist_mode: + cmp engineMode, MODE_HEIST + jne present_frame + call HandleHeist3D + call RenderHeist3D + jmp present_frame +draw_pause: + mov brEntryHold3D,0 + invoke DrawBoxBorder, 28, 36, 264, 168, 00151C21h, 00D8BC6Ah, 2 + invoke DrawString8x8, 44, 48, OFFSET textPause3D, 00FFFFFFh + cmp displayFill3D, 0 + je @F + invoke DrawString8x8, 44, 72, OFFSET textDisplayFill3D, 00D8BC6Ah + jmp pause_draw_quality +@@: + invoke DrawString8x8, 44, 72, OFFSET textDisplayFit3D, 00D8BC6Ah +pause_draw_quality: + invoke DrawString8x8, 44, 92, OFFSET textLowSpec3D, 00D8BC6Ah + mov eax, settingsLowSpec + cmp eax, 0 + jne @F + mov edx, OFFSET textLowSpecOff3D + jmp pause_draw_quality_value +@@: + cmp eax, 1 + jne @F + mov edx, OFFSET textLowSpecEco3D + jmp pause_draw_quality_value +@@: + mov edx, OFFSET textLowSpecQuiet3D +pause_draw_quality_value: + invoke DrawString8x8, 208, 92, edx, 00FFFFFFh + invoke DrawString8x8, 44, 112, OFFSET textVolumeKeys3D, 00D8BC6Ah + invoke DrawString8x8, 44, 130, OFFSET textSoundLevel3D, 00BBBBBBh + invoke FormatNumber, settingsVolume, OFFSET hudNumBuffer + invoke DrawString8x8, 124, 130, OFFSET hudNumBuffer, 00FFFFFFh cmp brOwned3D,0 jne @F invoke DrawString8x8, 44, 150, OFFSET textFullscreenKey3D, 00A0A0A0h -@@: - invoke DrawString8x8, 44, 170, OFFSET textResume3D, 00D8BC6Ah - invoke DrawString8x8, 44, 188, OFFSET textQuit3D, 00BBBBBBh - invoke Pressed3D, 31h - test eax, eax - jz @F - xor displayFill3D, 1 - call SaveDisplaySettings3D -@@: - invoke Pressed3D, 32h - test eax, eax - jz @F - inc settingsLowSpec - cmp settingsLowSpec, 3 - jb pause_low_spec_saved - mov settingsLowSpec, 0 -pause_low_spec_saved: - call SaveProgress3D -@@: - invoke Pressed3D, 0BBh - test eax, eax - jz @F - cmp settingsVolume, 10 - jae @F - inc settingsVolume - call ApplySoundVolume - call SaveProgress3D -@@: - invoke Pressed3D, 0BDh - test eax, eax - jz @F - mov eax, settingsVolume - test eax, eax - jz @F - dec settingsVolume - call ApplySoundVolume - call SaveProgress3D -@@: - cmp brOwned3D,0 - je br_pause_inventory_done +@@: + invoke DrawString8x8, 44, 170, OFFSET textResume3D, 00D8BC6Ah + invoke DrawString8x8, 44, 188, OFFSET textQuit3D, 00BBBBBBh + invoke Pressed3D, 31h + test eax, eax + jz @F + xor displayFill3D, 1 + call SaveDisplaySettings3D +@@: + invoke Pressed3D, 32h + test eax, eax + jz @F + inc settingsLowSpec + cmp settingsLowSpec, 3 + jb pause_low_spec_saved + mov settingsLowSpec, 0 +pause_low_spec_saved: + call SaveProgress3D +@@: + invoke Pressed3D, 0BBh + test eax, eax + jz @F + cmp settingsVolume, 10 + jae @F + inc settingsVolume + call ApplySoundVolume + call SaveProgress3D +@@: + invoke Pressed3D, 0BDh + test eax, eax + jz @F + mov eax, settingsVolume + test eax, eax + jz @F + dec settingsVolume + call ApplySoundVolume + call SaveProgress3D +@@: + cmp brOwned3D,0 + je br_pause_inventory_done invoke DrawString8x8,44,150,OFFSET brToggle3D,00D8BC6Ah - invoke DrawString8x8,36,214,OFFSET brInventory3D,00D8BC6Ah - mov edx,OFFSET brDisabledText3D - cmp brEnabled3D,0 - je @F - mov edx,OFFSET brEnabledText3D -@@: - invoke DrawString8x8,248,150,edx,00FFFFFFh - invoke Pressed3D,52h - test eax,eax - jz br_pause_inventory_done - xor brEnabled3D,1 - call SaveProgress3D -br_pause_inventory_done: - invoke Pressed3D, 51h - test eax, eax - jz @F - call SaveProgress3D - jmp engine_shutdown -present_frame: - cmp brActive3D,0 - je br_record_clock_done - cmp engineMode,MODE_WALK - je br_record_clock_done - cmp paused3D,0 - jne br_record_clock_done - mov eax,deltaTime3D - add brClock3D,eax -br_record_clock_done: - call UpdateJukeboxAudio3D - call RenderTowerInGameBadge - call RenderJukeboxVolumeHUD - mov eax, engineMode - cmp eax, lastPersistMode3D - je @F - cmp eax, MODE_WALK - jne @F - call SaveProgress3D -@@: - mov eax, engineMode - mov lastPersistMode3D, eax - call Present3D - mov mouseClick3D, 0 - lea edi, pressedKeys3D - xor eax, eax - mov ecx, 64 - rep stosd - invoke timeGetTime - sub eax, frameStart3D - mov ecx, 16 - cmp settingsLowSpec, 1 - jne @F - mov ecx, 24 -@@: - cmp settingsLowSpec, 2 - jne @F - mov ecx, 33 -@@: - cmp eax, ecx - jae engine_loop - sub ecx, eax - invoke Sleep, ecx - jmp engine_loop -engine_idle: - mov brEntryHold3D,0 - call UnlockMouse3D - invoke Sleep, 50 - jmp engine_loop -engine_shutdown: + invoke DrawString8x8,36,214,OFFSET brInventory3D,00D8BC6Ah + mov edx,OFFSET brDisabledText3D + cmp brEnabled3D,0 + je @F + mov edx,OFFSET brEnabledText3D +@@: + invoke DrawString8x8,248,150,edx,00FFFFFFh + invoke Pressed3D,52h + test eax,eax + jz br_pause_inventory_done + xor brEnabled3D,1 + call SaveProgress3D +br_pause_inventory_done: + invoke Pressed3D, 51h + test eax, eax + jz @F + call SaveProgress3D + jmp engine_shutdown +present_frame: + cmp brActive3D,0 + je br_record_clock_done + cmp engineMode,MODE_WALK + je br_record_clock_done + cmp paused3D,0 + jne br_record_clock_done + mov eax,deltaTime3D + add brClock3D,eax +br_record_clock_done: + call UpdateJukeboxAudio3D + call RenderTowerInGameBadge + call RenderJukeboxVolumeHUD + mov eax, engineMode + cmp eax, lastPersistMode3D + je @F + cmp eax, MODE_WALK + jne @F + call SaveProgress3D +@@: + mov eax, engineMode + mov lastPersistMode3D, eax + call Present3D + mov mouseClick3D, 0 + lea edi, pressedKeys3D + xor eax, eax + mov ecx, 64 + rep stosd + invoke timeGetTime + sub eax, frameStart3D + mov ecx, 16 + cmp settingsLowSpec, 1 + jne @F + mov ecx, 24 +@@: + cmp settingsLowSpec, 2 + jne @F + mov ecx, 33 +@@: + cmp eax, ecx + jae engine_loop + sub ecx, eax + invoke Sleep, ecx + jmp engine_loop +engine_idle: + mov brEntryHold3D,0 + call UnlockMouse3D + invoke Sleep, 50 + jmp engine_loop +engine_shutdown: call FreeHellFPS3D - call StopFortuneWorker3D - call SettleScratchOnQuit3D - call UnlockMouse3D - cmp hRaycastThread, 0 - je @F - mov bRaycastQuit, 1 - invoke SetEvent, hRaycastStartEvent - invoke WaitForSingleObject, hRaycastThread, 1000 - invoke CloseHandle, hRaycastThread - invoke CloseHandle, hRaycastStartEvent - invoke CloseHandle, hRaycastDoneEvent - mov hRaycastThread, 0 - mov hRaycastStartEvent, 0 - mov hRaycastDoneEvent, 0 -@@: - call SaveProgress3D - invoke PlayCasinoSound3D, 0, 0, 0 - invoke FreeAnimPack3D,OFFSET brMaterials3D - call FreeRussianAssets3D - call FreeDarts3D - call FreeStartupAssets3D - call FreeCardTableAssets3D - call FreeBuckshotAssets3D - call FreeNativeSlots3D - call FreeNativeClover3D - call FreePyramidAssets3D - call FreeArrivalAssets3D - cmp h3DDC, 0 - je @F - invoke ReleaseDC, h3DWnd, h3DDC - mov h3DDC, 0 -@@: - cmp h3DWnd, 0 - je @F - invoke DestroyWindow, h3DWnd - mov h3DWnd, 0 -@@: - invoke timeEndPeriod, 1 - ret -StartCasino3D ENDP - -include src_graphics\platform_code.inc - -IFDEF CASINO_ACTION_TEST -include tools\tests\casino_actions_test.inc -ENDIF - - -IFDEF ARTIFACT_TEST -include tools\tests\artifacts_test.inc -ENDIF + call StopFortuneWorker3D + call SettleScratchOnQuit3D + call UnlockMouse3D + cmp hRaycastThread, 0 + je @F + mov bRaycastQuit, 1 + invoke SetEvent, hRaycastStartEvent + invoke WaitForSingleObject, hRaycastThread, 1000 + invoke CloseHandle, hRaycastThread + invoke CloseHandle, hRaycastStartEvent + invoke CloseHandle, hRaycastDoneEvent + mov hRaycastThread, 0 + mov hRaycastStartEvent, 0 + mov hRaycastDoneEvent, 0 +@@: + call SaveProgress3D + invoke PlayCasinoSound3D, 0, 0, 0 + invoke FreeAnimPack3D,OFFSET brMaterials3D + call FreeRussianAssets3D + call FreeDarts3D + call FreeStartupAssets3D + call FreeCardTableAssets3D + call FreeBuckshotAssets3D + call FreeNativeSlots3D + call FreeNativeClover3D + call FreePyramidAssets3D + call FreeArrivalAssets3D + cmp h3DDC, 0 + je @F + invoke ReleaseDC, h3DWnd, h3DDC + mov h3DDC, 0 +@@: + cmp h3DWnd, 0 + je @F + invoke DestroyWindow, h3DWnd + mov h3DWnd, 0 +@@: + invoke timeEndPeriod, 1 + ret +StartCasino3D ENDP + +include src_graphics\platform_code.inc + +IFDEF CASINO_ACTION_TEST +include tools\tests\casino_actions_test.inc +ENDIF + + +IFDEF ARTIFACT_TEST +include tools\tests\artifacts_test.inc +ENDIF diff --git a/dist/Assembler Casino.exe b/dist/Assembler Casino.exe index 1ed54ed..22f4c5f 100644 Binary files a/dist/Assembler Casino.exe and b/dist/Assembler Casino.exe differ diff --git a/dist/Uninstall Assembler Casino.exe b/dist/Uninstall Assembler Casino.exe index 1cf579d..06efdfa 100644 Binary files a/dist/Uninstall Assembler Casino.exe and b/dist/Uninstall Assembler Casino.exe differ diff --git a/docs/HEIST_AND_UNDERWORLD.md b/docs/HEIST_AND_UNDERWORLD.md new file mode 100644 index 0000000..48e48ba --- /dev/null +++ b/docs/HEIST_AND_UNDERWORLD.md @@ -0,0 +1,205 @@ +# Подполье Казино и Великое Ограбление (Underworld & The Grand Heist) + +Дизайн-документ и техническая спецификация для пяти взаимосвязанных систем: +1. **Подпольные крысиные / тараканьи бега** (`Rat Races`) в подвале. +2. **Ростовщик «Семён» и система долгов** (`Loan Shark & Debt`). +3. **Охрана и детектор шулерства** (`Pit Boss & Heat Level`). +4. **Интерактивный Бар с напитками-баффами** (`Interactive Bar & Buffs`). +5. **Квест «Ограбление Вегаса»** (`The Grand Heist`) — секретная сюжетная концовка в стиле *Payday 2* и *Иллюзии обмана*. + +--- + +## 1. Синергия систем (Игровая петля) + +``` + +---------------------------------------------+ + | Интерактивный Бар | + | - Баффы к удаче, концентрации и зрению | + | - Снижение шкалы Heat | + | - Слухи и вербовка Бармена | + +---------------------+-----------------------+ + | + +---------------+---------------+ + | | + v v ++------------------------+ +------------------------+ +| Шулерство за столом | | Подпольные бега | +| - Подмена карт | | в темном подвале | +| - Кража фишек | | - Быстрый куш | +| - Рост Heat (Охрана) | | - Стук по столу | ++------------+-----------+ +------------+-----------+ + | | + v v ++------------------------+ +------------------------+ +| Охрана и Pit Boss | | Ростовщик «Семён» | +| - Допрос / Взятка | | - Кредит при банкроте | +| - Побег / Конфискация | | - Стычка в переулке | ++------------+-----------+ +------------+-----------+ + \ / + \ / + v v + +---------------------------------------------+ + | Квест «Ограбление Вегаса» | + | - 4 сообщника: Бармен, Гадалка, Певица, | + | Хакер | + | - Отвлечение зала феерическим шоу | + | - Проникновение в хранилище через подвал | + | - Взлом сейфа и эвакуация на крышу | + +---------------------------------------------+ +``` + +--- + +## 2. Подпольные тараканьи / крысиные бега (Rat Races) + +### Локация +Подвал казино (координаты около темного угла лестницы к гадалке). Деревянный стол с ограждением, подвешенная тусклая лампа накаливания, толпа шепчущихся NPC. + +### Геймплей +* Клавиша **E** у стола открывает отдельный 2D экран тотализатора. +* Деревянный желоб на 4 дорожки (длина 70 клеток). +* 4 участника с уникальными именами и повадками: + 1. **Шустрый ASM** (высокая базовая скорость, но 15% шанс застыть от испуга). + 2. **Турбо-Маховик** (медленный старт, но ускоряется на второй половине дистанции). + 3. **Пьяный Боцман** (хаотичные прыжки, непредсказуемый темп). + 4. **Генерал Зарин** (стабильный танк, фаворит с коэффициентом 1.8x). +* **Случайные модификаторы забега**: + - `TURBO_RUSH` — рывок вперед на 3–5 клеток. + - `PANIC` — паническое метание на месте на 0.5 сек. + - `SLEEPY` — замедление шага. +* **Интерактив «Стук по столу»**: + - Клавиша **Пробел** один раз за забег позволяет игроку резко ударить кулаком по деревянному столу. + - Раздается громкий стук, экран на миг вздрагивает, и все участники получают случайную реакцию (кто-то пугается и ускоряется, кто-то впадает в ступор). +* **Ставки**: + - На победу (Win): выигрыш от x2.0 до x8.0. + - Топ-2 (Place): выигрыш от x1.4 до x3.0. + +--- + +## 3. Ростовщик «Семён» и система долгов (Loan Shark & Debt) + +### Триггер появления +Если баланс игрока опускается ниже $50 (или полный 0), в баре или около выхода из зала появляется NPC в кепке и кожаной куртке — Семён. + +### Условия займа +* **Пакет «Новичок»**: $500 (вернуть $700 за 20 раундов). +* **Пакет «Игрок»**: $2,500 (вернуть $3,750 за 35 раундов). +* **Пакет «Ва-Банк»**: $10,000 (вернуть $16,000 за 50 раундов). + +### Механика таймера +* Каждая сыгранная раздача (покер, блэкджек, дурак), бросок костей или спин слотов уменьшает счетчик оставшихся раундов на 1. +* В верхнем правом углу экрана пульсирует красная строка: + `ДОЛГ: $3,750 [ОСТАЛОСЬ: 12 РАУНДОВ]` +* При досрочной выплате через разговор с Семёном долг закрывается без последствий. + +### Просрочка и Коллекторы +Если счетчик дошел до 0, а денег для выплаты нет: +* При смене локации экран гаснет, играет тревожный звук, игрок оказывается в глухом переулке за казино перед двумя громилами. +* **Варианты развития**: + 1. **QTE Драка / Уклонение**: мини-игра на реакцию (вовремя нажимать стрелки / пробел). Победа дает отсрочку на 15 раундов. + 2. **Русская рулетка на долг**: заряжается 1 патрон. Выстрел в воздух/пустой камор — долг полностью списан за смелость. Осечка с выстрелом — сброс профиля в банкротство. + 3. **Конфискация**: если игрок сдается, громилы отбирают купленные талисманы и рубашки карт в счет уплаты. + +--- + +## 4. Охрана и детектор шулерства (Pit Boss & Heat Level) + +### Шкала подозрения (Heat: 0–100%) +* Использование шулерских трюков увеличивает Heat: + - Подглядывание закрытой карты: **+15%** + - Подмена карты из рукава: **+30%** + - Сдвиг фишек / кража со стола: **+25%** +* Естественное снижение: + - Честная игра: **-2%** за каждый раунд без фокусов. + - Покупка коктейлей в баре: **-15% .. -30%**. + +### Градации опасности +* `0% - 40%`: Зеленый статус, охрана расслаблена. +* `41% - 79%`: Желтый статус. Крупье подозрительно косится, в строке состояния горит `[ВНИМАНИЕ ОХРАНЫ]`. +* `80% - 99%`: Оранжевый статус. Сзади игрока вырастает спрайт охранника с рацией. +* `100%`: Красный статус! Звучит свисток, крупье кричит *«Шулер!»*, игра останавливается. + +### Комната допроса +Экран переносит игрока в служебное помещение охраны: +1. **Взятка**: отдать 40% текущего выигрыша и разойтись миром. +2. **Диалог / Блеф**: если у игрока куплен статус «VIP» или «Легенда казино», можно наехать на начальника охраны и заставить его извиниться. +3. **Побег**: скилл-чек на реакцию (опрокинуть стол, выбить дверь и скрыться в вентиляции). При провале — конфискация всех фишек за сессию и 10-минутный запрет на вход за карточные столы. + +--- + +## 5. Интерактивный Бар с напитками-баффами + +Интерактивная стойка на 1 этаже рядом с кабаре и джукбоксом. + +### Меню напитков +1. **Виски «Двойной блеф» ($50)**: + - *Эффект*: Полное подавление пульса и стресса на 10 минут. Прицел в дартсе не дрожит. + - *Побочный эффект*: Легкое покачивание камеры при ходьбе в 3D. +2. **Коктейль «Холодный расчет» ($100)**: + - *Эффект*: В блэкджеке и покере отображается точный математический шанс победы текущей руки в процентах. +3. **Энергетик «Кибер-Панч» ($75)**: + - *Эффект*: Замедляет шкалы времени в скилл-чеках (DbD hook, дартс, взлом замков) на 25%. +4. **Шот «Хамелеон» ($150)**: + - *Эффект*: Мгновенный сброс шкалы подозрения охраны (`Heat`) до 0 (бармен забалтывает охрану). +5. **Коктейль «Счастливый Клевер» ($300)**: + - *Эффект*: Повышает вероятность выпадения победных комбинаций на слотах CloverPit на 15 спинов. + +--- + +## 6. Вылазка в штаб владельцев конкурирующей сети + +Наше казино остаётся базой. Игрок нанимает команду, выбирает стелс или штурм, едет в машине от первого лица и попадает на отдельную карту чужого административного здания. Там можно проникнуть через служебный маршрут, отключить камеру и открыть хранилище через терминал либо взламывать дверь под огнём. Добычу нужно вынести к машине. После обратной поездки игрок возвращается в исходную точку нашего казино; только тогда выдаётся награда. + +Подробное описание текущей миссии, вербовки и управления: [HEIST_HQ.md](HEIST_HQ.md). Первоначальный вариант ограбления собственного казино с вертолётом заменён этим сценарием. + +--- + +## 7. План поэтапной реализации в MASM32 + +| Этап | Модуль | Файлы данных и кода | Описание | +|---|---|---|---| +| **Этап 1** | Интерактивный Бар | `src_graphics/bar_data.inc`, `src_graphics/bar_scene.inc` | Меню напитков, баффы таймеров, эффекты стресса/подозрения. | +| **Этап 2** | Ростовщик Семён | `src_graphics/debt_data.inc`, `src_graphics/debt_scene.inc` | Логика займа при 0 баланса, тикающий счетчик раундов, стычка с коллекторами. | +| **Этап 3** | Охрана и Heat | `src_graphics/security_data.inc`, `src_graphics/security_scene.inc` | Шкала подозрения, интеграция с шулерством, допрос у начальника охраны. | +| **Этап 4** | Подпольные бега | `src_graphics/rat_race_data.inc`, `src_graphics/rat_race.inc` | 2D трек на 4 полосы, физика рывков, стук по столу пробелом. | +| **Этап 5** | Великое Ограбление | `src_graphics/heist_data.inc`, `src_graphics/heist_mission.inc` | Дневник квеста, диалоги 4 сообщников, взлом сейфа, финал на крыше. | + + + +--- + +## 8. Как открыть новые активности + +Запусти обновлённый `poker.exe` из корня проекта или `dist/Assembler Casino.exe`. Если старая игра уже открыта, сначала закрой её: второй запуск передаёт фокус существующему процессу. + +В главном зале найди стальную дверь подвала, нажми **E** и пройди через открытый проём и лестницу. Внизу пройди в боковой проход слева ближе к лестнице: за стеной находится отдельный подпольный клуб с Семёном, бегами и планированием. Сидорович остался в собственной мастерской. Подходи и поворачивайся к объекту, пока не появится подсказка **E**. + +- **Семён:** **1–3** — заём; при активном долге **5** — возврат; **4/Esc** — уйти. Условия: $500 → $700 / 25 раундов, $2500 → $3750 / 40 раундов, $10000 → $16000 / 60 раундов. При просрочке коллекторы встречают игрока после возвращения в режим ходьбы. Драка: последовательность **W A D S**, по 1,5 секунды на клавишу; победа даёт 20 раундов отсрочки. Рулетка: риск проиграть всё 1/6. Сдача закрывает долг ценой всех фишек. +- **Крысиные бега:** **1–4** — участник, стрелки **вверх/вниз** — ставка $25–500, **P** — победа или топ-2, **Enter** — старт. Победа оплачивается по коэффициенту участника, топ-2 — x1,5; коэффициенты включают возврат ставки. **Space** один раз за гонку пугает или ускоряет случайных крыс. После результата **Enter** начинает новую ставку, **Esc** возвращает в подвал. +- **План ограбления:** **1–4** нанимают участников за $1000/$2000/$1500/$3000, **5** выбирает стелс/штурм, **Enter** запускает выезд в штаб конкурента. Управление на задании: WASD, мышь, ЛКМ, **1/2** оружие, **R** перезарядка, **Ctrl** присесть, **F** команда, **E** действия. Выплата $1000000 и золотая рубашка выдаются однократно после возвращения с добычей к машине и обратной поездки. Подробнее: [HEIST_HQ.md](HEIST_HQ.md). +- **Бар:** в главном зале **E** у стойки; **1–6** — напитки, **7** — найм бармена. Мышь выбирает те же строки. Виски убирает дрожание прицела дартса, анализ даёт вероятность взять карту без перебора в одиночном блэкджеке и текущую комбинацию в покере, энергетик увеличивает скорость ходьбы, хамелеон сбрасывает подозрение, клевер даёт 15 спинов с дополнительным 15% шансом удачного исхода. Временные эффекты действуют десять минут. +- **Охрана:** **P** во время своего хода в покере/блэкджеке раскрывает скрытые карты на текущую раздачу, добавляя 30% подозрения один раз за руку. Обычные победы не повышают подозрение; завершённые раунды снижают его на 2%. При 100% допрос начинается после выхода из оплаченной игры. Варианты: взятка 40% баланса, блеф с шансом 50%, побег по шкале реакции. + +## 9. Реализованный этап + +Рабочие сцены и интерфейс остаются на MASM. ImageGen создал три новых прозрачных атласа: + +- `assets/sprites/hall/underworld-portraits-v2.png`: 11 портретов и предметов. +- `assets/sprites/hall/underworld-world-v2.png`: три позы Семёна, коллектор, два стола и закрытый/открытый сейф. +- `assets/sprites/hall/rat-race-v2.png`: четыре согласованных беговых цикла по четыре кадра. + +Игровые паки: `underworld-portraits-v2.bin`, `underworld-world-v2.bin`, `rat-race-v2.bin` в `assets/animations/hall/`. Три позы Семёна анимируются в подвале; крысы имеют разные темпы, рывки и остановки. Закрытый/открытый сейф и портрет коллектора подготовлены как ресурсы; текущий взлом использует отдельный лимб. + +Для совпадения персонажей слотам бармена, певицы и гадалки присвоены изображения из их существующих игровых сцен. Пропорции Семёна и крыс исправлены; поза Семёна меняется по состоянию долга, без бессмысленного перебора жестов. + +Офлайн-компилятор `tools/generators/pack_underworld_v2.py` разрезает утверждённые листы, сохраняет общий масштаб и точку опоры кадров, создаёт ANM1 BGRA и GIF-превью. Полные промпты находятся в `assets/sprites/hall/prompts-underworld-v2.json`. Старый процедурный генератор v1 не используется для новых игровых паков. + +Долг, подозрение, нанятые участники, оставшиеся спины клевера и флаг однократной награды сохраняются рядом с выбранным профилем в файле с суффиксом `.underworld`. Формат имеет контрольную подпись; запись идёт через временный файл и замену. Старые основные сохранения не меняют формат. Активные игровые экраны не прерывают незавершённую ставку допросом или коллекторами. + +`build.bat` обновляет корневой EXE, `build/graphics/poker.exe`, `bin/poker.exe` и контрольную сумму лаунчера. + +Проверка: `python tools/tests/check_underworld.py`. Она собирает настоящий ASM с отдельной точкой входа, проверяет заём и возврат, QTE, отложенные переходы, подглядывание, расчёт безопасной карты, найм и награду, 100 оплаченных гонок при четырёх частотах кадров, загрузку прогресса, подходы к трём объектам и создаёт 10 снимков настоящего framebuffer. Существующие профили проверяются на неизменность. Дополнительно проверяются выезд, оба подхода, стены и стрельба, обнаружение/урон, терминал и доступ в хранилище, сейф без ранней выплаты, эвакуация с однократной наградой, смерть/отмена и точное возвращение на базу. Сняты 19 кадров настоящего игрового framebuffer. Кадры и GIF находятся в `build/underworld/`. + +## 10. Оставшаяся работа + +Личные задания вербовки пока не сделаны: команда нанимается за фишки, с указанными ролями. Текущая самостоятельная вылазка — одна карта с базовыми патрулями, камерой, ограниченным подкреплением и простыми напарниками прикрытия; сложные тактические команды, пейджеры, заложники и несколько контрактов пока не реализованы. Анализ в покере показывает текущую комбинацию, а не вероятность победы; энергетик ускоряет ходьбу. Конфискация коллекторами касается фишек, а не купленных артефактов. diff --git a/docs/HEIST_HQ.md b/docs/HEIST_HQ.md new file mode 100644 index 0000000..b89eb1f --- /dev/null +++ b/docs/HEIST_HQ.md @@ -0,0 +1,48 @@ +# Вылазка в штаб конкурирующей сети + +Статус: сохранённый необязательный прототип. Доступен со стола подготовки в клубе, не требуется для основного прохождения. Развитие отдельного FPS пока отложено в пользу казино. + +Наше казино — база. Цель операции находится на отдельной карте: административный штаб владельцев конкурирующей сети, с охраной, архивом, терминалом безопасности и закрытым хранилищем. После задания команда возвращается в подпольный клуб нашего казино. + +## Подготовка и найм + +В подвале Сидорович сохранил собственную мастерскую. В конце мастерской, ближе к лестнице, открыт боковой проход налево. За стеной находится отдельный подпольный клуб: бега, Семён и стол подготовки задания. + +На столе нажми **E**. Участники нанимаются клавишами **1–4**: бармен-водитель $1000, прикрытие $2000, наводчик $1500, специалист по доступу $3000. Бармена также можно нанять клавишей **7** у стойки. Повторный найм бесплатен, состав сохраняется с профилем. Личные квесты найма пока не сделаны; сейчас это контракт за фишки. Портреты бармена, певицы и гадалки взяты из их существующих игровых сцен. + +Клавиша **5** переключает начальный подход: **стелс** или **штурм**. **Enter** запускает поездку, когда команда собрана. Игрок видит дорогу из пассажирского кресла, водителя в маске и своё оружие. Поездка автоматическая, длится шесть секунд. + +## Задание от первого лица + +- **WASD** — движение, **мышь** — обзор, стрелки влево/вправо также поворачивают камеру. +- **Ctrl** — присесть и двигаться медленнее; обнаружение растёт медленнее. +- **Shift** — бег. +- **1** — пистолет с глушителем; **2** — карабин. +- **ЛКМ / Space** — стрелять; **R** — перезарядка из ограниченного резерва. +- **E** — терминал, документы, дверь хранилища, сейф, эвакуация у машины. +- **F** — напарникам ждать / следовать; при тревоге они начинают прикрывать игрока. +- **Esc** — отступить на базу без награды; в интерфейсе сейфа возвращает к движению по штабу. + +С парадного входа начинается лобби со стойкой, по боковому пути слева можно попасть в помещение охраны. Патрули проверяют направление взгляда и видимость через карту, постепенно заполняя шкалу обнаружения. Камера в центральном коридоре также обнаруживает игрока. Полная шкала или выстрел из карабина включает тревогу. Через 15 секунд прибывает ограниченная группа подкрепления. Выстрелы и перемещение блокируются стенами; напарники поддерживают огнём при тревоге. + +**Тихий путь:** обойти здание слева, пробраться в охрану, подойти к терминалу и нажать **E**. Взлом занимает 1,5 секунды, требует оставаться рядом, отключает камеру и открывает дверь хранилища. Пистолет с глушителем может нейтрализовать отдельного охранника без глобальной тревоги. Патрули и прямую видимость всё равно нужно учитывать. + +**Силовой путь:** выбрать штурм при подготовке или открыть огонь из карабина. У двери хранилища **E** начинает десятисекундный взлом с тревогой. Можно также захватить терминал. Если отойти от двери или терминала, действие отменяется. + +В кабинете владельцев лежат документы; **E** рядом с ними раскрывает комбинацию **24–71–45**. Их можно пропустить и искать цифры по звуковым щелчкам. В хранилище **E** у сейфа открывает панель поверх вида от первого лица: **A/D** или стрелки поворачивают лимб, **Space** фиксирует цифру, **Esc** закрывает панель. Охрана продолжает действовать, поэтому перед взломом нужно обеспечить безопасность. На попытку даётся 120 секунд; истечение времени поднимает тревогу. + +## Добыча и возвращение + +Открытие сейфа даёт сумку с добычей, без выплаты на баланс. Нужно самостоятельно вернуться через здание к машине во дворе и нажать **E**. Затем проходит обратная поездка, восстанавливаются карта и точная исходная позиция в нашем клубе. Только тогда начисляются **$1000000** и золотая рубашка. Награда однократная для профиля. + +Смерть, отмена или выход до эвакуации не выдают награду и не списывают основной банк. Найм команды сохраняется для новой попытки. Наше казино не становится картой штурма, и охрана штаба не переносится на базу. + +## Ресурсы и проверка + +Весь игровой код — MASM: `heist_hq_data.inc`, `heist_hq.inc`, `heist_hq_render.inc`, карта `heist_hq_map.inc`. Скрипт `tools/generators/pack_heist_hq.py` используется только офлайн: компилирует утверждённые PNG и карту в игровые ресурсы. + +Исходники ImageGen: `assets/sprites/hall/heist-{van,actors,weapons,props}-v1.png`. Полные промпты: `assets/sprites/hall/prompts-heist-hq-v1.json`. ANM1-паки, включая материалы улицы, находятся в `assets/animations/hall/`. Городские материалы переиспользованы из существующего оформления игры. + +`python tools/tests/check_underworld.py` запускает реальные обработчики и рендер без пользовательских профилей. Проверяются выезд, оба подхода, урон и стены, обнаружение, терминал, документы, сейф без ранней выплаты, эвакуация с однократной наградой, возвращение на исходную карту и позицию, смерть и отмена. Кадры настоящего framebuffer находятся в `build/underworld/hq-*.png`, отдельный клуб — `club.png` и `club-semyon.png`. + +Это первая самостоятельная миссия с базовыми патрулями и напарниками прикрытия. Несколько заданий, личные квесты вербовки, полноценная система заложников/пейджеров и сложные тактические команды пока не реализованы. diff --git a/docs/STARTUP_PRESENTATION.md b/docs/STARTUP_PRESENTATION.md index badcc4a..2e9ad53 100644 --- a/docs/STARTUP_PRESENTATION.md +++ b/docs/STARTUP_PRESENTATION.md @@ -1,84 +1,160 @@ -# Startup presentation and hall briefing - -All runtime presentation, text, timing, input and drawing are MASM32. No browser, -video player, Python runtime or additional graphics dependency is introduced. - -## Startup order - -1. Existing Eblan Games animated logo (7 seconds; its F2 variant is retained). -2. Russian AI-use disclosure (10 seconds): artificial intelligence technologies - were used to create some game textures; third-party resources retain their - authors and licences. -3. Code fact (11 seconds): side-by-side editor-style C++ and MASM panels for - clearing the same 640×480 framebuffer. C++ is explicitly an illustrative - equivalent, not a second game runtime. MASM shows the actual clear operation - from `src_graphics/startup_sequence.inc`. -4. Existing first-person city opening, guards and profile selection. - -Pages advance automatically. **Enter/Space** advances one page, clearing held -input so it cannot skip several screens at once. **Escape** skips the startup -pages and begins the existing city scene. Starting again resets all pages. -Existing missing-logo fallback still works; the two new pages need no art files. - -## Post-entry briefing - -After a guest/existing/new profile is admitted and the player enters the hall, -the jukebox starts **Bolden - Art Deco** on repeat at **50% user volume** (5/10). -Existing distance/floor attenuation still applies, so it sounds quieter away -from the cabinet. Volume is applied before playback, avoiding a full-volume -startup burst. No jukebox music plays during startup/profile selection. -Closing the briefing does not restart the track or reset volume; the existing -jukebox controls and +/- volume keys remain available after closing it. - -At the same entry point, the centred panel deploys from a point: horizontal -expansion for 200 ms, then -vertical ease-out for 400 ms. Cyan/magenta rails and a scanning marker frame the -dark panel. The hall is rendered by the normal ASM renderer and dimmed beneath -it; movement, interactions and camera input do not run until the modal closes. - -After deployment, Russian text types at one character per 18 ms with a blinking -cursor: version **4.0 / Windows x86**, engine, activities, controls -and profile persistence. Version follows the existing 4.0 build identity; this -change does not introduce a new release/version bump or alter save formats. - -- **Enter/Space**: complete the text; press again to close. -- **Escape**: close immediately, without opening pause. -- **Enter game** button: same complete/close behaviour, with mouse input. -- No automatic dismissal; the information remains readable. -- Shown once per admission on each launch, not on returning from tables or Hell. - -The core remains assembly-only; the pre-existing C# packaging tools and the -approved C++ fortune inference worker are separate from the game engine. - -## Copy and implementation - -- `tools/generators/make_presentation_text.py`: editable Russian copy; emits - numeric CP1251 declarations into `src_graphics/presentation_text.inc`. -- `src_graphics/presentation_data.inc`: timings, page/briefing state and API. -- `src_graphics/presentation_code.inc`: native bitmap text, code windows, - unfolding modal and typewriter. -- `src_graphics/startup_code.inc`: three-page sequencing. -- `src_graphics/arrival_scene.inc`: briefing starts after admission/entry only. -- `casino3d.inc`: modal input gate, mouse unlock and Escape handling. - -## Verification - -```powershell -python tools/generators/make_presentation_text.py -python tools/tests/check_presentation.py -python tools/tests/check_presentation.py --window -``` - -Tests compile the production procedures with an isolated ASM entry point. They -check automatic and key transitions, restart/reset, existing city-scene handoff, -guest admission, delayed modal trigger, deployment, typing and manual completion, -button/close input cleanup, and unchanged bank, RNG and player save files. -They also query actual MCI playback and gain after entry, verify silence before -admission, retain a changed volume and playback position across modal closure, -then exercise manual track selection and Stop. MCI gain assertions allow device -rounding (four units out of 1000); both success and failure close `jboxmusic`. -`--window` also presents 150 real Win32 frames. - -Outputs: `build/scratch/presentation-00..11.png`, `presentation-contact.png` and -`presentation-window.png`. Existing action/arrival tests also check the revised -startup order and the new admission trigger. +# Startup presentation and hall briefing + +The current ident belongs to **Eblan Games**. It is a real 3D workshop rendered +offline in Blender Cycles. A phosphor signature forms on the curved glass +of an old CRT and resolves into a full-screen studio title. The camera moves from the shared corridor through the door of +Room 17 and across the studio workbench. + +## Startup order + +1. **Content disclaimer / 8.5 s.** Russian copy describes the fictional setting, + simulated currency, smoking, violence and strong language. A quiet footer + retains AI-art and third-party disclosure. The 18+ notice is not an official + age certification. +2. **Eblan Games workshop / 16 s, 1920x1080, 24 fps.** The camera rushes down the + corridor as door 17 swings in. A draught lifts the corner of a marked test + sheet while the take-up reel draws loose magnetic tape along the wood. The + spinning hub cuts to the aluminium end of a can rolling off the computer desk. + The camera follows its lower rim onto the floor switch in slow motion. The + relay opens and five spring-loaded letters rise in sequence. The camera holds + on the complete word before cutting to dark glass. + A point ignites on frame 264, spreads into a line, and reveals the EG + monogram. The last shot carries the studio name on black. +3. **Game features / 11 s.** Three Russian sections introduce the games, + first-person exploration, secrets and characters, with WASD/mouse/E controls. +4. **Existing first-person opening.** The fade joins the closed-eyes start of + the rainy alley, followed by guards, profile admission and the hall. + +Pages advance automatically. **Enter/Space** advances one page and clears held +input; **Escape** skips to the existing opening scene. Starting again returns to +the disclaimer. Page sound stops on skip. Missing sounds do not cause a Windows +default beep. + +## Editable sources and rebuild + +- `assets/cinematics/blender/eblan-workshop-v8.blend`: editable meshes, + materials, physical lights, camera animation and depth of field. +- `assets/cinematics/blender/screen-v8/`: the terminal animation as a + 384-frame texture sequence for the actual curved CRT glass. Keep this folder + beside the blend file along with `signature-v8/`, the final title sequence. +- The exporter writes the reusable ProRes 422 HQ master with stereo PCM audio to + `assets/cinematics/masters/Eblan-Games-master-v8.mov`. +- `assets/cinematics/blender/printed-v7/`: original notes and the marked audio channel test sheet. +- `assets/cinematics/blender/models/sources-v7.json`: source, license and file + hashes for 18 additional Poly Haven scans and four surface materials. Earlier + scan records are in `models/sources.json`, `models/sources-v5.json` and + `models/sources-v6.json`. +- `tools/generators/make_studio_v5.jsx` defines the current eight-shot finishing + timeline. The After Effects helper saves it as `EblanGames-workshop-v8-16s.aep` + when run successfully. The older `EblanGames-workshop-v8.aep` has the 12-second edit. +- `assets/audio/startup/studio-workshop-v8.wav`: original 16-second score and + sound effects shared by the game and preview. + +Run from the repository root, with Blender installed: + +```powershell +& '/blender.exe' --background --python-exit-code 1 --python tools/generators/build_studio_v8.py -- --animation +python tools/generators/pack_studio_hd.py --version 8 +python tools/previews/export_studio_v5.py --version 8 --ffmpeg '' +python tools/previews/export_studio_v5.py --version 8 --master --ffmpeg '' +powershell -ExecutionPolicy Bypass -File tools/generators/build_studio_ae.ps1 -Version 8 +``` + +Use `--proof 36 62 74 125 162 230` to render selected frames. The +review exporter reads the game's JPEG payload. To regenerate title textures +and sound, run `python tools/generators/make_studio_v8_media.py`. The optional +`--build` mode rebuilds the finished scene from a local copy of the v7 workshop. + +The AE helper launches an isolated app instance through an ASCII temporary +bridge, because the installed AE CLI did not execute a Cyrillic script path. +The bridge uses Unicode escapes to load the actual repository JSX. + +Blender outputs `build/cinematic-v8/frames/frame_0001..0384.png`. +The review film is `assets/cinematics/masters/Eblan-Games-v8.mp4`. The native +resource is `assets/animations/intro/eblan-studio-v8.hfm` plus its JSON manifest. +Blender, After Effects, ffmpeg and Python are offline authoring tools. Players +do not need them. Editable sets and raw scans are excluded from installer payloads. + +The earlier casino exterior, roulette set and v3 AE project remain source +experiments. Their city/title section is not part of the current startup route. + +## Native Full HD presentation + +The assembly-only runtime policy is retained. MASM owns timing, input, file +validation, seeking, sound, page transitions and presentation. The game does not +launch Python, Blender, AE, a browser or an external video player. + +`HFM4` stores 384 independent Full HD JPEG frames. Its 32-byte header fixes +1920x1080, 24 fps, 384 frames, a 16000 ms duration and a 2 MiB maximum frame +chunk. The native reader validates the header, contiguous index, frame bounds +and file length before allocating. It streams one chunk and retains one decoded +frame. Windows GDI+ decodes JPEG; the game checks the actual bitmap dimensions. + +`PresentHDStudio3D` presents that **1920x1080 bitmap directly** to the window, +preserving 16:9 and clearing letterbox/pillarbox bars. It bypasses the 640x480 +gameplay framebuffer. A separate small preview exists only for existing capture +tools. The ident's fades are baked into the Full HD images. Skip, restart and +failure paths free the bitmap/DCs, frame buffer, stream and GDI+ session. + +Missing/truncated/corrupt media falls back to the retained v3/native studio +path, mapped to its first eight seconds so the old city chapter stays out of the +16-second fallback. The page sequence goes directly from studio to features. Bank, +player position, camera, RNG and profile files are unchanged by playback. + +Relevant assembly files: + +- `src_graphics/cinematic_hd.inc`, `cinematic_hd_data.inc`: HFM4 reader, + decoder lifecycle, cache and direct Full HD presenter. +- `src_graphics/startup_film.inc`: Full HD / earlier master / native fallback. +- `src_graphics/platform_code.inc`: full-resolution window presentation. +- `src_graphics/startup_code.inc`: disclaimer → studio → features → alley. +- `src_graphics/presentation_data.inc`: timings and sound path. +- `tools/generators/make_presentation_text.py`: Russian notice/feature text; + emits numeric CP1251 declarations into `presentation_text.inc`. + +## Post-entry briefing + +After a guest/existing/new profile is admitted and the player enters the hall, +the jukebox starts **Bolden - Art Deco** on repeat at **50% user volume** (5/10). +Normal distance/floor attenuation still applies. Gain is applied before playback. +No jukebox music plays during startup or profile selection. Closing the briefing +does not restart the track or reset volume; normal jukebox controls remain usable. + +The centred panel deploys horizontally for 200 ms, then vertically for 400 ms. +Cyan/magenta rails and a scanning marker frame the dark panel. The ordinary ASM +hall renderer runs beneath it and is dimmed. Movement/interactions/camera input +are blocked until it closes. Russian text types at one character per 18 ms: +version **4.0 / Windows x86**, game information, controls and profile persistence. +This does not change the game's release version or save format. + +- **Enter/Space**: complete the text, then press again to close. +- **Escape**: close immediately without opening pause. +- **Enter game** button: the same complete/close behaviour. +- No automatic dismissal. Shown once per admission on each launch. + +The existing C# packaging tools and approved C++ fortune inference worker remain +separate from the assembly game engine. + +## Verification + +```powershell +& '/blender.exe' -b assets/cinematics/blender/eblan-workshop-v8.blend --python-exit-code 1 -P tools/tests/check_studio_motion_blender.py +python tools/tests/check_studio_hd.py +python tools/tests/check_studio_hd.py --production +python tools/tests/check_presentation.py +python tools/tests/check_underworld.py +cmd /c build.bat +``` + +The Full HD probe compiles the production ASM loader/presenter. It exercises all +384 frame indices, seeking and cache reuse, missing/truncated/bad data and cleanup. +It captures the actual native presenter at 1920x1080, 1920x1440 and 2560x1080, +compares pixels to the JPEG source and checks that aspect bars are black. +`--production` repeats this on the rendered workshop movie. + +The presentation check verifies ordered pages, automatic/key/skip transitions, +fresh-launch reset, original alley handoff, admission, briefing deployment, +typing, input cleanup and actual MCI playback/volume behaviour. It captures 333 +native frames, including the complete studio motion at 20 fps. The 640x480 test +captures are previews; the separate Full HD probe verifies shipping resolution. +Both probes verify unchanged player saves, bank and RNG. diff --git a/poker.exe b/poker.exe index 31c6a01..7db6c4c 100644 Binary files a/poker.exe and b/poker.exe differ diff --git a/src_graphics/card_tables_data.inc b/src_graphics/card_tables_data.inc index 32d16e7..206171c 100644 --- a/src_graphics/card_tables_data.inc +++ b/src_graphics/card_tables_data.inc @@ -56,6 +56,7 @@ HandleCardExit3D PROTO LeaveCardTable3D PROTO RenderCardExit3D PROTO .data +szCalcAnalysis db 91,192,205,192,203,200,199,58,32,192,202,210,200,194,197,205,93,0 cardExitActive3D dd 0 cardExitChoice3D dd 0 cardExitButton3D db 194,32,245,238,235,235,0 diff --git a/src_graphics/card_tables_render.inc b/src_graphics/card_tables_render.inc index e093265..08d02c7 100644 --- a/src_graphics/card_tables_render.inc +++ b/src_graphics/card_tables_render.inc @@ -73,6 +73,7 @@ RenderNativePoker3D PROC uses ebx esi edi local shown:DWORD,slide:DWORD,hidden:DWORD call RenderCardTable3D invoke DrawTableHeader3D, OFFSET pkTitle3D, pkPot3D + call DrawUnderworldAnalysis3D xor eax, eax cmp pkState3D, PK_IDLE je poker_render_stake_enabled @@ -140,11 +141,11 @@ poker_render_chip_path: @@: cmp pkState3D, PK_PLAYER jne @F - invoke DrawString8x8, 8, 36, OFFSET pkCostText3D, 00DCCFB2h + invoke DrawString8x8, 8, 46, OFFSET pkCostText3D, 00DCCFB2h mov eax, pkCurrent3D sub eax, pkPaid3D invoke FormatNumber, eax, OFFSET hudNumBuffer - invoke DrawString8x8, 56, 36, OFFSET hudNumBuffer, 00F4F3E8h + invoke DrawString8x8, 56, 46, OFFSET hudNumBuffer, 00F4F3E8h @@: cmp pkState3D, PK_IDLE je poker_render_buttons @@ -197,6 +198,10 @@ poker_reveal_width: poker_render_open_hole: mov hidden, 0 poker_render_fixed_hole: + cmp uwPeeked,0 + je @F + mov hidden,0 +@@: invoke RenderPokerHole3D, ebx, hidden, 0, 0 jmp poker_render_next_hole poker_render_initial: @@ -256,12 +261,14 @@ poker_result_class: cmp pkResult3D, 1 jne poker_render_buttons invoke NativePokerClass3D, pkScore3D - invoke DrawString8x8, 8, 36, pkRankNames3D[eax*4], 00F7EACAh + invoke DrawString8x8, 8, 46, pkRankNames3D[eax*4], 00F7EACAh jmp poker_render_buttons poker_render_ai_status: mov eax, pkAiMessage3D invoke DrawString8x8, 128, 103, pkAiNames3D[eax*4], 00DCE7DBh poker_render_buttons: + invoke DrawBox,64,200,248,18,00151D20h + invoke DrawString8x8,64,206,OFFSET uwPeekText,00A8B6BBh call DrawQueuedTableHand3D cmp pkError3D, 2 jne @F @@ -321,6 +328,7 @@ RenderNativeBlackjack3D PROC uses ebx esi edi @@: call RenderCardTable3D invoke DrawTableHeader3D, OFFSET cbTitle3D, cbStake3D + call DrawUnderworldAnalysis3D xor eax, eax cmp cbState3D, CB_IDLE je bj_render_stake_enabled @@ -332,9 +340,9 @@ bj_render_stake_enabled: invoke DrawStakeControls3D, eax cmp obsActive3D,0 jne bj_observer_cards - invoke DrawString8x8, 8, 36, OFFSET textBet3D, 00DDCFB1h + invoke DrawString8x8, 8, 46, OFFSET textBet3D, 00DDCFB1h invoke FormatNumber, cbBet3D, OFFSET hudNumBuffer - invoke DrawString8x8, 80, 36, OFFSET hudNumBuffer, 00F6F4DDh + invoke DrawString8x8, 80, 46, OFFSET hudNumBuffer, 00F6F4DDh bj_observer_cards: cmp cbState3D, CB_IDLE je bj_render_buttons @@ -382,7 +390,10 @@ bj_render_card: jne bj_render_animation cmp cbVisible3D, 0 jne bj_render_animation + cmp uwPeeked,0 + jne @F mov hidden, 1 +@@: bj_render_animation: cmp cbState3D, CB_HIT jne @F @@ -418,7 +429,10 @@ bj_render_fixed: jne bj_render_dealer_extra cmp cbTimer3D, 180 jae bj_render_dealer_extra + cmp uwPeeked,0 + jne @F mov hidden, 1 +@@: mov eax, cbTimer3D sub eax, 90 jns @F @@ -465,7 +479,7 @@ bj_render_next_card: cmp cbState3D, CB_DEAL je bj_render_buttons invoke FormatNumber, cbPlayerScore3D, OFFSET hudNumBuffer - invoke DrawString8x8, 149, 207, OFFSET hudNumBuffer, 00EDDFB1h + invoke DrawString8x8, 280, 190, OFFSET hudNumBuffer, 00EDDFB1h mov eax, cbDealerScore3D cmp cbVisible3D, 0 jne @F @@ -483,6 +497,8 @@ bj_render_next_card: @@: invoke DrawString8x8, 116, 135, cbResults3D[eax*4], 00EFD583h bj_render_buttons: + invoke DrawBox,64,200,248,18,00151D20h + invoke DrawString8x8,64,206,OFFSET uwPeekText,00A8B6BBh call DrawQueuedTableHand3D call DrawBJPartySelector3D cmp cbError3D, 0 diff --git a/src_graphics/cinematic_hd.inc b/src_graphics/cinematic_hd.inc new file mode 100644 index 0000000..c61291f --- /dev/null +++ b/src_graphics/cinematic_hd.inc @@ -0,0 +1,401 @@ +FreeHDStudio3D PROC + cmp hdDC,0 + je @F + invoke SelectObject,hdDC,hdOriginal + invoke DeleteDC,hdDC + mov hdDC,0 +@@: + cmp hdBitmap,0 + je @F + invoke DeleteObject,hdBitmap + mov hdBitmap,0 +@@: + cmp hdPreviewDC,0 + je @F + invoke SelectObject,hdPreviewDC,hdPreviewOld + invoke DeleteDC,hdPreviewDC + mov hdPreviewDC,0 +@@: + cmp hdPreviewBmp,0 + je @F + invoke DeleteObject,hdPreviewBmp + mov hdPreviewBmp,0 + mov hdPreviewPixels,0 +@@: + cmp hdToken,0 + je @F + push hdToken + call hdFnShutdown + mov hdToken,0 +@@: + cmp hdFile,-1 + je @F + invoke CloseHandle,hdFile + mov hdFile,-1 +@@: + cmp hdBuffer,0 + je @F + invoke GetProcessHeap + invoke HeapFree,eax,0,hdBuffer + mov hdBuffer,0 +@@: + mov hdCachedFrame,-1 + ret +FreeHDStudio3D ENDP + +LoadHDStudio3D PROC uses ebx esi edi + local count:DWORD + cmp hdFile,-1 + jne hd_load_ready + mov hdLastStage,1 + invoke CreateFileA,hdPathPtr,80000000h,1,0,3,80h,0 + cmp eax,-1 + je hd_load_failed + mov hdFile,eax + invoke GetFileSize,eax,0 + cmp eax,1024*1024*1024 + ja hd_load_failed + mov hdFileSize,eax + mov hdLastStage,2 + invoke ReadFile,hdFile,OFFSET hdHeader,32,ADDR count,0 + test eax,eax + jz hd_load_failed + cmp count,32 + jne hd_load_failed + cmp hdHeader,344D4648h + jne hd_load_failed + cmp hdHeader[4],4 + jne hd_load_failed + cmp hdHeader[8],1920 + jne hd_load_failed + cmp hdHeader[12],1080 + jne hd_load_failed + cmp hdHeader[16],24 + jne hd_load_failed + cmp hdHeader[20],STUDIO_HD_FRAMES + jne hd_load_failed + cmp hdHeader[24],2*1024*1024 + jne hd_load_failed + cmp hdHeader[28],STUDIO_HD_DURATION + jne hd_load_failed + mov hdLastStage,3 + invoke ReadFile,hdFile,OFFSET hdIndex,STUDIO_HD_FRAMES*8,ADDR count,0 + test eax,eax + jz hd_load_failed + cmp count,STUDIO_HD_FRAMES*8 + jne hd_load_failed + xor esi,esi + mov ebx,32+STUDIO_HD_FRAMES*8 +hd_check_entry: + mov eax,hdIndex[esi*8] + cmp eax,ebx + jne hd_load_failed + mov edx,hdIndex[esi*8+4] + test edx,edx + jz hd_load_failed + cmp edx,2*1024*1024 + ja hd_load_failed + add eax,edx + jc hd_load_failed + cmp eax,hdFileSize + ja hd_load_failed + mov ebx,eax + inc esi + cmp esi,STUDIO_HD_FRAMES + jb hd_check_entry + cmp ebx,hdFileSize + jne hd_load_failed + mov hdLastStage,4 + cmp hdLibrary,0 + jne hd_bind_functions + invoke LoadLibraryA,OFFSET hdGdipName + test eax,eax + jz hd_load_failed + mov hdLibrary,eax +hd_bind_functions: + invoke GetProcAddress,hdLibrary,OFFSET hdStartupName + mov hdFnStartup,eax + invoke GetProcAddress,hdLibrary,OFFSET hdShutdownName + mov hdFnShutdown,eax + invoke GetProcAddress,hdLibrary,OFFSET hdDecodeName + mov hdFnDecode,eax + invoke GetProcAddress,hdLibrary,OFFSET hdHBitmapName + mov hdFnHBitmap,eax + invoke GetProcAddress,hdLibrary,OFFSET hdDisposeName + mov hdFnDispose,eax + invoke GetProcAddress,hdLibrary,OFFSET hdWidthName + mov hdFnWidth,eax + invoke GetProcAddress,hdLibrary,OFFSET hdHeightName + mov hdFnHeight,eax + cmp hdShellLibrary,0 + jne @F + invoke LoadLibraryA,OFFSET hdShellName + mov hdShellLibrary,eax +@@: + invoke GetProcAddress,hdShellLibrary,OFFSET hdStreamName + mov hdFnStream,eax + mov eax,hdFnStartup + test eax,eax + jz hd_load_failed + cmp hdFnShutdown,0 + je hd_load_failed + cmp hdFnDecode,0 + je hd_load_failed + cmp hdFnHBitmap,0 + je hd_load_failed + cmp hdFnDispose,0 + je hd_load_failed + cmp hdFnWidth,0 + je hd_load_failed + cmp hdFnHeight,0 + je hd_load_failed + cmp hdFnStream,0 + je hd_load_failed + mov hdLastStage,5 + push 0 + push OFFSET hdStartupInput + push OFFSET hdToken + call hdFnStartup + test eax,eax + jnz hd_load_failed + mov hdLastStage,6 + invoke GetProcessHeap + invoke HeapAlloc,eax,0,2*1024*1024 + test eax,eax + jz hd_load_failed + mov hdBuffer,eax + mov hdLastStage,7 + invoke CreateCompatibleDC,0 + test eax,eax + jz hd_load_failed + mov hdDC,eax + mov hdLastStage,8 + invoke CreateCompatibleDC,0 + test eax,eax + jz hd_load_failed + mov hdPreviewDC,eax + mov hdLastStage,9 + invoke CreateDIBSection,0,OFFSET hdPreviewInfo,0,OFFSET hdPreviewPixels,0,0 + test eax,eax + jz hd_load_failed + mov hdPreviewBmp,eax + invoke SelectObject,hdPreviewDC,eax + mov hdPreviewOld,eax + mov hdCachedFrame,-1 +hd_load_ready: + mov hdLastStage,10 + mov eax,1 + ret +hd_load_failed: + mov hdLastStatus,eax + call FreeHDStudio3D + xor eax,eax + ret +LoadHDStudio3D ENDP + +RenderHDStudio3D PROC uses ebx esi edi timeMs:DWORD + local index:DWORD,count:DWORD,stream:DWORD,image:DWORD,newBitmap:DWORD + local imageW:DWORD,imageH:DWORD + cmp hdFile,-1 + je hd_render_unavailable + mov stream,0 + mov image,0 + mov newBitmap,0 + mov eax,timeMs + cmp eax,STUDIO_HD_DURATION + jb @F + mov eax,STUDIO_HD_DURATION-1 +@@: + imul eax,24 + xor edx,edx + mov ecx,1000 + div ecx + mov index,eax + cmp eax,hdCachedFrame + je hd_copy_preview + mov ebx,eax + mov hdLastStage,20 + invoke SetFilePointer,hdFile,hdIndex[ebx*8],0,0 + cmp eax,-1 + je hd_render_failed + invoke ReadFile,hdFile,hdBuffer,hdIndex[ebx*8+4],ADDR count,0 + test eax,eax + jz hd_render_failed + mov eax,hdIndex[ebx*8+4] + cmp eax,count + jne hd_render_failed + mov hdLastStage,21 + push count + push hdBuffer + call hdFnStream + test eax,eax + jz hd_render_failed + mov stream,eax + mov hdLastStage,22 + lea eax,image + push eax + push stream + call hdFnDecode + test eax,eax + jnz hd_render_failed + mov hdLastStage,23 + lea eax,imageW + push eax + push image + call hdFnWidth + test eax,eax + jnz hd_render_failed + mov hdLastStage,24 + lea eax,imageH + push eax + push image + call hdFnHeight + test eax,eax + jnz hd_render_failed + cmp imageW,1920 + jne hd_render_failed + cmp imageH,1080 + jne hd_render_failed + mov hdLastStage,25 + push 0 + lea eax,newBitmap + push eax + push image + call hdFnHBitmap + test eax,eax + jnz hd_render_failed + push image + call hdFnDispose + mov image,0 + mov eax,stream + mov edx,[eax] + push eax + call DWORD PTR [edx+8] + mov stream,0 + invoke SelectObject,hdDC,newBitmap + cmp hdBitmap,0 + jne @F + mov hdOriginal,eax +@@: + cmp hdBitmap,0 + je @F + invoke DeleteObject,hdBitmap +@@: + mov eax,newBitmap + mov hdBitmap,eax + mov newBitmap,0 + mov eax,index + mov hdCachedFrame,eax + ; A small preview keeps existing capture/debug tools functional. Presentation + ; uses the separate 1920x1080 bitmap, never this downscaled buffer. + invoke PatBlt,hdPreviewDC,0,0,640,480,42h + invoke SetStretchBltMode,hdPreviewDC,4 + invoke StretchBlt,hdPreviewDC,0,60,640,360,hdDC,0,0,1920,1080,SRCCOPY + invoke GdiFlush +hd_copy_preview: + mov hdLastStage,30 + mov esi,hdPreviewPixels + lea edi,screenBuffer + mov ecx,SCREEN_SIZE + rep movsd + mov eax,1 + ret +hd_render_failed: + mov hdLastStatus,eax + cmp image,0 + je @F + push image + call hdFnDispose +@@: + cmp stream,0 + je @F + mov eax,stream + mov edx,[eax] + push eax + call DWORD PTR [edx+8] +@@: + cmp newBitmap,0 + je @F + invoke DeleteObject,newBitmap +@@: + call FreeHDStudio3D + call LoadCinematicMaster3D + test eax,eax + jnz hd_render_unavailable + call LoadStartupProceduralAssets3D +hd_render_unavailable: + xor eax,eax + ret +RenderHDStudio3D ENDP + +PresentHDStudio3D PROC uses ebx esi edi dc:DWORD,clientW:DWORD,clientH:DWORD + local wide:DWORD,tall:DWORD,left:DWORD,top:DWORD + cmp engineMode,MODE_INTRO + jne hd_present_no + cmp startupPage3D,STARTUP_STUDIO + jne hd_present_no + cmp hdBitmap,0 + je hd_present_no + mov eax,clientW + mov wide,eax + imul eax,9 + mov ebx,clientH + imul ebx,16 + cmp eax,ebx + jbe hd_present_fit_width + mov eax,clientH + mov tall,eax + imul eax,16 + xor edx,edx + mov ecx,9 + div ecx + mov wide,eax + mov eax,tall + jmp hd_present_geometry +hd_present_fit_width: + xor edx,edx + mov ecx,16 + div ecx +hd_present_geometry: + mov tall,eax + mov eax,clientW + sub eax,wide + shr eax,1 + mov left,eax + mov eax,clientH + sub eax,tall + shr eax,1 + mov top,eax + test eax,eax + jz @F + invoke PatBlt,dc,0,0,clientW,top,42h +@@: + mov eax,top + add eax,tall + mov edx,clientH + sub edx,eax + test edx,edx + jz @F + invoke PatBlt,dc,0,eax,clientW,edx,42h +@@: + cmp left,0 + je @F + invoke PatBlt,dc,0,0,left,clientH,42h +@@: + mov eax,left + add eax,wide + mov edx,clientW + sub edx,eax + test edx,edx + jz @F + invoke PatBlt,dc,eax,0,edx,clientH,42h +@@: + invoke SetStretchBltMode,dc,4 + invoke StretchBlt,dc,left,top,wide,tall,hdDC,0,0,1920,1080,SRCCOPY + invoke SetStretchBltMode,dc,3 + mov eax,1 + ret +hd_present_no: + xor eax,eax + ret +PresentHDStudio3D ENDP diff --git a/src_graphics/cinematic_hd_data.inc b/src_graphics/cinematic_hd_data.inc new file mode 100644 index 0000000..dc733fb --- /dev/null +++ b/src_graphics/cinematic_hd_data.inc @@ -0,0 +1,66 @@ +STUDIO_HD_FRAMES equ STUDIO_HD_DURATION*24/1000 +; Full-resolution offline studio film; playback and input remain native MASM. +IFNDEF LoadLibraryA +LoadLibraryA PROTO :DWORD +ENDIF +IFNDEF CreateCompatibleDC +CreateCompatibleDC PROTO :DWORD +DeleteDC PROTO :DWORD +SelectObject PROTO :DWORD,:DWORD +DeleteObject PROTO :DWORD +CreateDIBSection PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD +StretchBlt PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD +ENDIF +LoadHDStudio3D PROTO +FreeHDStudio3D PROTO +RenderHDStudio3D PROTO :DWORD +PresentHDStudio3D PROTO :DWORD,:DWORD,:DWORD +IFNDEF GdiFlush +GdiFlush PROTO +ENDIF +.data +hdStudioPath db 'assets\animations\intro\eblan-studio-v8.hfm',0 +hdGdipName db 'gdiplus.dll',0 +hdShellName db 'shlwapi.dll',0 +hdStartupName db 'GdiplusStartup',0 +hdShutdownName db 'GdiplusShutdown',0 +hdDecodeName db 'GdipCreateBitmapFromStream',0 +hdHBitmapName db 'GdipCreateHBITMAPFromBitmap',0 +hdDisposeName db 'GdipDisposeImage',0 +hdWidthName db 'GdipGetImageWidth',0 +hdHeightName db 'GdipGetImageHeight',0 +hdStreamName db 'SHCreateMemStream',0 +ALIGN 4 +hdPathPtr dd OFFSET hdStudioPath +hdFile dd -1 +hdBuffer dd 0 +hdFileSize dd 0 +hdToken dd 0 +hdStartupInput dd 1,0,0,0 +hdLibrary dd 0 +hdShellLibrary dd 0 +hdFnStartup dd 0 +hdFnShutdown dd 0 +hdFnDecode dd 0 +hdFnHBitmap dd 0 +hdFnDispose dd 0 +hdFnWidth dd 0 +hdFnHeight dd 0 +hdFnStream dd 0 +hdBitmap dd 0 +hdDC dd 0 +hdOriginal dd 0 +hdPreviewDC dd 0 +hdPreviewBmp dd 0 +hdPreviewOld dd 0 +hdPreviewPixels dd 0 +hdCachedFrame dd -1 +hdLastStage dd 0 +hdLastStatus dd 0 +hdHeader dd 8 dup(0) +hdPreviewInfo dd 40,640,-480 + dw 1,32 + dd 0,640*480*4,0,0,0,0 +.data? +hdIndex dd STUDIO_HD_FRAMES*2 dup(?) +.code diff --git a/src_graphics/cinematic_master.inc b/src_graphics/cinematic_master.inc new file mode 100644 index 0000000..e97bcd9 --- /dev/null +++ b/src_graphics/cinematic_master.inc @@ -0,0 +1,215 @@ +FreeCinematicMaster3D PROC + cmp cinemaFile,-1 + je @F + invoke CloseHandle,cinemaFile + mov cinemaFile,-1 +@@: + cmp cinemaCompressed,0 + je @F + invoke GetProcessHeap + invoke HeapFree,eax,0,cinemaCompressed + mov cinemaCompressed,0 +@@: + cmp cinemaPixels,0 + je @F + invoke GetProcessHeap + invoke HeapFree,eax,0,cinemaPixels + mov cinemaPixels,0 +@@: + mov cinemaCachedFrame,-1 + cmp cinemaPacked,0 + je @F + invoke GetProcessHeap + invoke HeapFree,eax,0,cinemaPacked + mov cinemaPacked,0 +@@: + ret +FreeCinematicMaster3D ENDP + +LoadCinematicMaster3D PROC uses ebx esi edi + local count:DWORD,indexBytes:DWORD,minOffset:DWORD + cmp cinemaFile,-1 + jne cinema_load_ready + invoke GetModuleHandleA,OFFSET cinemaNtDll + test eax,eax + jz cinema_load_failure + invoke GetProcAddress,eax,OFFSET cinemaDecoderName + test eax,eax + jz cinema_load_failure + mov cinemaDecoder,eax + invoke CreateFileA,cinemaPathPtr,80000000h,1,0,3,80h,0 + cmp eax,-1 + je cinema_load_failure + mov cinemaFile,eax + invoke GetFileSize,eax,0 + cmp eax,256*1024*1024 + ja cinema_load_failure + mov cinemaFileBytes,eax + invoke ReadFile,cinemaFile,OFFSET cinemaHeader,32,ADDR count,0 + test eax,eax + jz cinema_load_failure + cmp count,32 + jne cinema_load_failure + cmp cinemaHeader,334D4643h + jne cinema_load_failure + cmp cinemaHeader[4],3 + jne cinema_load_failure + cmp cinemaHeader[8],30 + jne cinema_load_failure + cmp cinemaHeader[12],600 + jne cinema_load_failure + cmp cinemaHeader[16],SCREEN_W + jne cinema_load_failure + cmp cinemaHeader[20],SCREEN_H + jne cinema_load_failure + cmp cinemaHeader[24],SCREEN_SIZE*2 + jne cinema_load_failure + cmp cinemaHeader[28],SCREEN_SIZE*2+4096 + jne cinema_load_failure + mov indexBytes,600*8 + mov minOffset,32+600*8 + invoke ReadFile,cinemaFile,OFFSET cinemaIndex,indexBytes,ADDR count,0 + test eax,eax + jz cinema_load_failure + cmp count,600*8 + jne cinema_load_failure + xor esi,esi + mov ebx,32+600*8 +cinema_validate_entry: + mov eax,cinemaIndex[esi*8] + cmp eax,ebx + jne cinema_load_failure + mov edx,cinemaIndex[esi*8+4] + test edx,edx + jz cinema_load_failure + cmp edx,SCREEN_SIZE*2+4096 + ja cinema_load_failure + add eax,edx + jc cinema_load_failure + cmp eax,cinemaFileBytes + ja cinema_load_failure + mov ebx,eax + inc esi + cmp esi,600 + jb cinema_validate_entry + cmp ebx,cinemaFileBytes + jne cinema_load_failure + invoke GetProcessHeap + invoke HeapAlloc,eax,0,SCREEN_SIZE*2+4096 + test eax,eax + jz cinema_load_failure + mov cinemaCompressed,eax + invoke GetProcessHeap + invoke HeapAlloc,eax,0,SCREEN_SIZE*4 + test eax,eax + jz cinema_load_failure + mov cinemaPixels,eax + invoke GetProcessHeap + invoke HeapAlloc,eax,0,SCREEN_SIZE*2 + test eax,eax + jz cinema_load_failure + mov cinemaPacked,eax + xor edx,edx +cinema_build_color_table: + mov eax,edx + and eax,31 + mov ebx,eax + shl eax,3 + shr ebx,2 + or eax,ebx + mov edi,eax + mov eax,edx + shr eax,5 + and eax,63 + mov ebx,eax + shl eax,2 + shr ebx,4 + or eax,ebx + shl eax,8 + or edi,eax + mov eax,edx + shr eax,11 + mov ebx,eax + shl eax,3 + shr ebx,2 + or eax,ebx + shl eax,16 + or eax,edi + mov cinema565Table[edx*4],eax + inc edx + cmp edx,65536 + jb cinema_build_color_table + mov cinemaCachedFrame,-1 +cinema_load_ready: + mov eax,1 + ret +cinema_load_failure: + call FreeCinematicMaster3D + xor eax,eax + ret +LoadCinematicMaster3D ENDP + +RenderCinematicMaster3D PROC uses ebx esi edi timeMs:DWORD + local frame:DWORD,count:DWORD,unpacked:DWORD + cmp cinemaFile,-1 + je cinema_render_unavailable + mov eax,timeMs + cmp eax,20000 + jb @F + mov eax,19999 +@@: + imul eax,30 + xor edx,edx + mov ecx,1000 + div ecx + mov frame,eax + cmp eax,cinemaCachedFrame + je cinema_copy_frame + mov ebx,eax + invoke SetFilePointer,cinemaFile,cinemaIndex[ebx*8],0,0 + cmp eax,-1 + je cinema_render_failure + invoke ReadFile,cinemaFile,cinemaCompressed,cinemaIndex[ebx*8+4],ADDR count,0 + test eax,eax + jz cinema_render_failure + mov eax,cinemaIndex[ebx*8+4] + cmp eax,count + jne cinema_render_failure + lea eax,unpacked + push eax + push count + push cinemaCompressed + push SCREEN_SIZE*2 + push cinemaPacked + push 2 + call cinemaDecoder + test eax,eax + jnz cinema_render_failure + cmp unpacked,SCREEN_SIZE*2 + jne cinema_render_failure + mov esi,cinemaPacked + mov edi,cinemaPixels + mov ecx,SCREEN_SIZE +cinema_expand_color: + movzx eax,WORD PTR [esi] + mov eax,cinema565Table[eax*4] + stosd + add esi,2 + dec ecx + jnz cinema_expand_color + mov eax,frame + mov cinemaCachedFrame,eax +cinema_copy_frame: + mov esi,cinemaPixels + lea edi,screenBuffer + mov ecx,SCREEN_SIZE + rep movsd + mov eax,1 + ret +cinema_render_failure: + call FreeCinematicMaster3D + call LoadStartupProceduralAssets3D +cinema_render_unavailable: + xor eax,eax + ret +RenderCinematicMaster3D ENDP diff --git a/src_graphics/cinematic_master_data.inc b/src_graphics/cinematic_master_data.inc new file mode 100644 index 0000000..288abc2 --- /dev/null +++ b/src_graphics/cinematic_master_data.inc @@ -0,0 +1,24 @@ +; Bounded native frame stream. AE is used only offline to prepare this asset. +SetFilePointer PROTO :DWORD,:DWORD,:DWORD,:DWORD +LoadStartupProceduralAssets3D PROTO +LoadCinematicMaster3D PROTO +FreeCinematicMaster3D PROTO +RenderCinematicMaster3D PROTO :DWORD +.data +cinemaMasterPath db 'assets\animations\intro\cinematic-master-v3.cfm',0 +cinemaNtDll db 'ntdll.dll',0 +cinemaDecoderName db 'RtlDecompressBuffer',0 +ALIGN 4 +cinemaPathPtr dd OFFSET cinemaMasterPath +cinemaFile dd -1 +cinemaCompressed dd 0 +cinemaPixels dd 0 +cinemaPacked dd 0 +cinemaDecoder dd 0 +cinemaCachedFrame dd -1 +cinemaFileBytes dd 0 +cinemaHeader dd 8 dup(0) +.data? +cinemaIndex dd 1200*2 dup(?) +cinema565Table dd 65536 dup(?) +.code diff --git a/src_graphics/darts.inc b/src_graphics/darts.inc index d11165d..f5e7b09 100644 --- a/src_graphics/darts.inc +++ b/src_graphics/darts.inc @@ -124,6 +124,11 @@ DartsAim3D PROC uses ebx local amplitude:DWORD,phase:DWORD,secondary:DWORD ; Smooth mixed phases and gradual hold fatigue; never scatter after release. mov amplitude,10 + cmp barBuffCalmTimer,0 + jbe @F + mov amplitude,0 + jmp dt_aim_phase +@@: cmp dtHolding3D,0 je dt_aim_phase mov eax,dtHoldTime3D diff --git a/src_graphics/debt_data.inc b/src_graphics/debt_data.inc new file mode 100644 index 0000000..247ba4a --- /dev/null +++ b/src_graphics/debt_data.inc @@ -0,0 +1,89 @@ +; ============================================================================== +; LOAN SHARK & DEBT SYSTEM DATA (CP1251) +; ============================================================================== + +MODE_DEBT equ 32 + +TriggerDebtDialog3D PROTO +TriggerDebtAmbush3D PROTO +StepDebtRound3D PROTO +HandleDebt3D PROTO +RenderDebt3D PROTO + +.data +ALIGN 4 +debtActive dd 0 +debtAmount dd 0 +debtBorrowed dd 0 +debtRoundsLeft dd 0 +debtSubmode dd 0 ; 0=Semyon loan menu, 1=Ambush menu, 2=QTE fight, 3=Result +debtQteKey dd 0 ; expected key +debtQteKeyText db 0,0 ; null-terminated key for the HUD +debtQteTimer dd 0 ; countdown +debtQteStep dd 0 ; 0..3 steps +debtResultMsg dd 0 + +szDebtTitle db 208,206,209,210,206,194,217,200,202,32,209,197 + db 204,197,205,0 +szDebtPrompt db 212,238,240,242,243,237,224,32,238,242,226,229 + db 240,237,243,235,224,241,252,63,32,204,238,227 + db 243,32,226,251,240,243,247,232,242,252,32,236 + db 238,237,229,242,238,233,46,0 +szDebtOpt1 db 49,46,32,199,224,237,255,242,252,32,36,53 + db 48,48,32,40,228,238,235,227,32,36,55,48 + db 48,44,32,50,53,32,245,41,0 +szDebtOpt2 db 50,46,32,199,224,237,255,242,252,32,36,50 + db 53,48,48,32,40,228,238,235,227,32,36,51 + db 55,53,48,44,32,52,48,32,245,41,0 +szDebtOpt3 db 51,46,32,199,224,237,255,242,252,32,36,49 + db 48,48,48,48,32,40,228,238,235,227,32,36 + db 49,54,48,48,48,44,32,54,48,32,245,41 + db 0 +szDebtOpt4 db 52,46,32,206,242,234,224,231,224,242,252,241 + db 255,32,232,32,243,233,242,232,0 +szDebtRepay db 53,46,32,207,238,227,224,241,232,242,252,32 + db 228,238,235,227,32,40,36,0 +szDebtHud db 196,206,203,195,58,32,36,0 +szAmbushTitle db 207,197,208,197,211,203,206,202,32,199,192,32 + db 202,192,199,200,205,206,58,32,202,206,203,203 + db 197,202,210,206,208,219,0 +szAmbushText db 209,240,238,234,32,226,251,248,229,235,33,32 + db 200,231,32,242,229,236,237,238,242,251,32,226 + db 251,245,238,228,255,242,32,228,226,238,229,32 + db 241,32,224,240,236,224,242,243,240,238,233,46 + db 0 +szAmbushOpt1 db 49,46,32,211,235,232,247,237,224,255,32,228 + db 240,224,234,224,32,91,81,84,69,32,87,65 + db 83,68,93,0 +szAmbushOpt2 db 50,46,32,208,243,241,241,234,224,255,32,240 + db 243,235,229,242,234,224,32,237,224,32,228,238 + db 235,227,32,40,49,47,54,41,0 +szAmbushOpt3 db 51,46,32,206,242,228,224,242,252,32,226,241 + db 184,32,232,32,243,233,242,232,0 +szDebtSuccessRepay db 209,229,236,229,237,32,243,245,236,251,235,255 + db 229,242,241,255,58,32,196,238,235,227,32,231 + db 224,234,240,251,242,33,32,206,225,240,224,249 + db 224,233,241,255,32,229,249,229,46,0 +szDebtFightWin db 194,251,32,240,224,241,234,232,228,224,235,232 + db 32,227,240,238,236,232,235,33,32,206,242,241 + db 240,238,247,234,224,32,237,224,32,50,48,32 + db 240,224,243,237,228,238,226,33,0 +szDebtFightFail db 194,224,241,32,241,234,240,243,242,232,235,224 + db 32,232,32,238,242,238,225,240,224,235,232,32 + db 226,241,184,32,226,32,241,247,229,242,32,228 + db 238,235,227,224,33,0 +szDebtRouletteWin db 217,197,203,215,206,202,33,32,193,224,240,224 + db 225,224,237,32,239,243,241,242,46,32,202,238 + db 235,235,229,234,242,238,240,251,32,226,32,248 + db 238,234,229,58,32,196,238,235,227,32,241,239 + db 232,241,224,237,33,0 +szDebtRouletteFail db 194,219,209,210,208,197,203,33,32,206,241,229 + db 247,234,232,32,237,229,32,239,240,238,232,231 + db 238,248,235,238,46,46,46,0 +szDebtQtePrompt db 193,219,209,210,208,206,32,205,192,198,204,200 + db 210,197,58,32,0 +szDebtPressEnter db 91,69,110,116,101,114,58,32,207,240,238,228 + db 238,235,230,232,242,252,93,0 +szBankruptPrompt db 91,193,192,205,202,208,206,210,33,32,205,192 + db 201,196,200,210,197,32,209,197,204,203,205,192 + db 32,211,32,193,192,208,192,93,0 diff --git a/src_graphics/debt_scene.inc b/src_graphics/debt_scene.inc new file mode 100644 index 0000000..0a8d0f6 --- /dev/null +++ b/src_graphics/debt_scene.inc @@ -0,0 +1,295 @@ +; ============================================================================== +; LOAN SHARK & DEBT SYSTEM SCENE (CP1251) +; ============================================================================== + +TriggerDebtDialog3D PROC + mov debtSubmode, 0 + mov engineMode, MODE_DEBT + call ClearKeys3D + ret +TriggerDebtDialog3D ENDP + +StepDebtRound3D PROC + cmp debtActive, 0 + je step_debt_done + cmp debtRoundsLeft, 0 + jbe step_debt_check_pay + dec debtRoundsLeft + cmp debtRoundsLeft, 0 + jne step_debt_done + +step_debt_check_pay: + mov eax, debtAmount + cmp bankroll, eax + jb step_debt_ambush + sub bankroll, eax + mov debtActive, 0 + mov debtAmount, 0 + call SaveProgress3D + ret + +step_debt_ambush: + mov uwDebtPending,1 + +step_debt_done: + call SaveUnderworldProgress3D + ret +StepDebtRound3D ENDP + +HandleDebt3D PROC + cmp debtSubmode,0 + jne @F + invoke Pressed3D,1Bh + test eax,eax + jnz debt_exit_walk +@@: + cmp debtSubmode, 0 + jne debt_check_sub1 + + ; Submode 0: Semyon loan menu + invoke Pressed3D, 31h ; '1' + test eax, eax + jz @F + cmp debtActive, 0 + jnz @F + add bankroll, 500 + invoke PlayCasinoSound3D, OFFSET soundCoin, 0, 1 + mov debtAmount, 700 + mov debtBorrowed, 500 + mov debtRoundsLeft, 25 + mov debtActive, 1 + mov engineMode, MODE_WALK + call SaveProgress3D + ret +@@: + invoke Pressed3D, 32h ; '2' + test eax, eax + jz @F + cmp debtActive, 0 + jnz @F + add bankroll, 2500 + invoke PlayCasinoSound3D, OFFSET soundCoin, 0, 1 + mov debtAmount, 3750 + mov debtBorrowed, 2500 + mov debtRoundsLeft, 40 + mov debtActive, 1 + mov engineMode, MODE_WALK + call SaveProgress3D + ret +@@: + invoke Pressed3D, 33h ; '3' + test eax, eax + jz @F + cmp debtActive, 0 + jnz @F + add bankroll, 10000 + invoke PlayCasinoSound3D, OFFSET soundCoin, 0, 1 + mov debtAmount, 16000 + mov debtBorrowed, 10000 + mov debtRoundsLeft, 60 + mov debtActive, 1 + mov engineMode, MODE_WALK + call SaveProgress3D + ret +@@: + invoke Pressed3D, 34h ; '4' + test eax, eax + jz @F + mov engineMode, MODE_WALK + ret +@@: + invoke Pressed3D, 35h ; '5' + test eax, eax + jz debt_handle_done + cmp debtActive, 0 + je debt_handle_done + mov eax, debtAmount + cmp bankroll, eax + jb debt_handle_done + sub bankroll, eax + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + mov debtActive, 0 + mov debtAmount, 0 + mov debtResultMsg, OFFSET szDebtSuccessRepay + mov debtSubmode, 3 + call SaveProgress3D + ret + +debt_check_sub1: + cmp debtSubmode, 1 + jne debt_check_sub2 + + ; Submode 1: Ambush menu (1: Fight QTE, 2: Roulette, 3: Forfeit) + invoke Pressed3D, 31h ; '1' + test eax, eax + jz @F + mov debtSubmode, 2 + mov debtQteStep, 0 + mov debtQteKey, 57h ; 'W' + mov debtQteTimer, 1500 + ret +@@: + invoke Pressed3D, 32h ; '2' + test eax, eax + jz @F + ; Russian roulette (1/6 shot) + invoke RandomRange3D, 6 + cmp eax, 0 + je debt_rr_fail + ; Survived! + mov debtActive, 0 + mov debtAmount, 0 + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + mov debtResultMsg, OFFSET szDebtRouletteWin + mov debtSubmode, 3 + call SaveProgress3D + ret +debt_rr_fail: + mov bankroll, 0 + mov debtActive, 0 + mov debtAmount, 0 + invoke PlayCasinoSound3D, OFFSET soundRoundLose, 0, 1 + mov debtResultMsg, OFFSET szDebtRouletteFail + mov debtSubmode, 3 + call SaveProgress3D + ret +@@: + invoke Pressed3D, 33h ; '3' + test eax, eax + jz debt_handle_done + mov bankroll, 0 + mov debtActive, 0 + mov debtAmount, 0 + invoke PlayCasinoSound3D, OFFSET soundRoundLose, 0, 1 + mov debtResultMsg, OFFSET szDebtFightFail + mov debtSubmode, 3 + call SaveProgress3D + ret + +debt_check_sub2: + cmp debtSubmode, 2 + jne debt_check_sub3 + + ; Submode 2: QTE Street Fight + mov eax,deltaTime3D + sub debtQteTimer,eax + cmp debtQteTimer, 0 + jle debt_qte_timed_out + + invoke Pressed3D, debtQteKey + test eax, eax + jz debt_handle_done + + ; Key pressed correctly! + invoke PlayCasinoSound3D, OFFSET soundSkillHit, 0, 1 + inc debtQteStep + cmp debtQteStep, 4 + jae debt_qte_won + + ; Next key + mov eax, debtQteStep + .if eax == 1 + mov debtQteKey, 41h ; 'A' + .elseif eax == 2 + mov debtQteKey, 44h ; 'D' + .else + mov debtQteKey, 53h ; 'S' + .endif + mov debtQteTimer, 1500 + ret + +debt_qte_timed_out: + mov bankroll, 0 + mov debtActive, 0 + mov debtAmount, 0 + invoke PlayCasinoSound3D, OFFSET soundRoundLose, 0, 1 + mov debtResultMsg, OFFSET szDebtFightFail + mov debtSubmode, 3 + call SaveProgress3D + ret + +debt_qte_won: + add debtRoundsLeft, 20 + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + mov debtResultMsg, OFFSET szDebtFightWin + mov debtSubmode, 3 + call SaveProgress3D + ret + +debt_check_sub3: + ; Submode 3: Result message wait + invoke Pressed3D, 0Dh ; Enter + test eax, eax + jnz debt_exit_walk + invoke Pressed3D, 20h ; Space + test eax, eax + jnz debt_exit_walk + invoke Pressed3D, 1Bh ; Esc + test eax, eax + jz debt_handle_done +debt_exit_walk: + mov uwDebtPending,0 + mov engineMode, MODE_WALK + call ClearKeys3D + +debt_handle_done: + ret +HandleDebt3D ENDP + +RenderDebt3D PROC + invoke DrawBox,0,0,320,240,00121110h + invoke DrawBoxBorder,6,6,308,228,001A1816h,00836D42h,1 + invoke DrawUnderworldSprite3D,OFFSET secPortraitsPack,0,12,40,94,110 + cmp debtSubmode,0 + je uw_debt_menu + invoke DrawBox,10,36,100,150,001A1816h + invoke DrawUnderworldSprite3D,OFFSET secPortraitsPack,1,12,40,94,110 + invoke DrawString8x8,16,16,OFFSET uwAmbush,00E7CA88h + cmp debtSubmode,1 + je uw_debt_ambush + cmp debtSubmode,2 + je uw_debt_qte + invoke DrawUnderworldText3D,116,52,debtResultMsg,23,00E7CA88h + invoke DrawString8x8,16,202,OFFSET uwContinue,0055FF55h + jmp uw_debt_footer +uw_debt_menu: + invoke DrawString8x8,16,16,OFFSET uwLoanTitle,00E7CA88h + cmp debtActive,0 + jne uw_debt_repay + invoke DrawUnderworldText3D,116,42,OFFSET uwLoanIntro,23,00E4D9BDh + invoke DrawUnderworldText3D,116,90,OFFSET uwLoan1,23,00A8DDB9h + invoke DrawUnderworldText3D,116,126,OFFSET uwLoan2,23,00A8DDB9h + invoke DrawUnderworldText3D,116,162,OFFSET uwLoan3,23,00A8DDB9h + jmp uw_debt_back +uw_debt_repay: + invoke DrawString8x8,116,52,OFFSET uwDebt,00E7CA88h + invoke DrawNumber,172,52,debtAmount,00FFFFFFh + invoke DrawString8x8,116,78,OFFSET uwRounds,00E7CA88h + invoke DrawNumber,196,78,debtRoundsLeft,00FFFFFFh + invoke DrawString8x8,116,114,OFFSET uwLoanRepay,00A8DDB9h +uw_debt_back: + invoke DrawString8x8,16,202,OFFSET uwLoanBack,00A8B6BBh + jmp uw_debt_footer +uw_debt_ambush: + invoke DrawUnderworldText3D,116,46,OFFSET uwAmbush1,23,00E7CA88h + invoke DrawUnderworldText3D,116,98,OFFSET uwAmbush2,23,00E7CA88h + invoke DrawUnderworldText3D,116,150,OFFSET uwAmbush3,23,00A8B6BBh + jmp uw_debt_footer +uw_debt_qte: + invoke DrawUnderworldText3D,116,48,OFFSET uwFight,23,00E7CA88h + mov eax,debtQteKey + mov debtQteKeyText,al + invoke DrawBoxBorder,176,90,48,42,00222222h,00E7CA88h,1 + invoke DrawString8x8,196,106,OFFSET debtQteKeyText,0055FF55h + mov eax,debtQteTimer + imul eax,174 + xor edx,edx + mov ecx,1500 + div ecx + invoke DrawBox,122,152,eax,8,0055FF55h + invoke DrawNumber,196,176,debtQteStep,00E7CA88h +uw_debt_footer: + invoke DrawString8x8,16,220,OFFSET uwBank,00A8B6BBh + invoke DrawNumber,72,220,bankroll,00E5D6B0h + ret +RenderDebt3D ENDP diff --git a/src_graphics/graphic_profiles.inc b/src_graphics/graphic_profiles.inc index 6edd1d3..06bc800 100644 --- a/src_graphics/graphic_profiles.inc +++ b/src_graphics/graphic_profiles.inc @@ -215,6 +215,7 @@ graphic_select_load: invoke CopyCString, OFFSET saveFileName, ebx mov nativeProfileActive3D, 1 call LoadSave + call LoadUnderworldProgress3D call SyncGraphicBack3D call ApplySoundVolume mov eax, 1 @@ -265,6 +266,7 @@ graphic_create_store: mov nativeProfileActive3D, 1 call SyncGraphicBack3D call SaveGame + call LoadUnderworldProgress3D call ApplySoundVolume invoke ValidateGraphicProfile3D, OFFSET entryFindPath3D test eax, eax diff --git a/src_graphics/hall_data.inc b/src_graphics/hall_data.inc index 66b18d9..f78dd50 100644 --- a/src_graphics/hall_data.inc +++ b/src_graphics/hall_data.inc @@ -1,175 +1,195 @@ -MODE_BAR equ 14 -MODE_STAIRS equ 15 -INTERACT_BAR equ 21 -INTERACT_BASEMENT equ 22 -INTERACT_UPSTAIRS equ 23 -INTERACT_BILLIARDS equ 24 -RenderCeilingAndFloor PROTO -RenderSprites PROTO -InitHall3D PROTO -LoadHallAssets3D PROTO -FreeHallAssets3D PROTO -CheckHallInteractions3D PROTO -TriggerHallInteraction3D PROTO -RenderHall3D PROTO -HandleBar3D PROTO -RenderBar3D PROTO -HandleStairs3D PROTO -RenderStairs3D PROTO -RenderCityGuards3D PROTO -CanWalkHall3D PROTO :DWORD,:DWORD -RenderCityFacade3D PROTO -UpdateHall3D PROTO -UpdatePatrons3D PROTO -RenderPatrons3D PROTO -ResolveWorldSurface3D PROTO :DWORD -include src_graphics\hall_layout.inc -.data -ALIGN 4 -tableInvDelta3D dd 241 dup(0) -tableStepRatio3D dd 241 dup(0) -hallSign3D AnimPack3D <> -hallSignPath3D db "assets\animations\hall\sign.bin",0 -hallCityDetail3D AnimPack3D <> -hallCityDetailPath3D db "assets\animations\hall\city-detail.bin",0 -hallRoomMaterials3D AnimPack3D <> -hallRoomMaterialsPath3D db "assets\animations\hall\room-materials.bin",0 -hallPatrons3D AnimPack3D <> -hallPatronsPath3D db "assets\animations\hall\patrons.bin",0 -hallStreetLife3D AnimPack3D <> -hallStreetLifePath3D db "assets\animations\hall\street-life-v4.bin",0 -hallRoomHD3D AnimPack3D <> -hallArchitecture3D AnimPack3D <> -hallArchitectureHD3D AnimPack3D <> -hallDecorPack3D AnimPack3D <> -hallRoomHDPath3D db "assets\animations\hall\room-materials-hd.bin",0 -hallArchitecturePath3D db "assets\animations\hall\architecture.bin",0 -hallArchitectureHDPath3D db "assets\animations\hall\architecture-hd.bin",0 -hallDecorPath3D db "assets\animations\hall\architecture-props.bin",0 -patronClock3D dd 0 -HALL_PATRON_COUNT equ 16 -hallGuests3D CityProp3D <18*FP_1,18*FP_1,FP_1*3/5,FP_1*6/5,0,OFFSET hallPatrons3D> - CityProp3D <22*FP_1,20*FP_1,FP_1*3/5,FP_1*6/5,4,OFFSET hallPatrons3D> - CityProp3D <3*FP_1,27*FP_1+FP_HALF,FP_1*3/5,FP_1*4/5,8,OFFSET hallPatrons3D> - CityProp3D <10*FP_1,27*FP_1+FP_HALF,FP_1*3/5,FP_1*4/5,10,OFFSET hallPatrons3D> - CityProp3D <13*FP_1+FP_HALF,8*FP_1+FP_HALF,FP_1*3/5,FP_1*6/5,12,OFFSET hallPatrons3D> - CityProp3D <21*FP_1+FP_HALF,8*FP_1+FP_HALF,FP_1*3/5,FP_1*6/5,13,OFFSET hallPatrons3D> - CityProp3D <5*FP_1,15*FP_1,FP_1*3/5,FP_1*6/5,12,OFFSET hallPatrons3D> - CityProp3D <10*FP_1,25*FP_1,FP_1*3/5,FP_1*6/5,13,OFFSET hallPatrons3D> - CityProp3D <4*FP_1,27*FP_1,2*FP_1,2*FP_1,14,OFFSET hallPatrons3D> - CityProp3D <9*FP_1,27*FP_1,2*FP_1,2*FP_1,14,OFFSET hallPatrons3D> - CityProp3D <4*FP_1,24*FP_1+FP_1*4/5,FP_1/2,FP_1*3/5,15,OFFSET hallPatrons3D> - CityProp3D <8*FP_1,24*FP_1+FP_1*4/5,FP_1/2,FP_1*3/5,15,OFFSET hallPatrons3D> - CityProp3D <11*FP_1+FP_HALF,8*FP_1+FP_HALF,FP_1*3/5,FP_1*4/5,8,OFFSET hallPatrons3D> - CityProp3D <19*FP_1+FP_HALF,8*FP_1+FP_HALF,FP_1*3/5,FP_1*4/5,10,OFFSET hallPatrons3D> - CityProp3D <23*FP_1+FP_HALF,8*FP_1+FP_HALF,FP_1*3/5,FP_1*4/5,8,OFFSET hallPatrons3D> - CityProp3D <15*FP_1+FP_HALF,10*FP_1+FP_HALF,FP_1*3/5,FP_1*4/5,10,OFFSET hallPatrons3D> -HALL_LIGHT_COUNT equ 6 -hallLights3D CityProp3D <12*FP_1+FP_HALF,8*FP_1,FP_1*3/4,FP_1*13/20,0,OFFSET hallDecorPack3D,FP_1*37/20> - CityProp3D <16*FP_1+FP_HALF,10*FP_1,FP_1*3/4,FP_1*13/20,0,OFFSET hallDecorPack3D,FP_1*37/20> - CityProp3D <20*FP_1+FP_HALF,8*FP_1,FP_1*3/4,FP_1*13/20,0,OFFSET hallDecorPack3D,FP_1*37/20> - CityProp3D <24*FP_1+FP_HALF,8*FP_1,FP_1*3/4,FP_1*13/20,0,OFFSET hallDecorPack3D,FP_1*37/20> - CityProp3D <6*FP_1,23*FP_1,FP_1*3/4,FP_1*13/20,0,OFFSET hallDecorPack3D,FP_1*37/20> - CityProp3D <9*FP_1,27*FP_1,FP_1*3/4,FP_1*13/20,0,OFFSET hallDecorPack3D,FP_1*37/20> -bunkerDisplay3D CityProp3D <19*FP_1,16*FP_1+FP_HALF,FP_1*6/5,FP_1*6/5,3,OFFSET hallDecorPack3D> -bunkerDesk3D CityProp3D <15*FP_1,14*FP_1+FP_HALF,FP_1*3/2,FP_1,4,OFFSET hallDecorPack3D,FP_1/2> -hallLevel3D dd 0 -hallBartender3D AnimPack3D <> -hallProps3D AnimPack3D <> -hallDrink3D AnimPack3D <> -hallBartenderPath3D db "assets\animations\hall\bartender-v4.bin",0 -hallPropsPath3D db "assets\animations\hall\props.bin",0 -hallDrinkPath3D db "assets\animations\hall\drink-v4.bin",0 -hallLegacyPack3D AnimPack3D <314D4E41h,128,128,1,128*128*4,0> -hallSpriteTemp3D CityProp3D <> -; Tight sprite bounds: table height includes its legs; cabinets are not table-sized. -hallSpriteWidths3D dd 3 dup(FP_1*3/5),4 dup(FP_1*8/5),2 dup(FP_1),3 dup(FP_1*8/5),FP_1,FP_1*8/5,FP_1,FP_1,FP_1,5 dup(FP_1*8/5) -hallSpriteHeights3D dd 3 dup(FP_1*6/5),4 dup(FP_1*17/20),2 dup(FP_1*3/2),3 dup(FP_1*17/20),FP_1*9/5,FP_1*17/20,FP_1,FP_1*3/2,FP_1*3/2,5 dup(FP_1*17/20) -hallCardFurniture3D AnimPack3D <> -hallWheelFurniture3D AnimPack3D <> -hallBackFurniture3D AnimPack3D <> -hallSkillFurniture3D AnimPack3D <> -hallChairFurniture3D AnimPack3D <> -hallLampFurniture3D AnimPack3D <> -hallRopeFurniture3D AnimPack3D <> -hallSlotFurniture3D AnimPack3D <> -hallCardFurniturePath3D db "assets\animations\hall\card-table-v5.bin",0 -hallWheelFurniturePath3D db "assets\animations\hall\roulette-table-v5.bin",0 -hallBackFurniturePath3D db "assets\animations\hall\backroom-table-v5.bin",0 -hallSkillFurniturePath3D db "assets\animations\hall\skill-cabinet-v5.bin",0 -hallChairFurniturePath3D db "assets\animations\hall\lounge-chair-v5.bin",0 -hallLampFurniturePath3D db "assets\animations\hall\lamp-table-v5.bin",0 -hallRopeFurniturePath3D db "assets\animations\hall\velvet-rope-v5.bin",0 -hallSlotFurniturePath3D db "assets\animations\hall\slot-cabinets-v5.bin",0 -; Station order matches InitializeCasinoSprites3D; zero retains animated legacy art. -hallStationPacks3D dd 3 dup(0),OFFSET hallCardFurniture3D,OFFSET hallWheelFurniture3D - dd 2 dup(OFFSET hallCardFurniture3D),2 dup(OFFSET hallSlotFurniture3D) - dd 3 dup(OFFSET hallCardFurniture3D),OFFSET hallSkillFurniture3D,OFFSET hallCardFurniture3D - dd 3 dup(0),OFFSET hallBackFurniture3D,OFFSET hallCardFurniture3D - dd 2 dup(OFFSET hallBackFurniture3D),0 -HALL_DECOR_COUNT equ 12 -hallLoungeDecor3D CityProp3D <13*FP_1,19*FP_1,FP_1*3/4,FP_1,0,OFFSET hallChairFurniture3D> - CityProp3D <14*FP_1,19*FP_1,FP_1*3/5,FP_1*7/10,0,OFFSET hallLampFurniture3D> - CityProp3D <15*FP_1,19*FP_1,FP_1*3/4,FP_1,0,OFFSET hallChairFurniture3D> - CityProp3D <27*FP_1,18*FP_1,FP_1*3/4,FP_1,0,OFFSET hallChairFurniture3D> - CityProp3D <28*FP_1,18*FP_1,FP_1*3/5,FP_1*7/10,0,OFFSET hallLampFurniture3D> - CityProp3D <29*FP_1,18*FP_1,FP_1*3/4,FP_1,0,OFFSET hallChairFurniture3D> - CityProp3D <3*FP_1,18*FP_1,FP_1*3/4,FP_1,0,OFFSET hallChairFurniture3D> - CityProp3D <4*FP_1,18*FP_1,FP_1*3/5,FP_1*7/10,0,OFFSET hallLampFurniture3D> - CityProp3D <5*FP_1,18*FP_1,FP_1*3/4,FP_1,0,OFFSET hallChairFurniture3D> - CityProp3D <6*FP_1,6*FP_1,FP_1*9/5,FP_1*7/10,0,OFFSET hallRopeFurniture3D> - CityProp3D <26*FP_1,6*FP_1,FP_1*9/5,FP_1*7/10,0,OFFSET hallRopeFurniture3D> - CityProp3D <28*FP_1,22*FP_1,FP_1*9/5,FP_1*7/10,0,OFFSET hallRopeFurniture3D> -HALL_PROP_COUNT equ 19 -hallObjects3D CityProp3D <12*FP_1+FP_HALF,7*FP_1,FP_1*3/5,FP_1*6/5,0,OFFSET hallProps3D> - CityProp3D <16*FP_1+FP_HALF,9*FP_1,FP_1*3/5,FP_1*6/5,2,OFFSET hallProps3D> - CityProp3D <20*FP_1+FP_HALF,7*FP_1,FP_1*3/5,FP_1*6/5,1,OFFSET hallProps3D> - CityProp3D <24*FP_1+FP_HALF,7*FP_1,FP_1*3/5,FP_1*6/5,0,OFFSET hallProps3D> - CityProp3D <6*FP_1,22*FP_1+FP_HALF,FP_1,FP_1,0,OFFSET hallBartender3D,FP_1*9/20> - CityProp3D <27*FP_1,25*FP_1,FP_1*5/2,FP_1,4,OFFSET hallProps3D> - CityProp3D <28*FP_1+FP_HALF,10*FP_1+FP_HALF,FP_1*3/2,FP_1*9/5,5,OFFSET hallProps3D> - CityProp3D <3*FP_1,4*FP_1,FP_1*5/2,FP_1,6,OFFSET hallProps3D> - CityProp3D <27*FP_1,4*FP_1,FP_1*5/2,FP_1,6,OFFSET hallProps3D> - CityProp3D <3*FP_1,29*FP_1,FP_1*5/2,FP_1,6,OFFSET hallProps3D> - CityProp3D <10*FP_1,29*FP_1,FP_1*5/2,FP_1,6,OFFSET hallProps3D> - CityProp3D <11*FP_1+FP_HALF,11*FP_1+FP_HALF,FP_1/2,FP_1*5/2,7,OFFSET hallProps3D> - CityProp3D <24*FP_1+FP_HALF,11*FP_1+FP_HALF,FP_1/2,FP_1*5/2,7,OFFSET hallProps3D> - CityProp3D <11*FP_1+FP_HALF,19*FP_1+FP_HALF,FP_1/2,FP_1*5/2,7,OFFSET hallProps3D> - CityProp3D <24*FP_1+FP_HALF,19*FP_1+FP_HALF,FP_1/2,FP_1*5/2,7,OFFSET hallProps3D> - CityProp3D <16*FP_1,2*FP_1+FP_HALF,10*FP_1,FP_1*5/2,8,OFFSET hallProps3D> - CityProp3D <6*FP_1,13*FP_1,FP_1*3/5,FP_1*6/5,0,OFFSET hallProps3D> - CityProp3D <10*FP_1,14*FP_1,FP_1*3/5,FP_1*6/5,1,OFFSET hallProps3D> - CityProp3D <14*FP_1,14*FP_1,FP_1*3/5,FP_1*6/5,2,OFFSET hallProps3D> -bunkerMerchant3D CityProp3D <16*FP_1,13*FP_1,FP_1*3/2,FP_1*6/5,0,OFFSET merchantPack3D,FP_1/8> -bunkerDoor3D CityProp3D <16*FP_1,27*FP_1,FP_1*3/2,FP_1*7/5,5,OFFSET hallProps3D,FP_1> -cityGuardLeft3D CityProp3D <21*FP_1+FP_1*4/5,8*FP_1+FP_HALF,FP_1*17/20,FP_1*7/5,0,OFFSET guardPack3D> -cityGuardRight3D CityProp3D <23*FP_1+FP_1/5,8*FP_1+FP_HALF,FP_1*17/20,FP_1*7/5,0,OFFSET guardPack3D> -hallBarPrompt3D db 69,58,32,202,206,202,210,197,201,203,220,205,219,201,32,193,192,208,0 -hallBunkerPrompt3D db 69,58,32,207,206,196,194,192,203,32,47,32,204,192,195,192,199,200,205,0 -hallUpPrompt3D db 69,58,32,205,192,194,197,208,213,0 -hallPoolPrompt3D db 69,58,32,193,200,203,220,223,208,196,0 -barName3D db 193,192,208,32,209,210,192,208,206,195,206,32,195,206,208,206,196,192,0 -barDrinks3D db 49,32,213,192,201,193,206,203,32,36,49,48,48,0 -barDrinks23D db 50,32,202,206,202,210,197,201,203,220,32,36,50,48,48,0 -barDrinks33D db 51,32,194,206,196,192,32,36,48,0 -barPoor3D db 204,192,203,206,32,212,200,216,197,202,0 -barMixText3D db 209,204,197,216,200,194,192,197,204,0 -barDrinkText3D db 194,192,216,197,32,199,196,206,208,206,194,220,197,0 -barTime3D dd 0 -barPhase3D dd 0 -barSelection3D dd 0 -barPrice3D dd 100,200,0 -stairsTime3D dd 0 -stairsReturnX3D dd 0 -stairsReturnY3D dd 0 -stairsReturnAngle3D dd 0 -include src_graphics\world_dressing_data.inc -include src_graphics\terminal_data.inc -include src_graphics\hall_expansion_data.inc -include src_graphics\fortune_room_data.inc -include src_graphics\fortune_dialog_data.inc -include src_graphics\cabaret_data.inc -include src_graphics\rooftop_data.inc -include src_graphics\bowling_data.inc -include src_graphics\character_cast_data.inc -.code +MODE_BAR equ 14 +MODE_STAIRS equ 15 +INTERACT_BAR equ 21 +INTERACT_BASEMENT equ 22 +INTERACT_UPSTAIRS equ 23 +INTERACT_BILLIARDS equ 24 +INTERACT_SEMYON equ 57 +INTERACT_RAT_RACE equ 58 +INTERACT_HEIST equ 59 +RenderCeilingAndFloor PROTO +RenderSprites PROTO +InitHall3D PROTO +LoadHallAssets3D PROTO +FreeHallAssets3D PROTO +CheckHallInteractions3D PROTO +TriggerHallInteraction3D PROTO +RenderHall3D PROTO +HandleBar3D PROTO +RenderBar3D PROTO +HandleStairs3D PROTO +RenderStairs3D PROTO +RenderCityGuards3D PROTO +CanWalkHall3D PROTO :DWORD,:DWORD +RenderCityFacade3D PROTO +UpdateHall3D PROTO +UpdateBarBuffTimers3D PROTO +UpdatePatrons3D PROTO +RenderPatrons3D PROTO +ResolveWorldSurface3D PROTO :DWORD +include src_graphics\hall_layout.inc +.data +ALIGN 4 +tableInvDelta3D dd 241 dup(0) +tableStepRatio3D dd 241 dup(0) +hallSign3D AnimPack3D <> +hallSignPath3D db "assets\animations\hall\sign.bin",0 +hallCityDetail3D AnimPack3D <> +hallCityDetailPath3D db "assets\animations\hall\city-detail.bin",0 +hallRoomMaterials3D AnimPack3D <> +hallRoomMaterialsPath3D db "assets\animations\hall\room-materials.bin",0 +hallPatrons3D AnimPack3D <> +hallPatronsPath3D db "assets\animations\hall\patrons.bin",0 +hallStreetLife3D AnimPack3D <> +hallStreetLifePath3D db "assets\animations\hall\street-life-v4.bin",0 +hallRoomHD3D AnimPack3D <> +hallArchitecture3D AnimPack3D <> +hallArchitectureHD3D AnimPack3D <> +hallDecorPack3D AnimPack3D <> +hallRoomHDPath3D db "assets\animations\hall\room-materials-hd.bin",0 +hallArchitecturePath3D db "assets\animations\hall\architecture.bin",0 +hallArchitectureHDPath3D db "assets\animations\hall\architecture-hd.bin",0 +hallDecorPath3D db "assets\animations\hall\architecture-props.bin",0 +patronClock3D dd 0 +HALL_PATRON_COUNT equ 16 +hallGuests3D CityProp3D <18*FP_1,18*FP_1,FP_1*3/5,FP_1*6/5,0,OFFSET hallPatrons3D> + CityProp3D <22*FP_1,20*FP_1,FP_1*3/5,FP_1*6/5,4,OFFSET hallPatrons3D> + CityProp3D <3*FP_1,27*FP_1+FP_HALF,FP_1*3/5,FP_1*4/5,8,OFFSET hallPatrons3D> + CityProp3D <10*FP_1,27*FP_1+FP_HALF,FP_1*3/5,FP_1*4/5,10,OFFSET hallPatrons3D> + CityProp3D <13*FP_1+FP_HALF,8*FP_1+FP_HALF,FP_1*3/5,FP_1*6/5,12,OFFSET hallPatrons3D> + CityProp3D <21*FP_1+FP_HALF,8*FP_1+FP_HALF,FP_1*3/5,FP_1*6/5,13,OFFSET hallPatrons3D> + CityProp3D <5*FP_1,15*FP_1,FP_1*3/5,FP_1*6/5,12,OFFSET hallPatrons3D> + CityProp3D <10*FP_1,25*FP_1,FP_1*3/5,FP_1*6/5,13,OFFSET hallPatrons3D> + CityProp3D <4*FP_1,27*FP_1,2*FP_1,2*FP_1,14,OFFSET hallPatrons3D> + CityProp3D <9*FP_1,27*FP_1,2*FP_1,2*FP_1,14,OFFSET hallPatrons3D> + CityProp3D <4*FP_1,24*FP_1+FP_1*4/5,FP_1/2,FP_1*3/5,15,OFFSET hallPatrons3D> + CityProp3D <8*FP_1,24*FP_1+FP_1*4/5,FP_1/2,FP_1*3/5,15,OFFSET hallPatrons3D> + CityProp3D <11*FP_1+FP_HALF,8*FP_1+FP_HALF,FP_1*3/5,FP_1*4/5,8,OFFSET hallPatrons3D> + CityProp3D <19*FP_1+FP_HALF,8*FP_1+FP_HALF,FP_1*3/5,FP_1*4/5,10,OFFSET hallPatrons3D> + CityProp3D <23*FP_1+FP_HALF,8*FP_1+FP_HALF,FP_1*3/5,FP_1*4/5,8,OFFSET hallPatrons3D> + CityProp3D <15*FP_1+FP_HALF,10*FP_1+FP_HALF,FP_1*3/5,FP_1*4/5,10,OFFSET hallPatrons3D> +HALL_LIGHT_COUNT equ 6 +hallLights3D CityProp3D <12*FP_1+FP_HALF,8*FP_1,FP_1*3/4,FP_1*13/20,0,OFFSET hallDecorPack3D,FP_1*37/20> + CityProp3D <16*FP_1+FP_HALF,10*FP_1,FP_1*3/4,FP_1*13/20,0,OFFSET hallDecorPack3D,FP_1*37/20> + CityProp3D <20*FP_1+FP_HALF,8*FP_1,FP_1*3/4,FP_1*13/20,0,OFFSET hallDecorPack3D,FP_1*37/20> + CityProp3D <24*FP_1+FP_HALF,8*FP_1,FP_1*3/4,FP_1*13/20,0,OFFSET hallDecorPack3D,FP_1*37/20> + CityProp3D <6*FP_1,23*FP_1,FP_1*3/4,FP_1*13/20,0,OFFSET hallDecorPack3D,FP_1*37/20> + CityProp3D <9*FP_1,27*FP_1,FP_1*3/4,FP_1*13/20,0,OFFSET hallDecorPack3D,FP_1*37/20> +bunkerDisplay3D CityProp3D <19*FP_1,16*FP_1+FP_HALF,FP_1*6/5,FP_1*6/5,3,OFFSET hallDecorPack3D> +bunkerDesk3D CityProp3D <15*FP_1,14*FP_1+FP_HALF,FP_1*3/2,FP_1,4,OFFSET hallDecorPack3D,FP_1/2> +hallLevel3D dd 0 +hallBartender3D AnimPack3D <> +hallProps3D AnimPack3D <> +hallDrink3D AnimPack3D <> +hallBartenderPath3D db "assets\animations\hall\bartender-v4.bin",0 +hallPropsPath3D db "assets\animations\hall\props.bin",0 +hallDrinkPath3D db "assets\animations\hall\drink-v5.bin",0 +hallLegacyPack3D AnimPack3D <314D4E41h,128,128,1,128*128*4,0> +hallSpriteTemp3D CityProp3D <> +; Tight sprite bounds: table height includes its legs; cabinets are not table-sized. +hallSpriteWidths3D dd 3 dup(FP_1*3/5),4 dup(FP_1*8/5),2 dup(FP_1),3 dup(FP_1*8/5),FP_1,FP_1*8/5,FP_1,FP_1,FP_1,5 dup(FP_1*8/5) +hallSpriteHeights3D dd 3 dup(FP_1*6/5),4 dup(FP_1*17/20),2 dup(FP_1*3/2),3 dup(FP_1*17/20),FP_1*9/5,FP_1*17/20,FP_1,FP_1*3/2,FP_1*3/2,5 dup(FP_1*17/20) +hallCardFurniture3D AnimPack3D <> +hallWheelFurniture3D AnimPack3D <> +hallBackFurniture3D AnimPack3D <> +hallSkillFurniture3D AnimPack3D <> +hallChairFurniture3D AnimPack3D <> +hallLampFurniture3D AnimPack3D <> +hallRopeFurniture3D AnimPack3D <> +hallSlotFurniture3D AnimPack3D <> +hallCardFurniturePath3D db "assets\animations\hall\card-table-v5.bin",0 +hallWheelFurniturePath3D db "assets\animations\hall\roulette-table-v5.bin",0 +hallBackFurniturePath3D db "assets\animations\hall\backroom-table-v5.bin",0 +hallSkillFurniturePath3D db "assets\animations\hall\skill-cabinet-v5.bin",0 +hallChairFurniturePath3D db "assets\animations\hall\lounge-chair-v5.bin",0 +hallLampFurniturePath3D db "assets\animations\hall\lamp-table-v5.bin",0 +hallRopeFurniturePath3D db "assets\animations\hall\velvet-rope-v5.bin",0 +hallSlotFurniturePath3D db "assets\animations\hall\slot-cabinets-v5.bin",0 +; Station order matches InitializeCasinoSprites3D; zero retains animated legacy art. +hallStationPacks3D dd 3 dup(0),OFFSET hallCardFurniture3D,OFFSET hallWheelFurniture3D + dd 2 dup(OFFSET hallCardFurniture3D),2 dup(OFFSET hallSlotFurniture3D) + dd 3 dup(OFFSET hallCardFurniture3D),OFFSET hallSkillFurniture3D,OFFSET hallCardFurniture3D + dd 3 dup(0),OFFSET hallBackFurniture3D,OFFSET hallCardFurniture3D + dd 2 dup(OFFSET hallBackFurniture3D),0 +HALL_DECOR_COUNT equ 12 +hallLoungeDecor3D CityProp3D <13*FP_1,19*FP_1,FP_1*3/4,FP_1,0,OFFSET hallChairFurniture3D> + CityProp3D <14*FP_1,19*FP_1,FP_1*3/5,FP_1*7/10,0,OFFSET hallLampFurniture3D> + CityProp3D <15*FP_1,19*FP_1,FP_1*3/4,FP_1,0,OFFSET hallChairFurniture3D> + CityProp3D <27*FP_1,18*FP_1,FP_1*3/4,FP_1,0,OFFSET hallChairFurniture3D> + CityProp3D <28*FP_1,18*FP_1,FP_1*3/5,FP_1*7/10,0,OFFSET hallLampFurniture3D> + CityProp3D <29*FP_1,18*FP_1,FP_1*3/4,FP_1,0,OFFSET hallChairFurniture3D> + CityProp3D <3*FP_1,18*FP_1,FP_1*3/4,FP_1,0,OFFSET hallChairFurniture3D> + CityProp3D <4*FP_1,18*FP_1,FP_1*3/5,FP_1*7/10,0,OFFSET hallLampFurniture3D> + CityProp3D <5*FP_1,18*FP_1,FP_1*3/4,FP_1,0,OFFSET hallChairFurniture3D> + CityProp3D <6*FP_1,6*FP_1,FP_1*9/5,FP_1*7/10,0,OFFSET hallRopeFurniture3D> + CityProp3D <26*FP_1,6*FP_1,FP_1*9/5,FP_1*7/10,0,OFFSET hallRopeFurniture3D> + CityProp3D <28*FP_1,22*FP_1,FP_1*9/5,FP_1*7/10,0,OFFSET hallRopeFurniture3D> +HALL_PROP_COUNT equ 19 +hallObjects3D CityProp3D <12*FP_1+FP_HALF,7*FP_1,FP_1*3/5,FP_1*6/5,0,OFFSET hallProps3D> + CityProp3D <16*FP_1+FP_HALF,9*FP_1,FP_1*3/5,FP_1*6/5,2,OFFSET hallProps3D> + CityProp3D <20*FP_1+FP_HALF,7*FP_1,FP_1*3/5,FP_1*6/5,1,OFFSET hallProps3D> + CityProp3D <24*FP_1+FP_HALF,7*FP_1,FP_1*3/5,FP_1*6/5,0,OFFSET hallProps3D> + CityProp3D <6*FP_1,22*FP_1+FP_HALF,FP_1,FP_1,0,OFFSET hallBartender3D,FP_1*9/20> + CityProp3D <27*FP_1,25*FP_1,FP_1*5/2,FP_1,4,OFFSET hallProps3D> + CityProp3D <28*FP_1+FP_HALF,10*FP_1+FP_HALF,FP_1*3/2,FP_1*9/5,5,OFFSET hallProps3D> + CityProp3D <3*FP_1,4*FP_1,FP_1*5/2,FP_1,6,OFFSET hallProps3D> + CityProp3D <27*FP_1,4*FP_1,FP_1*5/2,FP_1,6,OFFSET hallProps3D> + CityProp3D <3*FP_1,29*FP_1,FP_1*5/2,FP_1,6,OFFSET hallProps3D> + CityProp3D <10*FP_1,29*FP_1,FP_1*5/2,FP_1,6,OFFSET hallProps3D> + CityProp3D <11*FP_1+FP_HALF,11*FP_1+FP_HALF,FP_1/2,FP_1*5/2,7,OFFSET hallProps3D> + CityProp3D <24*FP_1+FP_HALF,11*FP_1+FP_HALF,FP_1/2,FP_1*5/2,7,OFFSET hallProps3D> + CityProp3D <11*FP_1+FP_HALF,19*FP_1+FP_HALF,FP_1/2,FP_1*5/2,7,OFFSET hallProps3D> + CityProp3D <24*FP_1+FP_HALF,19*FP_1+FP_HALF,FP_1/2,FP_1*5/2,7,OFFSET hallProps3D> + CityProp3D <16*FP_1,2*FP_1+FP_HALF,10*FP_1,FP_1*5/2,8,OFFSET hallProps3D> + CityProp3D <6*FP_1,13*FP_1,FP_1*3/5,FP_1*6/5,0,OFFSET hallProps3D> + CityProp3D <10*FP_1,14*FP_1,FP_1*3/5,FP_1*6/5,1,OFFSET hallProps3D> + CityProp3D <14*FP_1,14*FP_1,FP_1*3/5,FP_1*6/5,2,OFFSET hallProps3D> +bunkerMerchant3D CityProp3D <16*FP_1,13*FP_1,FP_1*3/2,FP_1*6/5,0,OFFSET merchantPack3D,FP_1/8> +bunkerRatRace3D CityProp3D +semyonProp3D CityProp3D +heistDeskProp3D CityProp3D <11*FP_1,FP_1*244/10,FP_1*8/5,FP_1,5,OFFSET uwWorldPack> +bunkerDoor3D CityProp3D <16*FP_1,27*FP_1,FP_1*3/2,FP_1*7/5,5,OFFSET hallProps3D,FP_1> +cityGuardLeft3D CityProp3D <21*FP_1+FP_1*4/5,8*FP_1+FP_HALF,FP_1*17/20,FP_1*7/5,0,OFFSET guardPack3D> +cityGuardRight3D CityProp3D <23*FP_1+FP_1/5,8*FP_1+FP_HALF,FP_1*17/20,FP_1*7/5,0,OFFSET guardPack3D> +hallBarPrompt3D db 69,58,32,202,206,202,210,197,201,203,220,205,219,201,32,193,192,208,0 +hallBunkerPrompt3D db 69,58,32,207,206,196,194,192,203,32,45,32,209,197,204,168,205,32,47,32,193,197,195,192,32,47,32,206,195,208,192,193,203,197,205,200,197,0 +hallUpPrompt3D db 69,58,32,205,192,194,197,208,213,0 +hallPoolPrompt3D db 69,58,32,193,200,203,220,223,208,196,0 +szPromptSemyon db 69,58,32,208,238,241,242,238,226,249,232,234,32,209,229,236,229,237,0 +szPromptRatRace db 69,58,32,202,240,251,241,232,237,251,229,32,225,229,227,224,0 +szPromptHeist db 69,58,32,207,235,224,237,32,238,227,240,224,225,235,229,237,232,255,0 +szBarHeistRecruit db 55,32,205,192,205,223,210,220,32,193,192,208,204,197,205,192,32,47,32,36,49,48,48,48,0 +szBarHeistReady db 193,192,208,204,197,205,32,211,198,197,32,194,32,202,206,204,192,205,196,197,0 +barName3D db 193,192,208,32,209,210,192,208,206,195,206,32,195,206,208,206,196,192,0 +barDrinks3D db 49,32,194,200,209,202,200,32,47,32,209,207,206,202,206,201,209,210,194,200,197,32,36,49,48,48,0 +barDrinks23D db 50,32,202,206,202,210,197,201,203,220,32,47,32,192,205,192,203,200,199,32,36,50,48,48,0 +barDrinks33D db 51,32,202,200,193,197,208,45,207,192,205,215,32,47,32,209,202,206,208,206,209,210,220,32,36,49,53,48,0 +barDrinks43D db 52,32,213,192,204,197,203,197,206,205,32,47,32,209,193,208,206,209,32,206,213,208,192,205,219,32,36,51,48,48,0 +barDrinks53D db 53,32,202,203,197,194,197,208,32,47,32,49,53,32,209,207,200,205,206,194,32,36,53,48,48,0 +barDrinks63D db 54,32,194,206,196,192,32,47,32,210,208,197,199,194,206,209,210,220,32,36,48,0 +barPoor3D db 204,192,203,206,32,212,200,216,197,202,0 +barMixText3D db 209,204,197,216,200,194,192,197,204,0 +barDrinkText3D db 194,192,216,197,32,199,196,206,208,206,194,220,197,0 +barTime3D dd 0 +barPhase3D dd 0 +barSelection3D dd 0 +barPrice3D dd 100,200,150,300,500,0 +barBuffCalmTimer dd 0 +barBuffCalcTimer dd 0 +barBuffSpeedTimer dd 0 +barBuffLuckSpins dd 0 +barDrunkTimer dd 0 +stairsTime3D dd 0 +stairsReturnX3D dd 0 +stairsReturnY3D dd 0 +stairsReturnAngle3D dd 0 +include src_graphics\world_dressing_data.inc +include src_graphics\terminal_data.inc +include src_graphics\hall_expansion_data.inc +include src_graphics\fortune_room_data.inc +include src_graphics\fortune_dialog_data.inc +include src_graphics\cabaret_data.inc +include src_graphics\rooftop_data.inc +include src_graphics\bowling_data.inc +include src_graphics\character_cast_data.inc +.code diff --git a/src_graphics/hall_layout.inc b/src_graphics/hall_layout.inc index 68f721b..cb207a1 100644 --- a/src_graphics/hall_layout.inc +++ b/src_graphics/hall_layout.inc @@ -48,16 +48,16 @@ bunkerMap3D db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92 db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 - db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 - db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 - db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 - db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 - db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 - db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 - db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 - db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 - db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92,92,92 - db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92,92,92 + db 92,92,92,92,92,0,0,0,0,0,0,0,0,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 + db 92,92,92,92,92,0,0,0,0,0,0,0,0,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 + db 92,92,92,92,92,0,0,0,0,0,0,0,0,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 + db 92,92,92,92,92,0,0,0,0,0,0,0,0,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 + db 92,92,92,92,92,0,0,0,0,0,0,0,0,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 + db 92,92,92,92,92,0,0,0,0,0,0,0,0,92,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 + db 92,92,92,92,92,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 + db 92,92,92,92,92,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92 + db 92,92,92,92,92,0,0,0,0,0,0,0,0,92,92,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92,92,92 + db 92,92,92,92,92,0,0,0,0,0,0,0,0,92,92,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92,92,92 db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92,92,92 db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92,92,92 db 92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,0,0,0,92,92,92,92,92,92,92,92,92,92,92,92,92,92 diff --git a/src_graphics/hall_scene.inc b/src_graphics/hall_scene.inc index 66f7a7b..e3228db 100644 --- a/src_graphics/hall_scene.inc +++ b/src_graphics/hall_scene.inc @@ -1,42 +1,46 @@ -; Room planes use independent ceiling/floor distances; the eye is not the room midpoint. -RenderCeilingAndFloor PROC uses ebx esi edi - local row:DWORD,distance:DWORD,sx:DWORD,sy:DWORD,wx:DWORD,wy:DWORD - local material:DWORD,shade:DWORD +; Room planes use independent ceiling/floor distances; the eye is not the room midpoint. +RenderCeilingAndFloor PROC uses ebx esi edi + local row:DWORD,distance:DWORD,sx:DWORD,sy:DWORD,wx:DWORD,wy:DWORD + local material:DWORD,shade:DWORD cmp hallLevel3D,HALL_ROOF jne @F call DrawRoofSky3D @@: - mov row, 0 -hall_plane_row: - mov eax, row - cmp eax, viewHorizon3D - jge hall_plane_floor + mov row, 0 +hall_plane_row: + mov eax, row + cmp eax, viewHorizon3D + jge hall_plane_floor cmp hallLevel3D,HALL_ROOF je hall_plane_next_row - cmp outdoorRender3D, 0 - jne hall_plane_next_row - mov ecx, viewHorizon3D - sub ecx, eax - mov eax, viewCeiling3D - sub eax, viewEye3D - mov material, 101 - cmp engineMode,MODE_HELL_FPS - jne @F - mov material,HF_CEILING -@@: - cmp brActive3D,0 - je @F - cmp hallLevel3D,HALL_BACKROOMS - jne @F - mov material,BR_CEILING -@@: + cmp outdoorRender3D, 0 + jne hall_plane_next_row + mov ecx, viewHorizon3D + sub ecx, eax + mov eax, viewCeiling3D + sub eax, viewEye3D + mov material, 101 + cmp hqActive,0 + je @F + mov material,80 +@@: + cmp engineMode,MODE_HELL_FPS + jne @F + mov material,HF_CEILING +@@: + cmp brActive3D,0 + je @F + cmp hallLevel3D,HALL_BACKROOMS + jne @F + mov material,BR_CEILING +@@: cmp hallLevel3D,2 jne @F mov material,125 @@: cmp hallLevel3D, 1 jne @F - mov material, 93 + mov material, 93 @@: cmp hallLevel3D,3 je hall_plane_fortune_ceiling @@ -46,72 +50,72 @@ hall_plane_row: jne hall_plane_distance hall_plane_fortune_ceiling: mov material,133 - jmp hall_plane_distance -hall_plane_floor: - sub eax, viewHorizon3D - inc eax - mov ecx, eax - mov eax, viewEye3D - mov ebx, floorTexture3D - mov material, ebx -hall_plane_distance: - cmp ecx, 240 - jbe @F - mov ecx, 240 -@@: - cmp ecx, 1 - jae @F - mov ecx, 1 -@@: - push eax - mov edx, [tableInvDelta3D + ecx*4] - imul edx - shrd eax, edx, 16 - mov distance, eax - shr eax, 14 - neg eax - add eax, 256 - cmp eax, 55 - jge @F - mov eax, 55 -@@: - mov shade, eax - cmp hallLevel3D, 0 - je @F - mov eax, shade - imul eax, 7 - shr eax, 3 - mov shade, eax -@@: - pop eax - mov edx, [tableStepRatio3D + ecx*4] - imul edx - shrd eax, edx, 16 - mov ebx, eax - mov eax, playerPlaneX - imul ebx - shrd eax, edx, 16 - mov sx, eax - mov eax, playerPlaneY - imul ebx - shrd eax, edx, 16 - mov sy, eax - mov eax, playerDirX - sub eax, playerPlaneX - imul distance - shrd eax, edx, 16 - add eax, playerX - mov wx, eax - mov eax, playerDirY - sub eax, playerPlaneY - imul distance - shrd eax, edx, 16 - add eax, playerY - mov wy, eax - mov eax, row - imul eax, SCREEN_W*4 - lea edi, screenBuffer[eax] - mov esi, SCREEN_W + jmp hall_plane_distance +hall_plane_floor: + sub eax, viewHorizon3D + inc eax + mov ecx, eax + mov eax, viewEye3D + mov ebx, floorTexture3D + mov material, ebx +hall_plane_distance: + cmp ecx, 240 + jbe @F + mov ecx, 240 +@@: + cmp ecx, 1 + jae @F + mov ecx, 1 +@@: + push eax + mov edx, [tableInvDelta3D + ecx*4] + imul edx + shrd eax, edx, 16 + mov distance, eax + shr eax, 14 + neg eax + add eax, 256 + cmp eax, 55 + jge @F + mov eax, 55 +@@: + mov shade, eax + cmp hallLevel3D, 0 + je @F + mov eax, shade + imul eax, 7 + shr eax, 3 + mov shade, eax +@@: + pop eax + mov edx, [tableStepRatio3D + ecx*4] + imul edx + shrd eax, edx, 16 + mov ebx, eax + mov eax, playerPlaneX + imul ebx + shrd eax, edx, 16 + mov sx, eax + mov eax, playerPlaneY + imul ebx + shrd eax, edx, 16 + mov sy, eax + mov eax, playerDirX + sub eax, playerPlaneX + imul distance + shrd eax, edx, 16 + add eax, playerX + mov wx, eax + mov eax, playerDirY + sub eax, playerPlaneY + imul distance + shrd eax, edx, 16 + add eax, playerY + mov wy, eax + mov eax, row + imul eax, SCREEN_W*4 + lea edi, screenBuffer[eax] + mov esi, SCREEN_W hall_plane_pixel: cmp hallLevel3D,HALL_ROOF jne roof_floor_inside @@ -124,58 +128,68 @@ hall_plane_pixel: cmp wy,FP_1*211/10 jg roof_floor_outside roof_floor_inside: - mov ebx, material - cmp outdoorRender3D, 0 - je hall_plane_sample - mov eax, wy - cmp eax, 13*FP_1 - jb hall_plane_crossroad - cmp eax, 16*FP_1 - jb hall_plane_sample -hall_plane_crossroad: - mov eax, wx - cmp eax, 29*FP_1 - jl hall_plane_sidewalk - cmp eax, 32*FP_1 - jl hall_plane_sample -hall_plane_sidewalk: - mov ebx, 72 -hall_plane_sample: - cmp brActive3D,0 - je br_plane_sample_done - cmp hallLevel3D,HALL_BACKROOMS - jne br_plane_sample_done - mov eax,row - cmp eax,viewHorizon3D - jae br_plane_sample_done - mov ebx,BR_CEILING - mov eax,wx - shr eax,16 - and eax,3 - cmp eax,1 - jne br_plane_sample_done - mov eax,wy - shr eax,16 - and eax,3 - cmp eax,1 - jne br_plane_sample_done - mov ebx,BR_LAMP -br_plane_sample_done: - cmp outdoorRender3D, 0 - jne hall_plane_low_sample - mov eax, row - cmp eax, viewHorizon3D - jl hall_plane_choose_hd - cmp hallLevel3D, 0 - jne hall_plane_choose_hd - cmp wy, 23*FP_1 - jl hall_plane_choose_hd - cmp wx, 12*FP_1 - jl hall_plane_wood - cmp wx, 23*FP_1 - jl hall_plane_choose_hd -hall_plane_wood: - mov ebx, 85 + mov ebx, material + cmp outdoorRender3D, 0 + je hall_plane_sample + mov eax, wy + cmp eax, 13*FP_1 + jb hall_plane_crossroad + cmp eax, 16*FP_1 + jb hall_plane_sample +hall_plane_crossroad: + mov eax, wx + cmp eax, 29*FP_1 + jl hall_plane_sidewalk + cmp eax, 32*FP_1 + jl hall_plane_sample +hall_plane_sidewalk: + mov ebx, 72 +hall_plane_sample: + cmp hallLevel3D,1 + jne uw_room_plane_done + cmp wx,14*FP_1 + jge uw_room_plane_done + mov ebx,101 + mov eax,row + cmp eax,viewHorizon3D + jl uw_room_plane_done + mov ebx,85 +uw_room_plane_done: + cmp brActive3D,0 + je br_plane_sample_done + cmp hallLevel3D,HALL_BACKROOMS + jne br_plane_sample_done + mov eax,row + cmp eax,viewHorizon3D + jae br_plane_sample_done + mov ebx,BR_CEILING + mov eax,wx + shr eax,16 + and eax,3 + cmp eax,1 + jne br_plane_sample_done + mov eax,wy + shr eax,16 + and eax,3 + cmp eax,1 + jne br_plane_sample_done + mov ebx,BR_LAMP +br_plane_sample_done: + cmp outdoorRender3D, 0 + jne hall_plane_low_sample + mov eax, row + cmp eax, viewHorizon3D + jl hall_plane_choose_hd + cmp hallLevel3D, 0 + jne hall_plane_choose_hd + cmp wy, 23*FP_1 + jl hall_plane_choose_hd + cmp wx, 12*FP_1 + jl hall_plane_wood + cmp wx, 23*FP_1 + jl hall_plane_choose_hd +hall_plane_wood: + mov ebx, 85 hall_plane_choose_hd: cmp ebx,ROOF_DECK jne hall_plane_not_roof @@ -213,95 +227,95 @@ hall_plane_upper_fallback: mov ebx,85 mov material,ebx hall_plane_existing_hd: - cmp distance, 6*FP_1 - ja hall_plane_low_sample - mov ecx, hallRoomHD3D.pixels - cmp ebx, 80 - jb hall_plane_low_sample - cmp ebx, 103 - ja hall_plane_low_sample - cmp ebx, 92 - jb hall_plane_old_hd - mov ecx, hallArchitectureHD3D.pixels - sub ebx, 12 -hall_plane_old_hd: - test ecx, ecx - jz hall_plane_hd_fallback - sub ebx, 80 - shl ebx, 18 - add ecx, ebx + cmp distance, 6*FP_1 + ja hall_plane_low_sample + mov ecx, hallRoomHD3D.pixels + cmp ebx, 80 + jb hall_plane_low_sample + cmp ebx, 103 + ja hall_plane_low_sample + cmp ebx, 92 + jb hall_plane_old_hd + mov ecx, hallArchitectureHD3D.pixels + sub ebx, 12 +hall_plane_old_hd: + test ecx, ecx + jz hall_plane_hd_fallback + sub ebx, 80 + shl ebx, 18 + add ecx, ebx hall_plane_hd_coordinates: - mov eax, wy - shr eax, 8 - and eax, 255 - shl eax, 8 - mov edx, wx - shr edx, 8 - and edx, 255 - add eax, edx - mov eax, [ecx+eax*4] - jmp hall_plane_shade -hall_plane_hd_fallback: - mov ebx, material -hall_plane_low_sample: - shl ebx, 16 - mov eax, wy - shr eax, 9 - and eax, 127 - shl eax, 7 - mov edx, wx - shr edx, 9 - and edx, 127 - add eax, edx - lea ebx, texturesBuffer[ebx] - mov eax, [ebx+eax*4] -hall_plane_shade: - cmp outdoorRender3D, 0 - je hall_plane_ambient - invoke ShadeCityGround3D, eax, wx, wy, shade - jmp hall_plane_store -hall_plane_ambient: - mov ebx, eax - and eax, 0000FF00h - imul eax, shade - shr eax, 8 - and eax, 0000FF00h - mov ecx, ebx - and ecx, 0FFh - imul ecx, shade - shr ecx, 8 - or eax, ecx - shr ebx, 16 - and ebx, 0FFh - imul ebx, shade - shr ebx, 8 - shl ebx, 16 - or eax, ebx -hall_plane_store: - stosd - mov eax, sx - add wx, eax - mov eax, sy - add wy, eax - dec esi - jnz hall_plane_pixel -hall_plane_next_row: - inc row - cmp row, SCREEN_H - jb hall_plane_row - ret + mov eax, wy + shr eax, 8 + and eax, 255 + shl eax, 8 + mov edx, wx + shr edx, 8 + and edx, 255 + add eax, edx + mov eax, [ecx+eax*4] + jmp hall_plane_shade +hall_plane_hd_fallback: + mov ebx, material +hall_plane_low_sample: + shl ebx, 16 + mov eax, wy + shr eax, 9 + and eax, 127 + shl eax, 7 + mov edx, wx + shr edx, 9 + and edx, 127 + add eax, edx + lea ebx, texturesBuffer[ebx] + mov eax, [ebx+eax*4] +hall_plane_shade: + cmp outdoorRender3D, 0 + je hall_plane_ambient + invoke ShadeCityGround3D, eax, wx, wy, shade + jmp hall_plane_store +hall_plane_ambient: + mov ebx, eax + and eax, 0000FF00h + imul eax, shade + shr eax, 8 + and eax, 0000FF00h + mov ecx, ebx + and ecx, 0FFh + imul ecx, shade + shr ecx, 8 + or eax, ecx + shr ebx, 16 + and ebx, 0FFh + imul ebx, shade + shr ebx, 8 + shl ebx, 16 + or eax, ebx +hall_plane_store: + stosd + mov eax, sx + add wx, eax + mov eax, sy + add wy, eax + dec esi + jnz hall_plane_pixel +hall_plane_next_row: + inc row + cmp row, SCREEN_H + jb hall_plane_row + ret roof_floor_outside: mov eax,[edi] jmp hall_plane_store -RenderCeilingAndFloor ENDP - +RenderCeilingAndFloor ENDP + RenderSprites PROC uses ebx esi edi cmp engineMode,MODE_STAIRS je hall_sprites_done - cmp hallLevel3D, 0 - jne hall_sprites_done - xor esi, esi -hall_sprite_loop: + cmp hallLevel3D, 0 + jne hall_sprites_done + xor esi, esi +hall_sprite_loop: cmp esi,3 jb hall_sprite_next cmp esi,17 @@ -310,124 +324,124 @@ hall_sprite_loop: je hall_sprite_next cmp esi,21 je hall_sprite_next - cmp esi, 14 + cmp esi, 14 je hall_sprite_next cmp esi, 15 je hall_sprite_next cmp esi, 16 je hall_sprite_next - imul ebx, esi, SIZEOF SpriteObject - mov eax, casinoSprites[ebx].posX - mov hallSpriteTemp3D.posX, eax - mov eax, casinoSprites[ebx].posY - mov hallSpriteTemp3D.posY, eax - mov eax, hallSpriteWidths3D[esi*4] - mov hallSpriteTemp3D.worldW, eax - mov eax, hallSpriteHeights3D[esi*4] - mov hallSpriteTemp3D.worldH, eax - mov hallSpriteTemp3D.groundZ, 0 - cmp esi, 3 - jae @F - mov hallSpriteTemp3D.groundZ, FP_1/8 -@@: - mov ecx, casinoSprites[ebx].animSpeed - imul ecx, 40 - test ecx, ecx - jnz @F - mov ecx, 40 -@@: - mov eax, animationClock3D - cmp esi,3 - jae @F - mov edx,casinoSprites[ebx].curFrame - imul edx,ecx - add eax,edx -@@: - xor edx, edx - div ecx - mov ecx, casinoSprites[ebx].frameCount - test ecx, ecx - jnz @F - mov ecx, 1 -@@: - xor edx, edx - div ecx - add edx, casinoSprites[ebx].baseTexId - shl edx, 16 - add edx, OFFSET texturesBuffer - mov hallLegacyPack3D.pixels, edx - mov hallSpriteTemp3D.frame, 0 - mov hallSpriteTemp3D.asset, OFFSET hallLegacyPack3D - mov eax, hallStationPacks3D[esi*4] - test eax, eax - jz hall_sprite_draw - ; Missing dedicated art hides the station, never shows a contaminated atlas cell. - cmp [eax].AnimPack3D.pixels, 0 - je hall_sprite_next - mov hallSpriteTemp3D.asset, eax - cmp eax, OFFSET hallSlotFurniture3D - jne hall_sprite_draw - mov eax, animationClock3D - xor edx, edx - mov ecx, 320 - div ecx - add eax, esi - xor edx, edx - mov ecx, 3 - div ecx - mov hallSpriteTemp3D.frame, edx -hall_sprite_draw: - invoke DrawCityObject3D, OFFSET hallSpriteTemp3D, 0 -hall_sprite_next: - inc esi - cmp esi, NUM_SPRITES - jb hall_sprite_loop -hall_sprites_done: - ret -RenderSprites ENDP - + imul ebx, esi, SIZEOF SpriteObject + mov eax, casinoSprites[ebx].posX + mov hallSpriteTemp3D.posX, eax + mov eax, casinoSprites[ebx].posY + mov hallSpriteTemp3D.posY, eax + mov eax, hallSpriteWidths3D[esi*4] + mov hallSpriteTemp3D.worldW, eax + mov eax, hallSpriteHeights3D[esi*4] + mov hallSpriteTemp3D.worldH, eax + mov hallSpriteTemp3D.groundZ, 0 + cmp esi, 3 + jae @F + mov hallSpriteTemp3D.groundZ, FP_1/8 +@@: + mov ecx, casinoSprites[ebx].animSpeed + imul ecx, 40 + test ecx, ecx + jnz @F + mov ecx, 40 +@@: + mov eax, animationClock3D + cmp esi,3 + jae @F + mov edx,casinoSprites[ebx].curFrame + imul edx,ecx + add eax,edx +@@: + xor edx, edx + div ecx + mov ecx, casinoSprites[ebx].frameCount + test ecx, ecx + jnz @F + mov ecx, 1 +@@: + xor edx, edx + div ecx + add edx, casinoSprites[ebx].baseTexId + shl edx, 16 + add edx, OFFSET texturesBuffer + mov hallLegacyPack3D.pixels, edx + mov hallSpriteTemp3D.frame, 0 + mov hallSpriteTemp3D.asset, OFFSET hallLegacyPack3D + mov eax, hallStationPacks3D[esi*4] + test eax, eax + jz hall_sprite_draw + ; Missing dedicated art hides the station, never shows a contaminated atlas cell. + cmp [eax].AnimPack3D.pixels, 0 + je hall_sprite_next + mov hallSpriteTemp3D.asset, eax + cmp eax, OFFSET hallSlotFurniture3D + jne hall_sprite_draw + mov eax, animationClock3D + xor edx, edx + mov ecx, 320 + div ecx + add eax, esi + xor edx, edx + mov ecx, 3 + div ecx + mov hallSpriteTemp3D.frame, edx +hall_sprite_draw: + invoke DrawCityObject3D, OFFSET hallSpriteTemp3D, 0 +hall_sprite_next: + inc esi + cmp esi, NUM_SPRITES + jb hall_sprite_loop +hall_sprites_done: + ret +RenderSprites ENDP + InitHall3D PROC uses esi edi call InitBowling3D call InitRoof3D - lea esi, hallLayout3D - lea edi, casinoMap - mov ecx, 256 - rep movsd - mov hallLevel3D, 0 + lea esi, hallLayout3D + lea edi, casinoMap + mov ecx, 256 + rep movsd + mov hallLevel3D, 0 mov fortunePassageTarget3D,0 mov fortunePassageTime3D,0 mov fortunePassageClock3D,-1 - mov worldMap3D, OFFSET casinoMap + mov worldMap3D, OFFSET casinoMap mov viewEye3D, HALL_STANDING_EYE - mov viewCeiling3D, FP_1*5/2 - mov floorTexture3D, 100 - mov casinoSprites[14*SIZEOF SpriteObject].interactId, 0 - mov patronClock3D, 0 - ; Precalculate floor & ceiling distance / step LUTs (no division at runtime) - mov ecx, 1 -init_plane_lut: - cmp ecx, 241 - jge init_plane_done - mov eax, SCREEN_H * FP_1 - xor edx, edx - div ecx - mov [tableInvDelta3D + ecx*4], eax - mov eax, 98304 - xor edx, edx - div ecx - mov [tableStepRatio3D + ecx*4], eax - inc ecx - jmp init_plane_lut -init_plane_done: + mov viewCeiling3D, FP_1*5/2 + mov floorTexture3D, 100 + mov casinoSprites[14*SIZEOF SpriteObject].interactId, 0 + mov patronClock3D, 0 + ; Precalculate floor & ceiling distance / step LUTs (no division at runtime) + mov ecx, 1 +init_plane_lut: + cmp ecx, 241 + jge init_plane_done + mov eax, SCREEN_H * FP_1 + xor edx, edx + div ecx + mov [tableInvDelta3D + ecx*4], eax + mov eax, 98304 + xor edx, edx + div ecx + mov [tableStepRatio3D + ecx*4], eax + inc ecx + jmp init_plane_lut +init_plane_done: call InitCasinoNpcMind call PositionTerminalStations3D mov scrStation3D.posX,29*FP_1 mov scrStation3D.posY,FP_1*15/2 - call InitNpcLife3D + call InitNpcLife3D call BuildHallLighting3D - ret -InitHall3D ENDP - + ret +InitHall3D ENDP + LoadHallAssets3D PROC call LoadRoofAssets3D call InitUpperSurfaces3D @@ -455,75 +469,81 @@ LoadHallAssets3D PROC invoke ValidateCityPack3D, OFFSET basementDoorArt3D,256,512,18 call LoadWorldDressing3D call LoadScratchArt3D - invoke LoadAnimPack3D, OFFSET hallCardFurniture3D, OFFSET hallCardFurniturePath3D - invoke LoadAnimPack3D, OFFSET hallWheelFurniture3D, OFFSET hallWheelFurniturePath3D - invoke LoadAnimPack3D, OFFSET hallBackFurniture3D, OFFSET hallBackFurniturePath3D - invoke LoadAnimPack3D, OFFSET hallSkillFurniture3D, OFFSET hallSkillFurniturePath3D - invoke LoadAnimPack3D, OFFSET hallChairFurniture3D, OFFSET hallChairFurniturePath3D - invoke LoadAnimPack3D, OFFSET hallLampFurniture3D, OFFSET hallLampFurniturePath3D - invoke LoadAnimPack3D, OFFSET hallRopeFurniture3D, OFFSET hallRopeFurniturePath3D - invoke LoadAnimPack3D, OFFSET hallSlotFurniture3D, OFFSET hallSlotFurniturePath3D - invoke LoadAnimPack3D, OFFSET hallBartender3D, OFFSET hallBartenderPath3D - invoke LoadAnimPack3D, OFFSET hallProps3D, OFFSET hallPropsPath3D - invoke LoadAnimPack3D, OFFSET hallDrink3D, OFFSET hallDrinkPath3D - invoke LoadAnimPack3D, OFFSET hallCityDetail3D, OFFSET hallCityDetailPath3D - invoke LoadAnimPack3D, OFFSET hallRoomMaterials3D, OFFSET hallRoomMaterialsPath3D - invoke LoadAnimPack3D, OFFSET hallPatrons3D, OFFSET hallPatronsPath3D - invoke LoadAnimPack3D, OFFSET hallStreetLife3D, OFFSET hallStreetLifePath3D - invoke LoadAnimPack3D, OFFSET hallRoomHD3D, OFFSET hallRoomHDPath3D - invoke LoadAnimPack3D, OFFSET hallArchitecture3D, OFFSET hallArchitecturePath3D - invoke LoadAnimPack3D, OFFSET hallArchitectureHD3D, OFFSET hallArchitectureHDPath3D - invoke LoadAnimPack3D, OFFSET hallDecorPack3D, OFFSET hallDecorPath3D - cmp hallArchitecture3D.pixels, 0 - je @F - push esi - push edi - mov esi, hallArchitecture3D.pixels - mov edi, OFFSET texturesBuffer+(92*128*128*4) - mov ecx, 12*128*128 - rep movsd - pop edi - pop esi -@@: - cmp hallRoomMaterials3D.pixels, 0 - je @F - push esi - push edi - mov esi, hallRoomMaterials3D.pixels - mov edi, OFFSET texturesBuffer+(80*128*128*4) - mov ecx, 12*128*128 - rep movsd - pop edi - pop esi -@@: - invoke LoadAnimPack3D, OFFSET materialsPack3D, OFFSET materialsPath3D - cmp materialsPack3D.pixels, 0 - je hall_load_sign - push ebx - push esi - push edi - xor ebx, ebx -hall_copy_material: - mov esi, materialsPack3D.pixels - mov eax, ebx - shl eax, 16 - add esi, eax - mov eax, hallMaterialSlots3D[ebx*4] - shl eax, 16 - lea edi, texturesBuffer[eax] - mov ecx, 128*128 - rep movsd - inc ebx - cmp ebx, 4 - jb hall_copy_material - pop edi - pop esi - pop ebx -hall_load_sign: - ret -LoadHallAssets3D ENDP - + invoke LoadAnimPack3D, OFFSET hallCardFurniture3D, OFFSET hallCardFurniturePath3D + invoke LoadAnimPack3D, OFFSET hallWheelFurniture3D, OFFSET hallWheelFurniturePath3D + invoke LoadAnimPack3D, OFFSET hallBackFurniture3D, OFFSET hallBackFurniturePath3D + invoke LoadAnimPack3D, OFFSET hallSkillFurniture3D, OFFSET hallSkillFurniturePath3D + invoke LoadAnimPack3D, OFFSET hallChairFurniture3D, OFFSET hallChairFurniturePath3D + invoke LoadAnimPack3D, OFFSET hallLampFurniture3D, OFFSET hallLampFurniturePath3D + invoke LoadAnimPack3D, OFFSET hallRopeFurniture3D, OFFSET hallRopeFurniturePath3D + invoke LoadAnimPack3D, OFFSET hallSlotFurniture3D, OFFSET hallSlotFurniturePath3D + invoke LoadAnimPack3D, OFFSET hallBartender3D, OFFSET hallBartenderPath3D + invoke LoadAnimPack3D, OFFSET hallProps3D, OFFSET hallPropsPath3D + invoke LoadAnimPack3D, OFFSET hallDrink3D, OFFSET hallDrinkPath3D + invoke LoadAnimPack3D, OFFSET uwWorldPack, OFFSET uwWorldPath + invoke ValidateCityPack3D, OFFSET uwWorldPack,256,256,8 + invoke LoadAnimPack3D, OFFSET secPortraitsPack, OFFSET secPortraitsPath + invoke ValidateCityPack3D, OFFSET secPortraitsPack,256,256,11 + invoke LoadAnimPack3D, OFFSET ratRacePack, OFFSET ratRacePath + invoke LoadAnimPack3D, OFFSET hallCityDetail3D, OFFSET hallCityDetailPath3D + invoke LoadAnimPack3D, OFFSET hallRoomMaterials3D, OFFSET hallRoomMaterialsPath3D + invoke LoadAnimPack3D, OFFSET hallPatrons3D, OFFSET hallPatronsPath3D + invoke LoadAnimPack3D, OFFSET hallStreetLife3D, OFFSET hallStreetLifePath3D + invoke LoadAnimPack3D, OFFSET hallRoomHD3D, OFFSET hallRoomHDPath3D + invoke LoadAnimPack3D, OFFSET hallArchitecture3D, OFFSET hallArchitecturePath3D + invoke LoadAnimPack3D, OFFSET hallArchitectureHD3D, OFFSET hallArchitectureHDPath3D + invoke LoadAnimPack3D, OFFSET hallDecorPack3D, OFFSET hallDecorPath3D + cmp hallArchitecture3D.pixels, 0 + je @F + push esi + push edi + mov esi, hallArchitecture3D.pixels + mov edi, OFFSET texturesBuffer+(92*128*128*4) + mov ecx, 12*128*128 + rep movsd + pop edi + pop esi +@@: + cmp hallRoomMaterials3D.pixels, 0 + je @F + push esi + push edi + mov esi, hallRoomMaterials3D.pixels + mov edi, OFFSET texturesBuffer+(80*128*128*4) + mov ecx, 12*128*128 + rep movsd + pop edi + pop esi +@@: + invoke LoadAnimPack3D, OFFSET materialsPack3D, OFFSET materialsPath3D + cmp materialsPack3D.pixels, 0 + je hall_load_sign + push ebx + push esi + push edi + xor ebx, ebx +hall_copy_material: + mov esi, materialsPack3D.pixels + mov eax, ebx + shl eax, 16 + add esi, eax + mov eax, hallMaterialSlots3D[ebx*4] + shl eax, 16 + lea edi, texturesBuffer[eax] + mov ecx, 128*128 + rep movsd + inc ebx + cmp ebx, 4 + jb hall_copy_material + pop edi + pop esi + pop ebx +hall_load_sign: + ret +LoadHallAssets3D ENDP + FreeHallAssets3D PROC + call FreeHQAssets3D call FreeCharacterCast3D call FreeBowling3D call FreeRoofAssets3D @@ -542,94 +562,97 @@ FreeHallAssets3D PROC invoke FreeAnimPack3D, OFFSET npcWalkLeftArt3D invoke FreeAnimPack3D, OFFSET basementDoorArt3D call FreeWorldDressing3D - call FreeNativeWheelArt3D - call FreeNativeCoinArt3D - invoke FreeAnimPack3D, OFFSET hallCardFurniture3D - invoke FreeAnimPack3D, OFFSET hallWheelFurniture3D - invoke FreeAnimPack3D, OFFSET hallBackFurniture3D - invoke FreeAnimPack3D, OFFSET hallSkillFurniture3D - invoke FreeAnimPack3D, OFFSET hallChairFurniture3D - invoke FreeAnimPack3D, OFFSET hallLampFurniture3D - invoke FreeAnimPack3D, OFFSET hallRopeFurniture3D - invoke FreeAnimPack3D, OFFSET hallSlotFurniture3D - invoke FreeAnimPack3D, OFFSET hallBartender3D - invoke FreeAnimPack3D, OFFSET hallProps3D - invoke FreeAnimPack3D, OFFSET hallDrink3D - invoke FreeAnimPack3D, OFFSET hallCityDetail3D - invoke FreeAnimPack3D, OFFSET hallRoomMaterials3D - invoke FreeAnimPack3D, OFFSET hallPatrons3D - invoke FreeAnimPack3D, OFFSET hallStreetLife3D - invoke FreeAnimPack3D, OFFSET hallRoomHD3D - invoke FreeAnimPack3D, OFFSET hallArchitecture3D - invoke FreeAnimPack3D, OFFSET hallArchitectureHD3D - invoke FreeAnimPack3D, OFFSET hallDecorPack3D - ret -FreeHallAssets3D ENDP - -; EAX=pixels, ECX=width, EDX=height; legacy materials keep their 128px fallback. -ResolveWorldSurface3D PROC uses esi material:DWORD - mov eax, material - cmp eax,110 - jne @F - mov eax,OFFSET cityBenchMetal3D - mov ecx,32 - mov edx,32 - ret -@@: - cmp eax, 104 - jae surface_decor - cmp eax, 92 - jae surface_architecture - cmp eax, 80 - jae surface_room - cmp eax, 57 - jb surface_legacy - cmp eax, 72 - ja surface_legacy - mov esi, OFFSET hallCityDetail3D - sub eax, 57 - jmp surface_pack -surface_room: - mov esi, OFFSET hallRoomHD3D - sub eax, 80 - jmp surface_pack -surface_architecture: - mov esi, OFFSET hallArchitectureHD3D - sub eax, 92 - jmp surface_pack -surface_decor: - cmp eax, 109 - ja surface_missing - mov esi, OFFSET hallDecorPack3D - sub eax, 104 -surface_pack: - cmp [esi].AnimPack3D.pixels, 0 - je surface_legacy - cmp eax, [esi].AnimPack3D.frames - jae surface_missing - mov ecx, [esi].AnimPack3D.imageWidth - mov edx, [esi].AnimPack3D.height - imul eax, ecx - imul eax, edx - shl eax, 2 - add eax, [esi].AnimPack3D.pixels - ret -surface_legacy: - mov eax, material - cmp eax, 104 - jae surface_missing - shl eax, 16 - add eax, OFFSET texturesBuffer - mov ecx, 128 - mov edx, 128 - ret -surface_missing: - xor eax, eax - mov ecx, 128 - mov edx, 128 - ret -ResolveWorldSurface3D ENDP - + call FreeNativeWheelArt3D + call FreeNativeCoinArt3D + invoke FreeAnimPack3D, OFFSET hallCardFurniture3D + invoke FreeAnimPack3D, OFFSET hallWheelFurniture3D + invoke FreeAnimPack3D, OFFSET hallBackFurniture3D + invoke FreeAnimPack3D, OFFSET hallSkillFurniture3D + invoke FreeAnimPack3D, OFFSET hallChairFurniture3D + invoke FreeAnimPack3D, OFFSET hallLampFurniture3D + invoke FreeAnimPack3D, OFFSET hallRopeFurniture3D + invoke FreeAnimPack3D, OFFSET hallSlotFurniture3D + invoke FreeAnimPack3D, OFFSET hallBartender3D + invoke FreeAnimPack3D, OFFSET hallProps3D + invoke FreeAnimPack3D, OFFSET hallDrink3D + invoke FreeAnimPack3D, OFFSET uwWorldPack + invoke FreeAnimPack3D, OFFSET secPortraitsPack + invoke FreeAnimPack3D, OFFSET ratRacePack + invoke FreeAnimPack3D, OFFSET hallCityDetail3D + invoke FreeAnimPack3D, OFFSET hallRoomMaterials3D + invoke FreeAnimPack3D, OFFSET hallPatrons3D + invoke FreeAnimPack3D, OFFSET hallStreetLife3D + invoke FreeAnimPack3D, OFFSET hallRoomHD3D + invoke FreeAnimPack3D, OFFSET hallArchitecture3D + invoke FreeAnimPack3D, OFFSET hallArchitectureHD3D + invoke FreeAnimPack3D, OFFSET hallDecorPack3D + ret +FreeHallAssets3D ENDP + +; EAX=pixels, ECX=width, EDX=height; legacy materials keep their 128px fallback. +ResolveWorldSurface3D PROC uses esi material:DWORD + mov eax, material + cmp eax,110 + jne @F + mov eax,OFFSET cityBenchMetal3D + mov ecx,32 + mov edx,32 + ret +@@: + cmp eax, 104 + jae surface_decor + cmp eax, 92 + jae surface_architecture + cmp eax, 80 + jae surface_room + cmp eax, 57 + jb surface_legacy + cmp eax, 72 + ja surface_legacy + mov esi, OFFSET hallCityDetail3D + sub eax, 57 + jmp surface_pack +surface_room: + mov esi, OFFSET hallRoomHD3D + sub eax, 80 + jmp surface_pack +surface_architecture: + mov esi, OFFSET hallArchitectureHD3D + sub eax, 92 + jmp surface_pack +surface_decor: + cmp eax, 109 + ja surface_missing + mov esi, OFFSET hallDecorPack3D + sub eax, 104 +surface_pack: + cmp [esi].AnimPack3D.pixels, 0 + je surface_legacy + cmp eax, [esi].AnimPack3D.frames + jae surface_missing + mov ecx, [esi].AnimPack3D.imageWidth + mov edx, [esi].AnimPack3D.height + imul eax, ecx + imul eax, edx + shl eax, 2 + add eax, [esi].AnimPack3D.pixels + ret +surface_legacy: + mov eax, material + cmp eax, 104 + jae surface_missing + shl eax, 16 + add eax, OFFSET texturesBuffer + mov ecx, 128 + mov edx, 128 + ret +surface_missing: + xor eax, eax + mov ecx, 128 + mov edx, 128 + ret +ResolveWorldSurface3D ENDP + RenderHall3D PROC uses ebx esi cmp hallLevel3D,HALL_BOWLING jne @F @@ -663,171 +686,185 @@ fortune_hall_stairs: call RenderInteriorViews3D ret @@: - cmp hallLevel3D, 0 - jne hall_render_bunker - ; Fixed bar counter/stage are world geometry, with height and occlusion. - invoke DrawCityBoxSides3D, 3*FP_1,9*FP_1,23*FP_1,24*FP_1,0,FP_1*13/20,86 - invoke DrawCityHorizontal3D, 3*FP_1,9*FP_1,23*FP_1,24*FP_1,FP_1*13/20,85 - ; Three physical panels preserve detail instead of stretching one over the whole bar. - invoke DrawCityVertical3D,1,24*FP_1,3*FP_1,5*FP_1,0,FP_1*13/20,84 - invoke DrawCityVertical3D,1,24*FP_1,5*FP_1,7*FP_1,0,FP_1*13/20,84 - invoke DrawCityVertical3D,1,24*FP_1,7*FP_1,9*FP_1,0,FP_1*13/20,84 - invoke DrawCityBoxSides3D,3*FP_1,9*FP_1,21*FP_1,22*FP_1,0,FP_1*19/10,86 - invoke DrawCityVertical3D,1,22*FP_1,3*FP_1,5*FP_1,FP_1*3/5,FP_1*19/10,87 - invoke DrawCityVertical3D,1,22*FP_1,5*FP_1,7*FP_1,FP_1*3/5,FP_1*19/10,87 - invoke DrawCityVertical3D,1,22*FP_1,7*FP_1,9*FP_1,FP_1*3/5,FP_1*19/10,87 - invoke DrawCityBoxSides3D, 10*FP_1,22*FP_1,2*FP_1,5*FP_1,0,FP_1/8,2 - invoke DrawCityHorizontal3D, 10*FP_1,22*FP_1,2*FP_1,5*FP_1,FP_1/8,2 - ; Cabaret has a solid stage, side wings, stairs and lighting truss. - invoke DrawCityVertical3D,0,10*FP_1,2*FP_1,5*FP_1,FP_1/8,FP_1*23/10,2 - invoke DrawCityVertical3D,0,22*FP_1,2*FP_1,5*FP_1,FP_1/8,FP_1*23/10,2 - invoke DrawCityVertical3D,1,2*FP_1,10*FP_1,22*FP_1,FP_1/8,FP_1*23/10,2 - invoke DrawCityHorizontal3D,14*FP_1,18*FP_1,5*FP_1,FP_1*11/2,FP_1/12,85 - invoke DrawCityHorizontal3D,14*FP_1,18*FP_1,FP_1*11/2,6*FP_1,FP_1/24,85 - invoke DrawCityBoxSides3D,10*FP_1,22*FP_1,5*FP_1,FP_1*51/10,FP_1*11/5,FP_1*23/10,86 - ; Low room boundaries frame dining and billiards without closing their entrances. - invoke DrawCityBoxSides3D,FP_1*119/10,FP_1*121/10,24*FP_1,FP_1*51/2,0,FP_1*13/20,102 - invoke DrawCityHorizontal3D,FP_1*119/10,FP_1*121/10,24*FP_1,FP_1*51/2,FP_1*13/20,85 - invoke DrawCityBoxSides3D,FP_1*119/10,FP_1*121/10,FP_1*55/2,30*FP_1,0,FP_1*13/20,102 - invoke DrawCityBoxSides3D,23*FP_1,FP_1*116/5,23*FP_1,24*FP_1,0,FP_1*13/20,102 - invoke DrawCityBoxSides3D,23*FP_1,FP_1*116/5,26*FP_1,29*FP_1,0,FP_1*13/20,102 - invoke DrawCityVertical3D,1,6*FP_1,14*FP_1,18*FP_1,FP_1*17/10,FP_1*12/5,109 - invoke DrawCityBoxSides3D,1*FP_1,9*FP_1,FP_1,FP_1*6/5,FP_1*11/5,FP_1*5/2,103 - invoke DrawCityBoxSides3D,23*FP_1,31*FP_1,FP_1,FP_1*6/5,FP_1*11/5,FP_1*5/2,103 - mov eax, animationClock3D - xor edx, edx - mov ecx, 220 - div ecx - and eax, 1 - cmp engineMode, MODE_BAR - jne hall_bartender_pose - cmp barPhase3D, 1 - jne hall_bartender_pose - mov eax, barTime3D - xor edx, edx - mov ecx, 375 - div ecx - cmp eax, 7 - jbe hall_bartender_pose - mov eax, 7 - jmp hall_bartender_selected -hall_bartender_pose: - cmp engineMode, MODE_BAR - jne hall_bartender_store - cmp barPhase3D, 1 - je hall_bartender_selected - cmp barPhase3D, 2 - jne hall_bartender_store - mov eax,7 -hall_bartender_selected: - mov ecx, barSelection3D - shl ecx, 3 - add eax, ecx -hall_bartender_store: - mov hallObjects3D[4*SIZEOF CityProp3D].frame, eax - xor esi, esi -hall_render_props: - ; The former whole-stage billboard is replaced with world surfaces above. - cmp esi, 15 - je hall_render_next_prop - imul eax, esi, SIZEOF CityProp3D - add eax, OFFSET hallObjects3D + cmp hallLevel3D, 0 + jne hall_render_bunker + ; Fixed bar counter/stage are world geometry, with height and occlusion. + invoke DrawCityBoxSides3D, 3*FP_1,9*FP_1,23*FP_1,24*FP_1,0,FP_1*13/20,86 + invoke DrawCityHorizontal3D, 3*FP_1,9*FP_1,23*FP_1,24*FP_1,FP_1*13/20,85 + ; Three physical panels preserve detail instead of stretching one over the whole bar. + invoke DrawCityVertical3D,1,24*FP_1,3*FP_1,5*FP_1,0,FP_1*13/20,84 + invoke DrawCityVertical3D,1,24*FP_1,5*FP_1,7*FP_1,0,FP_1*13/20,84 + invoke DrawCityVertical3D,1,24*FP_1,7*FP_1,9*FP_1,0,FP_1*13/20,84 + invoke DrawCityBoxSides3D,3*FP_1,9*FP_1,21*FP_1,22*FP_1,0,FP_1*19/10,86 + invoke DrawCityVertical3D,1,22*FP_1,3*FP_1,5*FP_1,FP_1*3/5,FP_1*19/10,87 + invoke DrawCityVertical3D,1,22*FP_1,5*FP_1,7*FP_1,FP_1*3/5,FP_1*19/10,87 + invoke DrawCityVertical3D,1,22*FP_1,7*FP_1,9*FP_1,FP_1*3/5,FP_1*19/10,87 + invoke DrawCityBoxSides3D, 10*FP_1,22*FP_1,2*FP_1,5*FP_1,0,FP_1/8,2 + invoke DrawCityHorizontal3D, 10*FP_1,22*FP_1,2*FP_1,5*FP_1,FP_1/8,2 + ; Cabaret has a solid stage, side wings, stairs and lighting truss. + invoke DrawCityVertical3D,0,10*FP_1,2*FP_1,5*FP_1,FP_1/8,FP_1*23/10,2 + invoke DrawCityVertical3D,0,22*FP_1,2*FP_1,5*FP_1,FP_1/8,FP_1*23/10,2 + invoke DrawCityVertical3D,1,2*FP_1,10*FP_1,22*FP_1,FP_1/8,FP_1*23/10,2 + invoke DrawCityHorizontal3D,14*FP_1,18*FP_1,5*FP_1,FP_1*11/2,FP_1/12,85 + invoke DrawCityHorizontal3D,14*FP_1,18*FP_1,FP_1*11/2,6*FP_1,FP_1/24,85 + invoke DrawCityBoxSides3D,10*FP_1,22*FP_1,5*FP_1,FP_1*51/10,FP_1*11/5,FP_1*23/10,86 + ; Low room boundaries frame dining and billiards without closing their entrances. + invoke DrawCityBoxSides3D,FP_1*119/10,FP_1*121/10,24*FP_1,FP_1*51/2,0,FP_1*13/20,102 + invoke DrawCityHorizontal3D,FP_1*119/10,FP_1*121/10,24*FP_1,FP_1*51/2,FP_1*13/20,85 + invoke DrawCityBoxSides3D,FP_1*119/10,FP_1*121/10,FP_1*55/2,30*FP_1,0,FP_1*13/20,102 + invoke DrawCityBoxSides3D,23*FP_1,FP_1*116/5,23*FP_1,24*FP_1,0,FP_1*13/20,102 + invoke DrawCityBoxSides3D,23*FP_1,FP_1*116/5,26*FP_1,29*FP_1,0,FP_1*13/20,102 + invoke DrawCityVertical3D,1,6*FP_1,14*FP_1,18*FP_1,FP_1*17/10,FP_1*12/5,109 + invoke DrawCityBoxSides3D,1*FP_1,9*FP_1,FP_1,FP_1*6/5,FP_1*11/5,FP_1*5/2,103 + invoke DrawCityBoxSides3D,23*FP_1,31*FP_1,FP_1,FP_1*6/5,FP_1*11/5,FP_1*5/2,103 + mov eax, animationClock3D + xor edx, edx + mov ecx, 220 + div ecx + and eax, 1 + cmp engineMode, MODE_BAR + jne hall_bartender_pose + cmp barPhase3D, 1 + jne hall_bartender_pose + mov eax, barTime3D + xor edx, edx + mov ecx, 375 + div ecx + cmp eax, 7 + jbe hall_bartender_pose + mov eax, 7 + jmp hall_bartender_selected +hall_bartender_pose: + cmp engineMode, MODE_BAR + jne hall_bartender_store + cmp barPhase3D, 1 + je hall_bartender_selected + cmp barPhase3D, 2 + jne hall_bartender_store + mov eax,7 +hall_bartender_selected: + mov ecx, barSelection3D + shl ecx, 3 + add eax, ecx +hall_bartender_store: + mov hallObjects3D[4*SIZEOF CityProp3D].frame, eax + xor esi, esi +hall_render_props: + ; The former whole-stage billboard is replaced with world surfaces above. + cmp esi, 15 + je hall_render_next_prop + imul eax, esi, SIZEOF CityProp3D + add eax, OFFSET hallObjects3D cmp esi,6 je hall_render_next_prop - invoke DrawCityObject3D, eax, 0 -hall_render_next_prop: - inc esi - cmp esi, HALL_PROP_COUNT - jb hall_render_props - xor esi, esi -hall_render_lights: - imul eax, esi, SIZEOF CityProp3D - add eax, OFFSET hallLights3D - invoke DrawCityObject3D,eax,0 - inc esi - cmp esi, HALL_LIGHT_COUNT - jb hall_render_lights - xor esi, esi -hall_render_lounge: - imul eax, esi, SIZEOF CityProp3D - add eax, OFFSET hallLoungeDecor3D - invoke DrawCityObject3D,eax,0 - inc esi - cmp esi, HALL_DECOR_COUNT - jb hall_render_lounge - call RenderPatrons3D + invoke DrawCityObject3D, eax, 0 +hall_render_next_prop: + inc esi + cmp esi, HALL_PROP_COUNT + jb hall_render_props + xor esi, esi +hall_render_lights: + imul eax, esi, SIZEOF CityProp3D + add eax, OFFSET hallLights3D + invoke DrawCityObject3D,eax,0 + inc esi + cmp esi, HALL_LIGHT_COUNT + jb hall_render_lights + xor esi, esi +hall_render_lounge: + imul eax, esi, SIZEOF CityProp3D + add eax, OFFSET hallLoungeDecor3D + invoke DrawCityObject3D,eax,0 + inc esi + cmp esi, HALL_DECOR_COUNT + jb hall_render_lounge + call RenderPatrons3D call RenderCabaretActors3D invoke DrawCityObject3D,OFFSET scrStation3D,0 call RenderHallDressing3D call RenderHallPortals3D - call RenderHellPortal3D + call RenderHellPortal3D call RenderFortuneEntrance3D call RenderLift3D call ApplyHallLighting3D call RenderInteriorViews3D call DrawBasementLeaf3D - ret -hall_render_bunker: - invoke DrawCityBoxSides3D, 14*FP_1,20*FP_1,14*FP_1,15*FP_1,0,FP_1/2,96 - invoke DrawCityHorizontal3D, 14*FP_1,20*FP_1,14*FP_1,15*FP_1,FP_1/2,97 - invoke DrawCityVertical3D,1,11*FP_1+FP_1/10,14*FP_1,16*FP_1,FP_1/4,FP_1*8/5,95 - invoke DrawCityVertical3D,1,11*FP_1+FP_1/10,17*FP_1,19*FP_1+FP_HALF,FP_1/4,FP_1*8/5,95 - invoke DrawCityVertical3D,0,19*FP_1+FP_1*9/10,17*FP_1,20*FP_1,0,FP_1*3/2,99 - ; A narrow, stepped vault is real geometry, not a square workshop ceiling. - invoke DrawCityHorizontal3D,14*FP_1,15*FP_1,11*FP_1,24*FP_1,FP_1*9/5,93 - invoke DrawCityVertical3D,0,15*FP_1,11*FP_1,24*FP_1,FP_1*9/5,FP_1*11/5,93 - invoke DrawCityHorizontal3D,15*FP_1,16*FP_1,11*FP_1,24*FP_1,FP_1*11/5,93 - invoke DrawCityVertical3D,0,16*FP_1,11*FP_1,24*FP_1,FP_1*11/5,FP_1*5/2,93 - invoke DrawCityHorizontal3D,18*FP_1,19*FP_1,11*FP_1,24*FP_1,FP_1*11/5,93 - invoke DrawCityVertical3D,0,18*FP_1,11*FP_1,24*FP_1,FP_1*11/5,FP_1*5/2,93 - invoke DrawCityHorizontal3D,19*FP_1,20*FP_1,11*FP_1,24*FP_1,FP_1*9/5,93 - invoke DrawCityVertical3D,0,19*FP_1,11*FP_1,24*FP_1,FP_1*9/5,FP_1*11/5,93 - mov eax, animationClock3D - xor edx, edx - mov ecx, 240 - div ecx - and eax, 7 - mov bunkerMerchant3D.frame, eax - invoke DrawCityObject3D, OFFSET bunkerMerchant3D, 0 - invoke DrawCityObject3D, OFFSET bunkerDisplay3D, 0 + ret +hall_render_bunker: + invoke DrawCityBoxSides3D, 14*FP_1,20*FP_1,14*FP_1,15*FP_1,0,FP_1/2,96 + invoke DrawCityHorizontal3D, 14*FP_1,20*FP_1,14*FP_1,15*FP_1,FP_1/2,97 + invoke DrawCityVertical3D,1,11*FP_1+FP_1/10,14*FP_1,16*FP_1,FP_1/4,FP_1*8/5,95 + invoke DrawCityVertical3D,1,11*FP_1+FP_1/10,17*FP_1,19*FP_1+FP_HALF,FP_1/4,FP_1*8/5,95 + invoke DrawCityVertical3D,0,19*FP_1+FP_1*9/10,17*FP_1,20*FP_1,0,FP_1*3/2,99 + ; A narrow, stepped vault is real geometry, not a square workshop ceiling. + invoke DrawCityHorizontal3D,14*FP_1,15*FP_1,11*FP_1,24*FP_1,FP_1*9/5,93 + invoke DrawCityVertical3D,0,15*FP_1,11*FP_1,24*FP_1,FP_1*9/5,FP_1*11/5,93 + invoke DrawCityHorizontal3D,15*FP_1,16*FP_1,11*FP_1,24*FP_1,FP_1*11/5,93 + invoke DrawCityVertical3D,0,16*FP_1,11*FP_1,24*FP_1,FP_1*11/5,FP_1*5/2,93 + invoke DrawCityHorizontal3D,18*FP_1,19*FP_1,11*FP_1,24*FP_1,FP_1*11/5,93 + invoke DrawCityVertical3D,0,18*FP_1,11*FP_1,24*FP_1,FP_1*11/5,FP_1*5/2,93 + invoke DrawCityHorizontal3D,19*FP_1,20*FP_1,11*FP_1,24*FP_1,FP_1*9/5,93 + invoke DrawCityVertical3D,0,19*FP_1,11*FP_1,24*FP_1,FP_1*9/5,FP_1*11/5,93 + mov eax, animationClock3D + xor edx, edx + mov ecx, 240 + div ecx + and eax, 7 + mov bunkerMerchant3D.frame, eax + invoke DrawCityObject3D, OFFSET bunkerMerchant3D, 0 + invoke DrawCityObject3D, OFFSET bunkerDisplay3D, 0 invoke DrawCityObject3D, OFFSET bunkerDesk3D, 0 + invoke DrawCityObject3D, OFFSET bunkerRatRace3D, 0 + mov semyonProp3D.frame,0 + cmp debtActive,0 + je @F + mov semyonProp3D.frame,1 +@@: + invoke DrawCityObject3D, OFFSET semyonProp3D, 0 + invoke DrawCityObject3D, OFFSET heistDeskProp3D, 0 + mov eax,OFFSET uwClubEntrance + cmp playerX,14*FP_1 + jge @F + mov eax,OFFSET uwClubTitle +@@: + invoke DrawString8x8,8,34,eax,00E7CA88h call RenderInteriorViews3D - ret -RenderHall3D ENDP - -; Extra rooms use the same distance and facing checks as the existing tables. -HallTarget3D PROC uses ebx wx:DWORD,wy:DWORD,id:DWORD,prompt:DWORD - mov eax, wx - sub eax, playerX - sar eax, 8 - mov ebx, eax - imul eax, eax - mov ecx, eax - mov eax, wy - sub eax, playerY - sar eax, 8 - mov edx, eax - imul eax, eax - add ecx, eax - cmp ecx, 262144 - jae hall_target_done - mov eax, playerDirX - sar eax, 8 - imul eax, ebx - mov ebx, playerDirY - sar ebx, 8 - imul ebx, edx - add eax, ebx - cmp eax, 18000 - jl hall_target_done - mov eax, id - mov interactTargetId, eax - mov eax, prompt - mov interactPromptPtr, eax -hall_target_done: - ret -HallTarget3D ENDP - + ret +RenderHall3D ENDP + +; Extra rooms use the same distance and facing checks as the existing tables. +HallTarget3D PROC uses ebx wx:DWORD,wy:DWORD,id:DWORD,prompt:DWORD + mov eax, wx + sub eax, playerX + sar eax, 8 + mov ebx, eax + imul eax, eax + mov ecx, eax + mov eax, wy + sub eax, playerY + sar eax, 8 + mov edx, eax + imul eax, eax + add ecx, eax + cmp ecx, 262144 + jae hall_target_done + mov eax, playerDirX + sar eax, 8 + imul eax, ebx + mov ebx, playerDirY + sar ebx, 8 + imul ebx, edx + add eax, ebx + cmp eax, 18000 + jl hall_target_done + mov eax, id + mov interactTargetId, eax + mov eax, prompt + mov interactPromptPtr, eax +hall_target_done: + ret +HallTarget3D ENDP + CheckHallInteractions3D PROC cmp hallLevel3D,HALL_BOWLING jne @F @@ -849,43 +886,46 @@ CheckHallInteractions3D PROC call CheckUpperInteractions3D ret @@: - cmp hallLevel3D, 0 - jne hall_check_bunker - cmp playerX, 3*FP_1 - jl hall_check_other - cmp playerX, 9*FP_1 - jg hall_check_other - cmp playerY, 24*FP_1+9830 - jl hall_check_other - ; A point on the serving edge remains in front even when standing close. - invoke HallTarget3D, playerX,23*FP_1+FP_HALF,INTERACT_BAR,OFFSET hallBarPrompt3D -hall_check_other: - invoke HallTarget3D,FP_1*305/10,28*FP_1,INTERACT_DARTS,OFFSET dtPrompt - invoke HallTarget3D,JACKBOX_X,JACKBOX_Y,INTERACT_JACKBOX,OFFSET jackboxPrompt3D + cmp hallLevel3D, 0 + jne hall_check_bunker + cmp playerX, 3*FP_1 + jl hall_check_other + cmp playerX, 9*FP_1 + jg hall_check_other + cmp playerY, 24*FP_1+9830 + jl hall_check_other + ; A point on the serving edge remains in front even when standing close. + invoke HallTarget3D, playerX,23*FP_1+FP_HALF,INTERACT_BAR,OFFSET hallBarPrompt3D +hall_check_other: + invoke HallTarget3D,FP_1*305/10,28*FP_1,INTERACT_DARTS,OFFSET dtPrompt + invoke HallTarget3D,JACKBOX_X,JACKBOX_Y,INTERACT_JACKBOX,OFFSET jackboxPrompt3D invoke HallTarget3D,16*FP_1,FP_1*73/10,INTERACT_CABARET_SEAT,OFFSET cabaretSeat3D invoke HallTarget3D,scrStation3D.posX,scrStation3D.posY,INTERACT_SCRATCH,OFFSET scratchHall3D invoke HallTarget3D,FP_1*285/10,FP_1*105/10,INTERACT_BASEMENT,OFFSET hallBunkerPrompt3D - invoke HallTarget3D, 27*FP_1,25*FP_1,INTERACT_BILLIARDS,OFFSET hallPoolPrompt3D + invoke HallTarget3D, 27*FP_1,25*FP_1,INTERACT_BILLIARDS,OFFSET hallPoolPrompt3D invoke HallTarget3D,FP_1*305/10,21*FP_1,0,OFFSET upperStairPrompt3D - call CheckNpcInteractions3D + call CheckNpcInteractions3D call CheckFortuneInteractions3D call CheckRoofInteractions3D - invoke HallTarget3D,HF_PORTAL_X,HF_PORTAL_Y,INTERACT_HELL_FPS,OFFSET hfPortalPrompt - ret -hall_check_bunker: - mov interactTargetId, 0 - mov interactPromptPtr, 0 - invoke HallTarget3D, 16*FP_1,14*FP_1+FP_HALF,INTERACT_SHOP,OFFSET promptShop - ret -CheckHallInteractions3D ENDP - + invoke HallTarget3D,HF_PORTAL_X,HF_PORTAL_Y,INTERACT_HELL_FPS,OFFSET hfPortalPrompt + ret +hall_check_bunker: + mov interactTargetId, 0 + mov interactPromptPtr, 0 + invoke HallTarget3D, 16*FP_1,14*FP_1+FP_HALF,INTERACT_SHOP,OFFSET promptShop + invoke HallTarget3D, FP_1*85/10,FP_1*185/10,INTERACT_RAT_RACE,OFFSET szPromptRatRace + invoke HallTarget3D, FP_1*65/10,FP_1*238/10,INTERACT_SEMYON,OFFSET szPromptSemyon + invoke HallTarget3D, 11*FP_1,FP_1*244/10,INTERACT_HEIST,OFFSET szPromptHeist + ret +CheckHallInteractions3D ENDP + TriggerHallInteraction3D PROC - cmp interactTargetId,INTERACT_HELL_FPS - jne @F - call BeginHellFPS3D - mov eax,1 - ret -@@: + cmp interactTargetId,INTERACT_HELL_FPS + jne @F + call BeginHellFPS3D + mov eax,1 + ret +@@: call TryBowlingInteraction3D test eax,eax jnz hall_trigger_handled @@ -898,12 +938,12 @@ TriggerHallInteraction3D PROC call TryRoofInteraction3D test eax,eax jnz hall_trigger_handled - cmp interactTargetId,INTERACT_DARTS - jne hall_not_darts - call BeginDarts3D - mov eax,1 - ret -hall_not_darts: + cmp interactTargetId,INTERACT_DARTS + jne hall_not_darts + call BeginDarts3D + mov eax,1 + ret +hall_not_darts: call TryFortuneInteraction3D test eax,eax jnz hall_trigger_handled @@ -922,151 +962,249 @@ hall_not_darts: mov eax,1 ret @@: - cmp interactTargetId,INTERACT_NPC - jne @F - call OpenNpcDialog3D - ret -@@: - - cmp interactTargetId, INTERACT_BAR - jne hall_trigger_stairs - call LoadHallAssets3D - mov engineMode, MODE_BAR - mov barPhase3D, 0 - mov barTime3D, 0 - call ClearKeys3D - mov eax, 1 - ret -hall_trigger_stairs: - cmp interactTargetId, INTERACT_BASEMENT - jne hall_trigger_none + cmp interactTargetId,INTERACT_NPC + jne @F + call OpenNpcDialog3D + ret +@@: + + cmp interactTargetId, INTERACT_BAR + jne hall_trigger_stairs + mov engineMode, MODE_BAR + mov barPhase3D, 0 + mov barTime3D, 0 + call ClearKeys3D + mov eax, 1 + ret +hall_trigger_stairs: + cmp interactTargetId, INTERACT_BASEMENT + jne hall_trigger_none ; The button opens the steel leaf. Walking across its threshold is separate. mov basementDoorTarget3D,FP_1 - call ClearKeys3D - mov eax, 1 - ret -hall_trigger_none: - cmp interactTargetId, INTERACT_BILLIARDS - jne @F - call InitPool3D - mov engineMode, MODE_POOL - call ClearKeys3D - mov eax, 1 - ret -@@: + call ClearKeys3D + mov eax, 1 + ret +hall_trigger_none: + cmp interactTargetId, INTERACT_BILLIARDS + jne @F + call InitPool3D + mov engineMode, MODE_POOL + call ClearKeys3D + mov eax, 1 + ret +@@: + cmp interactTargetId, INTERACT_SEMYON + jne @F + call TriggerDebtDialog3D + mov eax, 1 + ret +@@: + cmp interactTargetId, INTERACT_RAT_RACE + jne @F + call BeginRatRace3D + mov eax, 1 + ret +@@: + cmp interactTargetId, INTERACT_HEIST + jne @F + call BeginHeistPlanning3D + mov eax, 1 + ret +@@: xor eax, eax hall_trigger_handled: - ret -TriggerHallInteraction3D ENDP - -HandleStairs3D PROC + ret +TriggerHallInteraction3D ENDP + +HandleStairs3D PROC call UpdateStairHeight3D call HandlePlayerInput call UpdateInteriorTravel3D call UpdateStairHeight3D - ret -HandleStairs3D ENDP - -RenderStairs3D PROC uses ebx esi - call UpdateCamera3D - call RenderCeilingAndFloor - call RenderWalls - call PrepareCityDepth3D - call RenderHall3D + ret +HandleStairs3D ENDP + +RenderStairs3D PROC uses ebx esi + call UpdateCamera3D + call RenderCeilingAndFloor + call RenderWalls + call PrepareCityDepth3D + call RenderHall3D call RenderHUD - ret -RenderStairs3D ENDP - -BuyBarDrink3D PROC drink:DWORD - cmp barPhase3D, 0 - jne bar_buy_done - mov ecx, drink - cmp ecx, 2 - ja bar_buy_done - mov eax, barPrice3D[ecx*4] - cmp bankroll, eax - jb bar_buy_poor - sub bankroll, eax - mov barSelection3D, ecx - mov barPhase3D, 1 - mov barTime3D, 0 - call SaveProgress3D - ret -bar_buy_poor: - invoke CopyString3D, OFFSET barPoor3D, OFFSET flashMessage - mov flashTimer, 150 -bar_buy_done: - ret -BuyBarDrink3D ENDP - -HandleBar3D PROC uses ebx - cmp barPhase3D, 0 - jne bar_animate - mov ebx, 31h -bar_select_key: - invoke Pressed3D, ebx - test eax, eax - jz @F - mov eax, ebx - sub eax, 31h - invoke BuyBarDrink3D, eax - ret -@@: - inc ebx - cmp ebx, 33h - jbe bar_select_key - cmp mouseClick3D, 0 - je bar_handle_done - cmp mouseX3D, 170 - jb bar_handle_done - cmp mouseY3D, 98 - jb bar_handle_done - cmp mouseY3D, 155 - jae bar_handle_done - mov eax, mouseY3D - sub eax, 98 - xor edx, edx - mov ecx, 19 - div ecx - invoke BuyBarDrink3D, eax - ret -bar_animate: - mov eax, deltaTime3D - add barTime3D, eax - cmp barPhase3D, 1 - jne bar_after_drink - cmp barTime3D, 3000 - jb bar_handle_done - mov barPhase3D, 2 - mov barTime3D, 0 - ret -bar_after_drink: - cmp barTime3D, 2400 - jb bar_handle_done - mov barPhase3D, 0 - mov barTime3D, 0 -bar_handle_done: - ret -HandleBar3D ENDP - -RenderBar3D PROC uses ebx - local oldX:DWORD,oldY:DWORD,oldAngle:DWORD,oldHorizon:DWORD,oldEye:DWORD,oldMode:DWORD - mov eax, playerX - mov oldX, eax - mov eax, playerY - mov oldY, eax - mov eax, playerAngle - mov oldAngle, eax - mov eax, viewHorizon3D - mov oldHorizon, eax - mov eax, viewEye3D - mov oldEye, eax - mov eax, engineMode - mov oldMode, eax - mov engineMode, MODE_BAR - mov playerX, 6*FP_1 - mov playerY, 25*FP_1+FP_1/3 - mov playerAngle, 384 + ret +RenderStairs3D ENDP + +BuyBarDrink3D PROC drink:DWORD + cmp barPhase3D, 0 + jne bar_buy_done + mov ecx, drink + cmp ecx, 5 + ja bar_buy_done + mov eax, barPrice3D[ecx*4] + cmp bankroll, eax + jb bar_buy_poor + sub bankroll, eax + mov barSelection3D, ecx + mov barPhase3D, 1 + mov barTime3D, 0 + call SaveProgress3D + ret +bar_buy_poor: + invoke CopyString3D, OFFSET barPoor3D, OFFSET flashMessage + mov flashTimer, 150 +bar_buy_done: + ret +BuyBarDrink3D ENDP + +HandleBar3D PROC uses ebx + cmp barPhase3D, 0 + jne bar_animate + mov ebx, 31h +bar_select_key: + invoke Pressed3D, ebx + test eax, eax + jz @F + mov eax, ebx + sub eax, 31h + invoke BuyBarDrink3D, eax + ret +@@: + inc ebx + cmp ebx, 36h + jbe bar_select_key + + ; Option 7: Recruit Bartender for Heist (,000) + invoke Pressed3D, 37h + test eax, eax + jz @F +bar_recruit_bartender: + cmp heistCrewBartender, 0 + jne @F + cmp bankroll, 1000 + jb @F + sub bankroll, 1000 + mov heistCrewBartender, 1 + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + call SaveProgress3D + ret +@@: + cmp mouseClick3D, 0 + je bar_handle_done + cmp mouseX3D, 8 + jb bar_handle_done + cmp mouseX3D, 316 + jae bar_handle_done + cmp mouseY3D, 68 + jb bar_handle_done + cmp mouseY3D, 180 + jae bar_handle_done + mov eax, mouseY3D + sub eax, 68 + xor edx, edx + mov ecx, 16 + div ecx + cmp eax,6 + je bar_recruit_bartender + invoke BuyBarDrink3D, eax + ret +bar_animate: + mov eax, deltaTime3D + add barTime3D, eax + cmp barPhase3D, 1 + jne bar_after_drink + cmp barTime3D, 3000 + jb bar_handle_done + mov barPhase3D, 2 + mov barTime3D, 0 + ret +bar_after_drink: + cmp barTime3D, 2400 + jb bar_handle_done + mov eax, barSelection3D + cmp eax, 0 + jne @F + mov barBuffCalmTimer, 600000 + jmp bar_buff_applied +@@: + cmp eax, 1 + jne @F + mov barBuffCalcTimer, 600000 + jmp bar_buff_applied +@@: + cmp eax, 2 + jne @F + mov barBuffSpeedTimer, 600000 + jmp bar_buff_applied +@@: + cmp eax, 3 + jne @F + mov securityHeat, 0 + jmp bar_buff_applied +@@: + cmp eax, 4 + jne @F + mov barBuffLuckSpins, 15 + jmp bar_buff_applied +@@: + mov barDrunkTimer, 0 +bar_buff_applied: + call SaveProgress3D + mov barPhase3D, 0 + mov barTime3D, 0 +bar_handle_done: + ret +HandleBar3D ENDP + +UpdateBarBuffTimers3D PROC + mov eax, deltaTime3D + cmp barBuffSpeedTimer, 0 + jbe @F + cmp barBuffSpeedTimer, eax + jbe buff_spd_zero + sub barBuffSpeedTimer, eax + jmp @F +buff_spd_zero: + mov barBuffSpeedTimer, 0 +@@: + cmp barBuffCalmTimer, 0 + jbe @F + cmp barBuffCalmTimer, eax + jbe buff_calm_zero + sub barBuffCalmTimer, eax + jmp @F +buff_calm_zero: + mov barBuffCalmTimer, 0 +@@: + cmp barBuffCalcTimer, 0 + jbe @F + cmp barBuffCalcTimer, eax + jbe buff_calc_zero + sub barBuffCalcTimer, eax + jmp @F +buff_calc_zero: + mov barBuffCalcTimer, 0 +@@: + ret +UpdateBarBuffTimers3D ENDP + +RenderBar3D PROC uses ebx + local oldX:DWORD,oldY:DWORD,oldAngle:DWORD,oldHorizon:DWORD,oldEye:DWORD,oldMode:DWORD + mov eax, playerX + mov oldX, eax + mov eax, playerY + mov oldY, eax + mov eax, playerAngle + mov oldAngle, eax + mov eax, viewHorizon3D + mov oldHorizon, eax + mov eax, viewEye3D + mov oldEye, eax + mov eax, engineMode + mov oldMode, eax + mov engineMode, MODE_BAR + mov playerX, 6*FP_1 + mov playerY, 25*FP_1+FP_1/3 + mov playerAngle, 384 cmp hallLevel3D,2 jne @F mov playerX,FP_1*25/2 @@ -1082,33 +1220,42 @@ RenderBar3D PROC uses ebx mov playerX,27*FP_1 mov playerY,FP_1*66/10 @@: - mov viewHorizon3D, HALF_H + mov viewHorizon3D, HALF_H mov viewEye3D, HALL_STANDING_EYE - call UpdateCamera3D + call UpdateCamera3D cmp hallLevel3D,HALL_BOWLING je bar_world_ready - call RenderCeilingAndFloor - call RenderWalls - call PrepareCityDepth3D + call RenderCeilingAndFloor + call RenderWalls + call PrepareCityDepth3D bar_world_ready: - call RenderHall3D - cmp barPhase3D, 0 - jne bar_active_scene - invoke DrawBoxBorder, 170,83,146,86,0017201Bh,00836D42h,1 - invoke DrawString8x8, 174,99,OFFSET barDrinks3D,00E4D9BDh - invoke DrawString8x8, 174,118,OFFSET barDrinks23D,00E4D9BDh - invoke DrawString8x8, 174,137,OFFSET barDrinks33D,00BCD7D0h - jmp bar_draw_title -bar_active_scene: - mov ebx, OFFSET barMixText3D - cmp barPhase3D, 2 - jne @F - mov ebx, OFFSET barDrinkText3D -@@: - invoke DrawBox,170,83,146,24,0017201Bh - invoke DrawString8x8,176,91,ebx,00E7CA88h -bar_draw_title: - invoke DrawBox,0,0,320,28,0014191Dh + call RenderHall3D + cmp barPhase3D, 0 + jne bar_active_scene + invoke DrawBoxBorder, 8,64,304,124,0017201Bh,00836D42h,1 + invoke DrawString8x8, 16,72,OFFSET barDrinks3D,00E4D9BDh + invoke DrawString8x8, 16,88,OFFSET barDrinks23D,00E4D9BDh + invoke DrawString8x8, 16,104,OFFSET barDrinks33D,00E4D9BDh + invoke DrawString8x8, 16,120,OFFSET barDrinks43D,00E4D9BDh + invoke DrawString8x8, 16,136,OFFSET barDrinks53D,00E4D9BDh + invoke DrawString8x8, 16,152,OFFSET barDrinks63D,00BCD7D0h + cmp heistCrewBartender, 1 + je bar_draw_bartender_ready + invoke DrawString8x8, 16,168,OFFSET szBarHeistRecruit,00FFFF55h + jmp bar_draw_title +bar_draw_bartender_ready: + invoke DrawString8x8, 16,168,OFFSET szBarHeistReady,0055FF55h + jmp bar_draw_title +bar_active_scene: + mov ebx, OFFSET barMixText3D + cmp barPhase3D, 2 + jne @F + mov ebx, OFFSET barDrinkText3D +@@: + invoke DrawBox,130,83,186,24,0017201Bh + invoke DrawString8x8,136,91,ebx,00E7CA88h +bar_draw_title: + invoke DrawBox,0,0,320,28,0014191Dh mov eax,OFFSET barName3D cmp hallLevel3D,2 jne @F @@ -1123,91 +1270,91 @@ bar_draw_title: mov eax,OFFSET bwBarName3D @@: invoke DrawString8x8, 18,15,eax,00E7CA88h - cmp barPhase3D, 2 - jne bar_render_done - mov eax, barTime3D - xor edx, edx - mov ecx, 343 - div ecx - cmp eax, 6 - jbe @F - mov eax, 6 -@@: - mov ecx, barSelection3D - imul ecx, 7 - add eax, ecx - invoke DrawAnimSprite3D, OFFSET hallDrink3D,eax,272,170,360,360 -bar_render_done: - invoke DrawNumber,240,15,bankroll,00E5D6B0h - mov eax, oldX - mov playerX, eax - mov eax, oldY - mov playerY, eax - mov eax, oldAngle - mov playerAngle, eax - mov eax, oldHorizon - mov viewHorizon3D, eax - mov eax, oldEye - mov viewEye3D, eax - mov eax, oldMode - mov engineMode, eax - call UpdateCamera3D - ret -RenderBar3D ENDP - -RenderCityGuards3D PROC uses ebx - mov eax, cityClock3D - xor edx, edx - mov ecx, 180 - div ecx - and eax, 7 - mov cityGuardLeft3D.frame, eax - cmp arrivalState3D, ARRIVAL_WALK - je city_world_guard_right - mov cityGuardLeft3D.frame, 15 - cmp arrivalState3D, ARRIVAL_STOP - jne city_world_guard_invite - mov eax, arrivalTime3D - xor edx, edx - mov ecx, 90 - div ecx - cmp eax, 7 - jbe @F - mov eax, 7 -@@: - add eax, 8 - mov cityGuardLeft3D.frame, eax - jmp city_world_guard_right -city_world_guard_invite: - cmp arrivalState3D, ARRIVAL_ADMIT - jb city_world_guard_right - mov eax, arrivalTime3D - xor edx, edx - mov ecx, 120 - div ecx - add eax, 16 - cmp eax, 22 - jbe @F - mov eax, 22 -@@: - mov cityGuardLeft3D.frame, eax -city_world_guard_right: - mov eax, cityClock3D - add eax, 590 - xor edx, edx - mov ecx, 220 - div ecx - and eax, 7 - cmp arrivalState3D, ARRIVAL_PROFILE - jne @F - add eax, 24 -@@: - mov cityGuardRight3D.frame, eax - invoke DrawCityObject3D, OFFSET cityGuardLeft3D,0 - invoke DrawCityObject3D, OFFSET cityGuardRight3D,0 - ret -RenderCityGuards3D ENDP - + cmp barPhase3D, 2 + jne bar_render_done + mov eax, barTime3D + xor edx, edx + mov ecx, 343 + div ecx + cmp eax, 6 + jbe @F + mov eax, 6 +@@: + mov ecx, barSelection3D + imul ecx, 7 + add eax, ecx + invoke DrawAnimSprite3D, OFFSET hallDrink3D,eax,272,170,360,360 +bar_render_done: + invoke DrawNumber,240,15,bankroll,00E5D6B0h + mov eax, oldX + mov playerX, eax + mov eax, oldY + mov playerY, eax + mov eax, oldAngle + mov playerAngle, eax + mov eax, oldHorizon + mov viewHorizon3D, eax + mov eax, oldEye + mov viewEye3D, eax + mov eax, oldMode + mov engineMode, eax + call UpdateCamera3D + ret +RenderBar3D ENDP + +RenderCityGuards3D PROC uses ebx + mov eax, cityClock3D + xor edx, edx + mov ecx, 180 + div ecx + and eax, 7 + mov cityGuardLeft3D.frame, eax + cmp arrivalState3D, ARRIVAL_WALK + je city_world_guard_right + mov cityGuardLeft3D.frame, 15 + cmp arrivalState3D, ARRIVAL_STOP + jne city_world_guard_invite + mov eax, arrivalTime3D + xor edx, edx + mov ecx, 90 + div ecx + cmp eax, 7 + jbe @F + mov eax, 7 +@@: + add eax, 8 + mov cityGuardLeft3D.frame, eax + jmp city_world_guard_right +city_world_guard_invite: + cmp arrivalState3D, ARRIVAL_ADMIT + jb city_world_guard_right + mov eax, arrivalTime3D + xor edx, edx + mov ecx, 120 + div ecx + add eax, 16 + cmp eax, 22 + jbe @F + mov eax, 22 +@@: + mov cityGuardLeft3D.frame, eax +city_world_guard_right: + mov eax, cityClock3D + add eax, 590 + xor edx, edx + mov ecx, 220 + div ecx + and eax, 7 + cmp arrivalState3D, ARRIVAL_PROFILE + jne @F + add eax, 24 +@@: + mov cityGuardRight3D.frame, eax + invoke DrawCityObject3D, OFFSET cityGuardLeft3D,0 + invoke DrawCityObject3D, OFFSET cityGuardRight3D,0 + ret +RenderCityGuards3D ENDP + CanWalkHall3D PROC uses esi ebx px:DWORD,py:DWORD cmp hallLevel3D,HALL_BOWLING jne @F @@ -1239,8 +1386,8 @@ fortune_collision_stairs: invoke UpperCanWalk3D,px,py ret @@: - cmp hallLevel3D, 0 - jne hall_collision_bunker + cmp hallLevel3D, 0 + jne hall_collision_bunker invoke FortuneEntranceCanWalk3D,px,py test eax,eax jz hall_collision_blocked @@ -1256,278 +1403,281 @@ fortune_collision_stairs: invoke JackboxCanWalk3D,px,py test eax,eax jz hall_collision_blocked - xor esi, esi -hall_collision_decor: - imul ebx, esi, SIZEOF CityProp3D - mov eax, px - sub eax, hallLoungeDecor3D[ebx].posX - test eax, eax - jns @F - neg eax -@@: - mov ecx, hallLoungeDecor3D[ebx].worldW - shr ecx, 1 - add ecx, 9830 - cmp eax, ecx - ja hall_collision_next_decor - mov eax, py - sub eax, hallLoungeDecor3D[ebx].posY - test eax, eax - jns @F - neg eax -@@: - cmp eax, FP_1*2/5 - jbe hall_collision_blocked -hall_collision_next_decor: - inc esi - cmp esi, HALL_DECOR_COUNT - jb hall_collision_decor - ; Stage and wings are solid: the audience stays in the cabaret's front aisle. - cmp px, 10*FP_1-9830 - jl hall_collision_stage_clear - cmp px, 22*FP_1+9830 - jg hall_collision_stage_clear - cmp py, 2*FP_1-9830 - jl hall_collision_stage_clear - cmp py, 5*FP_1+9830 - jle hall_collision_blocked -hall_collision_stage_clear: - cmp px, FP_1*47/4 - jl hall_collision_cabinets - cmp px, FP_1*49/4 - jg hall_collision_pool_divider - cmp py, 24*FP_1-9830 - jl hall_collision_cabinets - cmp py, FP_1*51/2+9830 - jle hall_collision_blocked - cmp py, FP_1*55/2-9830 - jl hall_collision_cabinets - cmp py, 30*FP_1+9830 - jle hall_collision_blocked -hall_collision_pool_divider: - cmp px, 23*FP_1-9830 - jl hall_collision_cabinets - cmp px, FP_1*116/5+9830 - jg hall_collision_cabinets - cmp py, 23*FP_1-9830 - jl hall_collision_cabinets - cmp py, 24*FP_1+9830 - jle hall_collision_blocked - cmp py, 26*FP_1-9830 - jl hall_collision_cabinets - cmp py, 29*FP_1+9830 - jle hall_collision_blocked -hall_collision_cabinets: - ; The work aisle is staff-only; player interaction is from the serving side. - cmp px, 3*FP_1-9830 - jl hall_collision_counter - cmp px, 9*FP_1+9830 - jg hall_collision_counter - cmp py, 21*FP_1-9830 - jl hall_collision_counter - cmp py, 24*FP_1+9830 - jle hall_collision_blocked -hall_collision_counter: - cmp px, 3*FP_1-9830 - jl hall_collision_dining - cmp px, 9*FP_1+9830 - jg hall_collision_pool - cmp py, 23*FP_1-9830 - jl hall_collision_clear - cmp py, 24*FP_1+9830 - jg hall_collision_dining - xor eax, eax - ret -hall_collision_pool: - cmp px, 26*FP_1-9830 - jl hall_collision_dining - cmp px, 28*FP_1+9830 - jg hall_collision_dining - cmp py, 24*FP_1-9830 - jl hall_collision_clear - cmp py, 26*FP_1+9830 - jg hall_collision_dining - xor eax, eax - ret -hall_collision_bunker: - cmp px, 14*FP_1-9830 - jl hall_collision_clear - cmp px, 20*FP_1+9830 - jg hall_collision_clear - cmp py, 14*FP_1-9830 - jl hall_collision_clear - cmp py, 15*FP_1+9830 - jg hall_collision_clear -hall_collision_blocked: - xor eax, eax - ret -hall_collision_clear: - mov eax, 1 - ret -hall_collision_dining: - cmp py, 26*FP_1+FP_1/3 - jl hall_collision_clear - cmp py, 29*FP_1+FP_HALF - jg hall_collision_clear - cmp px, 2*FP_1 - jl hall_collision_clear - cmp px, 5*FP_1 - jle hall_collision_blocked - cmp px, 8*FP_1 - jl hall_collision_clear - cmp px, 11*FP_1 - jle hall_collision_blocked - jmp hall_collision_clear -CanWalkHall3D ENDP - -RenderCityFacade3D PROC uses ebx esi - ; The original entrance artwork carries CASINO itself, mapped once across the doorway. - invoke DrawCityBoxSides3D,21*FP_1,24*FP_1,8*FP_1,8*FP_1+FP_1/5,0,FP_1*9/5,57 - invoke DrawCityVertical3D,1,8*FP_1+FP_1/5,21*FP_1,24*FP_1,0,FP_1*9/5,58 - invoke DrawCityBoxSides3D,FP_1*104/5,FP_1*106/5,8*FP_1,8*FP_1+FP_1*2/5,0,2*FP_1,103 - invoke DrawCityBoxSides3D,FP_1*119/5,FP_1*121/5,8*FP_1,8*FP_1+FP_1*2/5,0,2*FP_1,103 - invoke DrawCityBoxSides3D,FP_1*104/5,FP_1*121/5,8*FP_1,8*FP_1+FP_HALF,FP_1*9/5,2*FP_1,86 - invoke DrawCityHorizontal3D,FP_1*104/5,FP_1*121/5,8*FP_1,8*FP_1+FP_HALF,2*FP_1,85 - invoke DrawCityVertical3D,1,8*FP_1+FP_1*41/100,FP_1*101/5,FP_1*104/5,FP_1,FP_1*8/5,105 - invoke DrawCityVertical3D,1,8*FP_1+FP_1*41/100,FP_1*121/5,FP_1*124/5,FP_1,FP_1*8/5,105 - ; Recessed street windows, projecting bays and ledges are fixed world surfaces. - mov esi, 11 -hall_city_pilaster: - cmp esi, 20 - je hall_city_next_pilaster - cmp esi, 24 - je hall_city_next_pilaster - mov ebx, esi - shl ebx, 16 - lea eax, [ebx+FP_1/5] - invoke DrawCityBoxSides3D, ebx,eax,12*FP_1,12*FP_1+FP_1/6,0,5*FP_1,57 - lea eax, [ebx+FP_1/5] - invoke DrawCityBoxSides3D, ebx,eax,17*FP_1-FP_1/6,17*FP_1,0,5*FP_1,57 - lea eax, [ebx+FP_1/5] - lea edx, [ebx+FP_1*7/5] - invoke DrawCityBoxSides3D,eax,edx,FP_1*237/20,12*FP_1,FP_1/20,FP_1*13/10,57 - lea eax, [ebx+FP_1/5] - lea edx, [ebx+FP_1*7/5] - invoke DrawCityVertical3D,1,12*FP_1+FP_1/25,eax,edx,FP_1/20,FP_1*13/10,62 - lea eax, [ebx+FP_1/5] - lea edx, [ebx+FP_1*7/5] - invoke DrawCityBoxSides3D,eax,edx,12*FP_1,12*FP_1+FP_1/5,2*FP_1,FP_1*18/5,57 - lea eax, [ebx+FP_1/5] - lea edx, [ebx+FP_1*7/5] - invoke DrawCityVertical3D,1,12*FP_1+FP_1/5,eax,edx,2*FP_1,FP_1*18/5,106 - lea eax, [ebx+FP_1/5] - lea edx, [ebx+FP_1*7/5] - invoke DrawCityBoxSides3D,eax,edx,17*FP_1-FP_1/4,17*FP_1,2*FP_1,FP_1*18/5,57 - lea eax, [ebx+FP_1/5] - lea edx, [ebx+FP_1*7/5] - invoke DrawCityVertical3D,1,17*FP_1-FP_1/4,eax,edx,2*FP_1,FP_1*18/5,106 -hall_city_next_pilaster: - add esi, 4 - cmp esi, 29 - jb hall_city_pilaster - ret -RenderCityFacade3D ENDP - -UpdateHall3D PROC + xor esi, esi +hall_collision_decor: + imul ebx, esi, SIZEOF CityProp3D + mov eax, px + sub eax, hallLoungeDecor3D[ebx].posX + test eax, eax + jns @F + neg eax +@@: + mov ecx, hallLoungeDecor3D[ebx].worldW + shr ecx, 1 + add ecx, 9830 + cmp eax, ecx + ja hall_collision_next_decor + mov eax, py + sub eax, hallLoungeDecor3D[ebx].posY + test eax, eax + jns @F + neg eax +@@: + cmp eax, FP_1*2/5 + jbe hall_collision_blocked +hall_collision_next_decor: + inc esi + cmp esi, HALL_DECOR_COUNT + jb hall_collision_decor + ; Stage and wings are solid: the audience stays in the cabaret's front aisle. + cmp px, 10*FP_1-9830 + jl hall_collision_stage_clear + cmp px, 22*FP_1+9830 + jg hall_collision_stage_clear + cmp py, 2*FP_1-9830 + jl hall_collision_stage_clear + cmp py, 5*FP_1+9830 + jle hall_collision_blocked +hall_collision_stage_clear: + cmp px, FP_1*47/4 + jl hall_collision_cabinets + cmp px, FP_1*49/4 + jg hall_collision_pool_divider + cmp py, 24*FP_1-9830 + jl hall_collision_cabinets + cmp py, FP_1*51/2+9830 + jle hall_collision_blocked + cmp py, FP_1*55/2-9830 + jl hall_collision_cabinets + cmp py, 30*FP_1+9830 + jle hall_collision_blocked +hall_collision_pool_divider: + cmp px, 23*FP_1-9830 + jl hall_collision_cabinets + cmp px, FP_1*116/5+9830 + jg hall_collision_cabinets + cmp py, 23*FP_1-9830 + jl hall_collision_cabinets + cmp py, 24*FP_1+9830 + jle hall_collision_blocked + cmp py, 26*FP_1-9830 + jl hall_collision_cabinets + cmp py, 29*FP_1+9830 + jle hall_collision_blocked +hall_collision_cabinets: + ; The work aisle is staff-only; player interaction is from the serving side. + cmp px, 3*FP_1-9830 + jl hall_collision_counter + cmp px, 9*FP_1+9830 + jg hall_collision_counter + cmp py, 21*FP_1-9830 + jl hall_collision_counter + cmp py, 24*FP_1+9830 + jle hall_collision_blocked +hall_collision_counter: + cmp px, 3*FP_1-9830 + jl hall_collision_dining + cmp px, 9*FP_1+9830 + jg hall_collision_pool + cmp py, 23*FP_1-9830 + jl hall_collision_clear + cmp py, 24*FP_1+9830 + jg hall_collision_dining + xor eax, eax + ret +hall_collision_pool: + cmp px, 26*FP_1-9830 + jl hall_collision_dining + cmp px, 28*FP_1+9830 + jg hall_collision_dining + cmp py, 24*FP_1-9830 + jl hall_collision_clear + cmp py, 26*FP_1+9830 + jg hall_collision_dining + xor eax, eax + ret +hall_collision_bunker: + invoke UnderworldCanWalk3D,px,py + test eax,eax + jz hall_collision_blocked + cmp px, 14*FP_1-9830 + jl hall_collision_clear + cmp px, 20*FP_1+9830 + jg hall_collision_clear + cmp py, 14*FP_1-9830 + jl hall_collision_clear + cmp py, 15*FP_1+9830 + jg hall_collision_clear +hall_collision_blocked: + xor eax, eax + ret +hall_collision_clear: + mov eax, 1 + ret +hall_collision_dining: + cmp py, 26*FP_1+FP_1/3 + jl hall_collision_clear + cmp py, 29*FP_1+FP_HALF + jg hall_collision_clear + cmp px, 2*FP_1 + jl hall_collision_clear + cmp px, 5*FP_1 + jle hall_collision_blocked + cmp px, 8*FP_1 + jl hall_collision_clear + cmp px, 11*FP_1 + jle hall_collision_blocked + jmp hall_collision_clear +CanWalkHall3D ENDP + +RenderCityFacade3D PROC uses ebx esi + ; The original entrance artwork carries CASINO itself, mapped once across the doorway. + invoke DrawCityBoxSides3D,21*FP_1,24*FP_1,8*FP_1,8*FP_1+FP_1/5,0,FP_1*9/5,57 + invoke DrawCityVertical3D,1,8*FP_1+FP_1/5,21*FP_1,24*FP_1,0,FP_1*9/5,58 + invoke DrawCityBoxSides3D,FP_1*104/5,FP_1*106/5,8*FP_1,8*FP_1+FP_1*2/5,0,2*FP_1,103 + invoke DrawCityBoxSides3D,FP_1*119/5,FP_1*121/5,8*FP_1,8*FP_1+FP_1*2/5,0,2*FP_1,103 + invoke DrawCityBoxSides3D,FP_1*104/5,FP_1*121/5,8*FP_1,8*FP_1+FP_HALF,FP_1*9/5,2*FP_1,86 + invoke DrawCityHorizontal3D,FP_1*104/5,FP_1*121/5,8*FP_1,8*FP_1+FP_HALF,2*FP_1,85 + invoke DrawCityVertical3D,1,8*FP_1+FP_1*41/100,FP_1*101/5,FP_1*104/5,FP_1,FP_1*8/5,105 + invoke DrawCityVertical3D,1,8*FP_1+FP_1*41/100,FP_1*121/5,FP_1*124/5,FP_1,FP_1*8/5,105 + ; Recessed street windows, projecting bays and ledges are fixed world surfaces. + mov esi, 11 +hall_city_pilaster: + cmp esi, 20 + je hall_city_next_pilaster + cmp esi, 24 + je hall_city_next_pilaster + mov ebx, esi + shl ebx, 16 + lea eax, [ebx+FP_1/5] + invoke DrawCityBoxSides3D, ebx,eax,12*FP_1,12*FP_1+FP_1/6,0,5*FP_1,57 + lea eax, [ebx+FP_1/5] + invoke DrawCityBoxSides3D, ebx,eax,17*FP_1-FP_1/6,17*FP_1,0,5*FP_1,57 + lea eax, [ebx+FP_1/5] + lea edx, [ebx+FP_1*7/5] + invoke DrawCityBoxSides3D,eax,edx,FP_1*237/20,12*FP_1,FP_1/20,FP_1*13/10,57 + lea eax, [ebx+FP_1/5] + lea edx, [ebx+FP_1*7/5] + invoke DrawCityVertical3D,1,12*FP_1+FP_1/25,eax,edx,FP_1/20,FP_1*13/10,62 + lea eax, [ebx+FP_1/5] + lea edx, [ebx+FP_1*7/5] + invoke DrawCityBoxSides3D,eax,edx,12*FP_1,12*FP_1+FP_1/5,2*FP_1,FP_1*18/5,57 + lea eax, [ebx+FP_1/5] + lea edx, [ebx+FP_1*7/5] + invoke DrawCityVertical3D,1,12*FP_1+FP_1/5,eax,edx,2*FP_1,FP_1*18/5,106 + lea eax, [ebx+FP_1/5] + lea edx, [ebx+FP_1*7/5] + invoke DrawCityBoxSides3D,eax,edx,17*FP_1-FP_1/4,17*FP_1,2*FP_1,FP_1*18/5,57 + lea eax, [ebx+FP_1/5] + lea edx, [ebx+FP_1*7/5] + invoke DrawCityVertical3D,1,17*FP_1-FP_1/4,eax,edx,2*FP_1,FP_1*18/5,106 +hall_city_next_pilaster: + add esi, 4 + cmp esi, 29 + jb hall_city_pilaster + ret +RenderCityFacade3D ENDP + +UpdateHall3D PROC call UpdateCabaret3D call UpdateInteriorTravel3D - call UpdatePatrons3D + call UpdatePatrons3D call UpdateInteriorEye3D - ret -UpdateHall3D ENDP - -; Absolute route phase avoids accumulated movement drift and keeps walking FPS-independent. -UpdatePatrons3D PROC uses ebx esi edi - call UpdateNpcLife3D - ret -IF 0 - local wx:DWORD,wy:DWORD,phase:DWORD - cmp hallLevel3D, 0 - jne patron_update_done - mov eax, deltaTime3D - add eax, patronClock3D - xor edx, edx - mov ecx, 20000 - div ecx - mov patronClock3D, edx - xor esi, esi -patron_update_loop: - mov eax, esi - imul eax, 10000 - add eax, patronClock3D - xor edx, edx - mov ecx, 20000 - div ecx - mov eax, edx - xor edx, edx - mov ecx, 5000 - div ecx - mov phase, eax - mov eax, edx - imul eax, 4*FP_1 - xor edx, edx - div ecx - mov wx, 18*FP_1 - mov wy, 18*FP_1 - cmp phase, 0 - jne patron_route_south - add wx, eax - jmp patron_route_check -patron_route_south: - cmp phase, 1 - jne patron_route_west - mov wx, 22*FP_1 - shr eax, 1 - add wy, eax - jmp patron_route_check -patron_route_west: - mov wy, 20*FP_1 - cmp phase, 2 - jne patron_route_north - mov wx, 22*FP_1 - sub wx, eax - jmp patron_route_check -patron_route_north: - shr eax, 1 - sub wy, eax -patron_route_check: - invoke CanWalk3D,wx,wy - test eax, eax - jz patron_update_next - imul ebx, esi, SIZEOF CityProp3D - mov eax, wx - mov hallGuests3D[ebx].posX, eax - mov eax, wy - mov hallGuests3D[ebx].posY, eax - mov eax, patronClock3D - xor edx, edx - mov ecx, 220 - div ecx - and eax, 3 - lea eax, [eax+esi*4] - mov hallGuests3D[ebx].frame, eax -patron_update_next: - inc esi - cmp esi, 2 - jb patron_update_loop -patron_update_done: - call UpdateCasinoNpcMind - ret -ENDIF -UpdatePatrons3D ENDP - -RenderPatrons3D PROC uses esi - call RenderNpcLife3D - mov esi,8 -patron_render_loop: - imul eax, esi, SIZEOF CityProp3D - add eax, OFFSET hallGuests3D - invoke DrawCityObject3D,eax,0 - inc esi - cmp esi,12 - jb patron_render_loop - ret -RenderPatrons3D ENDP + ret +UpdateHall3D ENDP + +; Absolute route phase avoids accumulated movement drift and keeps walking FPS-independent. +UpdatePatrons3D PROC uses ebx esi edi + call UpdateNpcLife3D + ret +IF 0 + local wx:DWORD,wy:DWORD,phase:DWORD + cmp hallLevel3D, 0 + jne patron_update_done + mov eax, deltaTime3D + add eax, patronClock3D + xor edx, edx + mov ecx, 20000 + div ecx + mov patronClock3D, edx + xor esi, esi +patron_update_loop: + mov eax, esi + imul eax, 10000 + add eax, patronClock3D + xor edx, edx + mov ecx, 20000 + div ecx + mov eax, edx + xor edx, edx + mov ecx, 5000 + div ecx + mov phase, eax + mov eax, edx + imul eax, 4*FP_1 + xor edx, edx + div ecx + mov wx, 18*FP_1 + mov wy, 18*FP_1 + cmp phase, 0 + jne patron_route_south + add wx, eax + jmp patron_route_check +patron_route_south: + cmp phase, 1 + jne patron_route_west + mov wx, 22*FP_1 + shr eax, 1 + add wy, eax + jmp patron_route_check +patron_route_west: + mov wy, 20*FP_1 + cmp phase, 2 + jne patron_route_north + mov wx, 22*FP_1 + sub wx, eax + jmp patron_route_check +patron_route_north: + shr eax, 1 + sub wy, eax +patron_route_check: + invoke CanWalk3D,wx,wy + test eax, eax + jz patron_update_next + imul ebx, esi, SIZEOF CityProp3D + mov eax, wx + mov hallGuests3D[ebx].posX, eax + mov eax, wy + mov hallGuests3D[ebx].posY, eax + mov eax, patronClock3D + xor edx, edx + mov ecx, 220 + div ecx + and eax, 3 + lea eax, [eax+esi*4] + mov hallGuests3D[ebx].frame, eax +patron_update_next: + inc esi + cmp esi, 2 + jb patron_update_loop +patron_update_done: + call UpdateCasinoNpcMind + ret +ENDIF +UpdatePatrons3D ENDP + +RenderPatrons3D PROC uses esi + call RenderNpcLife3D + mov esi,8 +patron_render_loop: + imul eax, esi, SIZEOF CityProp3D + add eax, OFFSET hallGuests3D + invoke DrawCityObject3D,eax,0 + inc esi + cmp esi,12 + jb patron_render_loop + ret +RenderPatrons3D ENDP include src_graphics\world_dressing.inc include src_graphics\terminal.inc include src_graphics\hall_expansion.inc diff --git a/src_graphics/heist_data.inc b/src_graphics/heist_data.inc new file mode 100644 index 0000000..8616d5e --- /dev/null +++ b/src_graphics/heist_data.inc @@ -0,0 +1,68 @@ +; ============================================================================== +; GRAND HEIST SYSTEM DATA (CP1251) +; ============================================================================== + +MODE_HEIST equ 34 + +BeginHeistPlanning3D PROTO +HandleHeist3D PROTO +RenderHeist3D PROTO + +.data +ALIGN 4 +heistCrewBartender dd 0 ; 0=not ready, 1=ready +heistCrewSinger dd 0 ; 0=not ready, 1=ready +heistCrewFortune dd 0 ; 0=not ready, 1=ready +heistCrewHacker dd 0 ; 0=not ready, 1=ready + +heistPhase dd 0 ; 0=Planning screen, 1=Show distraction, 2=Safe cracking, 3=Victory +heistComplete dd 0 ; one-time reward guard +heistDialPos dd 0 ; 0..99 +heistDigitsFound dd 0 ; 0..3 +heistCode dd 24, 71, 45 ; combination code +heistDistractionTimer dd 0 ; ticks +heistSafeFeedback dd 0 ; message pointer + +szHeistTitle db 206,207,197,208,192,214,200,223,58,32,206,195 + db 208,192,193,203,197,205,200,197,32,194,197,195 + db 192,209,192,0 +szHeistStatusReady db 195,206,210,206,194,0 +szHeistStatusNot db 200,217,197,204,0 +szHeistPromptStart db 194,209,223,32,202,206,204,192,205,196,192,32 + db 194,32,209,193,206,208,197,33,32,91,69,78 + db 84,69,82,93,32,45,32,205,192,215,192,210 + db 220,32,206,207,197,208,192,214,200,222,0 +szHeistPromptGather db 194,197,208,193,211,201,210,197,32,202,206,204 + db 192,205,196,211,32,194,32,199,192,203,197,58 + db 32,193,192,208,204,197,205,44,32,207,197,194 + db 200,214,192,44,32,210,192,208,206,44,32,213 + db 192,202,197,208,0 +szHeistShowScene db 216,206,211,32,194,32,202,192,193,192,208,197 + db 32,205,192,215,192,203,206,209,220,33,32,194 + db 209,223,32,206,213,208,192,205,192,32,206,210 + db 194,203,197,215,197,205,192,33,0 +szHeistVaultPrompt db 194,199,203,206,204,32,209,197,201,212,192,58 + db 32,65,47,68,32,45,32,202,208,211,210,200 + db 210,220,44,32,207,208,206,193,197,203,32,45 + db 32,207,208,206,194,197,208,200,210,220,0 +szHeistClickHeard db 42,210,206,205,202,200,201,32,217,197,203,215 + db 206,202,32,216,197,209,210,197,208,205,200,42 + db 32,40,214,232,244,240,224,32,239,238,228,238 + db 225,240,224,237,224,33,41,0 +szHeistClickWrong db 42,195,203,211,213,206,201,32,209,210,211,202 + db 42,32,40,214,232,244,240,224,32,237,229,32 + db 239,238,228,238,248,235,224,41,0 +szHeistSuccess db 209,197,201,212,32,208,192,209,207,192,213,205 + db 211,210,33,32,202,211,216,58,32,36,49,48 + db 48,48,48,48,48,32,200,32,199,206,203,206 + db 210,192,223,32,202,206,203,206,196,192,33,0 +szHeistEscapeRoof db 194,197,208,210,206,203,197,210,32,209,32,202 + db 208,219,216,200,32,211,205,206,209,200,210,32 + db 194,192,209,32,194,32,205,197,206,205,206,194 + db 211,222,32,205,206,215,220,33,0 +szHeistCrewLabel1 db "1. ",193,192,208,204,197,205,58,32,0 ; "1. Бармен: " +szHeistCrewLabel2 db "2. ",207,197,194,200,214,192,58,32,0 ; "2. Певица: " +szHeistCrewLabel3 db "3. ",195,192,196,192,203,202,192,58,32,0 ; "3. Гадалка: " +szHeistCrewLabel4 db "4. ",213,192,202,197,208,58,32,0 ; "4. Хакер: " +szHeistRecruitKey db "[1-4] - ",207,238,239,251,242,232,242,252,241,255,32 + db 226,229,240,225,238,226,224,242,252,0 ; "[1-4] - попытаться завербовать" diff --git a/src_graphics/heist_hq.inc b/src_graphics/heist_hq.inc new file mode 100644 index 0000000..7cf740f --- /dev/null +++ b/src_graphics/heist_hq.inc @@ -0,0 +1,772 @@ +HQLoad3D PROC uses esi edi + invoke LoadAnimPack3D,OFFSET hqVanArt,OFFSET hqVanPath + test eax,eax + jz hq_load_done + invoke LoadAnimPack3D,OFFSET hqActorsArt,OFFSET hqActorsPath + test eax,eax + jz hq_load_done + invoke LoadAnimPack3D,OFFSET hqWeaponArt,OFFSET hqWeaponPath + test eax,eax + jz hq_load_done + invoke LoadAnimPack3D,OFFSET hqPropsArt,OFFSET hqPropsPath + test eax,eax + jz hq_load_done + invoke LoadAnimPack3D,OFFSET hqMaterialsArt,OFFSET hqMaterialsPath + test eax,eax + jz hq_load_done + cmp hqMaterialsArt.imageWidth,128 + jne hq_load_bad + cmp hqMaterialsArt.height,128 + jne hq_load_bad + cmp hqMaterialsArt.frames,4 + jne hq_load_bad + mov esi,hqMaterialsArt.pixels + mov edi,OFFSET texturesBuffer+197*65536 + mov ecx,4*128*128 + rep movsd + mov eax,1 + jmp hq_load_done +hq_load_bad: + xor eax,eax +hq_load_done: + ret +HQLoad3D ENDP + +FreeHQAssets3D PROC + invoke FreeAnimPack3D,OFFSET hqVanArt + invoke FreeAnimPack3D,OFFSET hqActorsArt + invoke FreeAnimPack3D,OFFSET hqWeaponArt + invoke FreeAnimPack3D,OFFSET hqPropsArt + invoke FreeAnimPack3D,OFFSET hqMaterialsArt + ret +FreeHQAssets3D ENDP + +BeginHQMission3D PROC + cmp hqActive,0 + jne hq_begin_done + cmp heistComplete,0 + jne hq_begin_done + call HQLoad3D + test eax,eax + jz hq_begin_done + mov eax,playerX + mov hqOldX,eax + mov eax,playerY + mov hqOldY,eax + mov eax,playerAngle + mov hqOldAngle,eax + mov eax,worldMap3D + mov hqOldMap,eax + mov eax,floorTexture3D + mov hqOldFloor,eax + mov eax,hallLevel3D + mov hqOldLevel,eax + mov eax,viewEye3D + mov hqOldEye,eax + mov eax,viewCeiling3D + mov hqOldCeiling,eax + mov eax,viewHorizon3D + mov hqOldHorizon,eax + mov eax,outdoorRender3D + mov hqOldOutdoor,eax + mov hqActive,1 + mov hqLoot,0 + mov hqFireHeld,0 + mov hqRideTime,0 + mov heistPhase,6 + mov worldMap3D,OFFSET hqRoadMap + mov hallLevel3D,98 + mov floorTexture3D,199 + mov viewEye3D,FP_1 + mov viewCeiling3D,4*FP_1 + mov viewHorizon3D,HALF_H + mov outdoorRender3D,0 + mov engineMode,MODE_HEIST + call StopJukeboxTrack3D + call ClearKeys3D +hq_begin_done: + ret +BeginHQMission3D ENDP + +HQDeploy3D PROC uses esi edi ebx + mov esi,OFFSET hqMapTemplate + mov edi,OFFSET hfMap + mov ecx,256 + rep movsd + mov esi,OFFSET hqSeeds + mov edi,OFFSET hqEnemies + xor ebx,ebx +hq_deploy_guard: + lodsd + mov [edi].HFEnemy.x,eax + lodsd + mov [edi].HFEnemy.y,eax + lodsd + mov [edi].HFEnemy.kind,eax + mov [edi].HFEnemy.hp,60 + cmp ebx,6 + jb @F + mov [edi].HFEnemy.hp,0 +@@: + mov [edi].HFEnemy.cooldown,12 + mov [edi].HFEnemy.timer,0 + mov [edi].HFEnemy.pose,0 + add edi,SIZEOF HFEnemy + inc ebx + cmp ebx,HQ_GUARDS + jb hq_deploy_guard + mov hqTeamX,14*FP_1 + mov hqTeamX[4],16*FP_1 + mov hqTeamX[8],18*FP_1 + mov hqTeamY,27*FP_1 + mov hqTeamY[4],27*FP_1 + mov hqTeamY[8],27*FP_1 + mov hqHealth,100 + mov hqMagazine,12 + mov hqMagazine[4],30 + mov hqReserve,24 + mov hqReserve[4],90 + mov hqAlarm,0 + mov hqAlarmTime,0 + mov hqSuspicion,0 + mov hqReinforced,0 + mov hqAccess,0 + mov hqIntel,0 + mov hqLoot,0 + mov hqCameras,1 + mov hqTicks,0 + mov hqAccumulator,0 + mov hqWeapon,0 + mov hqReload,0 + mov hqCooldown,0 + mov hqFlash,0 + mov hqHurt,0 + mov hqAction,0 + mov hqActionTime,0 + mov hqTeamCooldown,0 + mov hqTeamFollow,0 + mov hqHint,OFFSET hqGoalTerminal + mov playerX,FP_1*165/10 + mov playerY,FP_1*265/10 + mov playerAngle,384 + mov worldMap3D,OFFSET hfMap + mov floorTexture3D,82 + mov viewEye3D,FP_1 + mov viewCeiling3D,FP_1*5/2 + mov heistPhase,7 + cmp hqApproach,0 + je @F + mov hqWeapon,1 + call HQRaiseAlarm3D +@@: + call ClearKeys3D + call UpdateCamera3D + ret +HQDeploy3D ENDP + +HQLeave3D PROC + cmp hqActive,0 + je hq_leave_done + mov eax,hqOldX + mov playerX,eax + mov eax,hqOldY + mov playerY,eax + mov eax,hqOldAngle + mov playerAngle,eax + mov eax,hqOldMap + mov worldMap3D,eax + mov eax,hqOldFloor + mov floorTexture3D,eax + mov eax,hqOldLevel + mov hallLevel3D,eax + mov eax,hqOldEye + mov viewEye3D,eax + mov eax,hqOldCeiling + mov viewCeiling3D,eax + mov eax,hqOldHorizon + mov viewHorizon3D,eax + mov eax,hqOldOutdoor + mov outdoorRender3D,eax + mov hqActive,0 + mov hqFireHeld,0 + mov paused3D,0 + mov engineMode,MODE_WALK + call ClearKeys3D + call UpdateCamera3D +hq_leave_done: + ret +HQLeave3D ENDP + +HQFinishTrip3D PROC + cmp hqActive,1 + jne hq_finish_done + cmp heistPhase,8 + jne hq_finish_restore + cmp hqLoot,1 + jne hq_finish_restore + cmp heistComplete,0 + jne hq_finish_restore + add bankroll,1000000 + cmp bankroll,1000000000 + jbe @F + mov bankroll,1000000000 +@@: + mov heistComplete,1 + bts ownedBacks3D,3 + mov selectedBack3D,3 + call SaveProgress3D + invoke CopyString3D,OFFSET hqReturnText,OFFSET flashMessage + mov flashTimer,240 +hq_finish_restore: + call HQLeave3D +hq_finish_done: + ret +HQFinishTrip3D ENDP + +HQRaiseAlarm3D PROC + cmp hqAlarm,0 + jne @F + mov hqAlarm,1 + mov hqAlarmTime,0 + mov hqSuspicion,100 + mov hqTeamFollow,1 + invoke PlayCasinoSound3D,OFFSET soundSkillMiss,0,1 +@@: + ret +HQRaiseAlarm3D ENDP + +; Generic world collision is shared with the native raycaster. +HQMoveActor3D PROC uses esi ebx object:DWORD,stepDX:DWORD,stepDY:DWORD + mov esi,object + mov ebx,[esi].HFEnemy.x + add ebx,stepDX + invoke CanWalk3D,ebx,[esi].HFEnemy.y + test eax,eax + jz @F + mov [esi].HFEnemy.x,ebx +@@: + mov ebx,[esi].HFEnemy.y + add ebx,stepDY + invoke CanWalk3D,[esi].HFEnemy.x,ebx + test eax,eax + jz @F + mov [esi].HFEnemy.y,ebx +@@: + ret +HQMoveActor3D ENDP + +HQEnemyDamage3D PROC enemy:DWORD,damage:DWORD + mov edx,enemy + mov eax,damage + sub [edx].HFEnemy.hp,eax + cmp [edx].HFEnemy.hp,0 + jg @F + mov [edx].HFEnemy.hp,0 + mov [edx].HFEnemy.pose,3 +@@: + ret +HQEnemyDamage3D ENDP + +HQFire3D PROC uses ebx esi edi + local target:DWORD,best:DWORD + cmp heistPhase,7 + jne hq_fire_done + cmp hqCooldown,0 + jg hq_fire_done + cmp hqReload,0 + jg hq_fire_done + mov ebx,hqWeapon + cmp hqMagazine[ebx*4],0 + je hq_fire_done + dec hqMagazine[ebx*4] + mov hqCooldown,350 + mov hqFlash,90 + cmp ebx,0 + je @F + mov hqCooldown,160 + call HQRaiseAlarm3D +@@: + mov eax,OFFSET hqGunSound + cmp hqWeapon,0 + je @F + mov eax,OFFSET hqRifleSound +@@: + invoke PlayCasinoSound3D,eax,0,1 + mov target,0 + mov best,12*FP_1 + mov esi,OFFSET hqEnemies + mov edi,HQ_GUARDS +hq_fire_candidate: + cmp [esi].HFEnemy.hp,0 + jle hq_fire_next + invoke ProjectCityPoint3D,[esi].HFEnemy.x,[esi].HFEnemy.y + cmp edx,FP_1/3 + jle hq_fire_next + cmp edx,best + jae hq_fire_next + sub eax,320 + jns @F + neg eax +@@: + cmp eax,30 + ja hq_fire_next + push edx + invoke HFLineClear,playerX,playerY,[esi].HFEnemy.x,[esi].HFEnemy.y + pop edx + test eax,eax + jz hq_fire_next + mov best,edx + mov target,esi +hq_fire_next: + add esi,SIZEOF HFEnemy + dec edi + jnz hq_fire_candidate + cmp target,0 + je hq_fire_done + mov eax,60 + cmp hqWeapon,0 + je @F + mov eax,35 +@@: + invoke HQEnemyDamage3D,target,eax +hq_fire_done: + ret +HQFire3D ENDP + +HQUse3D PROC + invoke HFDistance,playerX,playerY,hqVanObject.posX,hqVanObject.posY + cmp eax,FP_1*9/5 + ja hq_use_terminal + cmp hqLoot,1 + jne hq_use_done + mov heistPhase,8 + mov hqRideTime,0 + mov hqFireHeld,0 + mov worldMap3D,OFFSET hqRoadMap + mov floorTexture3D,199 + call ClearKeys3D + ret +hq_use_terminal: + invoke HFDistance,playerX,playerY,hqTerminalObject.posX,hqTerminalObject.posY + cmp eax,FP_1*9/5 + ja hq_use_intel + invoke HFLineClear,playerX,playerY,hqTerminalObject.posX,hqTerminalObject.posY + test eax,eax + jz hq_use_done + cmp hqAccess,0 + jne hq_use_done + mov hqAction,1 + mov hqActionTime,1500 + ret +hq_use_intel: + invoke HFDistance,playerX,playerY,hqIntelObject.posX,hqIntelObject.posY + cmp eax,FP_1*3/2 + ja hq_use_door + invoke HFLineClear,playerX,playerY,hqIntelObject.posX,hqIntelObject.posY + test eax,eax + jz hq_use_done + mov hqIntel,1 + ret +hq_use_door: + cmp hqAccess,0 + jne hq_use_safe + invoke HFDistance,playerX,playerY,19*FP_1,FP_1*85/10 + cmp eax,2*FP_1 + ja hq_use_done + mov hqAction,2 + mov hqActionTime,10000 + call HQRaiseAlarm3D + ret +hq_use_safe: + cmp hqLoot,0 + jne hq_use_done + invoke HFDistance,playerX,playerY,hqSafeObject.posX,hqSafeObject.posY + cmp eax,FP_1*9/5 + ja hq_use_done + invoke HFLineClear,playerX,playerY,hqSafeObject.posX,hqSafeObject.posY + test eax,eax + jz hq_use_done + mov heistPhase,2 + mov heistDigitsFound,0 + mov heistDialPos,0 + mov heistSafeFeedback,0 + mov uwHeistTimer,120000 + mov hqFireHeld,0 + call ClearKeys3D +hq_use_done: + ret +HQUse3D ENDP + +HandleHQMission3D PROC uses ebx + cmp heistPhase,6 + je hq_handle_drive + cmp heistPhase,8 + je hq_handle_drive + cmp heistPhase,9 + je hq_handle_failed + cmp heistPhase,5 + jne @F + call HQRaiseAlarm3D + mov heistPhase,7 +@@: + mov viewEye3D,FP_1 + cmp keys3D[11h],0 + je @F + mov viewEye3D,FP_1*3/5 +@@: + call HandlePlayerInput + invoke Pressed3D,31h + test eax,eax + jz @F + mov hqWeapon,0 +@@: + invoke Pressed3D,32h + test eax,eax + jz @F + mov hqWeapon,1 +@@: + invoke Pressed3D,46h + test eax,eax + jz @F + xor hqTeamFollow,1 +@@: + invoke Pressed3D,52h + test eax,eax + jz @F + cmp hqReload,0 + jne @F + mov ebx,hqWeapon + cmp hqReserve[ebx*4],0 + je @F + mov hqReloadWeapon,ebx + mov hqReload,1000 +@@: + call HQSimulate3D + cmp heistPhase,7 + jne hq_handle_done + invoke Pressed3D,45h + test eax,eax + jz @F + call HQUse3D +@@: + mov eax,mouseClick3D + or eax,hqFireHeld + movzx ecx,keys3D[20h] + or eax,ecx + mov mouseClick3D,0 + test eax,eax + jz hq_handle_done + call HQFire3D + ret +hq_handle_drive: + mov eax,deltaTime3D + add hqRideTime,eax + cmp hqRideTime,6000 + jb hq_handle_done + cmp heistPhase,6 + jne @F + call HQDeploy3D + ret +@@: + call HQFinishTrip3D + ret +hq_handle_failed: + invoke Pressed3D,0Dh + test eax,eax + jz hq_handle_done + call HQLeave3D +hq_handle_done: + ret +HandleHQMission3D ENDP + +; 20 Hz guards, detection, support fire and timed hacking/drilling. +HQSimulate3D PROC uses ebx esi edi + mov eax,deltaTime3D + cmp eax,250 + jbe @F + mov eax,250 +@@: + add hqAccumulator,eax + sub hqCooldown,eax + jns @F + mov hqCooldown,0 +@@: + sub hqFlash,eax + jns @F + mov hqFlash,0 +@@: + sub hqHurt,eax + jns @F + mov hqHurt,0 +@@: + cmp hqReload,0 + jle hq_sim_loop + sub hqReload,eax + jg hq_sim_loop + mov ebx,hqReloadWeapon + mov ecx,12 + test ebx,ebx + jz @F + mov ecx,30 +@@: + sub ecx,hqMagazine[ebx*4] + cmp ecx,hqReserve[ebx*4] + jbe @F + mov ecx,hqReserve[ebx*4] +@@: + add hqMagazine[ebx*4],ecx + sub hqReserve[ebx*4],ecx + mov hqReload,0 +hq_sim_loop: + cmp hqAccumulator,50 + jb hq_sim_done + sub hqAccumulator,50 + call HQTick3D + cmp heistPhase,9 + jne hq_sim_loop + mov hqAccumulator,0 +hq_sim_done: + ret +HQSimulate3D ENDP + +HQTick3D PROC uses ebx esi edi + local distance:DWORD,stepDX:DWORD,stepDY:DWORD + inc hqTicks + mov hqSeen,0 + cmp hqAction,0 + je hq_tick_guards + mov ecx,hqTerminalObject.posX + mov edx,hqTerminalObject.posY + cmp hqAction,1 + je @F + mov ecx,19*FP_1 + mov edx,FP_1*85/10 +@@: + invoke HFDistance,playerX,playerY,ecx,edx + cmp eax,2*FP_1 + jb @F + mov hqAction,0 + jmp hq_tick_guards +@@: + sub hqActionTime,50 + jg hq_tick_guards + mov hqAction,0 + mov hqAccess,1 + mov hqCameras,0 + mov hfMap[8*32+19],0 + mov hfMap[9*32+19],0 +hq_tick_guards: + mov esi,OFFSET hqEnemies + mov edi,HQ_GUARDS +hq_guard_loop: + cmp [esi].HFEnemy.hp,0 + jle hq_guard_next + mov [esi].HFEnemy.pose,0 + cmp [esi].HFEnemy.cooldown,0 + jle @F + dec [esi].HFEnemy.cooldown +@@: + invoke HFDistance,playerX,playerY,[esi].HFEnemy.x,[esi].HFEnemy.y + mov distance,eax + cmp eax,10*FP_1 + ja hq_guard_patrol + invoke HFLineClear,playerX,playerY,[esi].HFEnemy.x,[esi].HFEnemy.y + test eax,eax + jz hq_guard_patrol + cmp hqAlarm,0 + jne hq_guard_attack + mov eax,playerX + sub eax,[esi].HFEnemy.x + sar eax,8 + mov ecx,[esi].HFEnemy.kind + mov edx,tableCos[ecx*4] + sar edx,8 + imul eax,edx + mov ebx,eax + mov eax,playerY + sub eax,[esi].HFEnemy.y + sar eax,8 + mov edx,tableSin[ecx*4] + sar edx,8 + imul eax,edx + add eax,ebx + mov ecx,distance + sar ecx,1 + cmp eax,ecx + jl hq_guard_patrol + mov hqSeen,1 + jmp hq_guard_patrol +hq_guard_attack: + mov [esi].HFEnemy.pose,2 + cmp distance,7*FP_1 + ja hq_guard_chase + cmp [esi].HFEnemy.cooldown,0 + jg hq_guard_next + mov [esi].HFEnemy.cooldown,20 + sub hqHealth,6 + mov hqHurt,120 + cmp hqHealth,0 + jg hq_guard_next + mov hqHealth,0 + mov heistPhase,9 + mov hqFireHeld,0 + ret +hq_guard_chase: + mov eax,playerX + sub eax,[esi].HFEnemy.x + mov ecx,1400 + imul ecx + idiv distance + mov stepDX,eax + mov eax,playerY + sub eax,[esi].HFEnemy.y + mov ecx,1400 + imul ecx + idiv distance + invoke HQMoveActor3D,esi,stepDX,eax + jmp hq_guard_next +hq_guard_patrol: + cmp hqAlarm,0 + jne hq_guard_chase + inc [esi].HFEnemy.timer + cmp [esi].HFEnemy.timer,80 + jb @F + mov [esi].HFEnemy.timer,0 + add [esi].HFEnemy.kind,256 + and [esi].HFEnemy.kind,511 +@@: + mov ecx,[esi].HFEnemy.kind + mov eax,tableCos[ecx*4] + imul eax,700 + sar eax,16 + mov stepDX,eax + mov eax,tableSin[ecx*4] + imul eax,700 + sar eax,16 + invoke HQMoveActor3D,esi,stepDX,eax + mov eax,hqTicks + shr eax,2 + and eax,1 + mov [esi].HFEnemy.pose,eax +hq_guard_next: + add esi,SIZEOF HFEnemy + dec edi + jnz hq_guard_loop + ; A visible ceiling camera covers the central corridor until hacked. + cmp hqCameras,0 + je hq_detection_finish + cmp playerY,FP_1*115/10 + jb hq_detection_finish + cmp playerY,18*FP_1 + ja hq_detection_finish + cmp playerX,14*FP_1 + jb hq_detection_finish + cmp playerX,18*FP_1 + ja hq_detection_finish + invoke HFLineClear,playerX,playerY,hqCameraObject.posX,hqCameraObject.posY + test eax,eax + jz hq_detection_finish + mov hqSeen,1 +hq_detection_finish: + cmp hqAlarm,0 + jne hq_alarm_tick + cmp hqSeen,0 + je hq_detection_decay + mov eax,5 + cmp keys3D[11h],0 + je @F + mov eax,2 +@@: + add hqSuspicion,eax + cmp hqSuspicion,100 + jb hq_tick_team + call HQRaiseAlarm3D + jmp hq_tick_team +hq_detection_decay: + sub hqSuspicion,3 + jns hq_tick_team + mov hqSuspicion,0 + jmp hq_tick_team +hq_alarm_tick: + add hqAlarmTime,50 + cmp hqAlarmTime,15000 + jb hq_tick_team + cmp hqReinforced,0 + jne hq_tick_team + mov hqReinforced,1 + mov esi,OFFSET hqEnemies+6*SIZEOF HFEnemy + mov ecx,4 +@@: + mov [esi].HFEnemy.hp,80 + add esi,SIZEOF HFEnemy + loop @B +hq_tick_team: + call HQTeamTick3D + ret +HQTick3D ENDP + +HQTeamTick3D PROC uses ebx esi edi + local distance:DWORD,nx:DWORD,ny:DWORD + cmp hqTeamFollow,0 + je hq_team_done + xor esi,esi +hq_team_loop: + invoke HFDistance,playerX,playerY,hqTeamX[esi*4],hqTeamY[esi*4] + mov distance,eax + cmp eax,3*FP_1 + jbe hq_team_next + mov eax,playerX + sub eax,hqTeamX[esi*4] + mov ecx,1800 + imul ecx + idiv distance + add eax,hqTeamX[esi*4] + mov nx,eax + mov eax,playerY + sub eax,hqTeamY[esi*4] + mov ecx,1800 + imul ecx + idiv distance + add eax,hqTeamY[esi*4] + mov ny,eax + invoke CanWalk3D,nx,hqTeamY[esi*4] + test eax,eax + jz @F + mov eax,nx + mov hqTeamX[esi*4],eax +@@: + invoke CanWalk3D,hqTeamX[esi*4],ny + test eax,eax + jz hq_team_next + mov eax,ny + mov hqTeamY[esi*4],eax +hq_team_next: + inc esi + cmp esi,3 + jb hq_team_loop + cmp hqAlarm,0 + je hq_team_done + inc hqTeamCooldown + cmp hqTeamCooldown,20 + jb hq_team_done + mov hqTeamCooldown,0 + mov esi,OFFSET hqEnemies + mov edi,HQ_GUARDS +hq_team_target: + cmp [esi].HFEnemy.hp,0 + jle hq_team_target_next + invoke HFDistance,hqTeamX,hqTeamY,[esi].HFEnemy.x,[esi].HFEnemy.y + cmp eax,7*FP_1 + ja hq_team_target_next + invoke HFLineClear,hqTeamX,hqTeamY,[esi].HFEnemy.x,[esi].HFEnemy.y + test eax,eax + jz hq_team_target_next + invoke HQEnemyDamage3D,esi,25 + jmp hq_team_done +hq_team_target_next: + add esi,SIZEOF HFEnemy + dec edi + jnz hq_team_target +hq_team_done: + ret +HQTeamTick3D ENDP diff --git a/src_graphics/heist_hq_data.inc b/src_graphics/heist_hq_data.inc new file mode 100644 index 0000000..d33505e --- /dev/null +++ b/src_graphics/heist_hq_data.inc @@ -0,0 +1,133 @@ +; Rival owners' HQ. One game runtime: MASM raycaster, input, combat and AI. +BeginHQMission3D PROTO +HandleHQMission3D PROTO +RenderHQMission3D PROTO +HQLeave3D PROTO +HQFinishTrip3D PROTO +HQSimulate3D PROTO +HQDeploy3D PROTO +HQRaiseAlarm3D PROTO +HQFire3D PROTO +HQUse3D PROTO +FreeHQAssets3D PROTO +include src_graphics\heist_hq_map.inc +HQ_GUARDS equ 10 +.data +ALIGN 4 +hqActive dd 0 +hqApproach dd 0 ; 0 stealth, 1 assault +hqAlarm dd 0 +hqSuspicion dd 0 +hqHealth dd 100 +hqLoot dd 0 +hqAccess dd 0 +hqIntel dd 0 +hqCameras dd 1 +hqRideTime dd 0 +hqAccumulator dd 0 +hqAlarmTime dd 0 +hqReinforced dd 0 +hqTicks dd 0 +hqWeapon dd 0 +hqMagazine dd 12,30 +hqReserve dd 24,90 +hqReload dd 0 +hqReloadWeapon dd 0 +hqCooldown dd 0 +hqFlash dd 0 +hqHurt dd 0 +hqFireHeld dd 0 +hqTeamFollow dd 0 +hqTeamCooldown dd 0 +hqAction dd 0 ; 1 terminal, 2 drill +hqActionTime dd 0 +hqSeen dd 0 +hqOldX dd 0 +hqOldY dd 0 +hqOldAngle dd 0 +hqOldMap dd 0 +hqOldFloor dd 0 +hqOldLevel dd 0 +hqOldEye dd 0 +hqOldCeiling dd 0 +hqOldHorizon dd 0 +hqOldOutdoor dd 0 +hqHint dd 0 +hqGunSound db "assets\hell\dspistol.wav",0 +hqRifleSound db "assets\hell\dsshotgn.wav",0 +hqVanArt AnimPack3D <> +hqActorsArt AnimPack3D <> +hqWeaponArt AnimPack3D <> +hqPropsArt AnimPack3D <> +hqMaterialsArt AnimPack3D <> +hqMaterialsPath db "assets\animations\hall\heist-materials-v1.bin",0 +hqVanPath db "assets\animations\hall\heist-van-v1.bin",0 +hqActorsPath db "assets\animations\hall\heist-actors-v1.bin",0 +hqWeaponPath db "assets\animations\hall\heist-weapons-v1.bin",0 +hqPropsPath db "assets\animations\hall\heist-props-v1.bin",0 +hqObject CityProp3D <0,0,FP_1*13/10,FP_1*17/10,0,OFFSET hqActorsArt> +hqVanObject CityProp3D +hqTerminalObject CityProp3D <9*FP_1,FP_1*135/10,FP_1,FP_1*6/5,1,OFFSET hqPropsArt> +hqSafeObject CityProp3D +hqIntelObject CityProp3D <8*FP_1,7*FP_1,FP_1,FP_1*3/5,2,OFFSET hqPropsArt,FP_1/2> +hqCameraObject CityProp3D +hqSeeds dd 12*FP_1,20*FP_1,128,19*FP_1,18*FP_1,128 + dd 10*FP_1,14*FP_1,0,15*FP_1,12*FP_1,128 + dd 10*FP_1,7*FP_1,0,23*FP_1,10*FP_1,384 + dd 9*FP_1,27*FP_1,0,22*FP_1,27*FP_1,256 + dd 11*FP_1,28*FP_1,0,21*FP_1,28*FP_1,256 +hqTeamX dd 14*FP_1,16*FP_1,18*FP_1 +hqTeamY dd 27*FP_1,27*FP_1,27*FP_1 +hqTitle db 216,210,192,193,32,202,206,205,202,211,208,197,205,210,192,32,47,32,194,219,203,192,199,202 + db 192,0 +hqStealthText db 209,210,197,203,209,32,47,32,206,193,205,192,208,211,198,197,205,200,197,0 +hqAlarmText db 210,208,197,194,206,195,192,32,47,32,216,210,211,208,204,0 +hqApproachStealth db 53,58,32,207,206,196,213,206,196,32,151,32,209,210,197,203,209,0 +hqApproachAssault db 53,58,32,207,206,196,213,206,196,32,151,32,216,210,211,208,204,0 +hqGoalTerminal db 214,197,203,220,58,32,210,197,208,204,200,205,192,203,32,200,203,200,32,194,199,203,206,204 + db 32,196,194,197,208,200,0 +hqGoalVault db 214,197,203,220,58,32,213,208,192,205,200,203,200,217,197,32,47,32,69,32,211,32,209,197 + db 201,212,192,0 +hqGoalEscape db 196,206,193,219,215,192,32,211,32,194,192,209,32,47,32,202,32,204,192,216,200,205,197,32 + db 47,32,69,0 +hqWorkingText db 194,199,203,206,204,32,47,32,206,209,210,192,203,206,209,220,32,209,197,202,58,0 +hqIntelText db 202,206,196,32,200,199,32,192,208,213,200,194,192,58,32,50,52,32,151,32,55,49,32,151 + db 32,52,53,0 +hqIntelHint db 69,58,32,199,192,193,208,192,210,220,32,196,206,202,211,204,197,205,210,219,0 +hqTeamWaitText db 70,58,32,202,206,204,192,205,196,192,32,198,196,168,210,32,211,32,204,192,216,200,205,219 + db 0 +hqTeamFollowText db 70,58,32,202,206,204,192,205,196,192,32,207,208,200,202,208,219,194,192,197,210,0 +hqHealthText db 72,80,0 +hqAmmoText db 207,192,210,208,58,0 +hqSlashText db 47,0 +hqControlsText db 87,65,83,68,32,47,32,204,219,216,220,32,47,32,203,202,204,32,47,32,69,32,47,32 + db 82,32,47,32,67,84,82,76,32,47,32,49,45,50,0 +hqSafeText db 209,197,201,212,32,216,210,192,193,192,0 +hqDialKeys db 65,47,68,32,47,32,83,80,65,67,69,32,47,32,69,83,67,0 +hqDeadText db 194,251,226,229,228,229,237,32,232,231,32,241,242,240,238,255,46,32,196,238,225,251,247,224 + db 32,239,238,242,229,240,255,237,224,46,32,202,238,236,224,237,228,224,32,238,242,241,242,243 + db 239,224,229,242,32,237,224,32,225,224,231,243,46,0 +hqAbortText db 69,78,84,69,82,32,47,32,69,83,67,58,32,205,192,32,193,192,199,211,0 +hqOutboundText db 194,219,197,199,196,32,202,32,216,210,192,193,211,32,194,203,192,196,197,203,220,214,197,194 + db 0 +hqInboundText db 194,206,199,194,208,192,217,197,205,200,197,32,194,32,205,192,216,197,32,202,192,199,200,205 + db 206,0 +hqCrewRideText db 202,206,204,192,205,196,192,32,194,32,204,192,209,202,192,213,46,32,209,205,192,208,223,198 + db 197,205,200,197,32,195,206,210,206,194,206,46,0 +hqReturnText db 194,219,203,192,199,202,192,32,199,192,194,197,208,216,197,205,192,58,32,43,36,49,48,48 + db 48,48,48,48,0 +hqPlanTitle db 194,219,203,192,199,202,192,32,194,32,216,210,192,193,32,202,206,205,202,211,208,197,205,210 + db 192,0 +hqRoleHire1 db 205,192,201,204,58,32,194,206,196,200,210,197,203,220,0 +hqRoleReady1 db 195,206,210,206,194,58,32,194,206,196,200,210,197,203,220,0 +hqRoleHire2 db 205,192,201,204,58,32,207,208,200,202,208,219,210,200,197,0 +hqRoleReady2 db 195,206,210,206,194,58,32,207,208,200,202,208,219,210,200,197,0 +hqRoleHire3 db 205,192,201,204,58,32,205,192,194,206,196,202,192,0 +hqRoleReady3 db 195,206,210,206,194,58,32,205,192,194,206,196,202,192,0 +hqRoleHire4 db 205,192,201,204,58,32,196,206,209,210,211,207,0 +hqRoleReady4 db 195,206,210,206,194,58,32,196,206,209,210,211,207,0 +.data +hqPrototypeLabel db 205,197,206,193,223,199,192,210,197,203,220,205,219,201,32,207,208,206,210,206,210,200,207,0 +.data? +hqEnemies HFEnemy HQ_GUARDS dup(<>) +.code diff --git a/src_graphics/heist_hq_map.inc b/src_graphics/heist_hq_map.inc new file mode 100644 index 0000000..a2ca285 --- /dev/null +++ b/src_graphics/heist_hq_map.inc @@ -0,0 +1,69 @@ +; Rival owners HQ and van road. Generated by pack_heist_hq.py. +.data +hqMapTemplate label byte + db 80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80 + db 80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80 + db 80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80 + db 80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80 + db 80,80,80,80,80,80,80,80,80,80,80,80,80,80,0,0,0,0,80,80,80,80,80,80,80,80,80,80,80,80,80,80 + db 80,80,80,80,80,80,0,0,0,0,0,0,0,80,0,0,0,0,80,80,0,0,0,0,0,0,80,80,80,80,80,80 + db 80,80,80,80,80,80,0,0,0,0,0,0,0,80,0,0,0,0,80,80,0,0,0,0,0,0,80,80,80,80,80,80 + db 80,80,80,80,80,80,0,0,0,0,0,0,0,80,0,0,0,0,80,80,0,0,0,0,0,0,80,80,80,80,80,80 + db 80,80,80,80,80,80,0,0,0,0,0,0,0,0,0,0,0,0,0,81,0,0,0,0,0,0,80,80,80,80,80,80 + db 80,80,80,80,80,80,0,0,0,0,0,0,0,0,0,0,0,0,0,81,0,0,0,0,0,0,80,80,80,80,80,80 + db 80,80,80,80,80,80,0,0,0,0,0,0,0,80,0,0,0,0,80,80,0,0,0,0,0,0,80,80,80,80,80,80 + db 80,80,80,80,80,80,80,80,80,80,80,80,80,80,0,0,0,0,80,80,0,0,0,0,0,0,80,80,80,80,80,80 + db 80,80,80,80,80,80,0,0,0,0,0,0,0,80,0,0,0,0,80,80,80,80,80,80,80,80,80,80,80,80,80,80 + db 80,80,0,0,0,80,0,0,0,0,0,0,0,80,0,0,0,0,80,80,80,80,80,80,80,80,80,80,80,80,80,80 + db 80,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,80,80,80,80,80,80,80,80,80,80,80,80,80 + db 80,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,80,80,80,80,80,80,80,80,80,80,80,80,80 + db 80,80,0,0,0,80,0,0,0,0,0,0,0,80,0,0,0,0,80,80,80,80,80,80,80,80,80,80,80,80,80,80 + db 80,80,0,0,0,80,80,80,80,80,0,0,0,0,0,0,0,0,0,0,0,0,80,80,80,80,80,80,80,80,80,80 + db 80,80,0,0,0,80,80,80,80,80,0,0,0,0,0,0,0,0,0,0,0,0,80,80,80,80,80,80,80,80,80,80 + db 80,80,0,0,0,80,80,80,80,80,0,0,0,0,83,83,83,83,0,0,0,0,80,80,80,80,80,80,80,80,80,80 + db 80,80,0,0,0,80,80,80,80,80,0,0,0,0,0,0,0,0,0,0,0,0,80,80,80,80,80,80,80,80,80,80 + db 80,80,0,0,0,80,80,80,80,80,0,0,0,0,0,0,0,0,0,0,0,0,80,80,80,80,80,80,80,80,80,80 + db 80,80,0,0,0,80,80,80,80,80,0,0,0,0,0,0,0,0,0,0,0,0,80,80,80,80,80,80,80,80,80,80 + db 80,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,80 + db 80,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,80 + db 80,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,80 + db 80,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,80 + db 80,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,80 + db 80,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,80 + db 80,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,80 + db 80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80 + db 80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80 +hqRoadMap label byte + db 197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197,197 + db 198,198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198,198 + db 198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198 + db 198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198 + db 198,198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198,198 + db 198,198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198,198 + db 197,197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197,197 + db 198,198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198,198 + db 198,198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198,198 + db 198,198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198,198 + db 198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198 + db 198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198 + db 197,197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197 + db 198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198 + db 198,198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198,198 + db 198,198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198,198 + db 198,198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198,198 + db 198,198,198,198,198,198,198,198,198,198,198,0,0,0,0,0,0,0,0,0,0,0,198,198,198,198,198,198,198,198,198,198 + db 197,197,197,197,197,197,197,197,197,197,0,0,0,0,0,0,0,0,0,0,0,0,0,197,197,197,197,197,197,197,197,197 + db 197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197,197 +.code diff --git a/src_graphics/heist_hq_render.inc b/src_graphics/heist_hq_render.inc new file mode 100644 index 0000000..7026f88 --- /dev/null +++ b/src_graphics/heist_hq_render.inc @@ -0,0 +1,198 @@ +RenderHQWorld3D PROC uses ebx esi edi + call UpdateCamera3D + call RenderCeilingAndFloor + cmp playerY,23*FP_1 + jae hq_world_sky + cmp playerX,5*FP_1 + jae hq_world_walls +hq_world_sky: + invoke DrawBox,0,0,320,120,00141B2Ah +hq_world_walls: + call RenderWalls + call PrepareCityDepth3D + mov esi,OFFSET hqEnemies + mov edi,HQ_GUARDS +hq_render_guard: + cmp [esi].HFEnemy.hp,0 + jg @F + cmp [esi].HFEnemy.pose,3 + jne hq_render_next_guard +@@: + mov eax,[esi].HFEnemy.x + mov hqObject.posX,eax + mov eax,[esi].HFEnemy.y + mov hqObject.posY,eax + mov eax,[esi].HFEnemy.pose + mov hqObject.frame,eax + invoke DrawCityObject3D,OFFSET hqObject,0 +hq_render_next_guard: + add esi,SIZEOF HFEnemy + dec edi + jnz hq_render_guard + xor ebx,ebx +hq_render_team: + mov eax,hqTeamX[ebx*4] + mov hqObject.posX,eax + mov eax,hqTeamY[ebx*4] + mov hqObject.posY,eax + lea eax,[ebx+4] + mov hqObject.frame,eax + invoke DrawCityObject3D,OFFSET hqObject,0 + inc ebx + cmp ebx,3 + jb hq_render_team + invoke DrawCityObject3D,OFFSET hqVanObject,0 + invoke DrawCityObject3D,OFFSET hqTerminalObject,0 + mov hqSafeObject.frame,6 + cmp hqLoot,0 + je @F + mov hqSafeObject.frame,7 +@@: + invoke DrawCityObject3D,OFFSET hqSafeObject,0 + cmp hqIntel,0 + jne @F + invoke DrawCityObject3D,OFFSET hqIntelObject,0 +@@: + cmp hqCameras,0 + je @F + invoke DrawCityObject3D,OFFSET hqCameraObject,0 +@@: + ret +RenderHQWorld3D ENDP + +RenderHQMission3D PROC uses ebx esi edi + cmp hqActive,0 + je hq_render_done + cmp heistPhase,6 + je hq_render_drive + cmp heistPhase,8 + je hq_render_drive + call RenderHQWorld3D + cmp heistPhase,9 + je hq_render_dead + mov eax,hqWeapon + shl eax,1 + cmp hqFlash,0 + jle @F + inc eax +@@: + mov ebx,154 + cmp hqReload,0 + jle @F + add ebx,70 +@@: + invoke DrawAnimSprite3D,OFFSET hqWeaponArt,eax,240,ebx,300,320 + invoke DrawBox,0,0,320,30,0014191Dh + invoke DrawString8x8,8,4,OFFSET hqTitle,00E7CA88h + mov eax,OFFSET hqStealthText + mov ecx,00A8DDB9h + cmp hqAlarm,0 + je @F + mov eax,OFFSET hqAlarmText + mov ecx,00FF7777h +@@: + invoke DrawString8x8,8,18,eax,ecx + invoke DrawNumber,264,18,hqSuspicion,ecx + mov eax,OFFSET hqGoalTerminal + cmp hqAccess,0 + je @F + mov eax,OFFSET hqGoalVault +@@: + cmp hqLoot,0 + je @F + mov eax,OFFSET hqGoalEscape +@@: + mov esi,eax + invoke DrawBox,0,30,320,14,0014191Dh + invoke DrawString8x8,8,33,esi,00E7CA88h + cmp hqAction,0 + je hq_render_intel + invoke DrawString8x8,8,52,OFFSET hqWorkingText,00E7CA88h + mov eax,hqActionTime + xor edx,edx + mov ecx,1000 + div ecx + inc eax + invoke DrawNumber,208,52,eax,00E7CA88h +hq_render_intel: + cmp hqIntel,0 + je @F + invoke DrawString8x8,8,66,OFFSET hqIntelText,00A8DDB9h +@@: + cmp hqLoot,0 + jne hq_render_team_hint + invoke HFDistance,playerX,playerY,8*FP_1,7*FP_1 + cmp eax,FP_1*3/2 + ja hq_render_team_hint + invoke DrawString8x8,8,82,OFFSET hqIntelHint,00E7CA88h +hq_render_team_hint: + mov eax,OFFSET hqTeamWaitText + cmp hqTeamFollow,0 + je @F + mov eax,OFFSET hqTeamFollowText +@@: + invoke DrawString8x8,8,196,eax,00A8DDB9h + invoke DrawBox,159,118,2,5,00FFFFFFh + invoke DrawBox,157,120,6,1,00FFFFFFh + invoke DrawBox,0,210,320,30,0014191Dh + invoke DrawString8x8,8,213,OFFSET hqHealthText,00A8DDB9h + invoke DrawNumber,32,213,hqHealth,00FFFFFFh + invoke DrawString8x8,80,213,OFFSET hqAmmoText,00A8DDB9h + mov ebx,hqWeapon + invoke DrawNumber,120,213,hqMagazine[ebx*4],00FFFFFFh + invoke DrawString8x8,144,213,OFFSET hqSlashText,00FFFFFFh + invoke DrawNumber,160,213,hqReserve[ebx*4],00FFFFFFh + invoke DrawString8x8,8,228,OFFSET hqControlsText,00A8B6BBh + cmp heistPhase,2 + je hq_render_safe + cmp hqHurt,0 + jle hq_render_done + invoke DrawBox,0,44,4,166,00FF4444h + invoke DrawBox,316,44,4,166,00FF4444h + jmp hq_render_done +hq_render_safe: + invoke DrawBoxBorder,162,46,150,158,00151A22h,00D8BC6Ah,1 + invoke DrawString8x8,170,54,OFFSET hqSafeText,00E7CA88h + invoke DrawUnderworldSprite3D,OFFSET secPortraitsPack,3,190,74,92,92 + invoke DrawNumber,224,170,heistDialPos,00FFFFFFh + invoke DrawNumber,176,170,heistDigitsFound,00A8DDB9h + mov eax,uwHeistTimer + xor edx,edx + mov ecx,1000 + div ecx + invoke DrawNumber,274,170,eax,00A8DDB9h + invoke DrawString8x8,170,188,OFFSET hqDialKeys,00E7CA88h + jmp hq_render_done +hq_render_dead: + invoke DrawBoxBorder,20,72,280,100,00151A22h,00FF7777h,1 + invoke DrawUnderworldText3D,32,88,OFFSET hqDeadText,32,00FF7777h + invoke DrawString8x8,32,144,OFFSET hqAbortText,00E7CA88h + jmp hq_render_done +hq_render_drive: + mov worldMap3D,OFFSET hqRoadMap + mov playerX,FP_1*165/10 + mov playerAngle,384 + mov eax,hqRideTime + mov ecx,21*FP_1 + mul ecx + mov ecx,6000 + div ecx + mov ebx,28*FP_1 + sub ebx,eax + mov playerY,ebx + call UpdateCamera3D + call RenderCeilingAndFloor + invoke DrawBox,0,0,320,120,00141B2Ah + call RenderWalls + invoke DrawAnimSprite3D,OFFSET hqVanArt,0,0,0,640,480 + invoke DrawBox,0,0,320,26,0014191Dh + mov eax,OFFSET hqOutboundText + cmp heistPhase,8 + jne @F + mov eax,OFFSET hqInboundText +@@: + invoke DrawString8x8,8,6,eax,00E7CA88h + invoke DrawString8x8,8,228,OFFSET hqCrewRideText,00A8DDB9h +hq_render_done: + ret +RenderHQMission3D ENDP diff --git a/src_graphics/heist_mission.inc b/src_graphics/heist_mission.inc new file mode 100644 index 0000000..57f0be2 --- /dev/null +++ b/src_graphics/heist_mission.inc @@ -0,0 +1,361 @@ +; ============================================================================== +; GRAND HEIST SYSTEM SCENE (CP1251) +; ============================================================================== + +BeginHeistPlanning3D PROC + mov heistPhase, 0 + cmp heistComplete, 0 + je @F + mov heistPhase, 4 +@@: + mov engineMode, MODE_HEIST + call ClearKeys3D + ret +BeginHeistPlanning3D ENDP + +HandleHeist3D PROC + cmp hqActive,1 + jne hq_handle_planning + cmp heistPhase,2 + jne hq_handle_field + call HQSimulate3D + cmp heistPhase,2 + je heist_check_p2 + ret +hq_handle_field: + call HandleHQMission3D + ret +hq_handle_planning: + invoke Pressed3D,35h + test eax,eax + jz @F + xor hqApproach,1 +@@: + cmp heistPhase, 0 + jne heist_check_p1 + + ; Phase 0: Crew Recruitment & Planning + invoke Pressed3D, 31h ; '1' - Bartender ($1,000) + test eax, eax + jz @F + cmp heistCrewBartender, 1 + je @F + cmp bankroll, 1000 + jb @F + sub bankroll, 1000 + mov heistCrewBartender, 1 + call SaveProgress3D +@@: + invoke Pressed3D, 32h ; '2' - Singer ($2,000) + test eax, eax + jz @F + cmp heistCrewSinger, 1 + je @F + cmp bankroll, 2000 + jb @F + sub bankroll, 2000 + mov heistCrewSinger, 1 + call SaveProgress3D +@@: + invoke Pressed3D, 33h ; '3' - Fortune Teller ($1,500) + test eax, eax + jz @F + cmp heistCrewFortune, 1 + je @F + cmp bankroll, 1500 + jb @F + sub bankroll, 1500 + mov heistCrewFortune, 1 + call SaveProgress3D +@@: + invoke Pressed3D, 34h ; '4' - Hacker ($3,000) + test eax, eax + jz @F + cmp heistCrewHacker, 1 + je @F + cmp bankroll, 3000 + jb @F + sub bankroll, 3000 + mov heistCrewHacker, 1 + call SaveProgress3D +@@: + invoke Pressed3D, 1Bh ; Esc + test eax, eax + jz @F + mov engineMode, MODE_WALK + ret +@@: + invoke Pressed3D, 0Dh ; Enter - Start Operation if all ready + test eax, eax + jz heist_handle_done + + ; Check all 4 + cmp heistCrewBartender, 1 + jne heist_handle_done + cmp heistCrewSinger, 1 + jne heist_handle_done + cmp heistCrewFortune, 1 + jne heist_handle_done + cmp heistCrewHacker, 1 + jne heist_handle_done + + ; All ready! + cmp heistComplete, 0 + jne heist_handle_done + call BeginHQMission3D + ret + +heist_check_p1: + cmp heistPhase, 1 + jne heist_check_p2 + + ; Phase 1: Show Distraction cutscene + mov eax,deltaTime3D + sub heistDistractionTimer,eax + cmp heistDistractionTimer, 0 + jg @F + mov heistPhase, 2 + mov heistDialPos, 0 + mov heistDigitsFound, 0 + mov heistSafeFeedback, 0 + ret +@@: + invoke Pressed3D, 0Dh ; Enter to skip + test eax, eax + jz @F + mov heistPhase, 2 + mov heistDialPos, 0 + mov heistDigitsFound, 0 + mov heistSafeFeedback, 0 + ret +@@: + ret + +heist_check_p2: + cmp heistPhase, 2 + jne heist_check_p3 + + mov eax,deltaTime3D + sub uwHeistTimer,eax + cmp uwHeistTimer,0 + jg @F + mov heistPhase,5 + ret +@@: + ; Phase 2: Safe Cracking + invoke Pressed3D, 41h ; 'A' / Left + test eax, eax + jnz dial_step_left + invoke Pressed3D, 25h ; Left Arrow + test eax, eax + jz check_dial_right +dial_step_left: + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + cmp heistDialPos, 0 + jne dec_dial + mov heistDialPos, 99 + jmp check_dial_right +dec_dial: + dec heistDialPos + +check_dial_right: + invoke Pressed3D, 44h ; 'D' / Right + test eax, eax + jnz dial_step_right + invoke Pressed3D, 27h ; Right Arrow + test eax, eax + jz check_dial_try +dial_step_right: + invoke PlayCasinoSound3D, OFFSET soundClick, 0, 1 + cmp heistDialPos, 99 + jne inc_dial + mov heistDialPos, 0 + jmp check_dial_try +inc_dial: + inc heistDialPos + +check_dial_try: + mov ecx,heistDigitsFound + mov eax,heistCode[ecx*4] + sub eax,heistDialPos + jns @F + neg eax +@@: + cmp eax,2 + ja uw_safe_far + mov heistSafeFeedback,OFFSET uwNear + mov eax,animationClock3D + sub eax,uwHeistPulse + cmp eax,280 + jb uw_safe_far + mov eax,animationClock3D + mov uwHeistPulse,eax + invoke PlayCasinoSound3D,OFFSET soundSkillHit,0,1 +uw_safe_far: + invoke Pressed3D, 20h ; Space -> Try combination digit + test eax, eax + jz @F + + mov ecx, heistDigitsFound + cmp ecx, 3 + jae @F + mov eax, heistCode[ecx*4] + cmp eax, heistDialPos + jne dial_wrong + + ; Correct! + inc heistDigitsFound + invoke PlayCasinoSound3D, OFFSET soundSkillPerfect, 0, 1 + mov heistSafeFeedback, OFFSET uwNear + cmp heistDigitsFound, 3 + jb @F + + ; Vault open! ,000,000 jackpot & Golden Deck reward! + mov hqLoot,1 + mov heistPhase,7 + mov hqFireHeld,0 + call ClearKeys3D + ret + +dial_wrong: + invoke PlayCasinoSound3D, OFFSET soundSkillMiss, 0, 1 + mov heistSafeFeedback, OFFSET szHeistClickWrong +@@: + invoke Pressed3D, 1Bh ; Esc + test eax, eax + jz heist_handle_done + cmp hqActive,0 + je @F + mov heistPhase,7 + mov hqFireHeld,0 + call ClearKeys3D + ret +@@: + mov engineMode, MODE_WALK + ret + +heist_check_p3: + ; Phase 3: Victory & Escape + invoke Pressed3D, 0Dh ; Enter + test eax, eax + jnz heist_finish_escape + invoke Pressed3D, 20h ; Space + test eax, eax + jnz heist_finish_escape + invoke Pressed3D, 1Bh ; Esc + test eax, eax + jz heist_handle_done + +heist_finish_escape: + mov engineMode, MODE_WALK + call ClearKeys3D + +heist_handle_done: + ret +HandleHeist3D ENDP + +RenderHeist3D PROC uses ebx esi + cmp hqActive,1 + jne hq_render_planning + call RenderHQMission3D + ret +hq_render_planning: + invoke DrawBox,0,0,320,240,00101418h + invoke DrawBoxBorder,6,6,308,228,001E242Ch,00836D42h,1 + invoke DrawString8x8,16,16,OFFSET hqPlanTitle,00E7CA88h + invoke DrawString8x8,16,30,OFFSET hqPrototypeLabel,008E9D98h + cmp heistPhase,0 + jne uw_heist_show + invoke DrawUnderworldSprite3D,OFFSET secPortraitsPack,5,12,44,30,30 + invoke DrawString8x8,48,47,OFFSET uwCrew1,00E4D9BDh + mov eax,OFFSET hqRoleHire1 + cmp heistCrewBartender,0 + je @F + mov eax,OFFSET hqRoleReady1 +@@: + invoke DrawString8x8,48,61,eax,00A8DDB9h + invoke DrawUnderworldSprite3D,OFFSET secPortraitsPack,6,12,78,30,30 + invoke DrawString8x8,48,81,OFFSET uwCrew2,00E4D9BDh + mov eax,OFFSET hqRoleHire2 + cmp heistCrewSinger,0 + je @F + mov eax,OFFSET hqRoleReady2 +@@: + invoke DrawString8x8,48,95,eax,00A8DDB9h + invoke DrawUnderworldSprite3D,OFFSET secPortraitsPack,7,12,112,30,30 + invoke DrawString8x8,48,115,OFFSET uwCrew3,00E4D9BDh + mov eax,OFFSET hqRoleHire3 + cmp heistCrewFortune,0 + je @F + mov eax,OFFSET hqRoleReady3 +@@: + invoke DrawString8x8,48,129,eax,00A8DDB9h + invoke DrawUnderworldSprite3D,OFFSET secPortraitsPack,8,12,146,30,30 + invoke DrawString8x8,48,149,OFFSET uwCrew4,00E4D9BDh + mov eax,OFFSET hqRoleHire4 + cmp heistCrewHacker,0 + je @F + mov eax,OFFSET hqRoleReady4 +@@: + invoke DrawString8x8,48,163,eax,00A8DDB9h + invoke DrawUnderworldSprite3D,OFFSET secPortraitsPack,9,202,48,100,100 + mov eax,OFFSET hqApproachStealth + cmp hqApproach,0 + je @F + mov eax,OFFSET hqApproachAssault +@@: + invoke DrawString8x8,16,176,eax,00A8DDB9h + mov eax,heistCrewBartender + and eax,heistCrewSinger + and eax,heistCrewFortune + and eax,heistCrewHacker + test eax,eax + jz @F + invoke DrawString8x8,16,190,OFFSET uwStart,00A8DDB9h + jmp uw_heist_footer +@@: + invoke DrawUnderworldText3D,16,186,OFFSET uwGather,36,00E7CA88h + jmp uw_heist_footer +uw_heist_show: + cmp heistPhase,1 + jne uw_heist_safe + invoke DrawUnderworldSprite3D,OFFSET secPortraitsPack,6,16,40,128,144 + invoke DrawUnderworldText3D,160,54,OFFSET uwShow,17,00E7CA88h + jmp uw_heist_footer +uw_heist_safe: + cmp heistPhase,2 + jne uw_heist_finish + invoke DrawUnderworldSprite3D,OFFSET secPortraitsPack,3,16,44,124,124 + invoke DrawNumber,68,174,heistDialPos,00FFFFFFh + invoke DrawString8x8,152,48,OFFSET uwSafeGoal,00E7CA88h + invoke DrawNumber,288,48,heistDigitsFound,00A8DDB9h + invoke DrawString8x8,152,72,OFFSET uwSafeTime,00E7CA88h + mov eax,uwHeistTimer + xor edx,edx + mov ecx,1000 + div ecx + invoke DrawNumber,216,72,eax,00FFFFFFh + invoke DrawUnderworldText3D,152,100,OFFSET uwSafe,18,00E4D9BDh + cmp heistSafeFeedback,0 + je uw_heist_footer + invoke DrawUnderworldText3D,152,160,heistSafeFeedback,18,00A8DDB9h + jmp uw_heist_footer +uw_heist_finish: + cmp heistPhase,5 + jne @F + invoke DrawUnderworldText3D,24,72,OFFSET uwFailed,34,005555FFh + jmp uw_heist_footer +@@: + invoke DrawUnderworldSprite3D,OFFSET secPortraitsPack,4,16,40,110,100 + invoke DrawUnderworldSprite3D,OFFSET hqPropsArt,0,174,40,124,100 + mov eax,OFFSET uwVictory + cmp heistPhase,4 + jne @F + mov eax,OFFSET uwCompleted +@@: + invoke DrawUnderworldText3D,16,148,eax,36,00A8DDB9h +uw_heist_footer: + invoke DrawString8x8,16,220,OFFSET uwExit,00A8B6BBh + invoke DrawNumber,224,220,bankroll,00E5D6B0h + ret +RenderHeist3D ENDP diff --git a/src_graphics/hell_fps_data.inc b/src_graphics/hell_fps_data.inc index 2c6b29d..27da274 100644 --- a/src_graphics/hell_fps_data.inc +++ b/src_graphics/hell_fps_data.inc @@ -200,4 +200,4 @@ hfBolts HFBolt 32 dup(<>) hfFlow dw 1024 dup(?) hfQueue dd 1024 dup(?) hfImpacts HFImpact HF_SHOT_PELLETS dup(<>) -.code +.data diff --git a/src_graphics/native_blackjack.inc b/src_graphics/native_blackjack.inc index ba89a6f..3c2a1b2 100644 --- a/src_graphics/native_blackjack.inc +++ b/src_graphics/native_blackjack.inc @@ -138,6 +138,7 @@ StartNativeBlackjack3D PROC invoke NativeBJScore3D, OFFSET cbDealer3D, 2 mov cbDealerScore3D, eax mov cbTimer3D, 0 + mov uwPeeked,0 mov cbState3D, CB_DEAL call ClearKeys3D invoke PlayCasinoSound3D, OFFSET soundCards, 0, 1 @@ -169,6 +170,19 @@ bj_hit_done: NativeBJHit3D ENDP HandleNativeBlackjack3D PROC uses ebx + cmp obsActive3D,0 + jne uw_peek_skip_HandleNativeBlackjack3D + cmp cbState3D,CB_PLAYER + jne uw_peek_skip_HandleNativeBlackjack3D + cmp uwPeeked,0 + jne uw_peek_skip_HandleNativeBlackjack3D + invoke Pressed3D,50h + test eax,eax + jz uw_peek_skip_HandleNativeBlackjack3D + mov uwPeeked,1 + invoke AddSecurityHeat,30 + call SaveProgress3D +uw_peek_skip_HandleNativeBlackjack3D: call HandleCardExit3D test eax, eax jnz bj_input_done diff --git a/src_graphics/native_blackjack_party_render.inc b/src_graphics/native_blackjack_party_render.inc index 9c56d74..f1702f0 100644 --- a/src_graphics/native_blackjack_party_render.inc +++ b/src_graphics/native_blackjack_party_render.inc @@ -263,6 +263,8 @@ bj_party_dealer_card: jne @F cmp cbVisible3D,0 jne @F + cmp uwPeeked,0 + jne @F mov hide,1 @@: cmp cbState3D,CB_DEAL diff --git a/src_graphics/native_poker.inc b/src_graphics/native_poker.inc index 597a0e7..18896e8 100644 --- a/src_graphics/native_poker.inc +++ b/src_graphics/native_poker.inc @@ -98,6 +98,7 @@ StartNativePoker3D PROC uses ebx esi mov eax, pkButton3D mov pkTurn3D, eax mov pkTimer3D, 0 + mov uwPeeked,0 mov pkState3D, PK_DEAL call ClearKeys3D invoke PlayCasinoSound3D, OFFSET soundCards, 0, 1 @@ -500,6 +501,19 @@ poker_ai_call: PokerBotAct3D ENDP HandleNativePoker3D PROC uses ebx + cmp obsActive3D,0 + jne uw_peek_skip_HandleNativePoker3D + cmp pkState3D,PK_PLAYER + jne uw_peek_skip_HandleNativePoker3D + cmp uwPeeked,0 + jne uw_peek_skip_HandleNativePoker3D + invoke Pressed3D,50h + test eax,eax + jz uw_peek_skip_HandleNativePoker3D + mov uwPeeked,1 + invoke AddSecurityHeat,30 + call SaveProgress3D +uw_peek_skip_HandleNativePoker3D: call HandleCardExit3D test eax, eax jnz poker_input_done diff --git a/src_graphics/native_slots.inc b/src_graphics/native_slots.inc index 80b7938..5d00f34 100644 --- a/src_graphics/native_slots.inc +++ b/src_graphics/native_slots.inc @@ -71,6 +71,14 @@ StartNativeSlots3D PROC uses ebx esi mov slotEffects3D,0 call BackroomsLuck3D mov brSlotLuck3D,eax + cmp barBuffLuckSpins, 0 + jbe @F + dec barBuffLuckSpins + invoke RandomRange3D,100 + cmp eax,15 + jae @F + mov brSlotLuck3D, 1 +@@: xor esi,esi slot_start_reel: mov eax,slotStops3D[esi*4] diff --git a/src_graphics/npc_contracts.inc b/src_graphics/npc_contracts.inc index 392e823..654d616 100644 --- a/src_graphics/npc_contracts.inc +++ b/src_graphics/npc_contracts.inc @@ -192,6 +192,8 @@ NpcAcceptContract3D ENDP NpcRecordRound3D PROC uses ebx esi edi game:DWORD,won:DWORD cmp obsActive3D,0 jne npc_event_done + call StepDebtRound3D + invoke DecaySecurityHeat, 2 call NpcEnsureJournal3D test eax,eax jz npc_event_done diff --git a/src_graphics/platform_code.inc b/src_graphics/platform_code.inc index 93e325e..d3257bf 100644 --- a/src_graphics/platform_code.inc +++ b/src_graphics/platform_code.inc @@ -1,19 +1,33 @@ -; Main and owned coin-detail windows are processed on the same thread; no CMD fallback. -WindowEvents3D PROC uses ebx esi edi hwnd:DWORD, uMsg:DWORD, wp:DWORD, lp:DWORD - cmp engineMode,MODE_SCRATCH - jne @F - invoke ScratchMouseEvent3D,hwnd,uMsg,wp,lp - test eax,eax - jz @F - ret -@@: - cmp uMsg, 102h - jne @F - invoke ArrivalChar3D, wp - invoke FortuneChar3D, wp - xor eax, eax - ret -@@: +; Main and owned coin-detail windows are processed on the same thread; no CMD fallback. +WindowEvents3D PROC uses ebx esi edi hwnd:DWORD, uMsg:DWORD, wp:DWORD, lp:DWORD + cmp engineMode,MODE_SCRATCH + jne @F + invoke ScratchMouseEvent3D,hwnd,uMsg,wp,lp + test eax,eax + jz @F + ret +@@: + cmp uMsg, 102h + jne @F + invoke ArrivalChar3D, wp + invoke FortuneChar3D, wp + xor eax, eax + ret +@@: + cmp engineMode,MODE_HEIST + jne hq_window_mouse_done + cmp hqActive,1 + jne hq_window_mouse_done + cmp uMsg,201h + jne @F + mov hqFireHeld,1 + jmp event_done +@@: + cmp uMsg,202h + jne hq_window_mouse_done + mov hqFireHeld,0 + jmp event_done +hq_window_mouse_done: cmp engineMode,MODE_HELL_FPS jne hf_window_not_mouse cmp uMsg,201h @@ -27,704 +41,712 @@ WindowEvents3D PROC uses ebx esi edi hwnd:DWORD, uMsg:DWORD, wp:DWORD, lp:DWORD mov hfFireHeld,0 jmp event_done hf_window_not_mouse: - cmp uMsg,202h - jne @F - cmp engineMode,MODE_DARTS - jne event_default - mov dtMouseReleased3D,1 - jmp event_mouse_down -@@: - cmp uMsg, 201h - je event_mouse_down - cmp uMsg,203h - jne @F - cmp engineMode,MODE_POOL - je event_mouse_down - jmp event_default -@@: - cmp uMsg, 200h - jne @F - cmp engineMode,MODE_DARTS - je event_mouse_down - cmp engineMode, MODE_POOL - jne event_default - test wp, 1 - jnz event_mouse_down - jmp event_default -@@: - cmp uMsg, 100h - je event_key_down - cmp uMsg, 104h - jne @F - cmp wp, 0Dh - je event_fullscreen -@@: - cmp uMsg, 101h - je event_key_up - cmp uMsg, 8 - je event_focus_lost - cmp uMsg, 14h - je event_erase - cmp uMsg, 0Fh - je event_paint - cmp uMsg, WM_CLOSE - je event_close - cmp uMsg, WM_DESTROY - je event_close -event_default: - invoke DefWindowProcA, hwnd, uMsg, wp, lp - ret -event_mouse_down: - cmp viewWidth3D, 0 - je event_done - cmp viewHeight3D, 0 - je event_done - movsx eax, WORD PTR lp - sub eax, viewLeft3D - cmp eax, viewWidth3D - jae event_done - cmp engineMode,MODE_DARTS - jne event_coarse_x - push eax - imul eax,640*256 - xor edx,edx - div viewWidth3D - mov dtCursorX3D,eax - pop eax -event_coarse_x: - imul eax, 320 - xor edx, edx - div viewWidth3D - mov mouseX3D, eax - movsx eax, WORD PTR lp[2] - sub eax, viewTop3D - cmp eax, viewHeight3D - jae event_done - cmp engineMode,MODE_DARTS - jne event_coarse_y - push eax - imul eax,480*256 - xor edx,edx - div viewHeight3D - mov dtCursorY3D,eax - pop eax -event_coarse_y: - imul eax, 240 - xor edx, edx - div viewHeight3D - mov mouseY3D, eax - cmp uMsg,200h - jne @F - cmp eax,50 - jb event_done - cmp eax,211 - jae event_done -@@: - cmp uMsg,203h - je pyr_event_pick - mov pyrPickClick3D,0 - jmp pyr_event_pick_done -pyr_event_pick: - mov pyrPickClick3D,1 -pyr_event_pick_done: - cmp uMsg,202h - je event_done - cmp uMsg,200h - jne @F - cmp engineMode,MODE_DARTS - je event_done -@@: - mov mouseClick3D, 1 - jmp event_done -event_key_down: - mov ecx, wp - cmp ecx, 255 - ja event_done - test lp, 40000000h - jnz event_done - mov keys3D[ecx], 1 - mov pressedKeys3D[ecx], 1 - jmp event_done -event_key_up: - mov ecx, wp - cmp ecx, 255 - ja event_done - mov keys3D[ecx], 0 - cmp ecx,57h - je event_entry_release - cmp ecx,26h - jne event_done -event_entry_release: - mov brEntryHold3D,0 - jmp event_done -event_fullscreen: - test lp, 40000000h - jnz event_done - call ToggleFullscreen3D - jmp event_done -event_focus_lost: + cmp uMsg,202h + jne @F + cmp engineMode,MODE_DARTS + jne event_default + mov dtMouseReleased3D,1 + jmp event_mouse_down +@@: + cmp uMsg, 201h + je event_mouse_down + cmp uMsg,203h + jne @F + cmp engineMode,MODE_POOL + je event_mouse_down + jmp event_default +@@: + cmp uMsg, 200h + jne @F + cmp engineMode,MODE_DARTS + je event_mouse_down + cmp engineMode, MODE_POOL + jne event_default + test wp, 1 + jnz event_mouse_down + jmp event_default +@@: + cmp uMsg, 100h + je event_key_down + cmp uMsg, 104h + jne @F + cmp wp, 0Dh + je event_fullscreen +@@: + cmp uMsg, 101h + je event_key_up + cmp uMsg, 8 + je event_focus_lost + cmp uMsg, 14h + je event_erase + cmp uMsg, 0Fh + je event_paint + cmp uMsg, WM_CLOSE + je event_close + cmp uMsg, WM_DESTROY + je event_close +event_default: + invoke DefWindowProcA, hwnd, uMsg, wp, lp + ret +event_mouse_down: + cmp viewWidth3D, 0 + je event_done + cmp viewHeight3D, 0 + je event_done + movsx eax, WORD PTR lp + sub eax, viewLeft3D + cmp eax, viewWidth3D + jae event_done + cmp engineMode,MODE_DARTS + jne event_coarse_x + push eax + imul eax,640*256 + xor edx,edx + div viewWidth3D + mov dtCursorX3D,eax + pop eax +event_coarse_x: + imul eax, 320 + xor edx, edx + div viewWidth3D + mov mouseX3D, eax + movsx eax, WORD PTR lp[2] + sub eax, viewTop3D + cmp eax, viewHeight3D + jae event_done + cmp engineMode,MODE_DARTS + jne event_coarse_y + push eax + imul eax,480*256 + xor edx,edx + div viewHeight3D + mov dtCursorY3D,eax + pop eax +event_coarse_y: + imul eax, 240 + xor edx, edx + div viewHeight3D + mov mouseY3D, eax + cmp uMsg,200h + jne @F + cmp eax,50 + jb event_done + cmp eax,211 + jae event_done +@@: + cmp uMsg,203h + je pyr_event_pick + mov pyrPickClick3D,0 + jmp pyr_event_pick_done +pyr_event_pick: + mov pyrPickClick3D,1 +pyr_event_pick_done: + cmp uMsg,202h + je event_done + cmp uMsg,200h + jne @F + cmp engineMode,MODE_DARTS + je event_done +@@: + mov mouseClick3D, 1 + jmp event_done +event_key_down: + mov ecx, wp + cmp ecx, 255 + ja event_done + test lp, 40000000h + jnz event_done + mov keys3D[ecx], 1 + mov pressedKeys3D[ecx], 1 + jmp event_done +event_key_up: + mov ecx, wp + cmp ecx, 255 + ja event_done + mov keys3D[ecx], 0 + cmp ecx,57h + je event_entry_release + cmp ecx,26h + jne event_done +event_entry_release: + mov brEntryHold3D,0 + jmp event_done +event_fullscreen: + test lp, 40000000h + jnz event_done + call ToggleFullscreen3D + jmp event_done +event_focus_lost: + mov hqFireHeld,0 mov hfFireHeld,0 mov hfFirePending,0 - mov brEntryHold3D,0 - mov dtHolding3D,0 - mov dtMouseReleased3D,0 - call ClearKeys3D - jmp event_done -event_erase: - mov eax, 1 - ret -event_paint: - invoke BeginPaint, hwnd, OFFSET paint3D - cmp h3DDC, 0 - je @F - call Present3D -@@: - invoke EndPaint, hwnd, OFFSET paint3D - jmp event_done -event_close: - invoke PostQuitMessage, 0 -event_done: - xor eax, eax - ret -WindowEvents3D ENDP - -LoadDisplaySettings3D PROC uses ebx - invoke CreateFileA, OFFSET displaySettingsPath3D, 80000000h, 1, 0, 3, 80h, 0 - cmp eax, -1 - je display_settings_load_done - mov ebx, eax - invoke ReadFile, ebx, OFFSET displaySettingsData3D, 12, OFFSET displaySettingsIo3D, 0 - invoke CloseHandle, ebx - cmp displaySettingsIo3D, 12 - jne display_settings_load_done - cmp displaySettingsData3D, 44535031h - jne display_settings_load_done - mov eax, displaySettingsData3D[4] - and eax, 1 - mov displayFill3D, eax -display_settings_load_done: - ret -LoadDisplaySettings3D ENDP - -SaveDisplaySettings3D PROC uses ebx - invoke CreateDirectoryA, OFFSET runtime3D, 0 - mov displaySettingsData3D, 44535031h - mov eax, displayFill3D - mov displaySettingsData3D[4], eax - mov displaySettingsData3D[8], 0 - invoke CreateFileA, OFFSET displaySettingsPath3D, 40000000h, 0, 0, 2, 80h, 0 - cmp eax, -1 - je display_settings_save_done - mov ebx, eax - invoke WriteFile, ebx, OFFSET displaySettingsData3D, 12, OFFSET displaySettingsIo3D, 0 - invoke CloseHandle, ebx -display_settings_save_done: - ret -SaveDisplaySettings3D ENDP - -Pressed3D PROC key:DWORD - mov ecx, key - xor eax, eax - cmp ecx, 255 - ja @F - cmp pressedKeys3D[ecx], 0 - je @F - mov pressedKeys3D[ecx], 0 - mov eax, 8000h -@@: - ret -Pressed3D ENDP - -InitPaths3D PROC uses ebx esi edi - invoke GetModuleFileNameA, 0, OFFSET directory3D, SIZEOF directory3D - test eax, eax - jz path_done - lea esi, directory3D - mov edi, esi -path_scan: - mov al, [esi] - test al, al - jz path_found - cmp al, '\' - jne @F - mov edi, esi -@@: - inc esi - jmp path_scan -path_found: - mov BYTE PTR [edi], 0 - invoke SetCurrentDirectoryA, OFFSET directory3D - mov ebx, 3 -path_assets: - invoke GetFileAttributesA, OFFSET szTexturesRelPath - cmp eax, -1 - jne path_done - dec ebx - jz path_restore - ; Root, bin and build/graphics launches resolve the same asset directory. - invoke SetCurrentDirectoryA, OFFSET parent3D - test eax, eax - jnz path_assets -path_restore: - invoke SetCurrentDirectoryA, OFFSET directory3D -path_done: - ret -InitPaths3D ENDP - -Create3DWindow PROC uses ebx esi edi - local widthPx:DWORD - local heightPx:DWORD - invoke GetModuleHandleA, OFFSET user32Name3D - invoke GetProcAddress, eax, OFFSET dpiName3D - test eax, eax - jz @F - call eax -@@: - invoke GetModuleHandleA, 0 - mov h3DInst, eax - mov wc3D.hInstance, eax - invoke LoadIconA, eax, 1 - mov wc3D.hIcon, eax - mov wc3D.hIconSm, eax - invoke LoadCursorA, 0, 32512 - mov wc3D.hCursor, eax - mov wc3D.cbSize, SIZEOF C3D_WNDCLASSEX - mov wc3D.style, CS_HREDRAW or CS_VREDRAW - mov wc3D.lpfnWndProc, OFFSET Casino3DWndProc - mov wc3D.lpszClassName, OFFSET sz3DClassName - invoke RegisterClassExA, OFFSET wc3D - mov bmi3D.bmiHeader.biSize, SIZEOF C3D_BITMAPINFOHEADER - mov bmi3D.bmiHeader.biWidth, SCREEN_W - mov bmi3D.bmiHeader.biHeight, -SCREEN_H - mov bmi3D.bmiHeader.biPlanes, 1 - mov bmi3D.bmiHeader.biBitCount, 32 - mov bmi3D.bmiHeader.biSizeImage, SCREEN_SIZE * 4 - invoke GetSystemMetrics, 0 - mov esi, eax - sub eax, 80 - cmp eax, 1120 - jle @F - mov eax, 1120 -@@: - mov widthPx, eax - invoke GetSystemMetrics, 1 - mov edi, eax - sub eax, 120 - mov heightPx, eax - mov eax, widthPx - imul eax, 3 - shr eax, 2 - cmp eax, heightPx - jle @F - mov eax, heightPx - imul eax, 4 - xor edx, edx - mov ecx, 3 - div ecx - mov widthPx, eax -@@: - mov eax, widthPx - imul eax, 3 - shr eax, 2 - mov clientRect3D[12], eax - mov eax, widthPx - mov clientRect3D[8], eax - invoke AdjustWindowRectEx, OFFSET clientRect3D, WS_OVERLAPPEDWINDOW, 0, 0 - mov eax, clientRect3D[8] - sub eax, clientRect3D - mov widthPx, eax - sub esi, eax - sar esi, 1 - mov eax, clientRect3D[12] - sub eax, clientRect3D[4] - mov heightPx, eax - sub edi, eax - sar edi, 1 - invoke CreateWindowExA, 0, OFFSET sz3DClassName, OFFSET sz3DWindowTitle, WS_OVERLAPPEDWINDOW, esi, edi, widthPx, heightPx, 0, 0, h3DInst, 0 - test eax, eax - jz window_failed - mov h3DWnd, eax - invoke GetDC, h3DWnd - mov h3DDC, eax - test eax, eax - jz window_failed - invoke SetStretchBltMode, h3DDC, 3 - ; Resize while hidden. Init3DEngine paints the ident before showing it. - mov fullscreen3D, 0 - call ToggleFullscreen3D - mov eax, 1 -window_failed: - ret -Create3DWindow ENDP - -LoadTextures3D PROC uses ebx - local count:DWORD - invoke CreateFileA, OFFSET szTexturesRelPath, 80000000h, 1, 0, 3, 80h, 0 - cmp eax, -1 - je assets_failed - mov ebx, eax - invoke ReadFile, ebx, OFFSET texturesBuffer, 48*128*128*4, ADDR count, 0 - push eax - invoke CloseHandle, ebx - pop eax - test eax, eax - jz assets_failed - cmp count, 48*128*128*4 - jne assets_failed - mov eax, 1 - ret -assets_failed: - invoke MessageBoxA, h3DWnd, OFFSET textMissing3D, OFFSET sz3DWindowTitle, 10h - xor eax, eax - ret -LoadTextures3D ENDP - -Present3D PROC uses ebx esi edi - local viewW:DWORD - local viewH:DWORD - local offsetX:DWORD - local offsetY:DWORD - invoke GetClientRect, h3DWnd, OFFSET clientRect3D - mov esi, clientRect3D[8] - mov edi, clientRect3D[12] - test esi, esi - jz present_done - test edi, edi - jz present_done - cmp displayFill3D, 0 - je present_keep_aspect - mov viewW, esi - mov viewH, edi - jmp present_geometry_ready -present_keep_aspect: - mov viewW, esi - mov eax, esi - imul eax, 3 - shr eax, 2 - cmp eax, edi - jle @F - mov eax, edi - imul eax, 4 - xor edx, edx - mov ecx, 3 - div ecx - mov viewW, eax - mov eax, edi -@@: - mov viewH, eax -present_geometry_ready: - mov ebx, esi - sub ebx, viewW - shr ebx, 1 - mov offsetX, ebx - mov ebx, edi - sub ebx, viewH - shr ebx, 1 - mov offsetY, ebx - mov viewTop3D, ebx - mov eax, offsetX - mov viewLeft3D, eax - mov eax, viewW - mov viewWidth3D, eax - mov eax, viewH - mov viewHeight3D, eax - ; Only clear the letterbox bars, never erase under the next frame. - cmp offsetY, 0 - je @F - invoke PatBlt, h3DDC, 0, 0, esi, offsetY, 42h -@@: - mov eax, offsetY - add eax, viewH - mov ecx, edi - sub ecx, eax - test ecx, ecx - jz @F - invoke PatBlt, h3DDC, 0, eax, esi, ecx, 42h -@@: - cmp offsetX, 0 - je @F - invoke PatBlt, h3DDC, 0, 0, offsetX, edi, 42h -@@: - mov eax, offsetX - add eax, viewW - mov ecx, esi - sub ecx, eax - test ecx, ecx - jz @F - invoke PatBlt, h3DDC, eax, 0, ecx, edi, 42h -@@: - invoke PresentRoofHD3D,h3DDC,offsetX,offsetY,viewW,viewH - test eax,eax - jnz present_done - invoke StretchDIBits, h3DDC, offsetX, offsetY, viewW, viewH, 0, 0, SCREEN_W, SCREEN_H, OFFSET screenBuffer, OFFSET bmi3D, 0, SRCCOPY -present_done: - ret -Present3D ENDP - -ToggleFullscreen3D PROC uses ebx esi edi - local visibleStyle:DWORD - local detailOpen:DWORD - mov eax,coinDetailWnd3D - mov detailOpen,eax - call CloseCoinDetail3D - invoke GetWindowLongA, h3DWnd, -16 - and eax, 10000000h - mov visibleStyle, eax - cmp fullscreen3D, 0 - jne restore_window - invoke GetWindowRect, h3DWnd, OFFSET savedRect3D - invoke MonitorFromWindow, h3DWnd, 2 - invoke GetMonitorInfoA, eax, OFFSET monitor3D - test eax, eax - jz fullscreen_done - mov eax, visibleStyle - or eax, 80000000h - invoke SetWindowLongA, h3DWnd, -16, eax - mov eax, monitor3D[12] - sub eax, monitor3D[4] - mov ebx, monitor3D[16] - sub ebx, monitor3D[8] - invoke SetWindowPos, h3DWnd, 0, monitor3D[4], monitor3D[8], eax, ebx, 24h - mov fullscreen3D, 1 - jmp fullscreen_done -restore_window: - mov eax, visibleStyle - or eax, WS_OVERLAPPEDWINDOW - invoke SetWindowLongA, h3DWnd, -16, eax - mov eax, savedRect3D[8] - sub eax, savedRect3D - mov ebx, savedRect3D[12] - sub ebx, savedRect3D[4] - invoke SetWindowPos, h3DWnd, 0, savedRect3D, savedRect3D[4], eax, ebx, 24h - mov fullscreen3D, 0 -fullscreen_done: - cmp detailOpen,0 - je @F - call OpenCoinDetail3D -@@: - ret -ToggleFullscreen3D ENDP - -UpdateCamera3D PROC uses ebx - mov eax, playerAngle - and eax, 511 - mov ebx, tableCos[eax*4] - mov playerDirX, ebx - mov eax, tableSin[eax*4] - mov playerDirY, eax - imul eax, -66 - cdq - mov ecx, 100 - idiv ecx - mov playerPlaneX, eax - mov eax, playerDirX - imul eax, 66 - cdq - idiv ecx - mov playerPlaneY, eax - ret -UpdateCamera3D ENDP - -; Four corners of a 0.3-tile-wide body; bounds checked before every map read. -CanWalk3D PROC uses ebx esi edi px:DWORD, py:DWORD + mov brEntryHold3D,0 + mov dtHolding3D,0 + mov dtMouseReleased3D,0 + call ClearKeys3D + jmp event_done +event_erase: + mov eax, 1 + ret +event_paint: + invoke BeginPaint, hwnd, OFFSET paint3D + cmp h3DDC, 0 + je @F + call Present3D +@@: + invoke EndPaint, hwnd, OFFSET paint3D + jmp event_done +event_close: + invoke PostQuitMessage, 0 +event_done: + xor eax, eax + ret +WindowEvents3D ENDP + +LoadDisplaySettings3D PROC uses ebx + invoke CreateFileA, OFFSET displaySettingsPath3D, 80000000h, 1, 0, 3, 80h, 0 + cmp eax, -1 + je display_settings_load_done + mov ebx, eax + invoke ReadFile, ebx, OFFSET displaySettingsData3D, 12, OFFSET displaySettingsIo3D, 0 + invoke CloseHandle, ebx + cmp displaySettingsIo3D, 12 + jne display_settings_load_done + cmp displaySettingsData3D, 44535031h + jne display_settings_load_done + mov eax, displaySettingsData3D[4] + and eax, 1 + mov displayFill3D, eax +display_settings_load_done: + ret +LoadDisplaySettings3D ENDP + +SaveDisplaySettings3D PROC uses ebx + invoke CreateDirectoryA, OFFSET runtime3D, 0 + mov displaySettingsData3D, 44535031h + mov eax, displayFill3D + mov displaySettingsData3D[4], eax + mov displaySettingsData3D[8], 0 + invoke CreateFileA, OFFSET displaySettingsPath3D, 40000000h, 0, 0, 2, 80h, 0 + cmp eax, -1 + je display_settings_save_done + mov ebx, eax + invoke WriteFile, ebx, OFFSET displaySettingsData3D, 12, OFFSET displaySettingsIo3D, 0 + invoke CloseHandle, ebx +display_settings_save_done: + ret +SaveDisplaySettings3D ENDP + +Pressed3D PROC key:DWORD + mov ecx, key + xor eax, eax + cmp ecx, 255 + ja @F + cmp pressedKeys3D[ecx], 0 + je @F + mov pressedKeys3D[ecx], 0 + mov eax, 8000h +@@: + ret +Pressed3D ENDP + +InitPaths3D PROC uses ebx esi edi + invoke GetModuleFileNameA, 0, OFFSET directory3D, SIZEOF directory3D + test eax, eax + jz path_done + lea esi, directory3D + mov edi, esi +path_scan: + mov al, [esi] + test al, al + jz path_found + cmp al, '\' + jne @F + mov edi, esi +@@: + inc esi + jmp path_scan +path_found: + mov BYTE PTR [edi], 0 + invoke SetCurrentDirectoryA, OFFSET directory3D + mov ebx, 3 +path_assets: + invoke GetFileAttributesA, OFFSET szTexturesRelPath + cmp eax, -1 + jne path_done + dec ebx + jz path_restore + ; Root, bin and build/graphics launches resolve the same asset directory. + invoke SetCurrentDirectoryA, OFFSET parent3D + test eax, eax + jnz path_assets +path_restore: + invoke SetCurrentDirectoryA, OFFSET directory3D +path_done: + ret +InitPaths3D ENDP + +Create3DWindow PROC uses ebx esi edi + local widthPx:DWORD + local heightPx:DWORD + invoke GetModuleHandleA, OFFSET user32Name3D + invoke GetProcAddress, eax, OFFSET dpiName3D + test eax, eax + jz @F + call eax +@@: + invoke GetModuleHandleA, 0 + mov h3DInst, eax + mov wc3D.hInstance, eax + invoke LoadIconA, eax, 1 + mov wc3D.hIcon, eax + mov wc3D.hIconSm, eax + invoke LoadCursorA, 0, 32512 + mov wc3D.hCursor, eax + mov wc3D.cbSize, SIZEOF C3D_WNDCLASSEX + mov wc3D.style, CS_HREDRAW or CS_VREDRAW + mov wc3D.lpfnWndProc, OFFSET Casino3DWndProc + mov wc3D.lpszClassName, OFFSET sz3DClassName + invoke RegisterClassExA, OFFSET wc3D + mov bmi3D.bmiHeader.biSize, SIZEOF C3D_BITMAPINFOHEADER + mov bmi3D.bmiHeader.biWidth, SCREEN_W + mov bmi3D.bmiHeader.biHeight, -SCREEN_H + mov bmi3D.bmiHeader.biPlanes, 1 + mov bmi3D.bmiHeader.biBitCount, 32 + mov bmi3D.bmiHeader.biSizeImage, SCREEN_SIZE * 4 + invoke GetSystemMetrics, 0 + mov esi, eax + sub eax, 80 + cmp eax, 1120 + jle @F + mov eax, 1120 +@@: + mov widthPx, eax + invoke GetSystemMetrics, 1 + mov edi, eax + sub eax, 120 + mov heightPx, eax + mov eax, widthPx + imul eax, 3 + shr eax, 2 + cmp eax, heightPx + jle @F + mov eax, heightPx + imul eax, 4 + xor edx, edx + mov ecx, 3 + div ecx + mov widthPx, eax +@@: + mov eax, widthPx + imul eax, 3 + shr eax, 2 + mov clientRect3D[12], eax + mov eax, widthPx + mov clientRect3D[8], eax + invoke AdjustWindowRectEx, OFFSET clientRect3D, WS_OVERLAPPEDWINDOW, 0, 0 + mov eax, clientRect3D[8] + sub eax, clientRect3D + mov widthPx, eax + sub esi, eax + sar esi, 1 + mov eax, clientRect3D[12] + sub eax, clientRect3D[4] + mov heightPx, eax + sub edi, eax + sar edi, 1 + invoke CreateWindowExA, 0, OFFSET sz3DClassName, OFFSET sz3DWindowTitle, WS_OVERLAPPEDWINDOW, esi, edi, widthPx, heightPx, 0, 0, h3DInst, 0 + test eax, eax + jz window_failed + mov h3DWnd, eax + invoke GetDC, h3DWnd + mov h3DDC, eax + test eax, eax + jz window_failed + invoke SetStretchBltMode, h3DDC, 3 + ; Resize while hidden. Init3DEngine paints the ident before showing it. + mov fullscreen3D, 0 + call ToggleFullscreen3D + mov eax, 1 +window_failed: + ret +Create3DWindow ENDP + +LoadTextures3D PROC uses ebx + local count:DWORD + invoke CreateFileA, OFFSET szTexturesRelPath, 80000000h, 1, 0, 3, 80h, 0 + cmp eax, -1 + je assets_failed + mov ebx, eax + invoke ReadFile, ebx, OFFSET texturesBuffer, 48*128*128*4, ADDR count, 0 + push eax + invoke CloseHandle, ebx + pop eax + test eax, eax + jz assets_failed + cmp count, 48*128*128*4 + jne assets_failed + mov eax, 1 + ret +assets_failed: + invoke MessageBoxA, h3DWnd, OFFSET textMissing3D, OFFSET sz3DWindowTitle, 10h + xor eax, eax + ret +LoadTextures3D ENDP + +Present3D PROC uses ebx esi edi + local viewW:DWORD + local viewH:DWORD + local offsetX:DWORD + local offsetY:DWORD + invoke GetClientRect, h3DWnd, OFFSET clientRect3D + mov esi, clientRect3D[8] + mov edi, clientRect3D[12] + test esi, esi + jz present_done + test edi, edi + jz present_done + invoke PresentHDStudio3D,h3DDC,esi,edi + test eax,eax + jnz present_done + cmp displayFill3D, 0 + je present_keep_aspect + mov viewW, esi + mov viewH, edi + jmp present_geometry_ready +present_keep_aspect: + mov viewW, esi + mov eax, esi + imul eax, 3 + shr eax, 2 + cmp eax, edi + jle @F + mov eax, edi + imul eax, 4 + xor edx, edx + mov ecx, 3 + div ecx + mov viewW, eax + mov eax, edi +@@: + mov viewH, eax +present_geometry_ready: + mov ebx, esi + sub ebx, viewW + shr ebx, 1 + mov offsetX, ebx + mov ebx, edi + sub ebx, viewH + shr ebx, 1 + mov offsetY, ebx + mov viewTop3D, ebx + mov eax, offsetX + mov viewLeft3D, eax + mov eax, viewW + mov viewWidth3D, eax + mov eax, viewH + mov viewHeight3D, eax + ; Only clear the letterbox bars, never erase under the next frame. + cmp offsetY, 0 + je @F + invoke PatBlt, h3DDC, 0, 0, esi, offsetY, 42h +@@: + mov eax, offsetY + add eax, viewH + mov ecx, edi + sub ecx, eax + test ecx, ecx + jz @F + invoke PatBlt, h3DDC, 0, eax, esi, ecx, 42h +@@: + cmp offsetX, 0 + je @F + invoke PatBlt, h3DDC, 0, 0, offsetX, edi, 42h +@@: + mov eax, offsetX + add eax, viewW + mov ecx, esi + sub ecx, eax + test ecx, ecx + jz @F + invoke PatBlt, h3DDC, eax, 0, ecx, edi, 42h +@@: + invoke PresentRoofHD3D,h3DDC,offsetX,offsetY,viewW,viewH + test eax,eax + jnz present_done + invoke StretchDIBits, h3DDC, offsetX, offsetY, viewW, viewH, 0, 0, SCREEN_W, SCREEN_H, OFFSET screenBuffer, OFFSET bmi3D, 0, SRCCOPY +present_done: + ret +Present3D ENDP + +ToggleFullscreen3D PROC uses ebx esi edi + local visibleStyle:DWORD + local detailOpen:DWORD + mov eax,coinDetailWnd3D + mov detailOpen,eax + call CloseCoinDetail3D + invoke GetWindowLongA, h3DWnd, -16 + and eax, 10000000h + mov visibleStyle, eax + cmp fullscreen3D, 0 + jne restore_window + invoke GetWindowRect, h3DWnd, OFFSET savedRect3D + invoke MonitorFromWindow, h3DWnd, 2 + invoke GetMonitorInfoA, eax, OFFSET monitor3D + test eax, eax + jz fullscreen_done + mov eax, visibleStyle + or eax, 80000000h + invoke SetWindowLongA, h3DWnd, -16, eax + mov eax, monitor3D[12] + sub eax, monitor3D[4] + mov ebx, monitor3D[16] + sub ebx, monitor3D[8] + invoke SetWindowPos, h3DWnd, 0, monitor3D[4], monitor3D[8], eax, ebx, 24h + mov fullscreen3D, 1 + jmp fullscreen_done +restore_window: + mov eax, visibleStyle + or eax, WS_OVERLAPPEDWINDOW + invoke SetWindowLongA, h3DWnd, -16, eax + mov eax, savedRect3D[8] + sub eax, savedRect3D + mov ebx, savedRect3D[12] + sub ebx, savedRect3D[4] + invoke SetWindowPos, h3DWnd, 0, savedRect3D, savedRect3D[4], eax, ebx, 24h + mov fullscreen3D, 0 +fullscreen_done: + cmp detailOpen,0 + je @F + call OpenCoinDetail3D +@@: + ret +ToggleFullscreen3D ENDP + +UpdateCamera3D PROC uses ebx + mov eax, playerAngle + and eax, 511 + mov ebx, tableCos[eax*4] + mov playerDirX, ebx + mov eax, tableSin[eax*4] + mov playerDirY, eax + imul eax, -66 + cdq + mov ecx, 100 + idiv ecx + mov playerPlaneX, eax + mov eax, playerDirX + imul eax, 66 + cdq + idiv ecx + mov playerPlaneY, eax + ret +UpdateCamera3D ENDP + +; Four corners of a 0.3-tile-wide body; bounds checked before every map read. +CanWalk3D PROC uses ebx esi edi px:DWORD, py:DWORD + cmp hqActive,1 + je br_generic_collision cmp engineMode,MODE_HELL_FPS je br_generic_collision cmp brActive3D,0 jne br_generic_collision - invoke CanWalkHall3D, px, py - test eax, eax - jz walk_blocked -br_generic_collision: - mov esi, -9830 -walk_corner_x: - mov edi, -9830 -walk_corner_y: - mov eax, px - add eax, esi - sar eax, 16 - cmp eax, MAP_WIDTH - jae walk_blocked - mov ebx, eax - mov eax, py - add eax, edi - sar eax, 16 - cmp eax, MAP_HEIGHT - jae walk_blocked - shl eax, 5 - add eax, ebx - mov ecx, worldMap3D - cmp BYTE PTR [ecx+eax], 0 - jne walk_blocked - add edi, 19660 - cmp edi, 9830 - jle walk_corner_y - add esi, 19660 - cmp esi, 9830 - jle walk_corner_x - mov eax, 1 - ret -walk_blocked: - xor eax, eax - ret -CanWalk3D ENDP - -LoadProgress3D PROC uses ebx - mov bankroll, 10000 - mov ownedBacks3D, 1 - mov selectedBack3D, 0 - mov charmCloverUses, 0 - mov charmHorseshoeUses, 0 - mov charmSkullUses, 0 - mov charmDevilUses, 0 - mov charmEnabledMask3D,7 + invoke CanWalkHall3D, px, py + test eax, eax + jz walk_blocked +br_generic_collision: + mov esi, -9830 +walk_corner_x: + mov edi, -9830 +walk_corner_y: + mov eax, px + add eax, esi + sar eax, 16 + cmp eax, MAP_WIDTH + jae walk_blocked + mov ebx, eax + mov eax, py + add eax, edi + sar eax, 16 + cmp eax, MAP_HEIGHT + jae walk_blocked + shl eax, 5 + add eax, ebx + mov ecx, worldMap3D + cmp BYTE PTR [ecx+eax], 0 + jne walk_blocked + add edi, 19660 + cmp edi, 9830 + jle walk_corner_y + add esi, 19660 + cmp esi, 9830 + jle walk_corner_x + mov eax, 1 + ret +walk_blocked: + xor eax, eax + ret +CanWalk3D ENDP + +LoadProgress3D PROC uses ebx + mov bankroll, 10000 + mov ownedBacks3D, 1 + mov selectedBack3D, 0 + mov charmCloverUses, 0 + mov charmHorseshoeUses, 0 + mov charmSkullUses, 0 + mov charmDevilUses, 0 + mov charmEnabledMask3D,7 mov hfCompleted,0 - mov brOwned3D,0 - mov brEnabled3D,1 - invoke CreateFileA, OFFSET savePath3D, 80000000h, 1, 0, 3, 80h, 0 - cmp eax, -1 - je progress_loaded - mov ebx, eax - invoke ReadFile, ebx, OFFSET saveData3D, 40, OFFSET saveIo3D, 0 - invoke CloseHandle, ebx - cmp saveIo3D, 16 - jb progress_loaded - cmp saveData3D,34443343h - jne progress_legacy_version - cmp saveIo3D,40 - jne progress_loaded - invoke PreviewArtifactSignature3D,OFFSET saveData3D - cmp eax,saveData3D[36] - jne progress_loaded - mov eax,saveData3D[32] + mov brOwned3D,0 + mov brEnabled3D,1 + invoke CreateFileA, OFFSET savePath3D, 80000000h, 1, 0, 3, 80h, 0 + cmp eax, -1 + je progress_loaded + mov ebx, eax + invoke ReadFile, ebx, OFFSET saveData3D, 40, OFFSET saveIo3D, 0 + invoke CloseHandle, ebx + cmp saveIo3D, 16 + jb progress_loaded + cmp saveData3D,34443343h + jne progress_legacy_version + cmp saveIo3D,40 + jne progress_loaded + invoke PreviewArtifactSignature3D,OFFSET saveData3D + cmp eax,saveData3D[36] + jne progress_loaded + mov eax,saveData3D[32] test eax,0FFF8FFF0h - jnz progress_loaded - test eax,20000h - jz @F - test eax,10000h - jz progress_loaded -@@: - mov ecx,eax - and ecx,15 - mov charmEnabledMask3D,ecx - shr eax,16 - and eax,1 - mov brOwned3D,eax - mov eax,saveData3D[32] - shr eax,17 - and eax,1 - mov brEnabled3D,eax + jnz progress_loaded + test eax,20000h + jz @F + test eax,10000h + jz progress_loaded +@@: + mov ecx,eax + and ecx,15 + mov charmEnabledMask3D,ecx + shr eax,16 + and eax,1 + mov brOwned3D,eax + mov eax,saveData3D[32] + shr eax,17 + and eax,1 + mov brEnabled3D,eax mov eax,saveData3D[32] shr eax,18 and eax,1 mov hfCompleted,eax - jmp progress_version_ok -progress_legacy_version: - cmp saveData3D, 33443343h - je progress_version_ok - cmp saveData3D, 32443343h - jne progress_loaded -; Preserve the old preview's gold/emerald/crimson purchases by identity. - mov edx, 1 - test saveData3D[8], 2 - jz @F - or edx, 8 -@@: - test saveData3D[8], 4 - jz @F - or edx, 20h -@@: - test saveData3D[8], 8 - jz @F - or edx, 4 -@@: - mov saveData3D[8], edx - mov ecx, saveData3D[12] - cmp ecx, 3 - ja progress_loaded - mov eax, previewBackMap3D[ecx*4] - mov saveData3D[12], eax -progress_version_ok: - mov eax, saveData3D[4] - cmp eax, 1000000000 - ja progress_loaded - mov bankroll, eax - mov eax, saveData3D[8] - and eax, 1FFFh - or eax, 1 - mov ownedBacks3D, eax - mov ecx, saveData3D[12] - cmp ecx, 12 - ja progress_loaded - bt eax, ecx - jnc progress_loaded - mov selectedBack3D, ecx - cmp saveIo3D, 32 - jb progress_loaded - mov eax, saveData3D[16] - mov charmCloverUses, eax - mov eax, saveData3D[20] - mov charmHorseshoeUses, eax - mov eax, saveData3D[24] - mov charmSkullUses, eax - mov eax, saveData3D[28] - mov charmDevilUses, eax -progress_loaded: - call ClampArtifacts3D - ret -LoadProgress3D ENDP - -SaveProgress3D PROC uses ebx - cmp obsActive3D,0 - jne progress_saved - IFDEF CASINO_ACTION_TEST - ret - ENDIF - cmp arrivalConfirmed3D, 0 - je progress_saved - call RefreshTerminalAchievements3D - cmp nativeProfileActive3D, 0 - je @F - call SaveGraphicProfile3D - ret -@@: - invoke CreateDirectoryA, OFFSET runtime3D, 0 - mov saveData3D, 34443343h - mov eax, bankroll - mov saveData3D[4], eax - mov eax, ownedBacks3D - mov saveData3D[8], eax - mov eax, selectedBack3D - mov saveData3D[12], eax - mov eax, charmCloverUses - mov saveData3D[16], eax - mov eax, charmHorseshoeUses - mov saveData3D[20], eax - mov eax, charmSkullUses - mov saveData3D[24], eax - mov eax, charmDevilUses - mov saveData3D[28], eax - mov eax,brOwned3D - and eax,1 - shl eax,16 - mov ecx,brEnabled3D - and ecx,brOwned3D - and ecx,1 - shl ecx,17 - or eax,ecx - or eax,charmEnabledMask3D + jmp progress_version_ok +progress_legacy_version: + cmp saveData3D, 33443343h + je progress_version_ok + cmp saveData3D, 32443343h + jne progress_loaded +; Preserve the old preview's gold/emerald/crimson purchases by identity. + mov edx, 1 + test saveData3D[8], 2 + jz @F + or edx, 8 +@@: + test saveData3D[8], 4 + jz @F + or edx, 20h +@@: + test saveData3D[8], 8 + jz @F + or edx, 4 +@@: + mov saveData3D[8], edx + mov ecx, saveData3D[12] + cmp ecx, 3 + ja progress_loaded + mov eax, previewBackMap3D[ecx*4] + mov saveData3D[12], eax +progress_version_ok: + mov eax, saveData3D[4] + cmp eax, 1000000000 + ja progress_loaded + mov bankroll, eax + mov eax, saveData3D[8] + and eax, 1FFFh + or eax, 1 + mov ownedBacks3D, eax + mov ecx, saveData3D[12] + cmp ecx, 12 + ja progress_loaded + bt eax, ecx + jnc progress_loaded + mov selectedBack3D, ecx + cmp saveIo3D, 32 + jb progress_loaded + mov eax, saveData3D[16] + mov charmCloverUses, eax + mov eax, saveData3D[20] + mov charmHorseshoeUses, eax + mov eax, saveData3D[24] + mov charmSkullUses, eax + mov eax, saveData3D[28] + mov charmDevilUses, eax +progress_loaded: + call LoadUnderworldProgress3D + call ClampArtifacts3D + ret +LoadProgress3D ENDP + +SaveProgress3D PROC uses ebx + cmp obsActive3D,0 + jne progress_saved + IFDEF CASINO_ACTION_TEST + ret + ENDIF + cmp arrivalConfirmed3D, 0 + je progress_saved + call RefreshTerminalAchievements3D + call SaveUnderworldProgress3D + cmp nativeProfileActive3D, 0 + je @F + call SaveGraphicProfile3D + ret +@@: + invoke CreateDirectoryA, OFFSET runtime3D, 0 + mov saveData3D, 34443343h + mov eax, bankroll + mov saveData3D[4], eax + mov eax, ownedBacks3D + mov saveData3D[8], eax + mov eax, selectedBack3D + mov saveData3D[12], eax + mov eax, charmCloverUses + mov saveData3D[16], eax + mov eax, charmHorseshoeUses + mov saveData3D[20], eax + mov eax, charmSkullUses + mov saveData3D[24], eax + mov eax, charmDevilUses + mov saveData3D[28], eax + mov eax,brOwned3D + and eax,1 + shl eax,16 + mov ecx,brEnabled3D + and ecx,brOwned3D + and ecx,1 + shl ecx,17 + or eax,ecx + or eax,charmEnabledMask3D mov ecx,hfCompleted and ecx,1 shl ecx,18 or eax,ecx - mov saveData3D[32],eax - invoke PreviewArtifactSignature3D,OFFSET saveData3D - mov saveData3D[36],eax - invoke CreateFileA, OFFSET savePath3D, 40000000h, 0, 0, 2, 80h, 0 - cmp eax, -1 - je progress_saved - mov ebx, eax - invoke WriteFile, ebx, OFFSET saveData3D, 40, OFFSET saveIo3D, 0 - invoke CloseHandle, ebx -progress_saved: - ret -SaveProgress3D ENDP + mov saveData3D[32],eax + invoke PreviewArtifactSignature3D,OFFSET saveData3D + mov saveData3D[36],eax + invoke CreateFileA, OFFSET savePath3D, 40000000h, 0, 0, 2, 80h, 0 + cmp eax, -1 + je progress_saved + mov ebx, eax + invoke WriteFile, ebx, OFFSET saveData3D, 40, OFFSET saveIo3D, 0 + invoke CloseHandle, ebx +progress_saved: + ret +SaveProgress3D ENDP diff --git a/src_graphics/presentation_code.inc b/src_graphics/presentation_code.inc index a8dddab..bc66edf 100644 --- a/src_graphics/presentation_code.inc +++ b/src_graphics/presentation_code.inc @@ -81,82 +81,8 @@ pres_text_done: ret PresentationText3D ENDP -RenderStartupNotice3D PROC uses ebx esi edi - local lineY:DWORD,ink:DWORD - invoke DrawBox,0,0,320,240,00060912h - ; Quiet terminal grid, fixed geometry: never consumes gameplay RNG. - mov ebx,12 -pres_notice_grid: - invoke DrawBox,0,ebx,320,1,000C1722h - add ebx,16 - cmp ebx,240 - jb pres_notice_grid - invoke DrawBox,20,26,3,22,00FFCE54h - invoke DrawBox,26,26,274,1,002C6875h - invoke DrawBox,20,212,280,1,002C6875h - cmp startupPage3D,STARTUP_AI - jne pres_notice_code - invoke PresentationText3D,56,60,OFFSET presAITag,004FE5E2h,1,-1 - invoke PresentationText3D,56,88,OFFSET presAIHeader,00FFDF82h,2,-1 - invoke PresentationText3D,40,156,OFFSET presAIBody,00CFDCE4h,2,-1 - invoke PresentationText3D,56,378,OFFSET presAIFooter,004FE5E2h,1,-1 - jmp pres_notice_footer -pres_notice_code: - invoke PresentationText3D,56,64,OFFSET presCodeHeader,00FFDF82h,2,-1 - invoke PresentationText3D,40,112,OFFSET presCodeSub,00CFDCE4h,2,-1 - invoke DrawBoxBorder,12,80,144,90,00080F1Bh,002D7C92h,1 - invoke DrawBoxBorder,164,80,144,90,00080F1Bh,003BE8CAh,1 - invoke DrawBox,13,81,142,14,0017283Ch - invoke DrawBox,165,81,142,14,00143435h - invoke PresentationText3D,36,170,OFFSET presCodeLeft,00D0DDEBh,1,-1 - invoke PresentationText3D,340,170,OFFSET presCodeRight,0062F3D3h,1,-1 - mov esi,0 - mov lineY,204 -pres_code_line: - mov ink,00C9D9E8h - cmp esi,0 - jne @F - mov ink,00657D92h -@@: - invoke PresentationText3D,36,lineY,presCppLines[esi*4],ink,1,-1 - invoke PresentationText3D,340,lineY,presAsmLines[esi*4],ink,1,-1 - add lineY,17 - inc esi - cmp esi,7 - jb pres_code_line - invoke PresentationText3D,24,356,OFFSET presCodeCaption,00FFDF82h,2,-1 - invoke PresentationText3D,40,386,OFFSET presCodeNote,009FB8C8h,1,-1 -pres_notice_footer: - invoke PresentationText3D,40,448,OFFSET presNext,006F939Fh,1,-1 - ; Fade the notice in, then out at its own page boundary. - mov eax,startupElapsed3D - cmp eax,300 - jae pres_notice_fade_out - shl eax,8 - xor edx,edx - mov ecx,300 - div ecx - invoke FadeCityFrame3D,eax - ret -pres_notice_fade_out: - mov ecx,startupPage3D - mov ebx,startupDurations3D[ecx*4] - sub ebx,400 - cmp eax,ebx - jb pres_notice_done - sub eax,ebx - cmp eax,400 - jbe @F - mov eax,400 -@@: - shl eax,8 - xor edx,edx - mov ecx,400 - div ecx - neg eax - add eax,256 - invoke FadeCityFrame3D,eax -pres_notice_done: +RenderStartupNotice3D PROC + call RenderStartupCinematic3D ret RenderStartupNotice3D ENDP diff --git a/src_graphics/presentation_data.inc b/src_graphics/presentation_data.inc index 0082e53..9965e61 100644 --- a/src_graphics/presentation_data.inc +++ b/src_graphics/presentation_data.inc @@ -1,7 +1,9 @@ -; All timings and presentation state are native ASM; no extra runtime or assets. -STARTUP_STUDIO equ 0 -STARTUP_AI equ 1 -STARTUP_CODE equ 2 +; Presentation state is native MASM. Cinematic art/audio are offline packed assets. +STUDIO_HD_DURATION equ 16000 +STARTUP_WARNING equ 0 +STARTUP_STUDIO equ 1 +STARTUP_TITLE equ 2 +STARTUP_FEATURES equ 3 WELCOME_OPEN_MS equ 600 WELCOME_CHAR_MS equ 18 BeginWelcome3D PROTO @@ -12,9 +14,12 @@ RenderWelcomeScene3D PROTO PresentationText3D PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD RenderStartupNotice3D PROTO AdvanceStartup3D PROTO +RenderStartupCinematic3D PROTO .data -startupPage3D dd STARTUP_STUDIO -startupDurations3D dd 7000,10000,11000 +startupPage3D dd STARTUP_WARNING +startupDurations3D dd 8500,STUDIO_HD_DURATION,12000,11000 +bootStudioSound db 'assets\audio\startup\studio-workshop-v8.wav',0 +bootTitleSound db 'assets\audio\startup\casino-title.wav',0 welcomeActive3D dd 0 welcomeElapsed3D dd 0 welcomeChars3D dd 0 @@ -24,4 +29,9 @@ presCppLines dd OFFSET presCpp0,OFFSET presCpp1,OFFSET presCpp2,OFFSET presCpp3 dd OFFSET presCpp4,OFFSET presCpp5,OFFSET presCpp6 presAsmLines dd OFFSET presAsm0,OFFSET presAsm1,OFFSET presAsm2,OFFSET presAsm3 dd OFFSET presAsm4,OFFSET presAsm5,OFFSET presAsm6 +bootFeatureNumbers dd OFFSET bootNumber1,OFFSET bootNumber2,OFFSET bootNumber3 +bootFeatureHeaders dd OFFSET bootHeader1,OFFSET bootHeader2,OFFSET bootHeader3 +bootFeatureBodies dd OFFSET bootBody1,OFFSET bootBody2,OFFSET bootBody3 +.code +include src_graphics\startup_geometry.inc .code diff --git a/src_graphics/presentation_text.inc b/src_graphics/presentation_text.inc index 620aef6..e06e248 100644 --- a/src_graphics/presentation_text.inc +++ b/src_graphics/presentation_text.inc @@ -1,5 +1,62 @@ ; Generated by tools/generators/make_presentation_text.py. CP1251 bytes. .data +bootAge db 49,56,43,0 +bootAgeEnd label byte +bootWarningTag db 207,197,208,197,196,32,205,192,215,192,203,206,204,32,47,32,65,83,83,69,77,66,76,69,82,32,67,65,83,73,78,79 + db 0 +bootWarningTagEnd label byte +bootWarningTitle db 207,206,32,210,211,32,209,210,206,208,206,205,211,32,211,196,192,215,200,0 +bootWarningTitleEnd label byte +bootWarningBody db 221,242,238,32,226,251,236,251,248,235,229,237,237,251,233,32,236,232,240,32,224,231,224,240,242,237,251,245,32,232,227,240 + db 46,10,194,241,229,32,241,242,224,226,234,232,32,45,32,237,224,32,232,227,240,238,226,243,254,32,226,224,235,254,242,243 + db 46,10,194,251,232,227,240,251,248,32,237,229,32,232,236,229,229,242,32,228,229,237,229,230,237,238,233,32,246,229,237,237 + db 238,241,242,232,46,10,10,194,32,232,227,240,229,32,229,241,242,252,32,241,246,229,237,251,32,234,243,240,229,237,232,255 + db 32,232,32,237,224,241,232,235,232,255,44,10,224,32,242,224,234,230,229,32,237,229,237,238,240,236,224,242,232,226,237,224 + db 255,32,235,229,234,241,232,234,224,46,0 +bootWarningBodyEnd label byte +bootWarningAI db 215,224,241,242,252,32,232,231,238,225,240,224,230,229,237,232,233,32,241,238,231,228,224,237,224,32,241,32,239,238,236,238 + db 249,252,254,32,65,73,46,10,192,226,242,238,240,241,242,226,238,32,232,32,235,232,246,229,237,231,232,232,32,241,242,238 + db 240,238,237,237,232,245,32,240,229,241,243,240,241,238,226,10,241,238,245,240,224,237,229,237,251,46,32,209,239,232,241,238 + db 234,32,236,224,242,229,240,232,224,235,238,226,32,239,240,232,235,238,230,229,237,32,234,32,232,227,240,229,46,0 +bootWarningAIEnd label byte +bootPresents db 207,208,197,196,209,210,192,194,203,223,197,210,0 +bootPresentsEnd label byte +bootTitleTag db 211,32,202,192,198,196,206,201,32,209,210,192,194,202,200,32,197,209,210,220,32,214,197,205,192,46,0 +bootTitleTagEnd label byte +bootNext db 69,78,84,69,82,32,47,32,83,80,65,67,69,58,32,196,192,203,220,216,197,32,32,32,69,83,67,58,32,202,32,209 + db 214,197,205,197,0 +bootNextEnd label byte +bootFeatureTag db 207,208,197,198,196,197,32,215,197,204,32,206,210,202,208,206,197,210,209,223,32,196,194,197,208,220,0 +bootFeatureTagEnd label byte +bootFeatureTitle db 206,196,205,192,32,205,206,215,220,46,32,210,194,206,200,32,207,208,192,194,200,203,192,46,0 +bootFeatureTitleEnd label byte +bootNumber1 db 48,49,0 +bootNumber1End label byte +bootNumber2 db 48,50,0 +bootNumber2End label byte +bootNumber3 db 48,51,0 +bootNumber3End label byte +bootHeader1 db 200,195,208,192,201,0 +bootHeader1End label byte +bootHeader2 db 200,209,209,203,197,196,211,201,0 +bootHeader2End label byte +bootHeader3 db 199,205,192,202,206,204,220,209,223,0 +bootHeader3End label byte +bootBody1 db 202,224,240,242,251,44,32,240,243,235,229,242,234,224,44,32,224,226,242,238,236,224,242,251,32,232,32,239,238,228,239,238 + db 235,252,229,46,10,208,232,241,234,243,233,32,244,232,248,234,224,236,232,32,232,32,241,235,229,228,232,32,231,224,32,241 + db 226,238,232,236,32,225,224,237,234,238,236,46,0 +bootBody1End label byte +bootBody2 db 202,224,231,232,237,238,32,236,238,230,237,238,32,238,225,238,233,242,232,32,238,242,32,239,229,240,226,238,227,238,32,235 + db 232,246,224,46,10,199,224,227,235,255,228,251,226,224,233,32,226,32,234,238,236,237,224,242,251,32,232,32,232,249,232,32 + db 241,229,234,240,229,242,251,46,0 +bootBody2End label byte +bootBody3 db 211,32,225,224,240,224,44,32,226,32,239,238,228,226,224,235,229,32,232,32,231,224,32,231,224,234,240,251,242,251,236,232 + db 32,228,226,229,240,255,236,232,10,242,229,225,255,32,230,228,243,242,32,241,226,238,232,32,235,254,228,232,32,232,32,241 + db 226,238,232,32,232,241,242,238,240,232,232,46,0 +bootBody3End label byte +bootFeatureControls db 87,65,83,68,58,32,200,196,210,200,32,32,32,204,219,216,220,58,32,206,193,199,206,208,32,32,32,69,58,32,196,197 + db 201,209,210,194,200,197,0 +bootFeatureControlsEnd label byte presNext db 69,78,84,69,82,32,47,32,83,80,65,67,69,58,32,196,192,203,220,216,197,32,32,32,69,83,67,58,32,207,208,206 db 207,211,209,210,200,210,220,0 presNextEnd label byte diff --git a/src_graphics/rat_race.inc b/src_graphics/rat_race.inc new file mode 100644 index 0000000..073bb7d --- /dev/null +++ b/src_graphics/rat_race.inc @@ -0,0 +1,313 @@ +; ============================================================================== +; UNDERGROUND RAT RACES SCENE (CP1251) +; ============================================================================== + +InitRatRace3D PROC + invoke LoadAnimPack3D, OFFSET ratRacePack, OFFSET ratRacePath + ret +InitRatRace3D ENDP + +FreeRatRace3D PROC + invoke FreeAnimPack3D, OFFSET ratRacePack + ret +FreeRatRace3D ENDP + +BeginRatRace3D PROC uses edi + mov edi,OFFSET racerX + xor eax,eax + mov ecx,12 + rep stosd + mov edi,OFFSET racerState + mov ecx,4 + rep stosd + mov edi,OFFSET uwRatRanks + mov ecx,4 + rep stosd + mov uwRatFinished,0 + mov uwRaceAccumulator,0 + mov ratRacePhase,0 + mov ratRaceSlamUsed,0 + mov uwRatSlamTimer,0 + mov ratRacePayout,0 + mov engineMode,MODE_RAT_RACE + call ClearKeys3D + ret +BeginRatRace3D ENDP + +HandleRatRace3D PROC uses ebx esi edi + cmp ratRacePhase,0 + jne uw_race_running + mov esi,0 +uw_choose_rat: + lea eax,[esi+31h] + invoke Pressed3D,eax + test eax,eax + jz @F + mov ratRaceSelected,esi +@@: + inc esi + cmp esi,4 + jb uw_choose_rat + invoke Pressed3D,50h + test eax,eax + jz @F + xor uwRatPlaceBet,1 +@@: + invoke Pressed3D,26h + test eax,eax + jz @F + cmp ratRaceBet,500 + jae @F + add ratRaceBet,25 +@@: + invoke Pressed3D,28h + test eax,eax + jz @F + cmp ratRaceBet,25 + jbe @F + sub ratRaceBet,25 +@@: + invoke Pressed3D,1Bh + test eax,eax + jnz uw_race_exit + invoke Pressed3D,0Dh + test eax,eax + jz uw_race_done + mov eax,ratRaceBet + cmp bankroll,eax + jb uw_race_done + sub bankroll,eax + mov ratRacePhase,1 + call SaveProgress3D + ret +uw_race_running: + cmp ratRacePhase,1 + jne uw_race_result_input + invoke Pressed3D,20h + test eax,eax + jz uw_race_clock + cmp ratRaceSlamUsed,0 + jne uw_race_clock + mov ratRaceSlamUsed,1 + mov uwRatSlamTimer,350 + invoke PlayCasinoSound3D,OFFSET soundSkillHit,0,1 + xor esi,esi +uw_race_slam: + invoke RandomRange3D,3 + cmp eax,0 + jne @F + mov racerState[esi*4],6 + jmp uw_race_slam_next +@@: + cmp eax,1 + jne uw_race_slam_next + add racerX[esi*4],10 +uw_race_slam_next: + inc esi + cmp esi,4 + jb uw_race_slam +uw_race_clock: + mov eax,deltaTime3D + cmp eax,200 + jbe @F + mov eax,200 +@@: + add uwRaceAccumulator,eax + sub uwRatSlamTimer,eax + jns @F + mov uwRatSlamTimer,0 +@@: +uw_race_step: + cmp uwRaceAccumulator,70 + jb uw_race_done + sub uwRaceAccumulator,70 + invoke RandomRange3D,4 + mov edi,eax + xor esi,esi +uw_race_move: + lea ebx,[esi+edi] + and ebx,3 + cmp uwRatRanks[ebx*4],0 + jne uw_race_next + cmp racerState[ebx*4],0 + je uw_race_speed + dec racerState[ebx*4] + jmp uw_race_next +uw_race_speed: + invoke RandomRange3D,100 + cmp eax,5 + jae @F + mov racerState[ebx*4],5 + jmp uw_race_next +@@: + cmp eax,13 + jae @F + mov eax,6 + jmp uw_race_advance +@@: + invoke RandomRange3D,3 + inc eax + cmp ebx,0 + jne @F + inc eax +@@: + cmp ebx,1 + jne @F + cmp racerX[ebx*4],100 + jb @F + add eax,2 +@@: + cmp ebx,2 + jne @F + add eax,eax +@@: + cmp ebx,3 + jne uw_race_advance + mov eax,3 +uw_race_advance: + add racerX[ebx*4],eax + inc racerAnimFrame[ebx*4] + cmp racerX[ebx*4],192 + jb uw_race_next + mov racerX[ebx*4],192 + inc uwRatFinished + mov eax,uwRatFinished + mov uwRatRanks[ebx*4],eax + cmp eax,1 + jne uw_race_next + mov ratRaceWinner,ebx +uw_race_next: + inc esi + cmp esi,4 + jb uw_race_move + cmp uwRatFinished,4 + jb uw_race_step + mov ratRacePhase,2 + mov ebx,ratRaceSelected + mov ecx,1 + cmp uwRatPlaceBet,0 + je @F + mov ecx,2 +@@: + cmp uwRatRanks[ebx*4],ecx + ja uw_race_lost + mov eax,ratRaceBet + mov ecx,racerOddsNumerator[ebx*4] + cmp uwRatPlaceBet,0 + je @F + mov ecx,15 +@@: + mul ecx + mov ecx,10 + div ecx + mov ratRacePayout,eax + add bankroll,eax + invoke PlayCasinoSound3D,OFFSET soundRoundWin,0,1 + jmp uw_race_settle +uw_race_lost: + invoke PlayCasinoSound3D,OFFSET soundRoundLose,0,1 +uw_race_settle: + call StepDebtRound3D + invoke DecaySecurityHeat,2 + call SaveProgress3D + ret +uw_race_result_input: + invoke Pressed3D,1Bh + test eax,eax + jnz uw_race_exit + invoke Pressed3D,0Dh + test eax,eax + jz uw_race_done + cmp uwDebtPending,0 + jne uw_race_exit + call BeginRatRace3D + ret +uw_race_exit: + mov engineMode,MODE_WALK + call ClearKeys3D +uw_race_done: + ret +HandleRatRace3D ENDP + +RenderRatRace3D PROC uses ebx esi edi + invoke DrawBox,0,0,320,240,0014100Bh + invoke DrawBoxBorder,6,6,308,228,00221A12h,00836D42h,1 + invoke DrawString8x8,16,16,OFFSET uwRatTitle,00E7CA88h + mov eax,ratRaceSelected + mov eax,uwRatNamePtrs[eax*4] + invoke DrawString8x8,16,30,eax,00A8DDB9h + xor esi,esi +uw_race_lane: + imul ebx,esi,34 + add ebx,40 + mov edi,004A3C2Fh + cmp esi,ratRaceSelected + jne @F + mov edi,00D8BC6Ah +@@: + invoke DrawBoxBorder,16,ebx,288,30,002D241Bh,edi,1 + mov eax,esi + inc eax + add ebx,10 + invoke DrawNumber,20,ebx,eax,edi + sub ebx,10 + mov eax,esi + shl eax,2 + mov edx,racerAnimFrame[esi*4] + and edx,3 + add eax,edx + mov ecx,racerX[esi*4] + add ecx,38 + cmp uwRatSlamTimer,0 + je @F + add ecx,2 +@@: + invoke DrawUnderworldSprite3D,OFFSET ratRacePack,eax,ecx,ebx,56,28 + mov eax,uwRatRanks[esi*4] + test eax,eax + jz @F + add ebx,10 + invoke DrawNumber,288,ebx,eax,00E7CA88h +@@: + inc esi + cmp esi,4 + jb uw_race_lane + invoke DrawBox,280,40,2,132,00D8BC6Ah + cmp ratRacePhase,0 + jne uw_race_render_running + invoke DrawString8x8,16,180,OFFSET uwRatKeys,00E4D9BDh + invoke DrawString8x8,16,192,OFFSET uwRatStart,00E4D9BDh + mov eax,OFFSET uwRatWinBet + cmp uwRatPlaceBet,0 + je @F + mov eax,OFFSET uwRatPlaceText +@@: + invoke DrawString8x8,16,206,eax,00A8DDB9h + jmp uw_race_footer +uw_race_render_running: + cmp ratRacePhase,1 + jne uw_race_render_result + mov eax,OFFSET uwRatRun + cmp ratRaceSlamUsed,0 + je @F + mov eax,OFFSET uwRatUsed +@@: + invoke DrawString8x8,16,188,eax,00E7CA88h + jmp uw_race_footer +uw_race_render_result: + cmp ratRacePayout,0 + je @F + invoke DrawString8x8,16,182,OFFSET uwRatWon,00A8DDB9h + invoke DrawNumber,104,182,ratRacePayout,00A8DDB9h + jmp uw_race_result_keys +@@: + invoke DrawString8x8,16,182,OFFSET uwRatLost,005555FFh +uw_race_result_keys: + invoke DrawString8x8,16,200,OFFSET uwRatResult,00E7CA88h +uw_race_footer: + invoke DrawString8x8,16,220,OFFSET uwRatMoney,00A8B6BBh + invoke DrawNumber,80,220,ratRaceBet,00E5D6B0h + invoke DrawString8x8,152,220,OFFSET uwBank,00A8B6BBh + invoke DrawNumber,208,220,bankroll,00E5D6B0h + ret +RenderRatRace3D ENDP diff --git a/src_graphics/rat_race_data.inc b/src_graphics/rat_race_data.inc new file mode 100644 index 0000000..e9dddaf --- /dev/null +++ b/src_graphics/rat_race_data.inc @@ -0,0 +1,55 @@ +; ============================================================================== +; UNDERGROUND RAT RACES DATA (CP1251) +; ============================================================================== + +MODE_RAT_RACE equ 31 + +BeginRatRace3D PROTO +HandleRatRace3D PROTO +RenderRatRace3D PROTO + +.data +ALIGN 4 +ratRacePack AnimPack3D <> +ratRacePath db "assets\animations\hall\rat-race-v2.bin",0 + +racerX dd 0, 0, 0, 0 ; positions along track (0..200) +racerSpeed dd 0, 0, 0, 0 ; current speed +racerAnimFrame dd 0, 0, 0, 0 ; animation frame (0..3) +racerOddsNumerator dd 35, 45, 55, 20 ; multipliers / 10 +racerState dd 0, 0, 0, 0 ; 0=normal, 1=burst, 2=stun + +ratRacePhase dd 0 ; 0=Betting, 1=Running, 2=Finished +ratRaceSelected dd 0 ; 0..3 +ratRaceBet dd 50 +ratRaceWinner dd 0 +ratRaceSlamUsed dd 0 +ratRaceShakeTimer dd 0 +ratRacePayout dd 0 +ratRaceLastTick dd 0 + +szRatTitle db 207,206,196,207,206,203,220,205,219,201,32,210 + db 206,210,192,203,200,199,192,210,206,208,58,32 + db 202,208,219,209,200,205,219,197,32,193,197,195 + db 192,0 +szRatRacer1 db 49,46,32,216,243,241,242,240,251,233,32,65 + db 83,77,32,40,120,51,46,53,41,0 +szRatRacer2 db 50,46,32,210,243,240,225,238,45,204,224,245 + db 238,226,232,234,32,40,120,52,46,53,41,0 +szRatRacer3 db 51,46,32,207,252,255,237,251,233,32,193,238 + db 246,236,224,237,32,40,120,53,46,53,41,0 +szRatRacer4 db 52,46,32,195,229,237,229,240,224,235,32,199 + db 224,240,232,237,32,40,120,50,46,48,41,0 +szRatBetPrompt db 194,219,193,206,208,58,32,49,45,52,44,32 + db 209,210,192,194,202,192,58,32,194,194,197,208 + db 213,47,194,205,200,199,44,32,209,210,192,208 + db 210,58,32,69,78,84,69,82,0 +szRatBetInfo db 209,210,192,194,202,192,58,32,36,0 +szRatSlamPrompt db 91,207,208,206,193,197,203,93,32,45,32,209 + db 210,211,202,205,211,210,220,32,207,206,32,209 + db 210,206,203,211,33,0 +szRatFinishWon db 207,206,193,197,196,192,33,32,194,219,200,195 + db 208,219,216,58,32,36,0 +szRatFinishLost db 194,192,216,32,193,197,195,211,205,32,207,208 + db 206,200,195,208,192,203,33,32,91,69,78,84 + db 69,82,93,32,45,32,194,219,213,206,196,0 diff --git a/src_graphics/security_data.inc b/src_graphics/security_data.inc new file mode 100644 index 0000000..ee3c542 --- /dev/null +++ b/src_graphics/security_data.inc @@ -0,0 +1,62 @@ +; ============================================================================== +; SECURITY, HEAT & PIT BOSS INTERROGATION DATA (CP1251) +; ============================================================================== + +MODE_SECURITY equ 33 + +AddSecurityHeat PROTO :DWORD +DecaySecurityHeat PROTO :DWORD +TriggerInterrogation3D PROTO +HandleSecurity3D PROTO +RenderSecurity3D PROTO + +.data +ALIGN 4 +securityHeat dd 0 +securityAlertLevel dd 0 +securitySubmode dd 0 +securityBribeAmount dd 0 +securitySkillNeedle dd 50 +securitySkillSpeed dd 3 +securitySkillDir dd 1 +securityResultMsg dd 0 + +secPortraitsPack AnimPack3D <> +secPortraitsPath db "assets\animations\hall\underworld-portraits-v2.bin",0 + +szSecTitle db 202,192,193,200,205,197,210,32,205,192,215,192 + db 203,220,205,200,202,192,32,193,197,199,206,207 + db 192,209,205,206,209,210,200,0 +szSecPrompt db 194,251,32,239,238,233,236,224,237,251,32,231 + db 224,32,239,238,228,238,231,240,232,242,229,235 + db 252,237,238,233,32,232,227,240,238,233,33,0 +szSecOpt1 db 49,46,32,192,234,234,243,240,224,242,237,224 + db 255,32,226,231,255,242,234,224,32,40,36,0 +szSecOpt2 db 50,46,32,205,224,228,224,226,232,242,252,32 + db 224,226,242,238,240,232,242,229,242,238,236,32 + db 86,73,80,0 +szSecOpt3 db 51,46,32,207,238,239,251,242,224,242,252,241 + db 255,32,241,225,229,230,224,242,252,32,91,207 + db 240,238,225,229,235,93,0 +szSecResultBribe db 207,232,242,45,225,238,241,241,32,243,225,232 + db 240,224,229,242,32,234,238,237,226,229,240,242 + db 58,32,209,226,238,225,238,228,229,237,46,32 + db 205,229,32,239,238,239,224,228,224,233,241,255 + db 46,0 +szSecResultBluff db 207,232,242,45,225,238,241,241,32,241,226,229 + db 240,255,229,242,32,241,239,232,241,238,234,32 + db 86,73,80,58,32,207,240,238,248,243,32,239 + db 240,238,249,229,237,232,255,44,32,241,253,240 + db 46,0 +szSecResultEscape db 194,251,32,238,239,240,238,234,232,237,243,235 + db 232,32,241,242,238,235,32,232,32,241,234,240 + db 251,235,232,241,252,32,226,32,226,229,237,242 + db 232,235,255,246,232,232,33,0 +szSecResultBust db 194,224,241,32,241,234,240,243,242,232,235,224 + db 32,238,245,240,224,237,224,33,32,202,238,237 + db 244,232,241,234,224,246,232,255,32,232,32,248 + db 242,240,224,244,33,0 +szSecPressEnter db 91,69,110,116,101,114,58,32,207,240,238,228 + db 238,235,230,232,242,252,93,0 +szSecHeatBar db 91,194,205,200,204,192,205,200,197,32,206,213 + db 208,192,205,219,58,32,0 diff --git a/src_graphics/security_scene.inc b/src_graphics/security_scene.inc new file mode 100644 index 0000000..69de466 --- /dev/null +++ b/src_graphics/security_scene.inc @@ -0,0 +1,218 @@ +; ============================================================================== +; SECURITY, HEAT & PIT BOSS INTERROGATION SCENE (CP1251) +; ============================================================================== + +InitSecurity3D PROC + invoke LoadAnimPack3D, OFFSET secPortraitsPack, OFFSET secPortraitsPath + ret +InitSecurity3D ENDP + +FreeSecurity3D PROC + invoke FreeAnimPack3D, OFFSET secPortraitsPack + ret +FreeSecurity3D ENDP + +AddSecurityHeat PROC amount:DWORD + mov eax, amount + add securityHeat, eax + cmp securityHeat, 100 + jb sec_heat_ok + mov securityHeat, 100 + mov uwSecurityPending,1 +sec_heat_ok: + ret +AddSecurityHeat ENDP + +DecaySecurityHeat PROC amount:DWORD + mov eax, amount + cmp securityHeat, eax + jbe sec_decay_zero + sub securityHeat, eax + ret +sec_decay_zero: + mov securityHeat, 0 + ret +DecaySecurityHeat ENDP + +TriggerInterrogation3D PROC + mov eax, bankroll + mov ecx, 40 + mul ecx + mov ecx, 100 + div ecx + mov securityBribeAmount, eax + mov securitySubmode, 0 + mov securitySkillNeedle, 10 + mov securitySkillDir, 1 + mov uwSecurityAccumulator,0 + mov engineMode, MODE_SECURITY + call ClearKeys3D + ret +TriggerInterrogation3D ENDP + +HandleSecurity3D PROC + cmp securitySubmode, 0 + jne sec_check_sub1 + + ; Submode 0: Menu choices (1: Bribe, 2: Bluff, 3: Escape) + invoke Pressed3D, 31h ; '1' + test eax, eax + jz @F + ; Bribe + mov eax, securityBribeAmount + cmp bankroll, eax + jb sec_bribe_fail + sub bankroll, eax + invoke PlayCasinoSound3D, OFFSET soundCoin, 0, 1 + mov securityResultMsg, OFFSET szSecResultBribe + mov securitySubmode, 2 + call SaveProgress3D + ret +sec_bribe_fail: + invoke PlayCasinoSound3D, OFFSET soundRoundLose, 0, 1 + mov securityResultMsg, OFFSET szSecResultBust + mov bankroll, 0 + mov securitySubmode, 2 + call SaveProgress3D + ret +@@: + invoke Pressed3D, 32h ; '2' + test eax, eax + jz @F + ; Bluff: 50% chance or check if high roller + invoke RandomRange3D, 2 + test eax, eax + jz sec_bluff_fail + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + mov securityResultMsg, OFFSET szSecResultBluff + mov securitySubmode, 2 + ret +sec_bluff_fail: + mov eax, bankroll + shr eax, 1 + mov bankroll, eax + invoke PlayCasinoSound3D, OFFSET soundRoundLose, 0, 1 + mov securityResultMsg, OFFSET szSecResultBust + mov securitySubmode, 2 + call SaveProgress3D + ret +@@: + invoke Pressed3D, 33h ; '3' + test eax, eax + jz sec_handle_done + ; Start escape skill-check + mov securitySubmode, 1 + mov securitySkillNeedle, 10 + mov securitySkillDir, 1 + ret + +sec_check_sub1: + cmp securitySubmode, 1 + jne sec_check_sub2 + + ; Submode 1: Skill check oscillation + mov eax,deltaTime3D + add eax,uwSecurityAccumulator + xor edx,edx + mov ecx,16 + div ecx + mov uwSecurityAccumulator,edx + imul eax,securitySkillSpeed + cmp securitySkillDir, 1 + jne sec_needle_left + add securitySkillNeedle, eax + cmp securitySkillNeedle, 90 + jbe @F + mov securitySkillNeedle, 90 + mov securitySkillDir, -1 + jmp @F +sec_needle_left: + sub securitySkillNeedle, eax + cmp securitySkillNeedle, 10 + jae @F + mov securitySkillNeedle, 10 + mov securitySkillDir, 1 +@@: + ; Check Space pressed + invoke Pressed3D, 20h ; Space + test eax, eax + jz sec_handle_done + + ; Needle in green zone (38..62)? + cmp securitySkillNeedle, 38 + jb sec_escape_busted + cmp securitySkillNeedle, 62 + ja sec_escape_busted + ; Escaped! + invoke PlayCasinoSound3D, OFFSET soundRoundWin, 0, 1 + mov securityResultMsg, OFFSET szSecResultEscape + mov securityHeat, 0 + mov securitySubmode, 2 + ret +sec_escape_busted: + mov eax, bankroll + shr eax, 1 + mov bankroll, eax + invoke PlayCasinoSound3D, OFFSET soundRoundLose, 0, 1 + mov securityResultMsg, OFFSET szSecResultBust + mov securityHeat, 0 + mov securitySubmode, 2 + call SaveProgress3D + ret + +sec_check_sub2: + ; Submode 2: Result display, wait for Enter/Space + invoke Pressed3D, 0Dh ; Enter + test eax, eax + jnz sec_exit_to_walk + invoke Pressed3D, 20h ; Space + test eax, eax + jnz sec_exit_to_walk + invoke Pressed3D, 1Bh ; Esc + test eax, eax + jz sec_handle_done +sec_exit_to_walk: + mov uwSecurityPending,0 + mov securityHeat, 0 + call SaveProgress3D + mov engineMode, MODE_WALK + call ClearKeys3D + +sec_handle_done: + ret +HandleSecurity3D ENDP + +RenderSecurity3D PROC + invoke DrawBox,0,0,320,240,00101418h + invoke DrawBoxBorder,6,6,308,228,00161C22h,00836D42h,1 + invoke DrawString8x8,16,16,OFFSET uwSecurity,00E7CA88h + invoke DrawUnderworldSprite3D,OFFSET secPortraitsPack,2,12,44,94,110 + cmp securitySubmode,0 + jne uw_sec_skill + invoke DrawString8x8,116,54,OFFSET uwBribe,00E4D9BDh + invoke DrawNumber,204,54,securityBribeAmount,00A8DDB9h + invoke DrawUnderworldText3D,116,96,OFFSET uwBluff,23,00E4D9BDh + invoke DrawUnderworldText3D,116,140,OFFSET uwEscape,23,00E7CA88h + jmp uw_sec_footer +uw_sec_skill: + cmp securitySubmode,1 + jne uw_sec_result + invoke DrawUnderworldText3D,116,54,OFFSET uwSkill,23,00E7CA88h + invoke DrawBox,120,112,176,12,00222222h + invoke DrawBox,187,112,42,12,00228822h + mov eax,securitySkillNeedle + imul eax,176 + xor edx,edx + mov ecx,100 + div ecx + add eax,120 + invoke DrawBox,eax,108,2,20,0055FFFFh + jmp uw_sec_footer +uw_sec_result: + invoke DrawUnderworldText3D,116,52,securityResultMsg,23,00E7CA88h + invoke DrawString8x8,16,202,OFFSET uwContinue,00A8DDB9h +uw_sec_footer: + invoke DrawString8x8,16,220,OFFSET uwBank,00A8B6BBh + invoke DrawNumber,72,220,bankroll,00E5D6B0h + ret +RenderSecurity3D ENDP diff --git a/src_graphics/startup_cinematic.inc b/src_graphics/startup_cinematic.inc new file mode 100644 index 0000000..1f3d3ae --- /dev/null +++ b/src_graphics/startup_cinematic.inc @@ -0,0 +1,446 @@ +; Native 640x480 motion graphics. Geometry, timing and drawing are all MASM. +StartupRect3D PROC uses edi ebx x:SDWORD,y:SDWORD,w:DWORD,h:DWORD,ink:DWORD + local right:DWORD,bottom:DWORD + mov eax,x + add eax,w + cmp eax,SCREEN_W + jle @F + mov eax,SCREEN_W +@@: + mov right,eax + mov eax,y + add eax,h + cmp eax,SCREEN_H + jle @F + mov eax,SCREEN_H +@@: + mov bottom,eax + cmp x,0 + jge @F + mov x,0 +@@: + cmp y,0 + jge @F + mov y,0 +@@: + mov ebx,y +startup_rect_row: + cmp ebx,bottom + jge startup_rect_done + mov ecx,right + sub ecx,x + jle startup_rect_done + mov eax,ebx + imul eax,SCREEN_W + add eax,x + lea edi,screenBuffer[eax*4] + mov eax,ink + rep stosd + inc ebx + jmp startup_rect_row +startup_rect_done: + ret +StartupRect3D ENDP + +StartupLine3D PROC uses ebx esi edi x:SDWORD,y:SDWORD,x2:SDWORD,y2:SDWORD,ink:DWORD,weight:DWORD + local lineDX:SDWORD,lineDY:SDWORD,stepX:SDWORD,stepY:SDWORD,err:SDWORD,twice:SDWORD + mov stepX,1 + mov eax,x2 + sub eax,x + jns @F + neg eax + mov stepX,-1 +@@: + mov lineDX,eax + mov stepY,1 + mov eax,y2 + sub eax,y + jns @F + neg eax + mov stepY,-1 +@@: + neg eax + mov lineDY,eax + add eax,lineDX + mov err,eax +startup_line_pixel: + invoke StartupRect3D,x,y,weight,weight,ink + mov eax,x + cmp eax,x2 + jne startup_line_step + mov eax,y + cmp eax,y2 + je startup_line_done +startup_line_step: + mov eax,err + add eax,eax + mov twice,eax + cmp eax,lineDY + jl startup_line_y + mov eax,lineDY + add err,eax + mov eax,stepX + add x,eax +startup_line_y: + mov eax,twice + cmp eax,lineDX + jg startup_line_pixel + mov eax,lineDX + add err,eax + mov eax,stepY + add y,eax + jmp startup_line_pixel +startup_line_done: + ret +StartupLine3D ENDP + +StartupInk3D PROC uses ebx ink:DWORD,gain:DWORD + mov eax,ink + and eax,00FF00FFh + imul eax,gain + shr eax,8 + and eax,00FF00FFh + mov ebx,eax + mov eax,ink + and eax,0000FF00h + imul eax,gain + shr eax,8 + and eax,0000FF00h + or eax,ebx + ret +StartupInk3D ENDP + +StartupGlyph3D PROC uses ebx esi edi x:DWORD,y:DWORD,glyphCode:DWORD,unit:DWORD,ink:DWORD + local glyphX1:DWORD,glyphY1:DWORD,glyphX2:DWORD,glyphY2:DWORD,weight:DWORD + mov eax,glyphCode + sub eax,'A' + cmp eax,25 + ja startup_glyph_done + mov esi,startupGlyphs3D[eax*4] + movzx edi,BYTE PTR [esi] + inc esi + mov eax,unit + shr eax,1 + inc eax + mov weight,eax +startup_glyph_segment: + movzx eax,BYTE PTR [esi] + imul eax,unit + add eax,x + mov glyphX1,eax + movzx eax,BYTE PTR [esi+1] + imul eax,unit + add eax,y + mov glyphY1,eax + movzx eax,BYTE PTR [esi+2] + imul eax,unit + add eax,x + mov glyphX2,eax + movzx eax,BYTE PTR [esi+3] + imul eax,unit + add eax,y + mov glyphY2,eax + invoke StartupLine3D,glyphX1,glyphY1,glyphX2,glyphY2,ink,weight + add esi,4 + dec edi + jnz startup_glyph_segment +startup_glyph_done: + ret +StartupGlyph3D ENDP + +StartupWord3D PROC uses esi edi ebx x:DWORD,y:DWORD,text:DWORD,unit:DWORD,tracking:DWORD,ink:DWORD,start:DWORD + local charY:DWORD,charInk:DWORD,age:DWORD,offsetY:DWORD + mov esi,text + xor edi,edi +startup_word_char: + movzx ebx,BYTE PTR [esi] + test ebx,ebx + jz startup_word_done + mov eax,edi + imul eax,75 + add eax,start + mov edx,startupElapsed3D + sub edx,eax + js startup_word_done + mov age,edx + mov eax,edx + cmp eax,500 + jbe @F + mov eax,500 +@@: + imul eax,256 + xor edx,edx + mov ecx,500 + div ecx + invoke StartupInk3D,ink,eax + mov charInk,eax + mov eax,age + cmp eax,600 + jb @F + mov eax,600 +@@: + neg eax + add eax,600 + imul eax,eax + imul eax,18 + xor edx,edx + mov ecx,360000 + div ecx + add eax,y + mov charY,eax + ; A single restrained highlight crosses each settled word, without flicker. + mov eax,startupElapsed3D + sub eax,start + sub eax,1500 + js startup_word_draw + xor edx,edx + mov ecx,120 + div ecx + cmp eax,edi + jne startup_word_draw + mov charInk,00F8EBCCh +startup_word_draw: + invoke StartupGlyph3D,x,charY,ebx,unit,charInk + mov eax,unit + imul eax,10 + add eax,tracking + add x,eax + inc esi + inc edi + jmp startup_word_char +startup_word_done: + ret +StartupWord3D ENDP + +StartupCanvas3D PROC uses ebx esi edi + local row:DWORD,base:DWORD + lea edi,screenBuffer + mov row,0 +startup_canvas_row: + mov eax,row + sub eax,220 + cdq + xor eax,edx + sub eax,edx + shr eax,5 + neg eax + add eax,9 + mov base,eax + xor ebx,ebx +startup_canvas_pixel: + mov eax,ebx + sub eax,320 + cdq + xor eax,edx + sub eax,edx + shr eax,6 + neg eax + add eax,base + cmp eax,2 + jge @F + mov eax,2 +@@: + mov ecx,ebx + imul ecx,13 + xor ecx,row + and ecx,1 + add eax,ecx + imul eax,00010101h + add eax,00010406h + stosd + inc ebx + cmp ebx,SCREEN_W + jb startup_canvas_pixel + inc row + cmp row,SCREEN_H + jb startup_canvas_row + ret +StartupCanvas3D ENDP + +StartupEmblem3D PROC uses esi edi ebx centerX:DWORD,centerY:DWORD,radius:DWORD,start:DWORD + local x1:SDWORD,y1:SDWORD,x2:SDWORD,y2:SDWORD,progress:DWORD + mov eax,startupElapsed3D + sub eax,start + js startup_emblem_done + ; An outline builds edge by edge. Final edge is interpolated each frame. + imul eax,8 + cmp eax,8000 + jbe @F + mov eax,8000 +@@: + mov progress,eax + xor esi,esi +startup_emblem_edge: + mov edi,esi + shl edi,3 + mov eax,startupOctagon3D[edi] + imul eax,radius + cdq + mov ebx,68 + idiv ebx + add eax,centerX + mov x1,eax + mov eax,startupOctagon3D[edi+4] + imul eax,radius + cdq + idiv ebx + add eax,centerY + mov y1,eax + mov eax,startupOctagon3D[edi+8] + imul eax,radius + cdq + idiv ebx + add eax,centerX + mov x2,eax + mov eax,startupOctagon3D[edi+12] + imul eax,radius + cdq + idiv ebx + add eax,centerY + mov y2,eax + mov eax,progress + cmp eax,1000 + jae startup_emblem_full_edge + mov eax,x2 + sub eax,x1 + imul eax,progress + cdq + mov ebx,1000 + idiv ebx + add eax,x1 + mov x2,eax + mov eax,y2 + sub eax,y1 + imul eax,progress + cdq + idiv ebx + add eax,y1 + mov y2,eax +startup_emblem_full_edge: + invoke StartupLine3D,x1,y1,x2,y2,00917A51h,2 + sub progress,1000 + jle startup_emblem_done + inc esi + cmp esi,8 + jb startup_emblem_edge +startup_emblem_done: + ret +StartupEmblem3D ENDP + +RenderStudioCinematic3D PROC + call RenderStudioFilm3D + ret +RenderStudioCinematic3D ENDP + +RenderTitleCinematic3D PROC + call RenderTitleFilm3D + ret +RenderTitleCinematic3D ENDP + +RenderBootWarning3D PROC + invoke StartupRect3D,48,56,66,34,00C3A574h + invoke StartupRect3D,49,57,64,32,000B1012h + invoke PresentationText3D,58,66,OFFSET bootAge,00E1C898h,2,-1 + invoke PresentationText3D,136,62,OFFSET bootWarningTag,00919B99h,1,-1 + invoke PresentationText3D,48,118,OFFSET bootWarningTitle,00E8DCC4h,2,-1 + invoke StartupRect3D,48,156,544,1,004B4639h + invoke PresentationText3D,48,186,OFFSET bootWarningBody,00BCC4C2h,2,-1 + invoke PresentationText3D,48,337,OFFSET bootWarningAI,008D9D9Bh,1,-1 + ret +RenderBootWarning3D ENDP + +RenderBootFeatures3D PROC uses esi ebx + local rowY:DWORD,headerY:DWORD,bodyY:DWORD + invoke PresentationText3D,48,48,OFFSET bootFeatureTag,00919B99h,1,-1 + invoke PresentationText3D,48,78,OFFSET bootFeatureTitle,00E8DCC4h,2,-1 + mov rowY,151 + xor esi,esi +boot_feature_row: + invoke StartupRect3D,48,rowY,2,55,008C744Dh + mov eax,rowY + add eax,2 + invoke PresentationText3D,66,eax,bootFeatureNumbers[esi*4],00B59A6Ch,1,-1 + mov eax,rowY + mov headerY,eax + add eax,28 + mov bodyY,eax + invoke PresentationText3D,108,headerY,bootFeatureHeaders[esi*4],00D8C8AAh,2,-1 + invoke PresentationText3D,108,bodyY,bootFeatureBodies[esi*4],00AABBB8h,1,-1 + add rowY,83 + inc esi + cmp esi,3 + jb boot_feature_row + invoke PresentationText3D,48,414,OFFSET bootFeatureControls,00A4ABA2h,1,-1 + ret +RenderBootFeatures3D ENDP + +RenderStartupCinematic3D PROC uses ebx esi edi + call StartupCanvas3D + cmp startupPage3D,STARTUP_WARNING + jne @F + call RenderBootWarning3D + jmp boot_cinematic_footer +@@: + cmp startupPage3D,STARTUP_STUDIO + jne @F + call RenderStudioCinematic3D + jmp boot_cinematic_footer +@@: + cmp startupPage3D,STARTUP_TITLE + jne @F + call RenderTitleCinematic3D + jmp boot_cinematic_footer +@@: + call RenderBootFeatures3D +boot_cinematic_footer: + ; Three active chapters: warning, studio, features (title slot is retained). + invoke PresentationText3D,48,456,OFFSET bootNext,006D7C7Ah,1,-1 + mov edi,startupPage3D + cmp edi,STARTUP_FEATURES + jne @F + dec edi +@@: + mov esi,0 + mov ebx,555 +boot_chapter_mark: + mov eax,003D463Fh + cmp esi,edi + jne @F + mov eax,00BBA173h +@@: + invoke StartupRect3D,ebx,457,9,2,eax + add ebx,15 + inc esi + cmp esi,3 + jb boot_chapter_mark + ; Every page ends at black, matching the opening's closed eyes. + mov eax,startupElapsed3D + cmp eax,400 + jae boot_cinematic_fade_out + imul eax,256 + xor edx,edx + mov ecx,400 + div ecx + invoke FadeCityFrame3D,eax + ret +boot_cinematic_fade_out: + mov ecx,startupPage3D + mov ebx,startupDurations3D[ecx*4] + sub ebx,500 + cmp eax,ebx + jb boot_cinematic_done + sub eax,ebx + cmp eax,500 + jbe @F + mov eax,500 +@@: + imul eax,256 + xor edx,edx + mov ecx,500 + div ecx + neg eax + add eax,256 + invoke FadeCityFrame3D,eax +boot_cinematic_done: + ret +RenderStartupCinematic3D ENDP diff --git a/src_graphics/startup_code.inc b/src_graphics/startup_code.inc index fc2d1bb..9aab319 100644 --- a/src_graphics/startup_code.inc +++ b/src_graphics/startup_code.inc @@ -1,4 +1,4 @@ -; A single 640x480 bitmap; scan reveal and illumination run entirely in MASM. +; Native startup sequencing, input and media lifecycle; Full HD studio playback. ClearKeys3D PROC uses edi call ScratchCancelStroke3D mov scrClick3D,0 @@ -11,6 +11,7 @@ ClearKeys3D PROC uses edi ClearKeys3D ENDP FreeStartupAssets3D PROC + call FreeStartupFilm3D call FreeStartupSequence3D cmp startupPixels3D, 0 je @F @@ -65,23 +66,24 @@ startup_asset_failed: LoadStartupAssets3D ENDP BeginStartup3D PROC + invoke PlayCasinoSound3D,0,0,0 mov engineMode, MODE_INTRO mov paused3D, 0 mov interactTargetId, 0 mov interactPromptPtr, 0 mov startupElapsed3D, 0 - mov startupPage3D, STARTUP_STUDIO + mov startupPage3D, STARTUP_WARNING mov welcomeActive3D, 0 mov startupVariant3D, 0 mov animationClock3D, 0 mov rr3d_state, RR_READY call ClearKeys3D - call LoadStartupAssets3D - call LoadStartupSequence3D + call LoadStartupFilm3D ret BeginStartup3D ENDP FinishStartup3D PROC + invoke PlayCasinoSound3D,0,0,0 mov paused3D, 0 mov interactTargetId, 0 mov interactPromptPtr, 0 @@ -92,9 +94,22 @@ FinishStartup3D PROC FinishStartup3D ENDP AdvanceStartup3D PROC - cmp startupPage3D,STARTUP_CODE + cmp startupPage3D,STARTUP_FEATURES jae startup_advance_finish + invoke PlayCasinoSound3D,0,0,0 inc startupPage3D + cmp startupPage3D,STARTUP_TITLE + jne @F + mov startupPage3D,STARTUP_FEATURES +@@: + cmp startupPage3D,STARTUP_STUDIO + jne @F + invoke PlayCasinoSound3D,OFFSET bootStudioSound,0,1 +@@: + cmp startupPage3D,STARTUP_TITLE + jne @F + invoke PlayCasinoSound3D,OFFSET bootTitleSound,0,1 +@@: mov startupElapsed3D,0 call ClearKeys3D ret @@ -106,14 +121,6 @@ AdvanceStartup3D ENDP HandleStartupInput3D PROC mov eax, deltaTime3D add startupElapsed3D, eax - invoke Pressed3D, 71h - test eax, eax - jz @F - cmp startupPage3D,STARTUP_STUDIO - jne @F - xor startupVariant3D, 1 - mov startupElapsed3D, 0 -@@: invoke Pressed3D, 0Dh test eax, eax jnz startup_enter @@ -135,21 +142,7 @@ startup_input_done: HandleStartupInput3D ENDP RenderStartup3D PROC - cmp startupPage3D,STARTUP_STUDIO - jne startup_notice - cmp startupVariant3D, 0 - jne startup_studio_variant - cmp startupSequence3D, 0 - je startup_studio_variant - call RenderStartupSequence3D - call FadeStartupOut3D - ret -startup_studio_variant: - call RenderStudioStartup3D - call FadeStartupOut3D - ret -startup_notice: - call RenderStartupNotice3D + call RenderStartupCinematic3D ret RenderStartup3D ENDP @@ -302,3 +295,7 @@ startup_render_done: RenderStudioStartup3D ENDP include src_graphics\startup_sequence.inc + +include src_graphics\startup_cinematic.inc + +include src_graphics\startup_film.inc diff --git a/src_graphics/startup_film.inc b/src_graphics/startup_film.inc new file mode 100644 index 0000000..002914a --- /dev/null +++ b/src_graphics/startup_film.inc @@ -0,0 +1,547 @@ +; Physical camera shots and moving textured objects. No video / second runtime. +include src_graphics\cinematic_master.inc +include src_graphics\cinematic_hd.inc +LoadStartupFilm3D PROC +IFNDEF CINEMATIC_SOURCE_CAPTURE + call LoadHDStudio3D + test eax,eax + jnz film_load_done + call LoadCinematicMaster3D + test eax,eax + jnz film_load_done +ENDIF + call LoadStartupProceduralAssets3D +film_load_done: + ret +LoadStartupFilm3D ENDP + +LoadStartupProceduralAssets3D PROC + invoke LoadAnimPack3D,OFFSET filmWheel,OFFSET filmWheelPath + invoke LoadAnimPack3D,OFFSET filmStudio,OFFSET filmStudioPath + invoke LoadAnimPack3D,OFFSET filmTitle,OFFSET filmTitlePath + call LoadArrivalAssets3D + call LoadCityArrival3D + ret +LoadStartupProceduralAssets3D ENDP + +FreeStartupFilm3D PROC + call FreeHDStudio3D + call FreeCinematicMaster3D + invoke FreeAnimPack3D,OFFSET filmWheel + invoke FreeAnimPack3D,OFFSET filmStudio + invoke FreeAnimPack3D,OFFSET filmTitle + ret +FreeStartupFilm3D ENDP + +FilmLerp3D PROC uses ebx timeMs:DWORD,durationMs:DWORD,fromValue:SDWORD,toValue:SDWORD + invoke CityEase3D,timeMs,durationMs + mov ebx,toValue + sub ebx,fromValue + imul ebx + shrd eax,edx,16 + add eax,fromValue + ret +FilmLerp3D ENDP + +; A rotating textured plane with an oblique camera, clipped in native pixels. +DrawFilmWheel3D PROC uses ebx esi edi centerX:SDWORD,centerY:SDWORD,wide:DWORD,tall:DWORD,angle:DWORD,gain:DWORD + local filmCos:SDWORD,filmSin:SDWORD,stepU:SDWORD,stepV:SDWORD + local texU:SDWORD,texV:SDWORD,rowU:SDWORD,rowV:SDWORD + local py:DWORD,px:DWORD,localX:SDWORD,localY:SDWORD,pixel:DWORD + cmp filmWheel.pixels,0 + je film_wheel_done + mov eax,angle + and eax,511 + mov edx,tableCos[eax*4] + mov filmCos,edx + mov edx,tableSin[eax*4] + mov filmSin,edx + mov eax,512*FP_1 + xor edx,edx + div wide + mov ebx,eax + imul filmCos + shrd eax,edx,16 + mov stepU,eax + mov eax,ebx + imul filmSin + shrd eax,edx,16 + neg eax + mov stepV,eax + mov py,32 +film_wheel_row: + mov eax,py + sub eax,centerY + mov ecx,512*FP_1 + imul ecx + idiv tall + mov localY,eax + mov eax,centerX + neg eax + mov ecx,512*FP_1 + imul ecx + idiv wide + mov localX,eax + mov eax,localX + imul filmCos + shrd eax,edx,16 + mov rowU,eax + mov eax,localY + imul filmSin + shrd eax,edx,16 + add eax,rowU + add eax,256*FP_1 + mov texU,eax + mov eax,localX + imul filmSin + shrd eax,edx,16 + neg eax + mov rowV,eax + mov eax,localY + imul filmCos + shrd eax,edx,16 + add eax,rowV + add eax,256*FP_1 + mov texV,eax + mov eax,py + imul eax,SCREEN_W + lea edi,screenBuffer[eax*4] + mov px,0 +film_wheel_pixel: + mov eax,texU + sar eax,16 + cmp eax,512 + jae film_wheel_next + mov ebx,texV + sar ebx,16 + cmp ebx,512 + jae film_wheel_next + shl ebx,9 + add eax,ebx + mov esi,filmWheel.pixels + mov eax,[esi+eax*4] + cmp eax,80000000h + jb film_wheel_next + invoke StartupInk3D,eax,gain + mov [edi],eax +film_wheel_next: + mov eax,stepU + add texU,eax + mov eax,stepV + add texV,eax + add edi,4 + inc px + cmp px,640 + jb film_wheel_pixel + inc py + cmp py,448 + jb film_wheel_row +film_wheel_done: + ret +DrawFilmWheel3D ENDP + +DrawFilmBall3D PROC uses ebx esi edi centerX:DWORD,centerY:DWORD,wide:DWORD,tall:DWORD,angle:DWORD + local ballX:SDWORD,ballY:SDWORD,dxVal:SDWORD,dyVal:SDWORD,ink:DWORD + mov eax,angle + and eax,511 + mov ebx,tableCos[eax*4] + mov esi,tableSin[eax*4] + mov eax,wide + imul eax,42 + xor edx,edx + mov ecx,100 + div ecx + imul ebx + shrd eax,edx,16 + add eax,centerX + mov ballX,eax + mov eax,tall + imul eax,42 + xor edx,edx + div ecx + imul esi + shrd eax,edx,16 + add eax,centerY + mov ballY,eax + mov dyVal,-6 +film_ball_row: + mov dxVal,-6 +film_ball_pixel: + mov eax,dxVal + imul eax,eax + mov ebx,dyVal + imul ebx,ebx + add eax,ebx + cmp eax,36 + ja film_ball_next + mov eax,dxVal + add eax,dyVal + add eax,12 + imul eax,8 + neg eax + add eax,245 + imul eax,00010101h + mov ink,eax + mov eax,ballX + add eax,dxVal + mov edx,ballY + add edx,dyVal + invoke BlendCityWeatherPixel3D,eax,edx,ink,245 +film_ball_next: + inc dxVal + cmp dxVal,6 + jle film_ball_pixel + inc dyVal + cmp dyVal,6 + jle film_ball_row + ret +DrawFilmBall3D ENDP + +DrawFilmDust3D PROC uses ebx esi edi + local px:DWORD,py:DWORD,alpha:DWORD + xor esi,esi +film_dust_particle: + mov eax,esi + imul eax,149 + add eax,startupElapsed3D + shr eax,2 + xor edx,edx + mov ecx,700 + div ecx + sub edx,30 + mov px,edx + mov eax,esi + imul eax,991 + mov ebx,startupElapsed3D + shr ebx,5 + sub eax,ebx + and eax,511 + mov py,eax + mov eax,esi + and eax,3 + imul eax,22 + add eax,30 + mov alpha,eax + invoke BlendCityWeatherPixel3D,px,py,00D6B584h,alpha + inc esi + cmp esi,40 + jb film_dust_particle + ret +DrawFilmDust3D ENDP + +FilmLetterbox3D PROC + invoke StartupRect3D,0,0,640,32,0 + invoke StartupRect3D,0,448,640,32,0 + ret +FilmLetterbox3D ENDP + +FilmGlint3D PROC uses ebx esi edi px:SDWORD,py:SDWORD,start:DWORD + local strength:DWORD,dxVal:SDWORD,alpha:DWORD + mov eax,startupElapsed3D + sub eax,start + js film_glint_done + cmp eax,900 + jae film_glint_done + sub eax,450 + cdq + xor eax,edx + sub eax,edx + neg eax + add eax,450 + imul eax,100 + xor edx,edx + mov ecx,450 + div ecx + mov strength,eax + mov dxVal,-90 +film_glint_ray: + mov eax,dxVal + cdq + xor eax,edx + sub eax,edx + neg eax + add eax,90 + imul eax,strength + xor edx,edx + mov ecx,90 + div ecx + mov alpha,eax + mov eax,px + add eax,dxVal + invoke BlendCityWeatherPixel3D,eax,py,00FFE9C0h,alpha + inc dxVal + cmp dxVal,90 + jle film_glint_ray +film_glint_done: + ret +FilmGlint3D ENDP + +GradeFilm3D PROC uses ebx esi edi + local rowGain:DWORD,row:DWORD,col:DWORD,gain:DWORD,pixel:DWORD + lea edi,screenBuffer[32*640*4] + mov row,32 +film_grade_row: + mov eax,row + sub eax,240 + cdq + xor eax,edx + sub eax,edx + shr eax,4 + neg eax + add eax,256 + mov rowGain,eax + mov col,0 +film_grade_pixel: + mov eax,col + sub eax,320 + cdq + xor eax,edx + sub eax,edx + shr eax,3 + neg eax + add eax,rowGain + mov gain,eax + mov eax,[edi] + and eax,00FF00FFh + imul eax,gain + shr eax,8 + and eax,00FF00FFh + mov ebx,eax + mov eax,[edi] + and eax,0000FF00h + imul eax,gain + shr eax,8 + and eax,0000FF00h + or eax,ebx + mov [edi],eax + add edi,4 + inc col + cmp col,640 + jb film_grade_pixel + inc row + cmp row,448 + jb film_grade_row + ret +GradeFilm3D ENDP + +RenderStudioFilm3D PROC uses ebx esi edi + local focalX:DWORD,focalY:DWORD,wide:DWORD,tall:DWORD,spin:DWORD,gain:DWORD + local logoW:DWORD,logoH:DWORD,left:DWORD,top:DWORD + local originalTime:DWORD + invoke RenderHDStudio3D,startupElapsed3D + test eax,eax + jnz studio_film_master_done + ; Map the longer ident to the retained eight-second fallback studio only. + mov eax,startupElapsed3D + mov originalTime,eax + imul eax,8000 + xor edx,edx + mov ecx,STUDIO_HD_DURATION + div ecx + cmp eax,7999 + jbe @F + mov eax,7999 +@@: + mov startupElapsed3D,eax + invoke RenderCinematicMaster3D,startupElapsed3D + test eax,eax + jnz studio_film_restore_time + invoke FilmLerp3D,startupElapsed3D,6200,140,320 + mov focalX,eax + invoke FilmLerp3D,startupElapsed3D,6200,500,420 + mov focalY,eax + invoke FilmLerp3D,startupElapsed3D,6200,1380,730 + mov wide,eax + imul eax,3 + shr eax,2 + mov tall,eax + mov eax,startupElapsed3D + imul eax,7 + xor edx,edx + mov ecx,80 + div ecx + mov spin,eax + invoke FilmLerp3D,startupElapsed3D,6500,256,92 + mov gain,eax + invoke DrawFilmWheel3D,focalX,focalY,wide,tall,spin,gain + mov eax,startupElapsed3D + imul eax,21 + xor edx,edx + mov ecx,80 + div ecx + neg eax + add eax,80 + invoke DrawFilmBall3D,focalX,focalY,wide,tall,eax + mov eax,startupElapsed3D + sub eax,3000 + js studio_film_fx + mov ebx,eax + invoke FilmLerp3D,ebx,2000,890,540 + mov logoW,eax + imul eax,2 + xor edx,edx + mov ecx,3 + div ecx + mov logoH,eax + mov eax,640 + sub eax,logoW + sar eax,1 + mov left,eax + mov eax,480 + sub eax,logoH + sar eax,1 + sub eax,12 + mov top,eax + invoke FilmLerp3D,ebx,1500,0,255 + mov animOpacity3D,eax + invoke DrawAnimSprite3D,OFFSET filmStudio,0,left,top,logoW,logoH + mov animOpacity3D,255 + cmp startupElapsed3D,5500 + jb studio_film_fx + invoke PresentationText3D,272,419,OFFSET bootPresents,00B9B5AAh,1,-1 +studio_film_fx: + call DrawFilmDust3D + invoke FilmGlint3D,438,168,4400 + call GradeFilm3D + call FilmLetterbox3D +studio_film_restore_time: + mov eax,originalTime + mov startupElapsed3D,eax +studio_film_master_done: + ret +RenderStudioFilm3D ENDP + +RenderTitleFilm3D PROC uses ebx esi edi + local t:DWORD,logoW:DWORD,logoH:DWORD,left:SDWORD,top:SDWORD + mov eax,startupElapsed3D + add eax,8000 + invoke RenderCinematicMaster3D,eax + test eax,eax + jnz title_film_master_done + ; Save the playable scene. The fly-through never moves the actual player. + push playerX + push playerY + push playerAngle + push worldMap3D + push viewHorizon3D + push floorTexture3D + push outdoorRender3D + push viewEye3D + push viewCeiling3D + push cityClock3D + lea esi,cityObjects3D + lea edi,filmObjectSave + mov ecx,CITY_PROP_COUNT*SIZEOF CityProp3D/4 + rep movsd + mov eax,startupElapsed3D + mov t,eax + cmp eax,4500 + jae film_camera_turn + invoke FilmLerp3D,eax,4500,FP_1*29,FP_1*223/10 + mov playerX,eax + invoke FilmLerp3D,t,4500,FP_1*14,FP_1*146/10 + mov playerY,eax + invoke FilmLerp3D,t,4500,FP_1*7,FP_1*42/10 + mov viewEye3D,eax + invoke FilmLerp3D,t,4500,256,288 + mov playerAngle,eax + invoke FilmLerp3D,t,4500,165,230 + mov viewHorizon3D,eax + jmp film_camera_ready +film_camera_turn: + sub eax,4500 + mov ebx,eax + invoke FilmLerp3D,ebx,3300,FP_1*223/10,FP_1*22 + mov playerX,eax + invoke FilmLerp3D,ebx,5500,FP_1*146/10,FP_1*116/10 + mov playerY,eax + invoke FilmLerp3D,ebx,3300,FP_1*42/10,FP_1*19/10 + mov viewEye3D,eax + invoke FilmLerp3D,ebx,3300,288,384 + mov playerAngle,eax + invoke FilmLerp3D,ebx,3300,230,300 + mov viewHorizon3D,eax +film_camera_ready: + mov eax,playerX + mov filmLastCameraX,eax + mov eax,playerY + mov filmLastCameraY,eax + mov eax,viewEye3D + mov filmLastCameraZ,eax + mov eax,playerAngle + mov filmLastCameraAngle,eax + mov worldMap3D,OFFSET cityMap3D + mov outdoorRender3D,1 + mov floorTexture3D,60 + mov viewCeiling3D,FP_1*13 + mov eax,startupElapsed3D + add eax,17000 + mov cityClock3D,eax + call UpdateCamera3D + call DrawCitySky3D + call RenderCeilingAndFloor + call DrawCitySkyline3D + call RenderWalls + call PrepareCityDepth3D + call RenderStreetDressing3D + call RenderCityObjects3D + call RenderCityFurniture3D + call RenderCityFacade3D + call RenderCityGuards3D + cmp startupElapsed3D,7800 + jae @F + invoke DrawCityObject3D,OFFSET filmSign,0 +@@: + call DrawCityRain3D + ; The sign becomes the full title as the dolly reaches the casino entrance. + mov eax,startupElapsed3D + sub eax,7800 + js film_title_finish + mov ebx,eax + invoke FilmLerp3D,ebx,1200,256,92 + invoke FadeCityFrame3D,eax + invoke FilmLerp3D,ebx,1400,760,568 + mov logoW,eax + imul eax,344 + xor edx,edx + mov ecx,1024 + div ecx + mov logoH,eax + mov eax,640 + sub eax,logoW + sar eax,1 + mov left,eax + mov eax,480 + sub eax,logoH + sar eax,1 + sub eax,8 + mov top,eax + invoke FilmLerp3D,ebx,1100,0,255 + mov animOpacity3D,eax + invoke DrawAnimSprite3D,OFFSET filmTitle,0,left,top,logoW,logoH + mov animOpacity3D,255 + cmp startupElapsed3D,9400 + jb film_title_finish + invoke PresentationText3D,220,373,OFFSET bootTitleTag,00D4D3BEh,1,-1 +film_title_finish: + invoke FilmGlint3D,422,207,8800 + call GradeFilm3D + call FilmLetterbox3D + lea esi,filmObjectSave + lea edi,cityObjects3D + mov ecx,CITY_PROP_COUNT*SIZEOF CityProp3D/4 + rep movsd + pop cityClock3D + pop viewCeiling3D + pop viewEye3D + pop outdoorRender3D + pop floorTexture3D + pop viewHorizon3D + pop worldMap3D + pop playerAngle + pop playerY + pop playerX + call UpdateCamera3D +title_film_master_done: + ret +RenderTitleFilm3D ENDP diff --git a/src_graphics/startup_film_data.inc b/src_graphics/startup_film_data.inc new file mode 100644 index 0000000..e03505c --- /dev/null +++ b/src_graphics/startup_film_data.inc @@ -0,0 +1,26 @@ +; Camera and physical cinematic art, all rendered by the existing MASM engine. +CityEase3D PROTO :DWORD,:DWORD +DrawCityObject3D PROTO :DWORD,:DWORD +LoadStartupFilm3D PROTO +FreeStartupFilm3D PROTO +RenderStudioFilm3D PROTO +RenderTitleFilm3D PROTO +.data +filmWheel AnimPack3D <> +filmStudio AnimPack3D <> +filmTitle AnimPack3D <> +filmWheelPath db 'assets\animations\intro\roulette-cinematic-v1.bin',0 +filmStudioPath db 'assets\animations\intro\eblan-cinematic-v2.bin',0 +filmTitlePath db 'assets\animations\intro\casino-cinematic-v2.bin',0 +ALIGN 4 +filmSign CityProp3D +filmLastCameraX dd 0 +filmLastCameraY dd 0 +filmLastCameraZ dd 0 +filmLastCameraAngle dd 0 +.data? +filmObjectSave db CITY_PROP_COUNT*SIZEOF CityProp3D dup(?) +.code +include src_graphics\cinematic_master_data.inc + +include src_graphics\cinematic_hd_data.inc diff --git a/src_graphics/startup_geometry.inc b/src_graphics/startup_geometry.inc new file mode 100644 index 0000000..e016bf5 --- /dev/null +++ b/src_graphics/startup_geometry.inc @@ -0,0 +1,41 @@ +; Original engraved alphabet. Generated by make_startup_geometry.py. +.data +startupGlyphs3D dd OFFSET startupGlyphA,OFFSET startupGlyphB,OFFSET startupGlyphC,OFFSET startupGlyphD,OFFSET startupGlyphE,OFFSET startupGlyphF + dd OFFSET startupGlyphG,OFFSET startupGlyphH,OFFSET startupGlyphI,OFFSET startupGlyphJ,OFFSET startupGlyphK,OFFSET startupGlyphL + dd OFFSET startupGlyphM,OFFSET startupGlyphN,OFFSET startupGlyphO,OFFSET startupGlyphP,OFFSET startupGlyphQ,OFFSET startupGlyphR + dd OFFSET startupGlyphS,OFFSET startupGlyphT,OFFSET startupGlyphU,OFFSET startupGlyphV,OFFSET startupGlyphW,OFFSET startupGlyphX + dd OFFSET startupGlyphY,OFFSET startupGlyphZ +startupGlyphA db 5,0,14,0,5,0,5,5,0,5,0,10,5,10,5,10,14,0,8,10,8 +startupGlyphB db 9,0,14,0,0,0,0,7,0,7,0,10,3,10,3,7,7,0,7,7,7,7,7,10,10,10,10,10,12,10,12,8,14,8,14,0,14 +startupGlyphC db 5,10,0,3,0,3,0,0,3,0,3,0,11,0,11,3,14,3,14,10,14 +startupGlyphD db 6,0,14,0,0,0,0,6,0,6,0,10,4,10,4,10,10,10,10,6,14,6,14,0,14 +startupGlyphE db 4,10,0,0,0,0,0,0,14,0,14,10,14,0,7,8,7 +startupGlyphF db 3,10,0,0,0,0,0,0,14,0,7,8,7 +startupGlyphG db 7,10,0,3,0,3,0,0,3,0,3,0,11,0,11,3,14,3,14,10,14,10,14,10,8,10,8,6,8 +startupGlyphH db 3,0,0,0,14,10,0,10,14,0,7,10,7 +startupGlyphI db 3,0,0,10,0,5,0,5,14,0,14,10,14 +startupGlyphJ db 5,0,0,10,0,10,0,10,11,10,11,7,14,7,14,3,14,3,14,0,11 +startupGlyphK db 3,0,0,0,14,10,0,0,8,2,6,10,14 +startupGlyphL db 2,0,0,0,14,0,14,10,14 +startupGlyphM db 4,0,14,0,0,0,0,5,7,5,7,10,0,10,0,10,14 +startupGlyphN db 3,0,14,0,0,0,0,10,14,10,14,10,0 +startupGlyphO db 8,3,0,7,0,7,0,10,3,10,3,10,11,10,11,7,14,7,14,3,14,3,14,0,11,0,11,0,3,0,3,3,0 +startupGlyphP db 6,0,14,0,0,0,0,7,0,7,0,10,3,10,3,10,5,10,5,7,7,7,7,0,7 +startupGlyphQ db 9,3,0,7,0,7,0,10,3,10,3,10,11,10,11,7,14,7,14,3,14,3,14,0,11,0,11,0,3,0,3,3,0,6,10,11,15 +startupGlyphR db 7,0,14,0,0,0,0,7,0,7,0,10,3,10,3,10,5,10,5,7,7,7,7,0,7,5,7,10,14 +startupGlyphS db 9,10,0,3,0,3,0,0,3,0,3,0,5,0,5,3,7,3,7,7,7,7,7,10,9,10,9,10,11,10,11,7,14,7,14,0,14 +startupGlyphT db 2,0,0,10,0,5,0,5,14 +startupGlyphU db 5,0,0,0,11,0,11,3,14,3,14,7,14,7,14,10,11,10,11,10,0 +startupGlyphV db 4,0,0,0,4,0,4,5,14,5,14,10,4,10,4,10,0 +startupGlyphW db 4,0,0,0,14,0,14,5,7,5,7,10,14,10,14,10,0 +startupGlyphX db 2,0,0,10,14,10,0,0,14 +startupGlyphY db 3,0,0,5,7,10,0,5,7,5,7,5,14 +startupGlyphZ db 3,0,0,10,0,10,0,0,14,0,14,10,14 +startupOctagon3D sdword 0,-68,48,-48,68,0,48,48,0,68,-48,48,-68,0,-48,-48,0,-68 +startupEWord db "E",0 +startupAWord db "A",0 +startupStudioWord db "EBLAN",0 +startupGamesWord db "GAMES",0 +startupTitleWord db "ASSEMBLER",0 +startupCasinoWord db "CASINO",0 +.code diff --git a/src_graphics/underworld.inc b/src_graphics/underworld.inc new file mode 100644 index 0000000..1ebe10d --- /dev/null +++ b/src_graphics/underworld.inc @@ -0,0 +1,290 @@ +DrawUnderworldSprite3D PROC pack:DWORD,frame:DWORD,x:DWORD,y:DWORD,w:DWORD,h:DWORD + shl x,1 + shl y,1 + shl w,1 + shl h,1 + invoke DrawAnimSprite3D,pack,frame,x,y,w,h + ret +DrawUnderworldSprite3D ENDP + +; Word wrap CP1251 to a bounded logical rectangle. Max y=196 protects footer. +DrawUnderworldText3D PROC uses ebx esi edi x:DWORD,y:DWORD,strPtr:DWORD,columns:DWORD,color:DWORD + local col:DWORD,wordLen:DWORD + mov esi,strPtr + mov col,0 +uw_text_next: + cmp y,196 + ja uw_text_done + movzx eax,BYTE PTR [esi] + test eax,eax + jz uw_text_done + cmp eax,10 + je uw_text_newline + cmp eax,32 + je uw_text_char + xor ecx,ecx +uw_word_scan: + movzx edx,BYTE PTR [esi+ecx] + cmp edx,32 + jbe uw_word_end + inc ecx + jmp uw_word_scan +uw_word_end: + mov eax,col + test eax,eax + jz uw_text_word + add eax,ecx + cmp eax,columns + jbe uw_text_word + add y,12 + mov col,0 +uw_text_word: + mov wordLen,ecx +uw_word_char: + cmp wordLen,0 + je uw_text_next + cmp y,196 + ja uw_text_done + movzx eax,BYTE PTR [esi] + mov uwCharText,al + mov eax,col + shl eax,3 + add eax,x + invoke DrawString8x8,eax,y,OFFSET uwCharText,color + inc esi + inc col + dec wordLen + mov eax,col + cmp eax,columns + jb uw_word_char + mov col,0 + add y,12 + jmp uw_word_char +uw_text_char: + inc esi + cmp col,0 + je uw_text_next + inc col + mov eax,col + cmp eax,columns + jb uw_text_next + mov col,0 + add y,12 + jmp uw_text_next +uw_text_newline: + inc esi + mov col,0 + add y,12 + jmp uw_text_next +uw_text_done: + ret +DrawUnderworldText3D ENDP + +UnderworldPath3D PROC + mov eax,OFFSET savePath3D + cmp nativeProfileActive3D,0 + je @F + mov eax,OFFSET saveFullPath +@@: + invoke CopyCString,OFFSET uwProgressPath,eax + invoke AppendCString,OFFSET uwProgressPath,OFFSET uwProgressSuffix + invoke CopyCString,OFFSET uwProgressTemp,OFFSET uwProgressPath + invoke AppendCString,OFFSET uwProgressTemp,OFFSET uwTempSuffix + ret +UnderworldPath3D ENDP + +UnderworldSignature3D PROC uses esi + mov esi,OFFSET uwProgressWords + mov ecx,15 + mov eax,554E4432h +@@: + rol eax,5 + xor eax,[esi] + add eax,9E3779B9h + add esi,4 + loop @B + ret +UnderworldSignature3D ENDP + +LoadUnderworldProgress3D PROC uses ebx + mov debtActive,0 + mov debtAmount,0 + mov debtBorrowed,0 + mov debtRoundsLeft,0 + mov securityHeat,0 + mov heistCrewBartender,0 + mov heistCrewSinger,0 + mov heistCrewFortune,0 + mov heistCrewHacker,0 + mov heistComplete,0 + mov uwDebtPending,0 + mov uwSecurityPending,0 + mov barBuffLuckSpins,0 + call UnderworldPath3D + invoke CreateFileA,OFFSET uwProgressPath,80000000h,1,0,3,80h,0 + cmp eax,-1 + je uw_load_done + mov ebx,eax + invoke ReadFile,ebx,OFFSET uwProgressWords,64,OFFSET uwProgressIo,0 + invoke CloseHandle,ebx + cmp uwProgressIo,64 + jne uw_load_done + cmp uwProgressWords,554E4432h + jne uw_load_done + call UnderworldSignature3D + cmp eax,uwProgressWords[60] + jne uw_load_done + cmp uwProgressWords[4],1 + ja uw_load_done + cmp uwProgressWords[8],16000 + ja uw_load_done + cmp uwProgressWords[16],1000 + ja uw_load_done + cmp uwProgressWords[20],100 + ja uw_load_done + cmp uwProgressWords[24],15 + ja uw_load_done + cmp uwProgressWords[28],1 + ja uw_load_done + cmp uwProgressWords[32],15 + ja uw_load_done + mov eax,uwProgressWords[4] + mov debtActive,eax + mov eax,uwProgressWords[8] + mov debtAmount,eax + mov eax,uwProgressWords[12] + mov debtBorrowed,eax + mov eax,uwProgressWords[16] + mov debtRoundsLeft,eax + mov eax,uwProgressWords[20] + mov securityHeat,eax + mov eax,uwProgressWords[24] + mov ecx,eax + and eax,1 + mov heistCrewBartender,eax + mov eax,ecx + shr eax,1 + and eax,1 + mov heistCrewSinger,eax + mov eax,ecx + shr eax,2 + and eax,1 + mov heistCrewFortune,eax + shr ecx,3 + and ecx,1 + mov heistCrewHacker,ecx + mov eax,uwProgressWords[28] + mov heistComplete,eax + mov eax,uwProgressWords[32] + mov barBuffLuckSpins,eax + cmp debtActive,0 + je @F + cmp debtRoundsLeft,0 + jne @F + mov uwDebtPending,1 +@@: + cmp securityHeat,100 + jne uw_load_done + mov uwSecurityPending,1 +uw_load_done: + ret +LoadUnderworldProgress3D ENDP + +SaveUnderworldProgress3D PROC uses ebx +IFDEF CASINO_ACTION_TEST + ret +ENDIF + cmp obsActive3D,0 + jne uw_save_done + cmp arrivalConfirmed3D,0 + je uw_save_done + call UnderworldPath3D + mov uwProgressWords,554E4432h + mov eax,debtActive + mov uwProgressWords[4],eax + mov eax,debtAmount + mov uwProgressWords[8],eax + mov eax,debtBorrowed + mov uwProgressWords[12],eax + mov eax,debtRoundsLeft + mov uwProgressWords[16],eax + mov eax,securityHeat + mov uwProgressWords[20],eax + mov eax,heistCrewHacker + shl eax,1 + or eax,heistCrewFortune + shl eax,1 + or eax,heistCrewSinger + shl eax,1 + or eax,heistCrewBartender + mov uwProgressWords[24],eax + mov eax,heistComplete + mov uwProgressWords[28],eax + mov eax,barBuffLuckSpins + mov uwProgressWords[32],eax + call UnderworldSignature3D + mov uwProgressWords[60],eax + invoke CreateFileA,OFFSET uwProgressTemp,40000000h,0,0,2,80h,0 + cmp eax,-1 + je uw_save_done + mov ebx,eax + invoke WriteFile,ebx,OFFSET uwProgressWords,64,OFFSET uwProgressIo,0 + invoke CloseHandle,ebx + cmp uwProgressIo,64 + jne uw_save_done + invoke MoveFileExA,OFFSET uwProgressTemp,OFFSET uwProgressPath,9 +uw_save_done: + ret +SaveUnderworldProgress3D ENDP + +; Defer interruptions until the paid game has settled and the player is walking. +UpdateUnderworld3D PROC + cmp engineMode,MODE_WALK + jne uw_update_done + cmp uwDebtPending,0 + je uw_update_security + mov uwDebtPending,0 + mov debtSubmode,1 + mov engineMode,MODE_DEBT + call ClearKeys3D + ret +uw_update_security: + cmp uwSecurityPending,0 + je uw_update_done + mov uwSecurityPending,0 + call TriggerInterrogation3D +uw_update_done: + ret +UpdateUnderworld3D ENDP + +UnderworldCanWalk3D PROC uses ebx esi px:DWORD,py:DWORD + mov esi,OFFSET bunkerRatRace3D + mov ebx,3 +uw_object_collision: + mov eax,px + sub eax,[esi].CityProp3D.posX + jns @F + neg eax +@@: + mov ecx,[esi].CityProp3D.worldW + shr ecx,1 + add ecx,FP_1/10 + cmp eax,ecx + ja uw_object_next + mov eax,py + sub eax,[esi].CityProp3D.posY + jns @F + neg eax +@@: + cmp eax,FP_1*2/5 + jbe uw_object_blocked +uw_object_next: + add esi,SIZEOF CityProp3D + dec ebx + jnz uw_object_collision + mov eax,1 + ret +uw_object_blocked: + xor eax,eax + ret +UnderworldCanWalk3D ENDP diff --git a/src_graphics/underworld_analysis.inc b/src_graphics/underworld_analysis.inc new file mode 100644 index 0000000..1d42d1c --- /dev/null +++ b/src_graphics/underworld_analysis.inc @@ -0,0 +1,94 @@ +; Public-information analysis only. Never consumes or inspects the shuffled deck. +UnderworldBJSafePercent3D PROC uses ebx esi edi + local total:DWORD,safe:DWORD + cmp cbPlayerCount3D,11 + ja uw_bj_analysis_none + mov ecx,cbPlayerCount3D + mov esi,OFFSET cbPlayer3D + mov edi,OFFSET uwAnalysisCards + rep movsd + mov total,0 + mov safe,0 + xor ebx,ebx +uw_bj_candidate: + xor esi,esi +uw_bj_known: + cmp esi,cbPlayerCount3D + jae uw_bj_upcard + cmp ebx,cbPlayer3D[esi*4] + je uw_bj_next_candidate + inc esi + jmp uw_bj_known +uw_bj_upcard: + cmp cbDealerCount3D,0 + je uw_bj_possible + cmp ebx,cbDealer3D + je uw_bj_next_candidate +uw_bj_possible: + mov ecx,cbPlayerCount3D + mov uwAnalysisCards[ecx*4],ebx + inc ecx + invoke NativeBJScore3D,OFFSET uwAnalysisCards,ecx + inc total + cmp eax,21 + ja uw_bj_next_candidate + inc safe +uw_bj_next_candidate: + inc ebx + cmp ebx,52 + jb uw_bj_candidate + cmp total,0 + je uw_bj_analysis_none + mov eax,safe + imul eax,100 + xor edx,edx + div total + ret +uw_bj_analysis_none: + xor eax,eax + ret +UnderworldBJSafePercent3D ENDP + +DrawUnderworldAnalysis3D PROC uses ebx esi edi + cmp barBuffCalcTimer,0 + je uw_analysis_done + cmp engineMode,MODE_BLACKJACK + jne uw_poker_analysis + cmp cbState3D,CB_PLAYER + jne uw_analysis_done + cmp cbBotCount3D,0 + jne uw_analysis_done + call UnderworldBJSafePercent3D + mov ebx,eax + invoke DrawBox,4,130,308,14,00151D20h + invoke DrawString8x8,8,134,OFFSET uwSafeHitText,00A8DDB9h + invoke DrawNumber,200,134,ebx,00A8DDB9h + invoke DrawString8x8,224,134,OFFSET uwPercentText,00A8DDB9h + jmp uw_analysis_done +uw_poker_analysis: + cmp engineMode,MODE_POKER + jne uw_analysis_done + cmp pkState3D,PK_PLAYER + jne uw_analysis_done + cmp pkBoardCount3D,3 + jb uw_analysis_done + mov eax,pkHole3D + mov uwAnalysisCards,eax + mov eax,pkHole3D[4] + mov uwAnalysisCards[4],eax + mov esi,OFFSET pkBoard3D + mov edi,OFFSET uwAnalysisCards+8 + mov ecx,pkBoardCount3D + cmp ecx,5 + ja uw_analysis_done + rep movsd + mov ecx,pkBoardCount3D + add ecx,2 + invoke EvaluateNativePoker3D,OFFSET uwAnalysisCards,ecx + invoke NativePokerClass3D,eax + mov ebx,pkRankNames3D[eax*4] + invoke DrawString8x8,8,34,OFFSET uwHandClassText,00A8DDB9h + invoke DrawString8x8,112,34,ebx,00A8DDB9h +uw_analysis_done: + ret +DrawUnderworldAnalysis3D ENDP diff --git a/src_graphics/underworld_data.inc b/src_graphics/underworld_data.inc new file mode 100644 index 0000000..4f920a8 --- /dev/null +++ b/src_graphics/underworld_data.inc @@ -0,0 +1,107 @@ +; Shared UI uses logical 320x240 coordinates; ANM1 draws physical 640x480. +UnderworldCanWalk3D PROTO :DWORD,:DWORD +UnderworldBJSafePercent3D PROTO +DrawUnderworldAnalysis3D PROTO +DrawUnderworldSprite3D PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD +DrawUnderworldText3D PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD +LoadUnderworldProgress3D PROTO +SaveUnderworldProgress3D PROTO +UpdateUnderworld3D PROTO +.data +ALIGN 4 +uwWorldPack AnimPack3D <> +uwWorldPath db "assets\animations\hall\underworld-world-v2.bin",0 +MoveFileExA PROTO :DWORD,:DWORD,:DWORD +uwProgressPath db 520 dup(0) +uwProgressTemp db 520 dup(0) +uwTempSuffix db ".tmp",0 +uwProgressSuffix db ".underworld",0 +uwProgressWords dd 16 dup(0) +uwProgressIo dd 0 +uwDebtPending dd 0 +uwSecurityPending dd 0 +uwHeistTimer dd 0 +uwHeistPulse dd 0 +uwRaceAccumulator dd 0 +uwRatFinished dd 0 +uwRatRanks dd 4 dup(0) +uwRatPlaceBet dd 0 +uwRatSlamTimer dd 0 +uwSecurityAccumulator dd 0 +uwRatNamePtrs dd OFFSET szRatRacer1,OFFSET szRatRacer2,OFFSET szRatRacer3,OFFSET szRatRacer4 +uwPeeked dd 0 +uwCharText db 0,0 +uwExit db 69,83,67,58,32,194,32,199,192,203,0 +uwBank db 193,192,205,202,32,36,0 +uwRounds db 208,192,211,205,196,206,194,58,0 +uwDebt db 196,206,203,195,32,36,0 +uwLoanTitle db 209,197,204,168,205,32,47,32,199,192,201,204,219,0 +uwLoanIntro db 194,251,225,229,240,232,32,241,243,236,236,243,46,32,196,238,235,227,32,237,243,230,237,238 + db 32,226,229,240,237,243,242,252,32,228,238,32,232,241,242,229,247,229,237,232,255,32,240,224 + db 243,237,228,238,226,46,0 +uwLoan1 db 49,58,32,36,53,48,48,32,47,32,226,229,240,237,243,242,252,32,36,55,48,48,32,47,32,50,53,32,240,224,243,237,228,238,226,0 +uwLoan2 db 50,58,32,36,50,53,48,48,32,47,32,226,229,240,237,243,242,252,32,36,51,55,53,48,32,47,32,52,48,32,240,224,243,237,228,238,226,0 +uwLoan3 db 51,58,32,36,49,48,48,48,48,32,47,32,226,229,240,237,243,242,252,32,36,49,54,48,48,48,32,47,32,54,48,32,240,224,243,237,228,238,226,0 +uwLoanRepay db 53,58,32,207,206,195,192,209,200,210,220,32,196,206,203,195,0 +uwLoanBack db 52,32,47,32,69,83,67,58,32,211,201,210,200,0 +uwAmbush db 202,206,203,203,197,202,210,206,208,219,0 +uwAmbush1 db 49,58,32,196,240,224,234,224,32,151,32,237,224,230,236,232,32,87,32,65,32,68,32,83,32,226,238,226,240,229,236,255,0 +uwAmbush2 db 50,58,32,208,243,235,229,242,234,224,32,151,32,240,232,241,234,32,49,32,234,32,54,0 +uwAmbush3 db 51,58,32,206,242,228,224,242,252,32,226,241,229,32,244,232,248,234,232,32,232,32,231,224,234,240,251,242,252,32,228,238,235,227,0 +uwContinue db 69,78,84,69,82,58,32,207,208,206,196,206,203,198,200,210,220,0 +uwFight db 205,192,198,204,200,32,211,202,192,199,192,205,205,211,222,32,202,203,192,194,200,216,211,0 +uwSecurity db 209,203,211,198,193,192,32,193,197,199,206,207,192,209,205,206,209,210,200,0 +uwBribe db 49,58,32,194,199,223,210,202,192,32,36,0 +uwBluff db 50,58,32,193,203,197,212,32,47,32,216,192,205,209,32,53,48,37,0 +uwEscape db 51,58,32,207,206,193,197,195,32,47,32,207,208,206,194,197,208,202,192,32,208,197,192,202,214,200,200,0 +uwSkill db 83,80,65,67,69,58,32,206,209,210,192,205,206,194,200,32,194,32,199,197,203,168,205,206,201,32,199,206,205,197,0 +uwHeist db 206,195,208,192,193,203,197,205,200,197,32,47,32,207,203,192,205,32,206,207,197,208,192,214,200,200,0 +uwCrew1 db 49,32,193,192,208,204,197,205,32,36,49,48,48,48,0 +uwCrew2 db 50,32,207,197,194,200,214,192,32,36,50,48,48,48,0 +uwCrew3 db 51,32,195,192,196,192,203,202,192,32,36,49,53,48,48,0 +uwCrew4 db 52,32,213,192,202,197,208,32,36,51,48,48,48,0 +uwReady db 195,206,210,206,194,0 +uwHire db 205,192,205,223,210,220,0 +uwStart db 69,78,84,69,82,58,32,205,192,215,192,210,220,32,206,207,197,208,192,214,200,222,0 +uwGather db 205,224,233,236,232,32,226,241,229,245,32,247,229,242,251,240,184,245,32,243,247,224,241,242,237,232,234,238,226,46,0 +uwShow db 202,224,225,224,240,229,32,238,242,226,235,229,234,224,229,242,32,238,245,240,224,237,243,46 + db 32,202,238,236,224,237,228,224,32,238,242,234,240,251,226,224,229,242,32,239,243,242,252,32 + db 234,32,245,240,224,237,232,235,232,249,243,46,0 +uwSafe db 65,47,68,32,232,235,232,32,241,242,240,229,235,234,232,58,32,226,240,224,249,224,242,252 + db 10,83,80,65,67,69,58,32,231,224,244,232,234,241,232,240,238,226,224,242,252,32,246,232 + db 244,240,243,0 +uwNear db 209,235,251,248,229,237,32,242,232,245,232,233,32,249,229,235,247,238,234,46,32,214,232,244,240,224,32,240,255,228,238,236,46,0 +uwSafeGoal db 207,206,196,206,193,208,192,205,206,32,214,200,212,208,58,0 +uwSafeTime db 194,208,197,204,223,58,0 +uwFailed db 209,240,224,225,238,242,224,235,224,32,242,240,229,226,238,227,224,33,32,205,224,227,240,224 + db 228,251,32,237,229,242,46,32,202,238,236,224,237,228,224,32,230,228,184,242,32,241,235,229 + db 228,243,254,249,229,233,32,239,238,239,251,242,234,232,46,0 +uwVictory db 209,229,233,244,32,238,242,234,240,251,242,33,32,207,238,235,243,247,229,237,238,32,36,49 + db 48,48,48,48,48,48,32,232,32,231,238,235,238,242,224,255,32,240,243,225,224,248,234,224 + db 32,234,224,240,242,46,32,194,229,240,242,238,235,184,242,32,243,237,238,241,232,242,32,234 + db 238,236,224,237,228,243,32,226,32,237,229,238,237,238,226,243,254,32,237,238,247,252,46,0 +uwCompleted db 206,239,229,240,224,246,232,255,32,243,230,229,32,231,224,226,229,240,248,229,237,224,46,32,205,224,227,240,224,228,224,32,239,238,235,243,247,229,237,224,46,0 +uwRatTitle db 207,206,196,207,206,203,220,205,219,197,32,202,208,219,209,200,205,219,197,32,193,197,195,192,0 +uwRatKeys db 49,45,52,58,32,193,197,195,211,205,32,47,32,209,210,208,197,203,202,200,58,32,209,210,192,194,202,192,0 +uwRatStart db 69,78,84,69,82,58,32,209,210,192,208,210,32,47,32,80,58,32,210,200,207,32,209,210,192,194,202,200,0 +uwRatWinBet db 205,192,32,207,206,193,197,196,211,0 +uwRatPlaceText db 210,206,207,45,50,58,32,120,49,46,53,0 +uwRatMoney db 209,210,192,194,202,192,32,36,0 +uwRatRun db 83,80,65,67,69,58,32,209,210,211,202,32,207,206,32,209,210,206,203,211,32,40,206,196,200,205,32,208,192,199,41,0 +uwRatUsed db 209,242,243,234,32,232,241,239,238,235,252,231,238,226,224,237,46,32,198,228,184,236,32,244,232,237,232,248,224,46,0 +uwRatWon db 194,219,200,195,208,219,216,32,36,0 +uwRatLost db 209,210,192,194,202,192,32,207,208,206,200,195,208,192,203,192,0 +uwRatResult db 69,78,84,69,82,58,32,197,217,168,32,199,192,193,197,195,32,47,32,69,83,67,58,32,194,219,201,210,200,0 +uwRatPoor db 205,197,196,206,209,210,192,210,206,215,205,206,32,212,200,216,197,202,0 +uwRoute db 207,206,196,194,192,203,58,32,193,197,195,192,32,47,32,209,197,204,168,205,32,47,32,207,203,192,205,0 +uwPeekText db 80,58,32,207,206,196,209,204,206,210,208,197,210,220,32,47,32,206,213,208,192,205,192,32,43,51,48,37,0 +uwAnalysisCards dd 12 dup(0) +uwSafeHitText db 193,197,199,32,207,197,208,197,193,206,208,192,32,207,208,200,32,194,199,223,210,200,200,58 + db 0 +uwHandClassText db 202,206,204,193,200,205,192,214,200,223,58,0 +uwPercentText db 37,0 +uwClubEntrance db 207,206,196,207,206,203,220,197,58,32,193,206,202,206,194,206,201,32,207,208,206,213,206,196 + db 32,209,203,197,194,192,0 +uwClubTitle db 207,206,196,207,206,203,220,205,219,201,32,202,203,211,193,32,47,32,193,197,195,192,32,200 + db 32,199,192,201,204,219,0 +.code diff --git a/tools/build_launcher.ps1 b/tools/build_launcher.ps1 new file mode 100644 index 0000000..24723b1 --- /dev/null +++ b/tools/build_launcher.ps1 @@ -0,0 +1,27 @@ +$ErrorActionPreference = 'Stop' +$repoPath = Split-Path -Parent $PSScriptRoot +$gamePath = Join-Path $repoPath 'poker.exe' +$binPath = Join-Path $repoPath 'bin' +New-Item -ItemType Directory -Path $binPath -Force | Out-Null +Copy-Item -LiteralPath $gamePath -Destination (Join-Path $binPath 'poker.exe') -Force +$sha = [System.Security.Cryptography.SHA256]::Create() +$gameStream = [System.IO.File]::OpenRead($gamePath) +try { $gameHash = [System.BitConverter]::ToString($sha.ComputeHash($gameStream)).Replace('-', '') } +finally { $gameStream.Dispose(); $sha.Dispose() } +$sourcePath = Join-Path $repoPath 'build/AssemblerCasinoLauncher.cs' +$sourceText = [System.IO.File]::ReadAllText($sourcePath) +$sourceText = [regex]::Replace($sourceText, 'ExpectedPokerSha256 = "[A-Fa-f0-9]+"', ('ExpectedPokerSha256 = "' + $gameHash + '"')) +[System.IO.File]::WriteAllText($sourcePath, $sourceText, (New-Object System.Text.UTF8Encoding($false))) +$compilerPath = Join-Path $env:WINDIR 'Microsoft.NET/Framework64/v4.0.30319/csc.exe' +if (-not (Test-Path -LiteralPath $compilerPath)) { + $compilerPath = Join-Path $env:WINDIR 'Microsoft.NET/Framework/v4.0.30319/csc.exe' +} +$outputPath = Join-Path $repoPath 'dist/Assembler Casino.exe' +$iconPath = Join-Path $repoPath 'assets/icons/casino.ico' +$savedCompilerLib = $env:LIB +try { + $env:LIB = '' + & $compilerPath /nologo /target:winexe /optimize+ /r:System.Windows.Forms.dll ("/win32icon:$iconPath") ("/out:$outputPath") $sourcePath +} finally { $env:LIB = $savedCompilerLib } +if ($LASTEXITCODE -ne 0) { throw 'Launcher compilation failed' } +Write-Output 'Updated bin/poker.exe and verified-hash launcher.' diff --git a/tools/build_setup.py b/tools/build_setup.py index 412687c..7bd2912 100644 --- a/tools/build_setup.py +++ b/tools/build_setup.py @@ -1,30 +1,50 @@ #!/usr/bin/env python3 -"""Build and package the complete modern Assembler Casino into PokerGameSetup.exe.""" +"""Build and package Assembler Casino into the modern CASINO-PACK-V2 installer.""" +import argparse import hashlib +import json import os import re +import struct import subprocess import sys import zipfile from pathlib import Path ROOT = Path(__file__).resolve().parents[1] -MARKER = b"<>" +FOOTER_MAGIC = b"CASINO-PACK-V2!\n" +STUDIO_MEDIA = ( + "assets/animations/intro/eblan-studio-v8.hfm", + "assets/animations/intro/eblan-studio-v8.json", + "assets/audio/startup/studio-workshop-v8.wav", +) -def get_sha256(data_or_path): - if isinstance(data_or_path, (str, Path)): - h = hashlib.sha256() - with open(data_or_path, "rb") as f: - while chunk := f.read(65536): - h.update(chunk) - return h.hexdigest().upper() - return hashlib.sha256(data_or_path).hexdigest().upper() +def sha256_stream(file_obj, length=None): + h = hashlib.sha256() + remaining = length if length is not None else float("inf") + while remaining > 0: + chunk_size = min(65536, remaining if length is not None else 65536) + chunk = file_obj.read(chunk_size) + if not chunk: + break + h.update(chunk) + if length is not None: + remaining -= len(chunk) + return h.hexdigest().lower() + + +def sha256_file(path): + with open(path, "rb") as f: + return sha256_stream(f) def collect_payload_files(): entries = [] + for relative in STUDIO_MEDIA: + if not (ROOT / relative).is_file(): + raise FileNotFoundError(f"Missing studio intro asset: {relative}") # Executables for src, dst in [ @@ -40,11 +60,20 @@ def collect_payload_files(): # Assets (excluding raw sprites used only for asset generation) assets_dir = ROOT / "assets" for r, dirs, files in os.walk(assets_dir): + if Path(r) == assets_dir: + # Editable Blender/AE projects, scans and source image sequences are + # offline authoring material. Ship their compiled media, not the set. + dirs[:] = [d for d in dirs if d not in {"cinematics", "sprites"}] if "sprites" in Path(r).parts: continue for f in sorted(files): fp = Path(r) / f rel = fp.relative_to(ROOT).as_posix() + if ( + rel.startswith(("assets/animations/intro/eblan-studio-v", "assets/audio/startup/studio-workshop-v")) + and rel not in STUDIO_MEDIA + ): + continue entries.append((fp, rel)) # Docs @@ -76,13 +105,7 @@ def collect_payload_files(): if (ROOT / "tools/tests/release_smoke_check.ps1").exists(): entries.append((ROOT / "tools/tests/release_smoke_check.ps1", "tools/release_smoke_check.ps1")) - # Runtime configuration and state - for rel in ["runtime/casino3d-progress.dat", "runtime/display.cfg"]: - fp = ROOT / rel - if fp.exists(): - entries.append((fp, rel)) - - # AI worker & metadata (without the 2.5 GB model per docs/FORTUNE_AI.md) + # AI worker & metadata (without models/ directory) ai_dir = ROOT / "ai" if ai_dir.exists(): for r, dirs, files in os.walk(ai_dir): @@ -93,110 +116,309 @@ def collect_payload_files(): rel = fp.relative_to(ROOT).as_posix() entries.append((fp, rel)) - # Root documentation - for rel in ["AGENTS.md", "README.md"]: + # Root documentation & legal + for rel in ["AGENTS.md", "README.md", "LICENSE"]: fp = ROOT / rel if fp.exists(): entries.append((fp, rel)) - return entries + # Clean and deduplicate entries + unique_entries = [] + seen_dest = set() + for src, dst in entries: + clean_dst = dst.replace("\\", "/").lstrip("/") + if clean_dst not in seen_dest: + seen_dest.add(clean_dst) + unique_entries.append((src, clean_dst)) + + return unique_entries def build_payload_zip(zip_path, entries): - print(f"Creating payload archive: {zip_path} ({len(entries)} files)...") + print(f"Creating game archive: {zip_path} ({len(entries)} files)...") zip_path.parent.mkdir(parents=True, exist_ok=True) - with zipfile.ZipFile(zip_path, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=6) as zf: + uncompressed_bytes = 0 + with zipfile.ZipFile(zip_path, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=4) as zf: for src, dst in entries: zf.write(src, dst) + uncompressed_bytes += src.stat().st_size size_mb = zip_path.stat().st_size / (1024 * 1024) - print(f"Payload archive created: {size_mb:.2f} MB") + print(f"Game archive created: {size_mb:.2f} MB (uncompressed: {uncompressed_bytes / (1024*1024):.2f} MB)") + return uncompressed_bytes -def compile_setup_base(source_path, base_exe_path): - csc = Path(os.environ.get("WINDIR", r"C:\Windows")) / r"Microsoft.NET\Framework\v4.0.30319\csc.exe" - if not csc.exists(): - raise RuntimeError(f"csc.exe not found at {csc}") +def compile_installer_base(index_sha256): + installer_dir = ROOT / "build/installer" + stamp_path = installer_dir / "PokerGameSetup/PackageStamp.cs" - icon = ROOT / "assets/icons/casino.ico" + stamp_content = f"""namespace PokerGameSetup; + +internal static class PackageStamp +{{ +\tpublic const string IndexSha256 = "{index_sha256}"; +}} +""" + stamp_path.write_text(stamp_content, encoding="utf-8") + print(f"Updated PackageStamp.cs with IndexSha256: {index_sha256}") + + out_dir = installer_dir / "bin" + out_dir.mkdir(parents=True, exist_ok=True) cmd = [ - str(csc), - "/nologo", - "/target:winexe", - "/platform:x86", - "/optimize+", - "/reference:System.Windows.Forms.dll", - "/reference:System.Drawing.dll", - "/reference:System.IO.Compression.dll", - "/reference:System.IO.Compression.FileSystem.dll", - "/reference:System.Core.dll", - f"/win32icon:{icon}", - f"/out:{base_exe_path}", - str(source_path), + "dotnet", + "build", + str(installer_dir / "PokerGameSetup.csproj"), + "-c", + "Release", + "-o", + str(out_dir), ] print(f"Compiling installer base: {' '.join(cmd)}") res = subprocess.run(cmd, capture_output=True, text=True) if res.returncode != 0: - raise RuntimeError(f"Compilation failed:\n{res.stdout}\n{res.stderr}") - print(f"Compiled: {base_exe_path} ({base_exe_path.stat().st_size} bytes)") + raise RuntimeError(f"dotnet build failed:\n{res.stdout}\n{res.stderr}") + + base_exe = out_dir / "Setup-base.exe" + if not base_exe.exists(): + base_exe = out_dir / "PokerGameSetup.exe" + if not base_exe.exists(): + raise FileNotFoundError(f"Compiled setup base executable not found in {out_dir}") + + print(f"Compiled base executable: {base_exe} ({base_exe.stat().st_size} bytes)") + return base_exe + + +def verify_package(setup_path, expected_index_sha256, has_model, expected_model_sha256=None): + print(f"Verifying package {setup_path}...") + size = setup_path.stat().st_size + if size < 32: + raise ValueError("Package too small to contain footer") + + with open(setup_path, "rb") as f: + f.seek(-32, os.SEEK_END) + footer = f.read(32) + payload_offset, index_len, magic = struct.unpack(" 16777216: + raise ValueError(f"Invalid index length: {index_len}") + if payload_offset < 0 or payload_offset > size - 32 - index_len: + raise ValueError(f"Invalid payload offset: {payload_offset}") + + index_offset = size - 32 - index_len + f.seek(index_offset) + index_bytes = f.read(index_len) + actual_index_hash = hashlib.sha256(index_bytes).hexdigest().lower() + if actual_index_hash != expected_index_sha256.lower(): + raise ValueError(f"Index hash mismatch: {actual_index_hash} != {expected_index_sha256}") + + # Test reading game zip slice + f.seek(payload_offset) + # Parse XML index + import xml.etree.ElementTree as ET + root = ET.fromstring(index_bytes.decode("utf-8")) + if root.tag != "casino-package": + raise ValueError(f"Invalid root tag: {root.tag}") + + game_elem = root.find("game") + if game_elem is None: + raise ValueError("Missing element") + + game_offset = int(game_elem.attrib["offset"]) + game_len = int(game_elem.attrib["length"]) + game_bytes = int(game_elem.attrib["bytes"]) + game_sha256 = game_elem.attrib["sha256"] + + if game_offset != 0: + raise ValueError("Game offset must be 0") + + f.seek(payload_offset + game_offset) + actual_game_hash = sha256_stream(f, game_len) + if actual_game_hash != game_sha256.lower(): + raise ValueError(f"Game hash mismatch: {actual_game_hash} != {game_sha256}") + + # Check zip archive validity + class SliceIO: + def __init__(self, f_obj, start, length): + self._f = f_obj + self._start = start + self._length = length + self._pos = 0 + + def read(self, n=-1): + if n < 0 or self._pos + n > self._length: + n = self._length - self._pos + if n <= 0: + return b"" + self._f.seek(self._start + self._pos) + data = self._f.read(n) + self._pos += len(data) + return data + + def seek(self, offset, whence=0): + if whence == 0: + self._pos = offset + elif whence == 1: + self._pos += offset + elif whence == 2: + self._pos = self._length + offset + self._pos = max(0, min(self._pos, self._length)) + return self._pos + + def tell(self): + return self._pos + + sio = SliceIO(f, payload_offset + game_offset, game_len) + with zipfile.ZipFile(sio, "r") as zf: + uncompressed = sum(info.file_size for info in zf.infolist()) + if uncompressed != game_bytes: + raise ValueError(f"Uncompressed bytes mismatch: {uncompressed} != {game_bytes}") + for info in zf.infolist(): + if info.filename.endswith("/") or info.is_dir() or not info.filename.split("/")[-1]: + raise ValueError(f"Forbidden directory entry in zip: {info.filename}") + if "\\" in info.filename: + raise ValueError(f"Forbidden backslash in entry: {info.filename}") + + # Check model if present + model_elem = root.find("model") + if has_model: + if model_elem is None: + raise ValueError("Expected element not found in index") + model_offset = int(model_elem.attrib["offset"]) + model_len = int(model_elem.attrib["length"]) + model_bytes = int(model_elem.attrib["bytes"]) + model_sha256 = model_elem.attrib["sha256"] + + if model_offset != game_len: + raise ValueError(f"Model offset {model_offset} != game length {game_len}") + if model_bytes != model_len: + raise ValueError(f"Model bytes {model_bytes} != model length {model_len}") + + f.seek(payload_offset + model_offset) + actual_model_hash = sha256_stream(f, model_len) + if actual_model_hash != model_sha256.lower(): + raise ValueError(f"Model hash mismatch: {actual_model_hash} != {model_sha256}") + if expected_model_sha256 and actual_model_hash != expected_model_sha256.lower(): + raise ValueError(f"Model hash mismatch with expected: {actual_model_hash}") + else: + if model_elem is not None: + raise ValueError("Unexpected element found when has_model is False") + + print("[VERIFIED] Package passed all structural and cryptographic checks!") def main(): - print("=== Building Assembler Casino PokerGameSetup ===") + parser = argparse.ArgumentParser(description="Build modern Assembler Casino installer.") + parser.add_argument("--no-model", action="store_true", help="Build installer without the 2.5 GB offline model") + parser.add_argument("--output", type=str, default="", help="Custom output installer filename") + args = parser.parse_args() - # 1. Collect files + include_model = not args.no_model + + if args.output: + output_name = args.output + else: + output_name = "PokerGameSetup.exe" if include_model else "PokerGameSetup_NoModel.exe" + + output_exe = ROOT / output_name + print(f"=== Building Assembler Casino Installer: {output_name} ===") + print(f"Include offline fortune model: {include_model}") + + # 1. Model verification (if enabled) + model_path = None + model_len = 0 + model_sha256 = "" + model_target_rel = "ai/models/fortune-qwen3-4b-q4_k_m.gguf" + + if include_model: + manifest_path = ROOT / "ai/model.json" + if not manifest_path.exists(): + raise FileNotFoundError(f"Model manifest not found: {manifest_path}") + manifest = json.loads(manifest_path.read_text("utf-8")) + model_path = ROOT / "ai" / manifest["file"] + if not model_path.exists(): + raise FileNotFoundError( + f"Offline fortune model not found at {model_path}. " + "Run download_fortune_model.bat to download it, or use --no-model." + ) + model_len = model_path.stat().st_size + expected_len = manifest["bytes"] + if model_len != expected_len: + raise ValueError(f"Model size mismatch: {model_len} != {expected_len}") + + print(f"Verifying offline model hash ({model_path.name})...") + model_sha256 = manifest["sha256"].lower() + actual_hash = sha256_file(model_path) + if actual_hash != model_sha256: + raise ValueError(f"Model SHA-256 mismatch: {actual_hash} != {model_sha256}") + print(f"Model verified: {model_len / (1024*1024):.2f} MB, SHA-256: {model_sha256}") + + # 2. Collect and zip game payload entries = collect_payload_files() payload_zip = ROOT / "build/payload_release_final.zip" - build_payload_zip(payload_zip, entries) + uncompressed_bytes = build_payload_zip(payload_zip, entries) + game_zip_len = payload_zip.stat().st_size + game_zip_sha256 = sha256_file(payload_zip) + print(f"Game ZIP SHA-256: {game_zip_sha256}") - # 2. Hash payload - payload_hash = get_sha256(payload_zip) - print(f"Payload SHA-256: {payload_hash}") + # 3. Construct XML index + if include_model: + xml_index = ( + f"\n" + f'' + f'' + f'' + f"" + ) + else: + xml_index = ( + f"\n" + f'' + f'' + f"" + ) - # 3. Update PokerGameSetupGui.cs with new payload hash - setup_cs = ROOT / "build/PokerGameSetupGui.cs" - cs_content = setup_cs.read_text(encoding="utf-8") - hash_pattern = r'const string ExpectedPayloadSha256 = "([A-Fa-f0-9]{64}|TO_BE_FILLED_BY_RELEASE_BUILD)";' - if not re.search(hash_pattern, cs_content): - raise ValueError("Could not find ExpectedPayloadSha256 constant in PokerGameSetupGui.cs") - new_cs_content = re.sub( - hash_pattern, - f'const string ExpectedPayloadSha256 = "{payload_hash}";', - cs_content, - count=1 - ) - setup_cs.write_text(new_cs_content, encoding="utf-8") - print("Updated ExpectedPayloadSha256 in PokerGameSetupGui.cs") + xml_bytes = xml_index.encode("utf-8") + index_sha256 = hashlib.sha256(xml_bytes).hexdigest().lower() + print(f"XML Index SHA-256: {index_sha256}") - # 4. Compile base setup executable - base_exe = ROOT / "build/PokerGameSetup_base.exe" - compile_setup_base(setup_cs, base_exe) + # 4. Compile base setup executable with index SHA-256 stamped + base_exe = compile_installer_base(index_sha256) + base_len = base_exe.stat().st_size - # 5. Assemble final PokerGameSetup.exe - setup_exe = ROOT / "PokerGameSetup.exe" - print(f"Assembling {setup_exe}...") - with open(setup_exe, "wb") as out_f: + # 5. Assemble final installer executable + print(f"Assembling {output_exe}...") + with open(output_exe, "wb") as out_f: + # Write base executable with open(base_exe, "rb") as in_base: out_f.write(in_base.read()) - out_f.write(MARKER) + + # Stream game zip + print("Writing game archive...") with open(payload_zip, "rb") as in_zip: - while chunk := in_zip.read(65536): + while chunk := in_zip.read(1048576): out_f.write(chunk) - total_mb = setup_exe.stat().st_size / (1024 * 1024) - print(f"=== Successfully built {setup_exe} ({total_mb:.2f} MB) ===") + # Stream model (if included) + if include_model: + print("Writing offline neural model (2.5 GB)...") + with open(model_path, "rb") as in_model: + while chunk := in_model.read(1048576): + out_f.write(chunk) + + # Write XML index + print("Writing XML index and footer...") + out_f.write(xml_bytes) + + # Write 32-byte footer: + footer_bytes = struct.pack("